From 5692e40d092d4ff6b72ddfbd053ea431c8d1d876 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 03 七月 2025 17:15:14 +0800
Subject: [PATCH] 添加任务删除功能及相关接口实现

---
 CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs |   47 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
index f4e72e0..06b5fb4 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
@@ -35,6 +35,10 @@
             if (isOutTray || isOutboundAndOutFinish || !isOutboundAndLineOutExecuting)
             {
                 conveyorLine.SendCommand(taskCommand, childDeviceCode);
+                //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, taskCommand.ConveyorLineTaskNum, childDeviceCode);
+                //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, taskCommand.ConveyorLineTargetAddress, childDeviceCode);
+                //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, taskCommand.ConveyorLineBarcode, childDeviceCode);
+                //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                 _taskService.UpdateTaskStatusToNext(taskOut);
             }
             else if (taskOut.TaskType == (int)TaskOutboundTypeEnum.OutTray && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
@@ -356,7 +360,19 @@
 
                 if (_taskRepository.QueryFirst(x => x.PalletCode == command.ConveyorLineBarcode) != null)
                 {
-                    WriteInfo(conveyorLine.DeviceName, "褰撳墠鎵樼洏瀛樺湪浠诲姟");
+                    List<string> strings = new List<string>() { "3637", "3633", "3629" };
+
+                    var taskExecuting = _taskRepository.QueryFirst(x => x.PalletCode == command.ConveyorLineBarcode && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting && strings.Contains(x.TargetAddress));
+
+                    if (taskExecuting != null)
+                    {
+                        taskExecuting.ExceptionMessage = "鏈帴鏀跺埌绾夸綋瀹屾垚淇″彿绯荤粺鍐呴儴鑷姩瀹屾垚";
+                        _taskService.Delete(taskExecuting);
+                    }
+
+                    ConsoleHelper.WriteErrorLine($"褰撳墠鎵樼洏瀛樺湪浠诲姟锛氥�恵command.ConveyorLineBarcode}銆�");
+
+                    WriteInfo(conveyorLine.DeviceName, $"褰撳墠鎵樼洏瀛樺湪浠诲姟{command.ConveyorLineBarcode}");
                     return;
                 }
 
@@ -367,11 +383,12 @@
                 var content = CreateAndSendTask(taskDTO);
                 if (content.Status)
                 {
-                    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+                    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.ConveyorLineBarcode);
                     if (task != null)
                     {
-                        var taskCommand = MapTaskCommand(task, command);
-                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
+                        conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, (long)task.TaskNum, childDeviceCode);
+                        conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, childDeviceCode);
+                        conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, childDeviceCode);
                         conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                         _taskService.UpdateTaskStatusToNext(task);
                     }
@@ -392,7 +409,7 @@
 
             var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
             var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
-            var requestTrayInTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
+            var requestTrayInTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTrayInTask)?.ConfigValue;
             if (wmsBase == null || requestTrayInTask == null)
             {
                 throw new InvalidOperationException("WMS IP 鏈厤缃�");
@@ -419,8 +436,9 @@
             var Hastask = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode);
             if (Hastask != null)
             {
-                ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(Hastask);
-                conveyorLine.SendCommand(taskCommand, childDeviceCode);
+                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, (long)Hastask.TaskNum, childDeviceCode);
+                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Hastask.NextAddress, childDeviceCode);
+                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, Hastask.PalletCode, childDeviceCode);
                 conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                 return;
             }
@@ -431,17 +449,22 @@
                 var task = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode);
                 if (task != null)
                 {
-                    ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
-                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
+                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, (long)task.TaskNum, childDeviceCode);
+                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, childDeviceCode);
+                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, childDeviceCode);
                     conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                     _taskService.UpdateTaskStatusToNext(task);
                 }
             }
             else
             {
-                WriteInfo(conveyorLine.DeviceName, content.Message);
-                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode);
-                conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
+                if (content.Message != "璇锋眰杩囦簬棰戠箒锛岃绋嶅悗鍐嶈瘯" || content.Message != "鏃犳硶鑾峰彇鐩爣鍦板潃")
+                {
+                    WriteInfo(conveyorLine.DeviceName, content.Message);
+                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode);
+                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
+                    ConsoleHelper.WriteErrorLine($"銆恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戣姹傜偣浣嶏細銆恵childDeviceCode}銆戝紓甯镐俊鎭�恵content.Message}銆�");
+                }
                 ConsoleHelper.WriteErrorLine($"銆恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戣姹傜偣浣嶏細銆恵childDeviceCode}銆戝紓甯镐俊鎭�恵content.Message}銆�");
             }
         }

--
Gitblit v1.9.3