From 64ec1a7fb55389d8db371d112e49f741de866796 Mon Sep 17 00:00:00 2001 From: lss <Lss@HanInfo> Date: 星期三, 18 六月 2025 16:41:26 +0800 Subject: [PATCH] 业务开发与优化 --- HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/wms/LocationHelper.cs | 91 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 70 insertions(+), 21 deletions(-) diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/wms/LocationHelper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/wms/LocationHelper.cs index 4e70816..ba4f872 100644 --- a/HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/wms/LocationHelper.cs +++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/wms/LocationHelper.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using static HH.WCS.DaYang.wms.WMSHelper.AddChangeModel; namespace HH.WCS.DaYang.wms { @@ -56,30 +57,31 @@ /// <summary> /// 鍏ュ簱绠楁硶 /// </summary> - /// <param name="loc">鍏ュ簱璧风偣</param> + /// <param name="itemCode">鐗╂枡缂栫爜</param> /// <returns></returns> - public static Location InStorage(Location loc) + public static Location InStorage(string itemCode) { var db = new SqlHelper<object>().GetInstance(); Location location = null; List<Location> list = Locations.Values.ToList(); - string itemCode = ""; + string areaCode = ""; try { - //鏍规嵁璧风偣鑾峰彇鎵樼洏鍜屾墭鐩樼墿鏂欑粦瀹氬叧绯�- var cntrLoc = LocationHelper.GetLocCntr(loc.S_CODE).FirstOrDefault(); - if (cntrLoc != null) - { - //鑾峰彇鎵樼洏鐗╂枡缁戝畾鍏崇郴 - var cntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE == cntrLoc.S_CNTR_CODE).First(); - if (cntrItem != null) - { - itemCode = cntrItem.S_ITEM_CODE; - } - } + ////鏍规嵁璧风偣鑾峰彇鎵樼洏鍜屾墭鐩樼墿鏂欑粦瀹氬叧绯�+ /// //string itemCode = ""; + //var cntrLoc = LocationHelper.GetLocCntr(loc.S_CODE).FirstOrDefault(); + //if (cntrLoc != null) + //{ + // //鑾峰彇鎵樼洏鐗╂枡缁戝畾鍏崇郴 + // var cntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE == cntrLoc.S_CNTR_CODE).First(); + // if (cntrItem != null) + // { + // itemCode = cntrItem.S_ITEM_CODE; + // } + //} - //绌烘墭鍏ュ簱锛岀浉鍚岀墿鏂欏唴娴嬫帓鐨勮揣浣�+ //鎵樼洏鍏ュ簱锛岀浉鍚岀墿鏂欏唴娴嬫帓鐨勮揣浣� var Locs = GetLocByItemCode(areaCode, itemCode, new int[] { 1, 4 }).OrderByDescending(b => b.N_COL).ToList(); if (Locs.Count > 0) @@ -115,7 +117,7 @@ //濡傛灉娌℃湁鎵惧埌鐩稿悓鐗╂枡鐨勫渚ц揣浣嶏紝鎵句竴涓唴娴嬬┖璐т綅 if (location == null) { - location = GetEmptyLocByItemCode(areaCode, new int[] { 1, 4 }); + location = GetEmptyLocByItemCode(areaCode, new List<int> { 1, 4 }); } return location; } @@ -127,12 +129,47 @@ } - - #endregion /// <summary> - /// 鏍规嵁鐗╂枡鑾峰緱瀵瑰簲鐨勫唴娴嬭揣浣�+ /// 鏍规嵁鐗╂枡鍜屾帓鍙疯幏寰楀搴旂殑鏈攣瀹氭墭鐩樿揣浣�+ /// </summary> + /// <param name="areaCode">搴撳尯缂栫爜</param> + /// <param name="row">璐т綅鎺�/param> + /// <param name="ItemCode">鐗╂枡缂栫爜</param> + /// <returns></returns> + internal static List<Location> GetLocByItemCodeOrderyTime(string areaCode, string ItemCode) + { + List<Location> locs; + var db = new SqlHelper<object>().GetInstance(); + + try + { + locs = db.Queryable<Location>() + .LeftJoin<LocCntrRel>((a, b) => a.S_CODE == b.S_LOC_CODE) + .LeftJoin<CntrItemDetail>((a, b, c) => b.S_CNTR_CODE == c.S_CNTR_CODE) + .Where((a, b, c) => a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode + && c.S_ITEM_CODE == ItemCode && a.N_LOCK_STATE == 0) + .GroupBy((a, b, c) => new { a.S_CODE, c.T_INBOUND_TIME ,a.N_POS }) + + .OrderBy((a, b, c) => c.T_INBOUND_TIME) + .OrderByDescending((a, b, c) => a.N_POS) + .ToList(); + + + + return locs; + } + catch (Exception ex) + { + LogHelper.Info($"GetLocByItemCode Error:{ex}"); + throw; + } + + } + + /// <summary> + /// 鏍规嵁鐗╂枡鍜屾帓鍙疯幏寰楀搴旂殑鏈攣瀹氭墭鐩樿揣浣�骞舵寜鎵樼洏鐗╂枡琛ㄦ椂闂村垎缁� /// </summary> /// <param name="areaCode">搴撳尯缂栫爜</param> /// <param name="row">璐т綅鎺�/param> @@ -147,7 +184,7 @@ var queryable = db.Queryable<Location>() .LeftJoin<LocCntrRel>((a, b) => a.S_CODE == b.S_LOC_CODE) .LeftJoin<CntrItemDetail>((a, b, c) => b.S_CNTR_CODE == c.S_CNTR_CODE) - .Where((a, b, c) => a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode && row.Contains(a.N_ROW) && c.S_ITEM_CODE == ItemCode); + .Where((a, b, c) => a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode && row.Contains(a.N_ROW) && c.S_ITEM_CODE == ItemCode && a.N_LOCK_STATE == 0); locs = queryable.ToList(); @@ -167,14 +204,25 @@ /// <param name="areaCode">搴撳尯缂栫爜</param> /// <param name="row">璐т綅鎺�/param> /// <returns></returns> - internal static Location GetEmptyLocByItemCode(string areaCode, int[] row) + internal static Location GetEmptyLocByItemCode(string areaCode, List<int> row) { var db = new SqlHelper<object>().GetInstance(); Location location = null; + try { + //鍒ゆ柇褰撳墠鎺掑彲鐢ㄨ揣浣嶅皬浜� 濡傛灉灏忎簬2鍒欎笉鍏佽鍏�+ for (int i = row.Count(); i < 0; i--) + { + var locationNum = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode && a.N_ROW == row[i]).ToList().Count; + if (locationNum <= 2) + { + row.RemoveAt(i); + } + } location = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode && row.Contains(a.N_ROW)).First(); + return location; } catch (Exception ex) @@ -460,6 +508,7 @@ model.S_LOCK_STATE = Location.GetLockStateStr(lockState); res = db.Updateable(model).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE }).ExecuteCommand() > 0; } + return res; } -- Gitblit v1.9.1