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 |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineTargetAddressSelector.cs
index 24c16e3..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 妫�鏌�
         }
@@ -456,4 +469,4 @@
             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