From 112c9bd20afed95d582b7eb227075ab8d10cdd12 Mon Sep 17 00:00:00 2001
From: 海波 张 <2956280567@qq.com>
Date: 星期二, 24 六月 2025 17:29:28 +0800
Subject: [PATCH] 金坛优化

---
 wms/LocationHelper.cs |   64 ++++++++++++++++++++++++++------
 1 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/wms/LocationHelper.cs b/wms/LocationHelper.cs
index a816b57..38141d3 100644
--- a/wms/LocationHelper.cs
+++ b/wms/LocationHelper.cs
@@ -10,6 +10,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using Top.Api;
+using WebSocketSharp.Frame;
 using static HH.WCS.ZhongCeJinTan.api.ApiModel;
 using static HH.WCS.ZhongCeJinTan.util.Settings;
 using static HH.WCS.ZhongCeJinTan.wms.WcsModel;
@@ -23,15 +24,15 @@
 
         static LocationHelper() {
             //鍒濆鍖杔ocation鍔犲叆鍒板瓧鍏哥紦瀛�-            locations = new Dictionary<string, Location>();
-            var list = GetAllLocList();
-            if (list.Count > 0) {
-                list.ForEach(a => {
-                    if (!locations.ContainsKey(a.S_CODE)) {
-                        locations.Add(a.S_CODE, a);
-                    }
-                });
-            }
+            //locations = new Dictionary<string, Location>();
+            //var list = GetAllLocList();
+            //if (list.Count > 0) {
+            //    list.ForEach(a => {
+            //        if (!locations.ContainsKey(a.S_CODE)) {
+            //            locations.Add(a.S_CODE, a);
+            //        }
+            //    });
+            //}
             //鍒濆鍖杔ocationExt鍔犲叆鍒伴泦鍚堢紦瀛�             //locationExts = new Dictionary<string, LocationExt>();
             //var exts = GetAllLocExtList();
@@ -111,7 +112,7 @@
             foreach (var item in locList)
             {
                 var ConnectionList = 0;
-                ConnectionList = db.Queryable<WMSTask>().Where(a => (a.S_END_LOC.Contains(item) || a.S_START_LOC.Contains(item)) && a.S_B_STATE != "瀹屾垚" && a.S_B_STATE != "鍙栨秷" && a.S_B_STATE != "閿欒").ToList().Count();
+                ConnectionList = db.Queryable<WMSTask>().Where(a => (a.S_END_LOC.Contains(item) || a.S_START_LOC.Contains(item)) && a.S_B_STATE != "瀹屾垚" && a.S_B_STATE != "鍙栨秷" && a.S_B_STATE != "澶辫触" && a.S_B_STATE != "宸插畬鎴� &&  a.S_B_STATE != "鏈墽琛�).ToList().Count();
                 var re = new connectionBalance();
                 var con = LocationHelper.GetLoc(item);
                 re.loc = con;
@@ -121,8 +122,18 @@
             return result.OrderBy(a => a.taskCount).ToList();
         }
 
+        /// <summary>
+        /// 杩斿洖褰撳墠鎺ラ┏浣嶆墽琛屼换鍔℃暟閲�+        /// </summary>
+        internal static int GetConnectionTaskCount(string connection)
+        {
+            var db = new SqlHelper<object>().GetInstance();
 
-        
+                var ConnectionList = 0;
+                ConnectionList = db.Queryable<WMSTask>().Where(a => (a.S_END_LOC.Contains(connection) || a.S_START_LOC.Contains(connection)) && a.S_B_STATE != "瀹屾垚" && a.S_B_STATE != "鍙栨秷" && a.S_B_STATE != "澶辫触" && a.S_B_STATE != "宸插畬鎴� ).ToList().Count();
+            return ConnectionList;
+        }
+
 
         /// <summary>
         /// 鎵剧粓鐐瑰贩閬撳彲鐢ㄧ┖璐т綅
@@ -336,7 +347,7 @@
             var v = lstTrueLocation.GroupBy(x => x.N_ROADWAY).Select(g => (new
             {
                 roadWay = g.Key,
-                qty = g.Count()
+                qty = g.Count(p => p.S_LOCK_STATE=="鏃�)
             })).OrderByDescending(o => o.qty);
 
             //鍊掑彊鎺掑垪鍚庣殑宸烽亾  寰幆
@@ -1540,5 +1551,34 @@
             }
             return res;
         }
+
+        /// <summary>
+        /// 鑾峰彇閫昏緫搴撳尯璐т綅
+        /// </summary>
+        /// <param name="zoneCode"></param>
+        /// <returns></returns>
+        public static List<Location> GetZoneLoc(string zoneCode) {
+            var db = new SqlHelper<object>().GetInstance();
+            LogHelper.Info($"ZCSendTask鍏ュ簱浠诲姟瀵绘壘閫昏緫搴撳尯鍙傛暟{zoneCode}", "Mes浠诲姟涓嬪彂");
+            var zones = db.Queryable<Zone>().Where(a => a.S_ZONE_CLS_CODE == zoneCode).ToList();
+            LogHelper.Info($"ZCSendTask鍏ュ簱浠诲姟瀵绘壘閫昏緫搴撳尯淇℃伅" +JsonConvert.SerializeObject(zones), "Mes浠诲姟涓嬪彂");
+            var locList = new List<Location>();
+
+            foreach (var item in zones)
+            {
+                var locations = db.Queryable<ZoneLoc>().Includes(t => t.Loc).Where(a => a.S_ZONE_CODE == item.S_CODE).ToList();
+             
+                foreach (var item1 in locations)
+                {
+                    locList.Add(item1.Loc);
+                }
+            }
+
+            LogHelper.Info($"ZCSendTask鍏ュ簱浠诲姟瀵绘壘閫昏緫璐т綅鏁伴噺淇℃伅{locList.Count}", "Mes浠诲姟涓嬪彂");
+
+            return locList.OrderBy(a => a.N_ROW).OrderBy(a => a.N_COL).ToList(); ;
+        }
+
+        
     }
 }

--
Gitblit v1.9.1