From 715cf4c8b9e097aae6c4bcaf00bdd67a763529c4 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 13:58:09 +0800
Subject: [PATCH] feat(stockChat): 集成 SignalR 实现实时库存更新

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
index 5e746e7..3fef97c 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
@@ -24,6 +24,7 @@
 using WIDESEAWCS_QuartzJob.DeviceBase;
 using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.StackerCrane;
+using WIDESEAWCS_QuartzJob.StackerCrane.Common;
 using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
 
 namespace WIDESEAWCS_QuartzJob
@@ -32,7 +33,7 @@
     /// 涓�鑸爢鍨涙満瀹炵幇绫伙紝瀹炵幇鍫嗗灈鏈烘帴鍙e眰
     /// </summary>
     [Description("鍫嗗灈鏈�")]
-    public class CommonStackerCrane : IStackerCrane
+    public class CommonStackerCrane : StackerCraneBase, IStackerCrane
     {
         #region Private Member
 
@@ -157,6 +158,11 @@
         public bool IsConnected => Communicator.IsConnected && _isConnected;
 
         /// <summary>
+        /// 鍫嗗灈鏈哄畬鎴愪簨浠舵槸鍚﹀凡璁㈤槄
+        /// </summary>
+        public bool IsEventSubscribed => StackerCraneTaskCompletedEventHandler != null;
+
+        /// <summary>
         /// 鍫嗗灈鏈轰换鍔″畬鎴愪簨浠�
         /// </summary>
         public event EventHandler<StackerCraneTaskCompletedEventArgs> StackerCraneTaskCompletedEventHandler;
@@ -166,10 +172,6 @@
         /// </summary>
         public object StackerCraneTaskCommand { get; set; }
 
-        /// <summary>
-        /// 鍫嗗灈鏈哄畬鎴愪簨浠舵槸鍚﹀凡璁㈤槄
-        /// </summary>
-        public bool IsEventSubscribed => StackerCraneTaskCompletedEventHandler != null;
 
         /// <summary>
         /// 涓婁竴娆′换鍔$殑绫诲瀷
@@ -234,7 +236,11 @@
         private int GetCurrentTaskNum()
         {
             DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CurrentTaskNum));
-            return devicePro == null ? throw new Exception($"璇诲彇褰撳墠浠诲姟鍙烽敊璇�,鏈幏鍙栧埌鍗忚淇℃伅,璇锋鏌ラ厤缃弬鏁板悕绉版槸鍚﹂厤缃�,涓旈厤缃负涓簕nameof(CurrentTaskNum)}") : (int)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
+            if (devicePro == null)
+                throw new Exception($"璇诲彇褰撳墠浠诲姟鍙烽敊璇�,鏈幏鍙栧埌鍗忚淇℃伅,璇锋鏌ラ厤缃弬鏁板悕绉版槸鍚﹂厤缃�,涓旈厤缃负{nameof(CurrentTaskNum)}");
+
+            object value = Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
+            return Convert.ToInt32(value);  // 缁熶竴杞崲涓� int
         }
 
         /// <summary>
@@ -385,10 +391,10 @@
                 _isChecked = true;
                 try
                 {
-                    DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(StackerCraneWorkStatus));
+                    DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(StackerCraneCompleted));
                     if (devicePro != null)
                     {
-                        DeviceProtocolDetailDTO? deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePro.DeviceProParamName && x.ProtocolDetailType == StackerCraneWorkStatus.WorkCompleted.ToString());
+                        DeviceProtocolDetailDTO? deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePro.DeviceProParamName && x.ProtocolDetailType == StackerCraneCompleted.Completed.ToString());
                         if (deviceProtocolDetail != null)
                         {
                             OperateResult<TimeSpan> operateResult = new OperateResult<TimeSpan>();

--
Gitblit v1.9.3