From 853f7a71577bd8694c848985e1eb21c74d30eba9 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期二, 21 四月 2026 21:19:23 +0800
Subject: [PATCH] fix(WCS): 修复输送线任务处理逻辑并更新设备映射

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
index c4ecdf4..0cd3ffd 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
@@ -1,5 +1,4 @@
-using Microsoft.Extensions.Logging;
-using WIDESEAWCS_Core.LogHelper;
+using Serilog;
 using WIDESEAWCS_QuartzJob;
 
 namespace WIDESEAWCS_Tasks
@@ -136,7 +135,14 @@
             // 璁板綍鍏ュ簱鍦烘櫙鐨勮皟璇曟棩蹇楋紝鍖呭惈瀛愯澶囧拰鐩爣鍦板潃淇℃伅
             WriteDebug(conveyorLine, "鍏ュ簱涓嬩竴鍦板潃", childDeviceCode, nextAddress);
             // 濮旀墭閫氱敤澶勭悊鏂规硶锛屽叆搴撳搴斾笂灞傦紙isUpper: true锛�
-            HandleDeviceRequest(conveyorLine, nextAddress, childDeviceCode, Layer.Upper);
+            //HandleDeviceRequest(conveyorLine, nextAddress, childDeviceCode, Layer.Upper);
+
+            var cvState = conveyorLine.GetValue<ConveyorLineDBNameNew, byte>(ConveyorLineDBNameNew.CV_State, nextAddress);
+            bool isAvailable = cvState == 2;
+            if (isAvailable)
+            {
+                conveyorLine.SetValue(ConveyorLineDBNameNew.Target, Convert.ToInt16(nextAddress), childDeviceCode);
+            }
         }
 
         /// <summary>
@@ -154,7 +160,14 @@
             // 璁板綍鍑哄簱鍦烘櫙鐨勮皟璇曟棩蹇楋紝鍖呭惈瀛愯澶囧拰鐩爣鍦板潃淇℃伅
             WriteDebug(conveyorLine, "鍑哄簱涓嬩竴鍦板潃", childDeviceCode, nextAddress);
             // 濮旀墭閫氱敤澶勭悊鏂规硶锛屽嚭搴撳搴斾笅灞傦紙isUpper: false锛�
-            HandleDeviceRequest(conveyorLine, nextAddress, childDeviceCode, Layer.Lower);
+            //HandleDeviceRequest(conveyorLine, nextAddress, childDeviceCode, Layer.Lower);
+
+            var cvState = conveyorLine.GetValue<ConveyorLineDBNameNew, byte>(ConveyorLineDBNameNew.CV_State, nextAddress);
+            bool isAvailable = cvState == 2;
+            if (isAvailable)
+            {
+                conveyorLine.SetValue(ConveyorLineDBNameNew.Target, Convert.ToInt16(nextAddress), childDeviceCode);
+            }
         }
 
         /// <summary>
@@ -276,7 +289,7 @@
             if (device == null)
             {
                 // 璁惧鏈壘鍒版椂璁板綍璋冭瘯鏃ュ織锛屾柟渚挎帓鏌ラ厤缃棶棰�
-                _logger.LogDebug("FindDevice锛氭湭鎵惧埌 {DeviceName}", deviceName);
+                _logger.Debug("FindDevice锛氭湭鎵惧埌 {DeviceName}", deviceName);
             }
             return device; // 鍙兘涓� null锛岀敱璋冪敤鏂硅礋璐� null 妫�鏌�
         }
@@ -418,10 +431,7 @@
             string deviceType)
         {
             // 璁板綍褰撳墠璇锋眰鐘舵�佺殑璋冭瘯鏃ュ織锛屼緵鎺掓煡闂浣跨敤
-            _logger.LogDebug("ProcessDeviceRequest锛歿DeviceType}锛屽瓙璁惧: {ChildDeviceCode}锛岀墿鏂欒姹�: {MaterialReq}锛屽嚭鏂欒姹�: {OutputReq}",
-                deviceType, childDeviceCode, materialRequest, outputRequest);
-            // 鍚屾鍐欏叆 Quartz 鏃ュ織鏂囦欢锛堝弻鍐欏彲杩芥函锛岃繖閲屼繚鐣欎笌鍘熼�昏緫涓�鑷寸殑琛屼负锛�
-            QuartzLogger.Debug($"ProcessDeviceRequest锛歿deviceType}锛屽瓙璁惧: {childDeviceCode}锛岀墿鏂欒姹�: {materialRequest}锛屽嚭鏂欒姹�: {outputRequest}", conveyorLine.DeviceCode);
+            QuartzLogHelper.LogDebug(_logger, "ProcessDeviceRequest锛歿DeviceType}锛屽瓙璁惧: {ChildDeviceCode}锛岀墿鏂欒姹�: {MaterialReq}锛屽嚭鏂欒姹�: {OutputReq}", $"ProcessDeviceRequest锛歿deviceType}锛屽瓙璁惧: {childDeviceCode}锛岀墿鏂欒姹�: {materialRequest}锛屽嚭鏂欒姹�: {outputRequest}", conveyorLine.DeviceCode, deviceType, childDeviceCode, materialRequest, outputRequest);
 
             // 鍒嗘敮鍒ゆ柇锛氳澶囨槸闇�瑕佺墿鏂欒繕鏄渶瑕佸嚭鏂�
             if (materialRequest)
@@ -432,8 +442,7 @@
                 // 2. 鍥炲 ACK 纭淇″彿锛屽憡鐭ヨ澶囧凡鏀跺埌璇锋眰
                 conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
                 // 3. 璁板綍淇℃伅鏃ュ織锛岃〃鏄庡凡瀹屾垚鐩爣鍦板潃璁剧疆鍜� ACK 鍥炲
-                _logger.LogInformation("ProcessDeviceRequest锛歿DeviceType} 闇�瑕佺墿鏂欙紝宸茶缃洰鏍囧湴鍧�鍜孉CK", deviceType);
-                QuartzLogger.Info($"ProcessDeviceRequest锛歿deviceType} 闇�瑕佺墿鏂欙紝宸茶缃洰鏍囧湴鍧�鍜孉CK", conveyorLine.DeviceCode);
+                QuartzLogHelper.LogInfo(_logger, "ProcessDeviceRequest锛歿DeviceType} 闇�瑕佺墿鏂欙紝宸茶缃洰鏍囧湴鍧�鍜孉CK", $"ProcessDeviceRequest锛歿deviceType} 闇�瑕佺墿鏂欙紝宸茶缃洰鏍囧湴鍧�鍜孉CK", conveyorLine.DeviceCode, deviceType);
             }
             else
             {
@@ -457,10 +466,7 @@
         private void WriteDebug(CommonConveyorLine conveyorLine, string scenario, string childDeviceCode, string nextAddress)
         {
             // 鍐欏叆缁撴瀯鍖栨棩蹇楋紙鍙 Serilog 绛夋棩蹇楁鏋舵崟鑾凤級
-            _logger.LogDebug("Handle{Scenario}锛氬瓙璁惧: {ChildDeviceCode}锛岀洰鏍囧湴鍧�: {NextAddress}",
-                scenario, childDeviceCode, nextAddress);
-            // 鍐欏叆 Quartz 涓撶敤鏃ュ織鏂囦欢锛堜緵瀹氭椂浠诲姟杞ㄨ抗杩借釜锛�
-            QuartzLogger.Debug($"Handle{scenario}锛氬瓙璁惧: {childDeviceCode}锛岀洰鏍囧湴鍧�: {nextAddress}", conveyorLine.DeviceCode);
+            QuartzLogHelper.LogDebug(_logger, "Handle{Scenario}锛氬瓙璁惧: {ChildDeviceCode}锛岀洰鏍囧湴鍧�: {NextAddress}", $"Handle{scenario}锛氬瓙璁惧: {childDeviceCode}锛岀洰鏍囧湴鍧�: {nextAddress}", conveyorLine.DeviceCode, scenario, childDeviceCode, nextAddress);
         }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3