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/ConveyorLineTargetAddressSelector.cs |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
index 46e6167..062265a 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
@@ -1,3 +1,5 @@
+using Microsoft.Extensions.Logging;
+using WIDESEAWCS_Core.LogHelper;
 using WIDESEAWCS_QuartzJob;
 
 namespace WIDESEAWCS_Tasks
@@ -44,6 +46,20 @@
         private static readonly List<string> PinMachineCodes = new List<string> { "10190", "20100" };
 
         /// <summary>
+        /// 鏃ュ織璁板綍鍣�
+        /// </summary>
+        private readonly ILogger _logger;
+
+        /// <summary>
+        /// 鏋勯�犲嚱鏁�
+        /// </summary>
+        /// <param name="logger">鏃ュ織璁板綍鍣�</param>
+        public ConveyorLineTargetAddressSelector(ILogger logger)
+        {
+            _logger = logger;
+        }
+
+        /// <summary>
         /// 澶勭悊鍏ュ簱鍦烘櫙鐨勪笅涓�鍦板潃璇锋眰
         /// </summary>
         /// <remarks>
@@ -55,6 +71,8 @@
         /// <param name="childDeviceCode">褰撳墠瀛愯澶囩紪鐮�</param>
         public void HandleInboundNextAddress(CommonConveyorLine conveyorLine, string nextAddress, string childDeviceCode)
         {
+            _logger.LogDebug("HandleInboundNextAddress锛氬叆搴撲笅涓�鍦板潃锛屽瓙璁惧: {ChildDeviceCode}锛岀洰鏍囧湴鍧�: {NextAddress}", childDeviceCode, nextAddress);
+            QuartzLogger.Debug($"HandleInboundNextAddress锛氬叆搴撲笅涓�鍦板潃锛屽瓙璁惧: {childDeviceCode}锛岀洰鏍囧湴鍧�: {nextAddress}", conveyorLine.DeviceCode);
             // 璋冪敤閫氱敤澶勭悊鏂规硶锛宨sUpper = true 琛ㄧず澶勭悊涓婂眰
             HandleDeviceRequest(conveyorLine, nextAddress, childDeviceCode, isUpper: true);
         }
@@ -71,6 +89,8 @@
         /// <param name="childDeviceCode">褰撳墠瀛愯澶囩紪鐮�</param>
         public void HandleOutboundNextAddress(CommonConveyorLine conveyorLine, string nextAddress, string childDeviceCode)
         {
+            _logger.LogDebug("HandleOutboundNextAddress锛氬嚭搴撲笅涓�鍦板潃锛屽瓙璁惧: {ChildDeviceCode}锛岀洰鏍囧湴鍧�: {NextAddress}", childDeviceCode, nextAddress);
+            QuartzLogger.Debug($"HandleOutboundNextAddress锛氬嚭搴撲笅涓�鍦板潃锛屽瓙璁惧: {childDeviceCode}锛岀洰鏍囧湴鍧�: {nextAddress}", conveyorLine.DeviceCode);
             // 璋冪敤閫氱敤澶勭悊鏂规硶锛宨sUpper = false 琛ㄧず澶勭悊涓嬪眰
             HandleDeviceRequest(conveyorLine, nextAddress, childDeviceCode, isUpper: false);
         }
@@ -99,6 +119,8 @@
                 ConstraintMachine? constraint = devices.OfType<ConstraintMachine>().FirstOrDefault(d => d.DeviceName == ConstraintMachineName);
                 if (constraint == null)
                 {
+                    _logger.LogDebug("HandleDeviceRequest锛氭湭鎵惧埌鎷樻潫鏈鸿澶�");
+                    QuartzLogger.Debug("HandleDeviceRequest锛氭湭鎵惧埌鎷樻潫鏈鸿澶�", conveyorLine.DeviceCode);
                     // 鏈壘鍒版嫎鏉熸満璁惧锛岀洿鎺ヨ繑鍥�
                     return;
                 }
@@ -126,7 +148,8 @@
                         {
                             constraint.SetValue(ConstraintMachineDBName.ConstraintTrayOutputReadyLower, outputReq ? 1 : 0);
                         }
-                    });
+                    },
+                    "鎷樻潫鏈�");
             }
             else if (PinMachineCodes.Contains(nextAddress))
             {
@@ -135,6 +158,8 @@
                 PinMachine? pinMachine = devices.OfType<PinMachine>().FirstOrDefault(d => d.DeviceName == PinMachineName);
                 if (pinMachine == null)
                 {
+                    _logger.LogDebug("HandleDeviceRequest锛氭湭鎵惧埌鎻掓嫈閽夋満璁惧");
+                    QuartzLogger.Debug("HandleDeviceRequest锛氭湭鎵惧埌鎻掓嫈閽夋満璁惧", conveyorLine.DeviceCode);
                     return;
                 }
 
@@ -161,7 +186,8 @@
                         {
                             pinMachine.SetValue(PinMachineDBName.PlugPinTrayOutputReadyLower, outputReq ? 1 : 0);
                         }
-                    });
+                    },
+                    "鎻掓嫈閽夋満");
             }
         }
 
@@ -178,18 +204,24 @@
         /// <param name="getMaterialRequest">鑾峰彇鐗╂枡璇锋眰鐘舵�佺殑濮旀墭</param>
         /// <param name="getOutputRequest">鑾峰彇鍑烘枡璇锋眰鐘舵�佺殑濮旀墭</param>
         /// <param name="setOutputReady">璁剧疆杈撳嚭灏辩华鏍囧織鐨勫鎵�</param>
-        private static void ProcessDeviceRequest(
+        /// <param name="deviceType">璁惧绫诲瀷鎻忚堪</param>
+        private void ProcessDeviceRequest(
             CommonConveyorLine conveyorLine,
             string childDeviceCode,
             Func<bool> getMaterialRequest,
             Func<bool> getOutputRequest,
-            Action<bool> setOutputReady)
+            Action<bool> setOutputReady,
+            string deviceType)
         {
             // 鑾峰彇鐗╂枡璇锋眰鐘舵��
             bool materialReq = getMaterialRequest();
 
             // 鑾峰彇鍑烘枡璇锋眰鐘舵��
             bool outputReq = getOutputRequest();
+
+            _logger.LogDebug("ProcessDeviceRequest锛歿DeviceType}锛屽瓙璁惧: {ChildDeviceCode}锛岀墿鏂欒姹�: {MaterialReq}锛屽嚭鏂欒姹�: {OutputReq}",
+                deviceType, childDeviceCode, materialReq, outputReq);
+            QuartzLogger.Debug($"ProcessDeviceRequest锛歿deviceType}锛屽瓙璁惧: {childDeviceCode}锛岀墿鏂欒姹�: {materialReq}锛屽嚭鏂欒姹�: {outputReq}", conveyorLine.DeviceCode);
 
             // 濡傛灉璁惧闇�瑕佺墿鏂�
             if (materialReq)
@@ -199,6 +231,9 @@
 
                 // 鍥炲 ACK 纭淇″彿
                 conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
+
+                _logger.LogInformation("ProcessDeviceRequest锛歿DeviceType} 闇�瑕佺墿鏂欙紝宸茶缃洰鏍囧湴鍧�鍜孉CK", deviceType);
+                QuartzLogger.Info($"ProcessDeviceRequest锛歿deviceType} 闇�瑕佺墿鏂欙紝宸茶缃洰鏍囧湴鍧�鍜孉CK", conveyorLine.DeviceCode);
             }
             else
             {

--
Gitblit v1.9.3