From b2c8747a85762bc32f310a31fe84cad69b61104a Mon Sep 17 00:00:00 2001
From: lss <Lss@HanInfo>
Date: 星期二, 10 六月 2025 17:32:46 +0800
Subject: [PATCH] 优化

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/wms/LocationHelper.cs |   46 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/wms/LocationHelper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/wms/LocationHelper.cs
index 0b60311..94f4928 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/wms/LocationHelper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/wms/LocationHelper.cs
@@ -7,6 +7,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using static HH.WCS.JiaTong.dispatch.NDC;
 
@@ -201,6 +202,7 @@
         "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
         "U", "V", "W", "X", "Y", "Z"
     };
+
         /// <summary>
         /// 鏍规嵁鐗╂枡鎵炬墭鐩�         /// </summary>
@@ -210,7 +212,10 @@
         /// <returns></returns>
         internal static List<Location> GetLocByItemCode(string areaCode, string ItemCode, string lev)
         {
+
             List<Location> locs;
+
+
             var db = new SqlHelper<object>().GetInstance();
             var queryable = db.Queryable<Location>()
       .LeftJoin<LocCntrRel>((a, b) => a.S_CODE == b.S_LOC_CODE)
@@ -232,7 +237,7 @@
             //.Skip(targetIndex)  // 璺宠繃楂樹簬鐩爣绛夌骇鐨勭瓑绾�             //.ToList();
 
-            // LogHelper.Info($"GetLocByItemCode=>鏍规嵁搴撳尯缂栫爜:{areaCode}锛岀墿鏂欑紪鐮�{ItemCode},鐗╂枡浼樺厛绾�{lev}锛岀墿鏂欑瓑绾ц绠楀嚭鏈夋墭鐩樿揣浣峽JsonConvert.SerializeObject(queryable.ToList())}");
+            LogHelper.Info($"GetLocByItemCode=>鏍规嵁搴撳尯缂栫爜:{areaCode}锛岀墿鏂欑紪鐮�{ItemCode},鐗╂枡浼樺厛绾�{lev}锛岀墿鏂欑瓑绾ц绠楀嚭鏈夋墭鐩樿揣浣峽JsonConvert.SerializeObject(queryable.ToList())}");
             //鍒ゆ柇闇�笉闇�鐗╂枡绛夌骇鏌ユ壘锛屽苟浼樺厛鍑哄簱浣欐枡
             if (string.IsNullOrEmpty(lev))
             {
@@ -261,7 +266,7 @@
                 {
                     queryable = queryable.Where((a, b, c) => c.S_ITEM_CODE == ItemCode);
                 }
-                //   LogHelper.Info($"GetLocByItemCode=>鏃犱綑鏂�鏌ユ壘鍏ㄩ儴{JsonConvert.SerializeObject(queryable.ToList())}");
+                LogHelper.Info($"GetLocByItemCode=>鏃犱綑鏂�鏌ユ壘鍏ㄩ儴{JsonConvert.SerializeObject(queryable.ToList())}");
 
 
                 if (string.IsNullOrEmpty(lev))
@@ -272,7 +277,7 @@
                 {
                     locs = queryable.Where((a, b, c) => c.LEV == lev).ToList();
                 }
-                //  LogHelper.Info($"GetLocByItemCode=>鏃犱綑鏂�鏌ユ壘鍏ㄩ儴{JsonConvert.SerializeObject(locs)}");
+                LogHelper.Info($"GetLocByItemCode=>鏃犱綑鏂�鏌ユ壘鍏ㄩ儴{JsonConvert.SerializeObject(locs)}");
             }
 
             return locs;
@@ -283,18 +288,33 @@
         /// </summary>
         /// <param name="areaCode">搴撳尯缂栫爜</param>
         /// <returns></returns>
-        internal static Location GetLocByAreacode(string areaCode)
+        internal static Location GetLocByAreacode(string areaCode, string type)
         {
             Location loc = new Location();
             var db = new SqlHelper<object>().GetInstance();
+            string CntrCodeWith = "";
+            if (type.Trim() == "PM")
+            {
+                CntrCodeWith = "MA";
+            }
+            else if (type.Trim() == "PN")
+            {
+                CntrCodeWith = "NA";
+            }
+            if (CntrCodeWith == "")
+            {
+                LogHelper.Info($"鎵樼洏绫诲瀷{type}涓嶅湪瑙勫畾鑼冨洿");
+            }
             var query = 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.S_AREA_CODE == areaCode && a.N_CURRENT_NUM == 1
-                       && a.N_LOCK_STATE == 0
-                       && b.S_CNTR_CODE != null && c.S_ITEM_CODE == null
-                       );
+   .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.S_AREA_CODE == areaCode && a.N_CURRENT_NUM == 1
+                   && a.N_LOCK_STATE == 0
+                   && b.S_CNTR_CODE != null && b.S_CNTR_CODE.Contains(CntrCodeWith) && c.S_ITEM_CODE == null
+                   );
             loc = query.First();
+
+
             return loc;
         }
 
@@ -544,7 +564,11 @@
                 }
                 else
                 {
-                    LogHelper.Info($"閿佸畾璐т綅{loc}鎴愬姛");
+                    LogHelper.Info($"閿佸畾璐т綅{loc}澶辫触,閲嶆柊閿�);
+                    Task.Run(() =>
+                    {
+                        LockLoc(loc, lockState);
+                    });
                 }
                 return res;
             }

--
Gitblit v1.9.1