From 843cc2ea1b104ecdf9da61318a4136a5d4096411 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期五, 24 四月 2026 11:07:21 +0800
Subject: [PATCH] 集成Quartz定时任务,支持NG出库自动化及WMS/WCS接口扩展

---
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs |  156 +++++++++++++--------------------------------------
 1 files changed, 41 insertions(+), 115 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs
index b15cf35..33a03e9 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs
@@ -47,94 +47,46 @@
         /// </summary>
         private void HandleNewTask(CommonConveyorLine_CW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
         {
-            Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
-
-            if (stationManager == null)
+            try
             {
-                // Handle the case where stationManager is not found, if necessary
-                Console.WriteLine($"鏈壘鍒皗childDeviceCode}绔欏彴");
-                return;
-            }
 
-            // 鏍规嵁绔欑被鍨嬫墽琛岀浉搴旂殑鏂规硶
-            switch (stationManager.stationType)
-            {
-                case 8:
-                case 9:
-                case 11:
-                case 12:
-                    var task = _taskService.QueryExecutingTaskByBarcode(command.ConveyorLineBarcode, childDeviceCode);
-                    if (task != null)
-                    {
+                Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
+
+                if (stationManager == null)
+                {
+                    // Handle the case where stationManager is not found, if necessary
+                    Console.WriteLine($"鏈壘鍒皗childDeviceCode}绔欏彴");
+                    return;
+                }
+
+                // 鏍规嵁绔欑被鍨嬫墽琛岀浉搴旂殑鏂规硶
+                switch (stationManager.stationType)
+                {
+                    case 8:
+                    case 9:
+                    case 11:
+                    case 12:
+                        var task = _taskService.QueryExecutingTaskByBarcode(command.ConveyorLineBarcode, childDeviceCode);
+                        if (task != null)
+                        {
+                            ExecuteStationAction(stationManager, conveyorLine, command, childDeviceCode);
+                        }
+                        break;
+                    case 1:
+                    case 6:
+                    case 10:
                         ExecuteStationAction(stationManager, conveyorLine, command, childDeviceCode);
-                    }
-                    break;
-                case 1:
-                case 6:
-                case 10:
-                    ExecuteStationAction(stationManager, conveyorLine, command, childDeviceCode);
-                    break;
-                    //case 16:
-                    //    ExecuteStationAction(stationManager, conveyorLine, command, childDeviceCode);
-                    //    break;
+                        break;
+                        //case 16:
+                        //    ExecuteStationAction(stationManager, conveyorLine, command, childDeviceCode);
+                        //    break;
+                }
+
             }
-
-            #region
-            //Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
-
-            //if (stationManager.stationType == 8)
-            //{
-            //    var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
-            //    if (task != null)
-            //    {
-            //        RequestInNextAddress(conveyorLine, command, childDeviceCode);
-            //    }
-            //}
-            //else if (stationManager.stationType == 9)
-            //{
-            //    var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
-            //    if (task != null)
-            //    {
-            //        ConveyorLineInFinish(conveyorLine, command, childDeviceCode);
-            //    }
-            //}
-            //else if (stationManager.stationType == 1)
-            //{
-            //    if (stationManager.stationArea.Contains("GW"))
-            //    {
-            //        var taskGW = _taskRepository.QueryFirst(x => x.TargetAddress == childDeviceCode && x.TaskState == (int)TaskOutStatusEnum.OutFinish);
-            //        if (taskGW != null)
-            //        {
-            //            command.ConveyorLineBarcode = taskGW.PalletCode;
-            //        }
-            //    }
-            //    RequestWmsTask(conveyorLine, command, childDeviceCode);
-            //}
-            //else if (stationManager.stationType == 10)
-            //{
-            //    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
-            //    if (task != null)
-            //    {
-            //        RequestOutbound(conveyorLine, command, childDeviceCode);
-            //    }
-            //}
-            //else if (stationManager.stationType == 11)
-            //{
-            //    var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
-            //    if (task != null)
-            //    {
-            //        RequestOutNextAddress(conveyorLine, command, childDeviceCode);
-            //    }
-            //}
-            //else if (stationManager.stationType == 12)
-            //{
-            //    var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
-            //    if (task != null)
-            //    {
-            //        ConveyorLineOutFinish(conveyorLine, command, childDeviceCode);
-            //    }
-            //}
-            #endregion
+            catch (Exception ex)
+            {
+                WriteInfo("HandleNewTask", $"銆恵ex.Message}銆�");
+            }
         }
 
         private void ExecuteStationAction(Dt_StationManager stationManager, CommonConveyorLine_CW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
@@ -168,23 +120,6 @@
                     AbNormalStationBZTask(conveyorLine, command, childDeviceCode);
                     break;
                 case 1:
-
-                    //if (stationManager.stationArea.Contains("GW"))
-                    //{
-                    //var taskGW = _taskRepository.QueryFirst(x => x.TargetAddress == childDeviceCode && (x.TaskState == (int)TaskOutStatusEnum.OutFinish || x.TaskState == (int)TaskOutStatusEnum.OutPending));
-                    //if (taskGW != null)
-                    //{
-                    //    command.ConveyorLineBarcode = taskGW.PalletCode;
-                    //}
-                    //}
-                    //濡傞珮娓╁嚭搴撳悗浠诲姟鏍囪NG寮傚父鍒欏皢浠诲姟鏇存柊涓哄紓甯告帓鍑轰换鍔�   --鍐犲畤鍙栨秷瓒呮椂妫�娴嬪悗  鎵樼洏瓒呮椂涓嶅湪鍑哄簱鑷冲紓甯稿彛
-                    //Dt_Task NGtask = _taskRepository.QueryFirst(x => x.Remark == "NG" && x.Roadway == stationManager.Roadway && x.Roadway.Contains("GW"));
-                    //if (NGtask != null)
-                    //{
-                    //    CreateAbNormalOutbound(conveyorLine, command, childDeviceCode, NGtask);
-                    //    break;
-                    //}
-
                     RequestWmsTask(conveyorLine, command, childDeviceCode, stationManager);
                     break;
             }
@@ -254,8 +189,6 @@
                         _taskService.Delete(taskExecuting);
                     }
 
-                    ConsoleHelper.WriteErrorLine($"褰撳墠鎵樼洏瀛樺湪浠诲姟锛氥�恵command.ConveyorLineBarcode}銆�");
-
                     WriteInfo(conveyorLine.DeviceName, $"褰撳墠鎵樼洏瀛樺湪浠诲姟{command.ConveyorLineBarcode}");
                 }
 
@@ -296,7 +229,9 @@
                 throw new InvalidOperationException("WMS IP 鏈厤缃�");
             }
             var wmsIpAddrss = wmsBase + requestTrayInTask;
+
             var result = HttpHelper.PostAsync(wmsIpAddrss, request.ToJsonString()).Result;
+
             if (result == null)
                 return new WMSTaskDTO();
 
@@ -315,24 +250,15 @@
             try
             {
                 if (command.ConveyorLineBarcode.IsNullOrEmpty()) return;
+
                 var content = await _taskService.RequestWMSTask(command.ConveyorLineBarcode, childDeviceCode);
+
                 if (content.Status)
                 {
                     var task = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode);
                     if (task != null)
                     {
-                        if (childDeviceCode == "1039")
-                        {
-                            var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList();
-                            if (GWTask.Count >= 2 && childDeviceCode == "1039" && task.Roadway.Contains("GWSC2"))
-                            {
-                                ConsoleHelper.WriteErrorLine($"鎵樼洏鍙凤細銆恵command.ConveyorLineBarcode}銆戦珮娓╀簩宸插瓨鍦ㄣ�恵GWTask.Count}銆戜釜浠诲姟澶т簬2涓换鍔′笉鍙笅鍙�");
-                                return;
-                            }
-                        }
-
                         ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
-                        //conveyorLine.SendCommand(taskCommand, childDeviceCode);
 
                         bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode);
                         if (sendFlag)
@@ -345,7 +271,7 @@
                 }
                 else
                 {
-                    if (content.Message != "璇锋眰杩囦簬棰戠箒锛岃绋嶅悗鍐嶈瘯" && content.Message != "鏃犳硶鑾峰彇鐩爣鍦板潃")
+                    if (content.Message != "璇锋眰杩囦簬棰戠箒锛岃绋嶅悗鍐嶈瘯" && content.Message != "鏃犳硶鑾峰彇鐩爣鍦板潃" && !content.Message.Contains("瀛樺湪浠诲姟") && !content.Message.Contains("瀛樺湪搴撳瓨涓嶅厑璁稿叆搴�"))
                     {
                         WriteInfo(conveyorLine.DeviceName, content.Message);
                         conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode);

--
Gitblit v1.9.3