From bf2aa9dd56432a74940ca1bb08fb4d7eaee37045 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 27 三月 2026 11:03:37 +0800
Subject: [PATCH] feat(WCS): 完善 WIDESEAWCS_Tasks 模块日志系统

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs
index 24700ff..5072e29 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs
@@ -1,7 +1,9 @@
 using MapsterMapper;
+using Microsoft.Extensions.Logging;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core.LogHelper;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
@@ -47,6 +49,11 @@
         private readonly IMapper _mapper;
 
         /// <summary>
+        /// 鏃ュ織璁板綍鍣�
+        /// </summary>
+        private readonly ILogger _logger;
+
+        /// <summary>
         /// 杈撻�佺嚎浠诲姟杩囨护鍣�
         /// </summary>
         /// <remarks>
@@ -69,16 +76,18 @@
         /// <param name="taskExecuteDetailService">浠诲姟鎵ц鏄庣粏鏈嶅姟</param>
         /// <param name="routerService">璺敱鏈嶅姟</param>
         /// <param name="mapper">瀵硅薄鏄犲皠鍣�</param>
-        public ConveyorLineDispatchHandler(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper)
+        /// <param name="logger">鏃ュ織璁板綍鍣�</param>
+        public ConveyorLineDispatchHandler(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ILogger logger)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
             _routerService = routerService;
             _mapper = mapper;
+            _logger = logger;
 
             // 鍒濆鍖栦换鍔¤繃婊ゅ櫒鍜岀洰鏍囧湴鍧�閫夋嫨鍣�
-            _taskFilter = new ConveyorLineTaskFilter(taskService);
-            _targetAddressSelector = new ConveyorLineTargetAddressSelector();
+            _taskFilter = new ConveyorLineTaskFilter(taskService, _logger);
+            _targetAddressSelector = new ConveyorLineTargetAddressSelector(_logger);
         }
 
         /// <summary>
@@ -96,6 +105,8 @@
         {
             // 娓呴櫎浠诲姟鍙凤紝琛ㄧず褰撳墠绌洪棽
             conveyorLine.SetValue(ConveyorLineDBNameNew.TaskNo, 0, childDeviceCode);
+            _logger.LogDebug("HeartBeat锛氬瓙璁惧 {ChildDeviceCode} 蹇冭烦", childDeviceCode);
+            QuartzLogger.Debug($"HeartBeat锛氬瓙璁惧 {childDeviceCode} 蹇冭烦", conveyorLine.DeviceCode);
         }
 
         /// <summary>
@@ -114,6 +125,9 @@
         /// <param name="childDeviceCode">瀛愯澶囩紪鐮�</param>
         public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
         {
+            _logger.LogInformation("RequestInbound锛氬瓙璁惧 {ChildDeviceCode} 璇锋眰鍏ュ簱", childDeviceCode);
+            QuartzLogger.Info($"璇锋眰鍏ュ簱锛屽瓙璁惧: {childDeviceCode}", conveyorLine.DeviceCode);
+
             // 鍚� WMS 璇锋眰鏂颁换鍔★紙鍩轰簬鏉$爜锛�
             if (_taskFilter.RequestWmsTask(command.Barcode, childDeviceCode))
             {
@@ -132,6 +146,9 @@
 
                     // 鏇存柊浠诲姟鐘舵�佸埌涓嬩竴闃舵
                     _taskService.UpdateTaskStatusToNext(task);
+
+                    _logger.LogInformation("RequestInbound锛氬叆搴撲换鍔″凡涓嬪彂锛屼换鍔″彿: {TaskNum}锛屽瓙璁惧: {ChildDeviceCode}", task.TaskNum, childDeviceCode);
+                    QuartzLogger.Info($"鍏ュ簱浠诲姟宸蹭笅鍙戯紝浠诲姟鍙�: {task.TaskNum}锛屽瓙璁惧: {childDeviceCode}", conveyorLine.DeviceCode);
                 }
             }
         }
@@ -152,8 +169,13 @@
             Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
             if (task == null)
             {
+                _logger.LogDebug("RequestInNextAddress锛氫换鍔� {TaskNo} 涓嶅瓨鍦�", command.TaskNo);
+                QuartzLogger.Debug($"RequestInNextAddress锛氫换鍔� {command.TaskNo} 涓嶅瓨鍦�", conveyorLine.DeviceCode);
                 return;
             }
+
+            _logger.LogInformation("RequestInNextAddress锛氬叆搴撲笅涓�鍦板潃锛屼换鍔″彿: {TaskNum}锛屽瓙璁惧: {ChildDeviceCode}", task.TaskNum, childDeviceCode);
+            QuartzLogger.Info($"RequestInNextAddress锛氬叆搴撲笅涓�鍦板潃锛屼换鍔″彿: {task.TaskNum}锛屽瓙璁惧: {childDeviceCode}", conveyorLine.DeviceCode);
 
             // 濡傛灉涓嶆槸绌烘墭鐩樹换鍔★紝澶勭悊鐩爣鍦板潃锛堜笌鎷樻潫鏈�/鎻掓嫈閽夋満浜や簰锛�
             if (task.TaskType != (int)TaskOutboundTypeEnum.OutEmpty)
@@ -189,7 +211,9 @@
 
                 // 鏇存柊浠诲姟鐘舵�佸埌涓嬩竴闃舵锛堥�氬父鏄畬鎴愶級
                 WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
-                Console.Out.WriteLine(content.Serialize());
+
+                _logger.LogInformation("ConveyorLineInFinish锛氬叆搴撳畬鎴愶紝浠诲姟鍙�: {TaskNum}锛屽瓙璁惧: {ChildDeviceCode}", task.TaskNum, childDeviceCode);
+                QuartzLogger.Info($"鍏ュ簱瀹屾垚锛屼换鍔″彿: {task.TaskNum}", conveyorLine.DeviceCode);
             }
         }
 
@@ -226,6 +250,9 @@
 
                 // 鏇存柊浠诲姟鐘舵��
                 _taskService.UpdateTaskStatusToNext(task);
+
+                _logger.LogInformation("RequestOutbound锛氬嚭搴撲换鍔″凡涓嬪彂锛屼换鍔″彿: {TaskNum}锛屽瓙璁惧: {ChildDeviceCode}", task.TaskNum, childDeviceCode);
+                QuartzLogger.Info($"鍑哄簱浠诲姟宸蹭笅鍙戯紝浠诲姟鍙�: {task.TaskNum}", conveyorLine.DeviceCode);
             }
         }
 
@@ -245,8 +272,13 @@
             Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
             if (task == null)
             {
+                _logger.LogDebug("RequestOutNextAddress锛氫换鍔� {TaskNo} 涓嶅瓨鍦�", command.TaskNo);
+                QuartzLogger.Debug($"RequestOutNextAddress锛氫换鍔� {command.TaskNo} 涓嶅瓨鍦�", conveyorLine.DeviceCode);
                 return;
             }
+
+            _logger.LogInformation("RequestOutNextAddress锛氬嚭搴撲笅涓�鍦板潃锛屼换鍔″彿: {TaskNum}锛屽瓙璁惧: {ChildDeviceCode}", task.TaskNum, childDeviceCode);
+            QuartzLogger.Info($"RequestOutNextAddress锛氬嚭搴撲笅涓�鍦板潃锛屼换鍔″彿: {task.TaskNum}锛屽瓙璁惧: {childDeviceCode}", conveyorLine.DeviceCode);
 
             // 濡傛灉涓嶆槸绌烘墭鐩樹换鍔★紝澶勭悊鐩爣鍦板潃
             if (task.TaskType != (int)TaskOutboundTypeEnum.OutEmpty)
@@ -282,7 +314,9 @@
 
                 // 鏇存柊浠诲姟鐘舵�佸埌涓嬩竴闃舵锛堥�氬父鏄畬鎴愶級
                 WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
-                Console.Out.WriteLine(content.Serialize());
+
+                _logger.LogInformation("ConveyorLineOutFinish锛氬嚭搴撳畬鎴愶紝浠诲姟鍙�: {TaskNum}锛屽瓙璁惧: {ChildDeviceCode}", task.TaskNum, childDeviceCode);
+                QuartzLogger.Info($"鍑哄簱瀹屾垚锛屼换鍔″彿: {task.TaskNum}", conveyorLine.DeviceCode);
             }
         }
     }

--
Gitblit v1.9.3