From 6b74e1dcf5642c8f56975471e27780d695953989 Mon Sep 17 00:00:00 2001
From: 陈勇 <竞男@ASUNA>
Date: 星期日, 26 四月 2026 15:48:01 +0800
Subject: [PATCH] 同步代码

---
 项目代码/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/RequestInboundRoadWayNo.cs |  101 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 64 insertions(+), 37 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/RequestInboundRoadWayNo.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/RequestInboundRoadWayNo.cs"
index d1f14f2..b346732 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/RequestInboundRoadWayNo.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/RequestInboundRoadWayNo.cs"
@@ -36,9 +36,6 @@
                     return response.OK("鐢宠鍏ュ簱鎴愬姛", data: checkTask);
                 }
 
-                var carInfo = _carBodyInfoRepository.QueryFirst(x => x.RFID == json.PVI && x.PalletCode == json.PalletCode);
-                if (carInfo == null) throw new Exception("鏈煡杞﹁韩淇℃伅,鏃犳硶鍏ュ簱");
-
                 //灞忚斀MES
                 if (json.Position == "EL01RB")
                 {
@@ -51,16 +48,8 @@
                     TZPassZZ(json);
                 }
 
-           
-                //{
-                //    Dt_CarBodyInfo _CarBodyInfo = new Dt_CarBodyInfo  //娴嬭瘯
-                //    {
-                //        PVI = "J25000660",
-                //        RFID = json.PVI,
-                //        BodyStatus = 0,
-                //        CarType = 1,
-                //    };
-                //}
+                var carInfo = _carBodyInfoRepository.QueryFirst(x => x.RFID == json.PVI && x.PalletCode == json.PalletCode);
+                if (carInfo == null) throw new Exception("鏈煡杞﹁韩淇℃伅,鏃犳硶鍏ュ簱");
 
                 List<Dt_RoadWay> roadWays = new List<Dt_RoadWay>();
                 if (carInfo.CarType == 1)
@@ -69,38 +58,47 @@
                 }
                 else if (carInfo.CarType == 2)
                 {
-                    roadWays = _roadWayRepository.QueryData(x => x.WirteCar == 2);
+                    roadWays = _roadWayRepository.QueryData(x => x.ColorCar == 2);
                 }
 
-                //var locations = _locationRepository.QueryData(x => (x.LocationType == carInfo.CarType || x.LocationType == 3) && x.LocationStatus == (int)LocationEnum.Free && x.EnalbeStatus == (int)EnableEnum.Enable);
+                string maxRoadwayNo = GetInboundRoadWayNo(carInfo.CarType);
 
-                var maxGroup = _locationRepository.QueryData(x => x.LocationType == carInfo.CarType && x.LocationStatus == (int)LocationEnum.Free && x.EnalbeStatus == (int)EnableEnum.Enable)
-                                .GroupBy(x => x.RoadwayNo)
-                                .OrderByDescending(g => g.Count()) // 鏍规嵁姣忎釜缁勭殑鍏冪礌鏁伴噺鎺掑簭
-                                .ToList(); // 鍙栧嚭鏁伴噺鏈�澶氱殑缁�
-
-                if (maxGroup.Count == 0)
+                if (string.IsNullOrEmpty(maxRoadwayNo))
                 {
-                    maxGroup = _locationRepository.QueryData(x => x.LocationType == (int)BodyType.Empty && x.LocationStatus == (int)LocationEnum.Free && x.EnalbeStatus == (int)EnableEnum.Enable)
-                   .GroupBy(x => x.RoadwayNo)
-                   .OrderByDescending(g => g.Count()) // 鏍规嵁姣忎釜缁勭殑鍏冪礌鏁伴噺鎺掑簭
-                   .ToList(); // 鍙栧嚭鏁伴噺鏈�澶氱殑缁�
+                    maxRoadwayNo = GetInboundRoadWayNo(3);
                 }
 
-                if (maxGroup.Count == 0) return response.Error(12, "鏃犲彲鐢ㄥ簱浣�");
+                if (string.IsNullOrEmpty(maxRoadwayNo)) return response.Error(12, "鏃犲彲鐢ㄥ簱浣�");
 
-                Dictionary<string, int> result = new Dictionary<string, int>();
-                foreach (var item in maxGroup)
-                {
-                    var number = _taskRepository.QueryData(x => x.RoadwayNo == item.Key && x.CarType == carInfo.CarType && (x.TaskType == (int)TaskInboundTypeEnum.Inbound || x.TaskType == (int)TaskInboundTypeEnum.InTray)).Count();
-                    if (item.Count() - number <= 0)
-                    {
-                        continue;
-                    }
-                    result.Add(item.Key, item.Count() - number);
-                }
+                #region 鍘熷簱浣嶅垎閰�
+                //var maxGroup = _locationRepository.QueryData(x => x.LocationType == carInfo.CarType && x.LocationStatus == (int)LocationEnum.Free && x.EnalbeStatus == (int)EnableEnum.Enable)
+                //                .GroupBy(x => x.RoadwayNo)
+                //                .OrderByDescending(g => g.Count()) // 鏍规嵁姣忎釜缁勭殑鍏冪礌鏁伴噺鎺掑簭
+                //                .ToList(); // 鍙栧嚭鏁伴噺鏈�澶氱殑缁�
 
-                string maxRoadwayNo = result.OrderByDescending(x => x.Value).FirstOrDefault().Key; // 鏁伴噺鏈�澶氱殑缁勭殑Key
+                //if (maxGroup.Count == 0)
+                //{
+                //    maxGroup = _locationRepository.QueryData(x => x.LocationType == (int)BodyType.Empty && x.LocationStatus == (int)LocationEnum.Free && x.EnalbeStatus == (int)EnableEnum.Enable)
+                //   .GroupBy(x => x.RoadwayNo)
+                //   .OrderByDescending(g => g.Count()) // 鏍规嵁姣忎釜缁勭殑鍏冪礌鏁伴噺鎺掑簭
+                //   .ToList(); // 鍙栧嚭鏁伴噺鏈�澶氱殑缁�
+                //}
+
+                //if (maxGroup.Count == 0) return response.Error(12, "鏃犲彲鐢ㄥ簱浣�");
+
+                //Dictionary<string, int> result = new Dictionary<string, int>();
+                //foreach (var item in maxGroup)
+                //{
+                //    var number = _taskRepository.QueryData(x => x.RoadwayNo == item.Key && x.CarType == carInfo.CarType && (x.TaskType == (int)TaskInboundTypeEnum.Inbound || x.TaskType == (int)TaskInboundTypeEnum.InTray)).Count();
+                //    if (item.Count() - number <= 0)
+                //    {
+                //        continue;
+                //    }
+                //    result.Add(item.Key, item.Count() - number);
+                //}
+
+                //string maxRoadwayNo = result.OrderByDescending(x => x.Value).FirstOrDefault().Key; // 鏁伴噺鏈�澶氱殑缁勭殑Key  
+                #endregion
 
                 var stationList = _stationManagerRepository.QueryData(x => x.RoadwayNo == maxRoadwayNo && x.stationArea == json.area && x.stationType == 1 && x.stationStatus == "1");
 
@@ -159,5 +157,34 @@
             }
             return response;
         }
+
+        private string GetInboundRoadWayNo(int CarType)
+        {
+            var maxGroup = _locationRepository.QueryData(x => x.LocationType == CarType && x.LocationStatus == (int)LocationEnum.Free && x.EnalbeStatus == (int)EnableEnum.Enable)
+                                .GroupBy(x => x.RoadwayNo)
+                                .OrderByDescending(g => g.Count()) // 鏍规嵁姣忎釜缁勭殑鍏冪礌鏁伴噺鎺掑簭
+                                .ToList(); // 鍙栧嚭鏁伴噺鏈�澶氱殑缁�
+
+            Dictionary<string, int> result = new Dictionary<string, int>();
+            foreach (var item in maxGroup)
+            {
+                int number = 0;
+                if (CarType == 3)
+                {
+                    number = _taskRepository.QueryData(x => x.RoadwayNo == item.Key && (x.TaskType == (int)TaskInboundTypeEnum.Inbound || x.TaskType == (int)TaskInboundTypeEnum.InTray) && x.TaskState <= (int)TaskInStatusEnum.Line_InFinish).Count();
+                }
+                else
+                {
+                    number = _taskRepository.QueryData(x => x.RoadwayNo == item.Key && x.CarType == CarType && (x.TaskType == (int)TaskInboundTypeEnum.Inbound || x.TaskType == (int)TaskInboundTypeEnum.InTray) && x.TaskState <= (int)TaskInStatusEnum.Line_InFinish).Count();
+                }
+                if (item.Count() - number <= 0)
+                {
+                    continue;
+                }
+                result.Add(item.Key, item.Count() - number);
+            }
+            return result.OrderByDescending(x => x.Value).FirstOrDefault().Key; // 鏁伴噺鏈�澶氱殑缁勭殑Key
+        }
+
     }
 }

--
Gitblit v1.9.3