From 3406bbd34469982efeefe164c207dcb5c4a0dac2 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 30 四月 2026 22:03:54 +0800
Subject: [PATCH] fix: 修复多个功能模块中的问题和优化逻辑

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

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
index 7788251..fa281cd 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
@@ -1,16 +1,11 @@
 using MapsterMapper;
 using Masuit.Tools;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json;
 using Quartz;
 using Serilog;
 using SqlSugar;
 using WIDESEA_Core;
-using WIDESEAWCS_Common.HttpEnum;
 using WIDESEAWCS_Common.TaskEnum;
-using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
-using WIDESEAWCS_DTO.TaskInfo;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
@@ -228,7 +223,11 @@
                             {
                                 // 濡傛灉 WCS_ACK 涓� 1锛屽厛娓呴櫎锛堣〃绀哄鐞嗚繃涓婁竴娆¤姹傦級
                                 if (command.WCS_ACK == 1)
-                                    conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)0, childDeviceCode);
+                                {
+                                    conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (byte)0, childDeviceCode);
+                                    //Thread.Sleep(300);
+                                    //conveyorLine.SetValue(ConveyorLineDBNameNew.Target, (short)0, childDeviceCode);
+                                }
 
                                 // 澶勭悊鎵嬪姩鍏ュ簱浠诲姟锛堣捣鐐逛负绾夸綋鐐逛綅鐨勪换鍔★級
                                 try
@@ -247,17 +246,36 @@
                                 }
                                 continue;
                             }
+                            else
+                            {
+                                if (childDeviceCode == "2103" || childDeviceCode == "2101")
+                                {
+                                    try
+                                    {
+                                        var task = _taskService.QueryManualInboundTask(childDeviceCode);
+                                        if (task != null)
+                                        {
+                                            QuartzLogHelper.LogInfo(_logger, $"鑾峰彇鍒拌緭閫佺嚎寮�濮嬩换鍔★紝浠诲姟鍙凤細{task.TaskNum}锛岀姸鎬�: {task.TaskStatus},褰撳墠鍦板潃锛歿conveyorLine.DeviceCode}", conveyorLine.DeviceCode);
+                                            var handler = new ManualInboundTaskHandler(_taskService, _logger);
+                                            handler.WriteTaskToPlc(conveyorLine, childDeviceCode, task);
+                                        }
+                                    }
+                                    catch (Exception ex)
+                                    {
+                                        QuartzLogHelper.LogError(_logger, ex, "澶勭悊鎵嬪姩鍏ュ簱浠诲姟寮傚父", $"澶勭悊鎵嬪姩鍏ュ簱浠诲姟寮傚父: {ex.Message}", "CommonConveyorLineNewJob");
+                                    }
+                                }
+                            }
 
-                            // ========== 澶勭悊鏃犳墭鐩樻潯鐮佺殑鎯呭喌 ==========
-                            // 鏃犳墭鐩樻潯鐮佹椂锛岃姹傚嚭搴撲换鍔�
-                            if (command.Barcode.IsNullOrEmpty() || command.Barcode.Replace("\0", "") == "")
+                            // 濡傛灉 PLC_STB 涓� 1锛屼絾娌℃湁浠诲姟鍙凤紝鍙兘鏄柊浠诲姟鐨勫紑濮嬶紝鍏堣姹傚嚭搴撲换鍔★紙閫傜敤浜庢棤鏉$爜鐨勬儏鍐碉級
+                            if (command.TaskNo == 1000)
                             {
                                 _conveyorLineDispatch.RequestOutbound(conveyorLine, command, childDeviceCode);
                                 continue;
                             }
 
                             // ========== 澶勭悊宸叉湁浠诲姟鍙风殑鎯呭喌 ==========
-                            if (command.TaskNo > 0 && !command.Barcode.IsNullOrEmpty())
+                            if (command.TaskNo > 0)
                             {
                                 // 鏌ヨ姝e湪鎵ц鐨勪换鍔�
                                 Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode);
@@ -299,48 +317,6 @@
                                         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;
-                                //    }
-
-                                //    // 璋冪敤 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);
-
-                                //    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);
-                                //    }
-                                //}
                             }
                         }
                         catch (Exception innerEx)

--
Gitblit v1.9.3