From e4921e003cc293fea714bdaf74dc6a6b6b750295 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期六, 25 四月 2026 16:20:51 +0800
Subject: [PATCH] Merge branch 'xiaoyang' into dev

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ManualInbound/ManualInboundTaskHandler.cs |   39 +++++++++++++++++++++++++++++----------
 1 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ManualInbound/ManualInboundTaskHandler.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ManualInbound/ManualInboundTaskHandler.cs
index f97e8bf..23adac0 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ManualInbound/ManualInboundTaskHandler.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ManualInbound/ManualInboundTaskHandler.cs
@@ -1,3 +1,4 @@
+using Serilog;
 using WIDESEAWCS_Core.LogHelper;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
@@ -20,12 +21,19 @@
         private readonly ITaskService _taskService;
 
         /// <summary>
+        /// 鏃ュ織璁板綍鍣�
+        /// </summary>
+        private readonly ILogger _logger;
+
+        /// <summary>
         /// 鏋勯�犲嚱鏁�
         /// </summary>
         /// <param name="taskService">浠诲姟鏈嶅姟</param>
-        public ManualInboundTaskHandler(ITaskService taskService)
+        /// <param name="logger">鏃ュ織璁板綍鍣�</param>
+        public ManualInboundTaskHandler(ITaskService taskService, ILogger logger)
         {
             _taskService = taskService;
+            _logger = logger;
         }
 
         /// <summary>
@@ -38,37 +46,48 @@
         {
             if (conveyorLine == null || string.IsNullOrEmpty(childDeviceCode) || task == null)
             {
-                QuartzLogger.Error("ManualInboundTaskHandler.WriteTaskToPlc: 鍙傛暟涓虹┖", "ManualInbound");
+                QuartzLogHelper.LogError(_logger, "ManualInboundTaskHandler.WriteTaskToPlc: 鍙傛暟涓虹┖", "ManualInbound");
                 return;
             }
 
             try
             {
                 // 鍐欏叆浠诲姟鍙�
-                conveyorLine.SetValue(ConveyorLineDBNameNew.TaskNo, (short)task.TaskNum, childDeviceCode);
-                // 鍐欏叆璧峰鍦板潃
-                conveyorLine.SetValue(ConveyorLineDBNameNew.Source, short.Parse(task.SourceAddress ?? "0"), childDeviceCode);
+                var isTaskNum = conveyorLine.SetValue(ConveyorLineDBNameNew.TaskNo, (short)task.TaskNum, childDeviceCode);
+                if (!isTaskNum) return;
+                QuartzLogHelper.LogInfo(_logger, $"浠诲姟鍙峰啓鍏LC鎴愬姛锛屼换鍔″彿銆恵task.TaskNum}銆�", conveyorLine.DeviceCode);
+                Thread.Sleep(500);
+
+                //// 鍐欏叆璧峰鍦板潃
+                //conveyorLine.SetValue(ConveyorLineDBNameNew.Source, short.Parse(task.SourceAddress ?? "0"), childDeviceCode);
+                //QuartzLogHelper.LogInfo(_logger, $"浠诲姟鍙峰啓鍏LC鎴愬姛锛屼换鍔″彿銆恵task.TaskNum}銆�", conveyorLine.DeviceCode);
+                //Thread.Sleep(500);
+
                 // 鍐欏叆鐩爣鍦板潃
-                conveyorLine.SetValue(ConveyorLineDBNameNew.Target, short.Parse(task.NextAddress ?? "0"), childDeviceCode);
+                var isTarget = conveyorLine.SetValue(ConveyorLineDBNameNew.Target, short.Parse(task.NextAddress ?? "0"), childDeviceCode);
+                if (!isTarget) return;
+                QuartzLogHelper.LogInfo(_logger, $"鐩爣鍦板潃鍐欏叆PLC鎴愬姛锛岀洰鏍囧湴鍧�銆恵task.NextAddress}銆�", conveyorLine.DeviceCode);
+                Thread.Sleep(500);
+
                 // 鍐欏叆鎵樼洏鍙�
-                conveyorLine.SetValue(ConveyorLineDBNameNew.Barcode, task.PalletCode, childDeviceCode);
+                //conveyorLine.SetValue(ConveyorLineDBNameNew.Barcode, task.PalletCode, childDeviceCode);
 
                 // 鏇存柊浠诲姟鐘舵�佸埌涓嬩竴闃舵
                 var updateResult = _taskService.UpdateTaskStatusToNext(task);
                 if (!updateResult.Status)
                 {
-                    QuartzLogger.Error($"ManualInboundTaskHandler: 鏇存柊浠诲姟鐘舵�佸け璐ワ紝浠诲姟鍙枫�恵task.TaskNum}銆戯紝閿欒淇℃伅:{updateResult.Message}", conveyorLine.DeviceCode);
+                    QuartzLogHelper.LogError(_logger, $"ManualInboundTaskHandler: 鏇存柊浠诲姟鐘舵�佸け璐ワ紝浠诲姟鍙枫�恵task.TaskNum}銆戯紝閿欒淇℃伅:{updateResult.Message}", conveyorLine.DeviceCode);
                     return;
                 }
 
                 // 鍐欏叆ACK鏍囧織
                 conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)1, childDeviceCode);
 
-                QuartzLogger.Info($"ManualInboundTaskHandler: 鎵嬪姩浠诲姟鍐欏叆PLC鎴愬姛锛屼换鍔″彿銆恵task.TaskNum}銆戯紝婧愬湴鍧�銆恵task.SourceAddress}銆�", conveyorLine.DeviceCode);
+                QuartzLogHelper.LogInfo(_logger, $"ManualInboundTaskHandler: 鎵嬪姩浠诲姟鍐欏叆PLC鎴愬姛锛屼换鍔″彿銆恵task.TaskNum}銆戯紝婧愬湴鍧�銆恵task.SourceAddress}銆戯紝鐩爣鍦板潃銆恵task.NextAddress}銆�", conveyorLine.DeviceCode);
             }
             catch (Exception ex)
             {
-                QuartzLogger.Error($"ManualInboundTaskHandler: 鍐欏叆杈撻�佺嚎浠诲姟寮傚父锛岄敊璇俊鎭�:{ex.Message}", "ManualInbound");
+                QuartzLogHelper.LogError(_logger, ex, $"ManualInboundTaskHandler: 鍐欏叆杈撻�佺嚎浠诲姟寮傚父", $"ManualInboundTaskHandler: 鍐欏叆杈撻�佺嚎浠诲姟寮傚父锛岄敊璇俊鎭�:{ex.Message}", "ManualInbound");
             }
         }
     }

--
Gitblit v1.9.3