From 4b483d9d06bead231b88ca212fd799196668a057 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期二, 28 四月 2026 22:58:27 +0800
Subject: [PATCH] fix(任务服务): 修复出库任务选择逻辑和货位分配问题

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs |  168 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 84 insertions(+), 84 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
index 8b45c00..7788251 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
@@ -88,7 +88,7 @@
         /// </summary>
         /// <remarks>
         /// </remarks>
-        private static List<string> AddressToDeviceType = new List<string> { "11020", "11028", "2125" };
+        private static List<string> AddressToDeviceType = new List<string> { "11020", "11028", "2125", "11062" };
 
         /// <summary>
         /// 鎵樼洏妫�鏌ヤ綅缃殑鏈�杩戞墽琛屾椂闂达紙鐢ㄤ簬30绉掗棿闅旈檺鍒讹級
@@ -168,57 +168,57 @@
 
                             // ========== 妫�鏌ョ壒瀹氫綅缃槸鍚︽湁鎵樼洏 ==========
                             // 浠庨厤缃腑璇诲彇闇�瑕佹鏌ユ墭鐩樼殑浣嶇疆鍒楄〃
-                            var checkPalletPositions = App.Configuration.GetSection("CheckPalletPositions")
-                                .Get<List<CheckPalletPosition>>() ?? new List<CheckPalletPosition>();
+                            //var checkPalletPositions = App.Configuration.GetSection("CheckPalletPositions")
+                            //    .Get<List<CheckPalletPosition>>() ?? new List<CheckPalletPosition>();
 
-                            // 濡傛灉褰撳墠璁惧鍦ㄦ鏌ュ垪琛ㄤ腑
-                            if (checkPalletPositions.Any(x => x.Code == childDeviceCode))
-                            {
-                                // 30绉掗棿闅旈檺鍒�
-                                if (_lastPalletCheckTime.TryGetValue(childDeviceCode, out var lastTime) &&
-                                    (DateTime.Now - lastTime).TotalSeconds < 30)
-                                {
-                                    continue;
-                                }
+                            //// 濡傛灉褰撳墠璁惧鍦ㄦ鏌ュ垪琛ㄤ腑
+                            //if (checkPalletPositions.Any(x => x.Code == childDeviceCode))
+                            //{
+                            //    // 30绉掗棿闅旈檺鍒�
+                            //    if (_lastPalletCheckTime.TryGetValue(childDeviceCode, out var lastTime) &&
+                            //        (DateTime.Now - lastTime).TotalSeconds < 30)
+                            //    {
+                            //        continue;
+                            //    }
 
-                                // 妫�鏌ヨ緭閫佺嚎鐘舵�侊紙鏄惁鏈夋墭鐩橈級
-                                if (command.CV_State == 2)
-                                {
-                                    // 妫�鏌ヨ浣嶇疆鏄惁宸叉湁浠诲姟
-                                    var existingTask = _taskService.Db.Queryable<Dt_Task>().Count(x => x.TargetAddress == childDeviceCode);
-                                    if (existingTask < 5)
-                                    {
-                                        // 娌℃湁浠诲姟锛屽悜 WMS 璇锋眰鍑哄簱鎵樼洏浠诲姟
-                                        var position = checkPalletPositions.FirstOrDefault(x => x.Code == childDeviceCode);
+                            //    // 妫�鏌ヨ緭閫佺嚎鐘舵�侊紙鏄惁鏈夋墭鐩橈級
+                            //    if (command.CV_State == 2)
+                            //    {
+                            //        // 妫�鏌ヨ浣嶇疆鏄惁宸叉湁浠诲姟
+                            //        var existingTask = _taskService.Db.Queryable<Dt_Task>().Count(x => x.TargetAddress == childDeviceCode);
+                            //        if (existingTask < 5)
+                            //        {
+                            //            // 娌℃湁浠诲姟锛屽悜 WMS 璇锋眰鍑哄簱鎵樼洏浠诲姟
+                            //            var position = checkPalletPositions.FirstOrDefault(x => x.Code == childDeviceCode);
 
-                                        string configKey = "GetOutBoundTrayTaskAsync";
-                                        string requestParam = new CreateTaskDto()
-                                        {
-                                            WarehouseId = position.WarehouseId,
-                                            TargetAddress = childDeviceCode
-                                        }.Serialize();
-                                        DateTime startTime = DateTime.Now;
+                            //            string configKey = "GetOutBoundTrayTaskAsync";
+                            //            string requestParam = new CreateTaskDto()
+                            //            {
+                            //                WarehouseId = position.WarehouseId,
+                            //                TargetAddress = childDeviceCode
+                            //            }.Serialize();
+                            //            DateTime startTime = DateTime.Now;
 
-                                        var responseResult = _httpClientHelper.Post<WebResponseContent>(configKey, requestParam);
+                            //            var responseResult = _httpClientHelper.Post<WebResponseContent>(configKey, requestParam);
 
-                                        _lastPalletCheckTime[childDeviceCode] = DateTime.Now;
+                            //            _lastPalletCheckTime[childDeviceCode] = DateTime.Now;
 
-                                        // 濡傛灉璇锋眰鎴愬姛锛屾帴鏀� WMS 杩斿洖鐨勪换鍔�
-                                        if (responseResult.IsSuccess && responseResult.Data.Status)
-                                        {
-                                            QuartzLogHelper.LogInfo(_logger, $"璋冪敤WMS鎺ュ彛鎴愬姛,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,鍝嶅簲鏁版嵁:銆恵responseResult.Data?.Data}銆�,鑰楁椂:{(DateTime.Now - startTime).TotalMilliseconds}ms", conveyorLine.DeviceCode);
-                                            var wmsTask = JsonConvert.DeserializeObject<WMSTaskDTO>(responseResult.Data.Data.ToString());
-                                            List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { wmsTask };
-                                            if (wmsTask != null)
-                                                _taskService.ReceiveWMSTask(taskDTOs);
-                                        }
-                                        else
-                                        {
-                                            QuartzLogHelper.LogError(_logger, $"璋冪敤WMS鎺ュ彛澶辫触,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,閿欒淇℃伅:銆恵responseResult.Data?.Message}銆�", conveyorLine.DeviceCode);
-                                        }
-                                    }
-                                }
-                            }
+                            //            // 濡傛灉璇锋眰鎴愬姛锛屾帴鏀� WMS 杩斿洖鐨勪换鍔�
+                            //            if (responseResult.IsSuccess && responseResult.Data.Status)
+                            //            {
+                            //                QuartzLogHelper.LogInfo(_logger, $"璋冪敤WMS鎺ュ彛鎴愬姛,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,鍝嶅簲鏁版嵁:銆恵responseResult.Data?.Data}銆�,鑰楁椂:{(DateTime.Now - startTime).TotalMilliseconds}ms", conveyorLine.DeviceCode);
+                            //                var wmsTask = JsonConvert.DeserializeObject<WMSTaskDTO>(responseResult.Data.Data.ToString());
+                            //                List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { wmsTask };
+                            //                if (wmsTask != null)
+                            //                    _taskService.ReceiveWMSTask(taskDTOs);
+                            //            }
+                            //            else
+                            //            {
+                            //                QuartzLogHelper.LogError(_logger, $"璋冪敤WMS鎺ュ彛澶辫触,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,閿欒淇℃伅:銆恵responseResult.Data?.Message}銆�", conveyorLine.DeviceCode);
+                            //            }
+                            //        }
+                            //    }
+                            //}
 
                             #endregion 妫�娴嬫槸鍚﹂渶瑕佺┖鎵樼洏
 
@@ -299,48 +299,48 @@
                                         conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)1, childDeviceCode);
                                     }
                                 }
-                                else if (!command.Barcode.IsNullOrEmpty() && (childDeviceCode == "11001" || childDeviceCode == "11010"))
-                                {
-                                    var isWcsTask = _taskService.Db.Queryable<Dt_Task>().Any(x => x.PalletCode == command.Barcode && (x.TaskStatus == (int)TaskOutStatusEnum.OutNew || x.TaskStatus == (int)TaskInStatusEnum.InNew));
-                                    var isRobotTask = _robotTaskService.Db.Queryable<Dt_RobotTask>().Any(x => x.RobotTargetAddressPalletCode == command.Barcode);
-                                    if (isWcsTask || isRobotTask)
-                                    {
-                                        continue;
-                                    }
+                                //else if (!command.Barcode.IsNullOrEmpty() && (childDeviceCode == "11001" || childDeviceCode == "11010"))
+                                //{
+                                //    var isWcsTask = _taskService.Db.Queryable<Dt_Task>().Any(x => x.PalletCode == command.Barcode && (x.TaskStatus == (int)TaskOutStatusEnum.OutNew || x.TaskStatus == (int)TaskInStatusEnum.InNew));
+                                //    var isRobotTask = _robotTaskService.Db.Queryable<Dt_RobotTask>().Any(x => x.RobotTargetAddressPalletCode == command.Barcode);
+                                //    if (isWcsTask || isRobotTask)
+                                //    {
+                                //        continue;
+                                //    }
 
-                                    // 璋冪敤 WMS 鍒涘缓绌烘墭鐩樺叆搴撲换鍔�
-                                    string configKey = nameof(ConfigKey.CreateTaskInboundAsync);
-                                    string requestParam = new CreateTaskDto()
-                                    {
-                                        PalletCode = command.Barcode,
-                                        SourceAddress = childDeviceCode,
-                                        TargetAddress = "GWSC1",  // 鐩爣鍦板潃
-                                        Roadway = "GWSC1",             // 宸烽亾
-                                        WarehouseId = 1,                   // 浠撳簱 ID
-                                        PalletType = 1,                             // 鎵樼洏绫诲瀷锛堥粯璁や负1锛�
-                                        TaskType = TaskTypeEnum.InEmpty.GetHashCode()                         // 浠诲姟绫诲瀷锛堝叆搴�/绌烘墭鐩樺叆搴擄級
-                                    }.Serialize();
-                                    DateTime startTime = DateTime.Now;
+                                //    // 璋冪敤 WMS 鍒涘缓绌烘墭鐩樺叆搴撲换鍔�
+                                //    string configKey = nameof(ConfigKey.CreateTaskInboundAsync);
+                                //    string requestParam = new CreateTaskDto()
+                                //    {
+                                //        PalletCode = command.Barcode,
+                                //        SourceAddress = childDeviceCode,
+                                //        TargetAddress = "GWSC1",  // 鐩爣鍦板潃
+                                //        Roadway = "GWSC1",             // 宸烽亾
+                                //        WarehouseId = 1,                   // 浠撳簱 ID
+                                //        PalletType = 1,                             // 鎵樼洏绫诲瀷锛堥粯璁や负1锛�
+                                //        TaskType = TaskTypeEnum.InEmpty.GetHashCode()                         // 浠诲姟绫诲瀷锛堝叆搴�/绌烘墭鐩樺叆搴擄級
+                                //    }.Serialize();
+                                //    DateTime startTime = DateTime.Now;
 
-                                    var responseResult = _httpClientHelper.Post<WebResponseContent>(configKey, requestParam);
+                                //    var responseResult = _httpClientHelper.Post<WebResponseContent>(configKey, requestParam);
 
-                                    if (responseResult.IsSuccess && responseResult.Data.Status)
-                                    {
-                                        QuartzLogHelper.LogInfo(_logger, $"璋冪敤WMS鎺ュ彛鎴愬姛,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,鍝嶅簲鏁版嵁:銆恵responseResult.Data?.Data}銆�,鑰楁椂:{(DateTime.Now - startTime).TotalMilliseconds}ms", conveyorLine.DeviceCode);
-                                        var wmsTask = JsonConvert.DeserializeObject<WMSTaskDTO>(responseResult?.Data?.Data?.ToString());
-                                        List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { wmsTask };
-                                        if (wmsTask == null) continue;
+                                //    if (responseResult.IsSuccess && responseResult.Data.Status)
+                                //    {
+                                //        QuartzLogHelper.LogInfo(_logger, $"璋冪敤WMS鎺ュ彛鎴愬姛,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,鍝嶅簲鏁版嵁:銆恵responseResult.Data?.Data}銆�,鑰楁椂:{(DateTime.Now - startTime).TotalMilliseconds}ms", conveyorLine.DeviceCode);
+                                //        var wmsTask = JsonConvert.DeserializeObject<WMSTaskDTO>(responseResult?.Data?.Data?.ToString());
+                                //        List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { wmsTask };
+                                //        if (wmsTask == null) continue;
 
-                                        if (_taskService.ReceiveWMSTask(taskDTOs).Status)
-                                        {
-                                            conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)1, childDeviceCode);
-                                        }
-                                    }
-                                    else
-                                    {
-                                        QuartzLogHelper.LogError(_logger, $"璋冪敤WMS鎺ュ彛澶辫触,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,閿欒淇℃伅:銆恵responseResult.Data?.Message}銆�", conveyorLine.DeviceCode);
-                                    }
-                                }
+                                //        if (_taskService.ReceiveWMSTask(taskDTOs).Status)
+                                //        {
+                                //            conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)1, childDeviceCode);
+                                //        }
+                                //    }
+                                //    else
+                                //    {
+                                //        QuartzLogHelper.LogError(_logger, $"璋冪敤WMS鎺ュ彛澶辫触,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,閿欒淇℃伅:銆恵responseResult.Data?.Message}銆�", conveyorLine.DeviceCode);
+                                //    }
+                                //}
                             }
                         }
                         catch (Exception innerEx)

--
Gitblit v1.9.3