From 5171d3f59b89389bf75293afd210cfa6de4ccff7 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 10 四月 2026 23:03:49 +0800
Subject: [PATCH] feat: 添加堆垛机相关常量类并重构代码使用常量

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/TaskAddressConstants.cs                |   33 ++++
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs                      |   21 +-
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs                          |   13 
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneTaskSelector.cs    |    3 
 Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs                            |   35 ++--
 Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/StockConstants.cs                      |   58 +++++++
 Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/OutboundTimeConstants.cs               |   44 +++++
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs       |    5 
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneCommandTypeEnum.cs      |   28 +++
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneConst.cs                |   41 +++++
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneRoadwayConst.cs         |   51 ++++++
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneWorkActionEnum.cs       |   26 +++
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs |    2 
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs       |    7 
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs           |    5 
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs  |   19 +-
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneDBName.cs          |    2 
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/DeviceAddressConst.cs               |   36 ++++
 18 files changed, 377 insertions(+), 52 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/DeviceAddressConst.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/DeviceAddressConst.cs
new file mode 100644
index 0000000..e6db980
--- /dev/null
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/DeviceAddressConst.cs
@@ -0,0 +1,36 @@
+namespace WIDESEAWCS_Common.Constants
+{
+    /// <summary>
+    /// 璁惧鍦板潃鍏叡甯搁噺
+    /// </summary>
+    /// <remarks>
+    /// 瀹氫箟璁惧閫氫俊涓娇鐢ㄧ殑鍏叡甯搁噺锛屽鍦板潃鏍煎紡銆佷俊鍙峰�肩瓑銆�
+    /// </remarks>
+    public class DeviceAddressConst
+    {
+        /// <summary>
+        /// 浜や簰淇″彿澶嶄綅鍊�
+        /// </summary>
+        /// <remarks>
+        /// 璁惧瀹屾垚浠诲姟鍚庯紝鍐欏叆姝ゅ�煎埌浜や簰淇″彿瀵勫瓨鍣ㄤ互澶嶄綅銆�
+        /// 鐢ㄤ簬杈撻�佺嚎绛夎澶囩殑浠诲姟瀹屾垚纭銆�
+        /// </remarks>
+        public const int InteractiveSignalReset = 0;
+
+        /// <summary>
+        /// 鍦板潃瀛楃涓插垎闅旂
+        /// </summary>
+        /// <remarks>
+        /// 鍦板潃鏍煎紡涓� "琛�-鍒�-灞�"锛屼緥濡� "1-2-3" 琛ㄧず绗�1琛屻�佺2鍒椼�佺3灞傘��
+        /// </remarks>
+        public const char AddressSeparator = '-';
+
+        /// <summary>
+        /// 鍦板潃瀛楃涓插垎闅旂锛堝瓧绗︿覆褰㈠紡锛�
+        /// </summary>
+        /// <remarks>
+        /// 鐢ㄤ簬瀛楃涓� Split 鎿嶄綔銆�
+        /// </remarks>
+        public const string AddressSeparatorString = "-";
+    }
+}
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneCommandTypeEnum.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneCommandTypeEnum.cs
new file mode 100644
index 0000000..3f14b3e
--- /dev/null
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneCommandTypeEnum.cs
@@ -0,0 +1,28 @@
+namespace WIDESEAWCS_Common.Constants
+{
+    /// <summary>
+    /// 鍫嗗灈鏈哄懡浠ょ被鍨嬫灇涓�
+    /// </summary>
+    /// <remarks>
+    /// 鏍规嵁宸烽亾绫诲瀷鐨勪笉鍚岋紝鍫嗗灈鏈哄彲鑳戒娇鐢ㄤ笉鍚岀殑鍛戒护鏍煎紡銆�
+    /// </remarks>
+    public enum StackerCraneCommandTypeEnum
+    {
+        /// <summary>
+        /// 鏍囧噯鍛戒护鏍煎紡
+        /// </summary>
+        /// <remarks>
+        /// 鐢ㄤ簬 GW銆丆W 寮�澶村贩閬撶殑鍫嗗灈鏈恒��
+        /// </remarks>
+        Standard,
+
+        /// <summary>
+        /// 鎴愬瀷鍛戒护鏍煎紡
+        /// </summary>
+        /// <remarks>
+        /// 鐢ㄤ簬 HC 寮�澶村贩閬撶殑鍫嗗灈鏈恒��
+        /// 鍖呭惈鏉$爜瀛楁锛岀敤浜庣數姹犺拷婧��
+        /// </remarks>
+        Formation
+    }
+}
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneConst.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneConst.cs
new file mode 100644
index 0000000..a9d0e40
--- /dev/null
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneConst.cs
@@ -0,0 +1,41 @@
+namespace WIDESEAWCS_Common.Constants
+{
+    /// <summary>
+    /// 鍫嗗灈鏈虹浉鍏冲父閲�
+    /// </summary>
+    public class StackerCraneConst
+    {
+        /// <summary>
+        /// 绌烘墭鐩樹换鍔$被鍨�
+        /// </summary>
+        /// <remarks>
+        /// 褰撲换鍔$被鍨嬩负绌烘墭鐩樺嚭搴�/鍏ュ簱鏃讹紝浣跨敤姝ょ壒娈婄被鍨嬪�间唬鏇垮師浠诲姟绫诲瀷銆�
+        /// 鐢ㄤ簬涓庣珯鍙拌矾鐢遍厤缃尮閰嶃��
+        /// </remarks>
+        public const int EmptyPalletTaskType = 100;
+
+        /// <summary>
+        /// 鐏鐘舵�佹甯�
+        /// </summary>
+        /// <remarks>
+        /// 鐏淇″彿涓� 0 琛ㄧず姝e父锛屾棤鐏伨鎶ヨ銆�
+        /// </remarks>
+        public const short FireAlarmNormal = 0;
+
+        /// <summary>
+        /// 蹇冭烦鍒濆鍊�
+        /// </summary>
+        /// <remarks>
+        /// 鍫嗗灈鏈哄懡浠や腑鐨勫績璺冲瓧娈靛垵濮嬪�笺��
+        /// </remarks>
+        public const short HeartBeatInitial = 0;
+
+        /// <summary>
+        /// 浣滀笟绫诲瀷 - 鍏ュ簱
+        /// </summary>
+        /// <remarks>
+        /// 鏍囪瘑浠诲姟涓哄叆搴撲綔涓氱被鍨嬨��
+        /// </remarks>
+        public const short WorkTypeInbound = 1;
+    }
+}
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneRoadwayConst.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneRoadwayConst.cs
new file mode 100644
index 0000000..97c82d6
--- /dev/null
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneRoadwayConst.cs
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+
+namespace WIDESEAWCS_Common.Constants
+{
+    /// <summary>
+    /// 鍫嗗灈鏈哄贩閬撳墠缂�甯搁噺
+    /// </summary>
+    /// <remarks>
+    /// 瀹氫箟宸烽亾缂栫爜鐨勫墠缂�涓庡懡浠ょ被鍨嬬殑鏄犲皠鍏崇郴銆�
+    /// </remarks>
+    public class StackerCraneRoadwayConst
+    {
+        /// <summary>
+        /// 鎴愬瀷鍫嗗灈鏈哄贩閬撳墠缂�
+        /// </summary>
+        /// <remarks>
+        /// 浠� HC 寮�澶寸殑宸烽亾浣跨敤鎴愬瀷鍫嗗灈鏈哄懡浠ゆ牸寮忋��
+        /// </remarks>
+        public const string FormationPrefix = "HC";
+
+        /// <summary>
+        /// 鏍囧噯鍫嗗灈鏈哄贩閬撳墠缂�锛圙W锛�
+        /// </summary>
+        /// <remarks>
+        /// 浠� GW 寮�澶寸殑宸烽亾浣跨敤鏍囧噯鍫嗗灈鏈哄懡浠ゆ牸寮忋��
+        /// </remarks>
+        public const string StandardPrefixGW = "GW";
+
+        /// <summary>
+        /// 鏍囧噯鍫嗗灈鏈哄贩閬撳墠缂�锛圕W锛�
+        /// </summary>
+        /// <remarks>
+        /// 浠� CW 寮�澶寸殑宸烽亾浣跨敤鏍囧噯鍫嗗灈鏈哄懡浠ゆ牸寮忋��
+        /// </remarks>
+        public const string StandardPrefixCW = "CW";
+
+        /// <summary>
+        /// 宸烽亾鍓嶇紑鍒板懡浠ょ被鍨嬬殑榛樿鏄犲皠
+        /// </summary>
+        /// <remarks>
+        /// Key: 宸烽亾缂栫爜鍓嶇紑
+        /// Value: 鍛戒护绫诲瀷鍚嶇О
+        /// </remarks>
+        public static readonly Dictionary<string, StackerCraneCommandTypeEnum> DefaultRoadwayCommandMapping = new()
+        {
+            { FormationPrefix, StackerCraneCommandTypeEnum.Formation },
+            { StandardPrefixGW, StackerCraneCommandTypeEnum.Standard },
+            { StandardPrefixCW, StackerCraneCommandTypeEnum.Standard }
+        };
+    }
+}
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneWorkActionEnum.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneWorkActionEnum.cs
new file mode 100644
index 0000000..74bfc24
--- /dev/null
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Constants/StackerCraneWorkActionEnum.cs
@@ -0,0 +1,26 @@
+namespace WIDESEAWCS_Common.Constants
+{
+    /// <summary>
+    /// 鍫嗗灈鏈轰綔涓氭寚浠ゆ灇涓�
+    /// </summary>
+    /// <remarks>
+    /// 鎺у埗鍫嗗灈鏈虹殑鍔ㄤ綔鎸囦护锛岄�氳繃 PLC 瀵勫瓨鍣ㄤ笌鍫嗗灈鏈洪�氫俊銆�
+    /// </remarks>
+    public enum StackerCraneWorkActionEnum
+    {
+        /// <summary>
+        /// 寮�濮嬫墽琛屼换鍔�
+        /// </summary>
+        StartTask = 1,
+
+        /// <summary>
+        /// 浠诲姟瀹屾垚/鍋滄
+        /// </summary>
+        TaskComplete = 2,
+
+        /// <summary>
+        /// 娑堥槻浠诲姟寮�濮�
+        /// </summary>
+        FireAlarmStart = 3
+    }
+}
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
index ea9e325..34470e0 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -24,6 +24,7 @@
 using MapsterMapper;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using Quartz;
+using WIDESEAWCS_Common.Constants;
 using WIDESEAWCS_Communicator;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
@@ -144,7 +145,7 @@
             Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
             if (task != null)
             {
-                conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
+                conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, DeviceAddressConst.InteractiveSignalReset, childDeviceCode);
                 WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
                 Console.Out.WriteLine(content.Serialize());
             }
@@ -201,7 +202,7 @@
             Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
             if (task != null)
             {
-                conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
+                conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, DeviceAddressConst.InteractiveSignalReset, childDeviceCode);
                 WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
                 Console.Out.WriteLine(content.Serialize());
             }
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
index 5985236..c016c47 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
@@ -211,7 +211,7 @@
                             {
                                 // 濡傛灉 WCS_ACK 涓� 1锛屽厛娓呴櫎锛堣〃绀哄鐞嗚繃涓婁竴娆¤姹傦級
                                 if (command.WCS_ACK == 1)
-                                    conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 0, childDeviceCode);
+                                    conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)0, childDeviceCode);
                                 continue;
                             }
 
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 1370478..69ec861 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -10,6 +10,7 @@
 using WIDESEAWCS_QuartzJob.Service;
 using WIDESEAWCS_QuartzJob.StackerCrane;
 using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
+using WIDESEAWCS_Common.Constants;
 using WIDESEAWCS_Tasks.StackerCraneJob;
 
 namespace WIDESEAWCS_Tasks
@@ -234,7 +235,7 @@
                 if (sendFlag)
                 {
                     Task.Delay(1000).Wait();
-                    commonStackerCrane.SetValue(StackerCraneDBName.WorkAction, (short)1);
+                    commonStackerCrane.SetValue(StackerCraneDBName.WorkAction, (short)StackerCraneWorkActionEnum.StartTask);
                     // 鍙戦�佹垚鍔燂紝鏇存柊鐘舵��
                     commonStackerCrane.LastTaskType = task.TaskType;
                     _taskService.UpdateTaskStatusToNext(task.TaskNum);
@@ -282,8 +283,8 @@
                 // 鏇存柊浠诲姟鐘舵�佷负瀹屾垚
                 if (_taskService.StackCraneTaskCompleted(e.TaskNum).Status)
                 {
-                    // 娓呴櫎鍫嗗灈鏈虹殑浣滀笟鎸囦护锛堣缃负 2锛岃〃绀虹┖闂诧級
-                    stackerCrane.SetValue(StackerCraneDBName.WorkAction, 2);
+                    // 娓呴櫎鍫嗗灈鏈虹殑浣滀笟鎸囦护锛堣缃负绌洪棽锛�
+                    stackerCrane.SetValue(StackerCraneDBName.WorkAction, (short)StackerCraneWorkActionEnum.TaskComplete);
                 }
             }
         }
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
index edf399a..a8637cb 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
@@ -1,6 +1,7 @@
 using Microsoft.Extensions.Logging;
 using System;
 using System.Diagnostics.CodeAnalysis;
+using WIDESEAWCS_Common.Constants;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core.LogHelper;
 using WIDESEAWCS_ITaskInfoService;
@@ -128,8 +129,8 @@
             return new StackerCraneTaskCommand
             {
                 TaskNum = task.TaskNum,   // 浠诲姟鍙�
-                WorkType = 1,             // 浣滀笟绫诲瀷
-                //WorkAction = 1            // 浣滀笟鎸囦护锛氬紑濮嬫墽琛�
+                WorkType = StackerCraneConst.WorkTypeInbound,  // 浣滀笟绫诲瀷锛氬叆搴�
+                //WorkAction = StackerCraneWorkActionEnum.StartTask  // 浣滀笟鎸囦护锛氬紑濮嬫墽琛�
             };
         }
 
@@ -148,10 +149,10 @@
             {
                 Barcode = task.PalletCode,   // 鎵樼洏鏉$爜
                 TaskNum = task.TaskNum,      // 浠诲姟鍙�
-                WorkType = 1,               // 浣滀笟绫诲瀷
-                WorkAction = 1,             // 浣滀笟鎸囦护锛氬紑濮嬫墽琛�
-                FireAlarm = 0,              // 鐏锛氭甯�
-                HeartBeat = 0,              // 蹇冭烦
+                WorkType = StackerCraneConst.WorkTypeInbound,  // 浣滀笟绫诲瀷锛氬叆搴�
+                WorkAction = (short)StackerCraneWorkActionEnum.StartTask,  // 浣滀笟鎸囦护锛氬紑濮嬫墽琛�
+                FireAlarm = StackerCraneConst.FireAlarmNormal,  // 鐏锛氭甯�
+                HeartBeat = StackerCraneConst.HeartBeatInitial,  // 蹇冭烦
                 FieldName = string.Empty     // 淇濈暀瀛楁
             };
         }
@@ -202,11 +203,11 @@
             _logger.LogInformation("BuildInboundCommand锛氭瀯寤哄叆搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", task.TaskNum);
             QuartzLogger.Info($"BuildInboundCommand锛氭瀯寤哄叆搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway);
 
-            // 纭畾浠诲姟绫诲瀷锛堢┖鎵樼洏鐢ㄧ壒娈婄被鍨� 100锛�
+            // 纭畾浠诲姟绫诲瀷锛堢┖鎵樼洏鐢ㄧ壒娈婄被鍨嬶級
             int taskType = 0;
             if (task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty)
             {
-                taskType = 100;
+                taskType = StackerCraneConst.EmptyPalletTaskType;
             }
             else
                 taskType = task.TaskType;
@@ -270,7 +271,7 @@
             int taskType = 0;
             if (task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty)
             {
-                taskType = 100;
+                taskType = StackerCraneConst.EmptyPalletTaskType;
             }
             else
                 taskType = task.TaskType;
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneDBName.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneDBName.cs
index f6b3848..a3d318d 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneDBName.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneDBName.cs
@@ -92,7 +92,7 @@
         /// 浣滀笟鎸囦护
         /// </summary>
         /// <remarks>
-        /// 鎺у埗鍫嗗灈鏈虹殑鍔ㄤ綔锛�
+        /// 鎺у埗鍫嗗灈鏈虹殑鍔ㄤ綔銆傚弬瑙� <see cref="Constants.StackerCraneWorkActionEnum"/>锛�
         /// - 1: 寮�濮嬫墽琛屼换鍔�
         /// - 2: 浠诲姟瀹屾垚/鍋滄
         /// - 3: 娑堥槻浠诲姟寮�濮�
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneTaskSelector.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneTaskSelector.cs
index 620b1fa..c52343a 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneTaskSelector.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneTaskSelector.cs
@@ -2,6 +2,7 @@
 using Newtonsoft.Json;
 using System.Diagnostics.CodeAnalysis;
 using WIDESEA_Core;
+using WIDESEAWCS_Common.Constants;
 using WIDESEAWCS_Common.HttpEnum;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
@@ -288,7 +289,7 @@
             if (task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty)
             {
                 // 绌烘墭鐩樺嚭搴�
-                taskType = 100;
+                taskType = StackerCraneConst.EmptyPalletTaskType;
             }
             else
                 taskType = task.TaskType;
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/OutboundTimeConstants.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/OutboundTimeConstants.cs
new file mode 100644
index 0000000..625e140
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/OutboundTimeConstants.cs
@@ -0,0 +1,44 @@
+namespace WIDESEA_Common.Constants
+{
+    /// <summary>
+    /// 搴撳瓨Remark璺敱鏍囪甯搁噺
+    /// </summary>
+    public static class StockRemarkConstants
+    {
+        /// <summary>
+        /// 楂樻俯1鍙疯矾鐢辨爣璁�
+        /// </summary>
+        public const string GW1 = "GW_1";
+
+        /// <summary>
+        /// 楂樻俯2鍙疯矾鐢辨爣璁�
+        /// </summary>
+        public const string GW2 = "GW_2";
+
+        /// <summary>
+        /// 甯告俯1鍙疯矾鐢辨爣璁�
+        /// </summary>
+        public const string CW1 = "CW_1";
+    }
+
+    /// <summary>
+    /// 鍑哄簱鏃舵晥甯搁噺锛堝皬鏃讹級
+    /// </summary>
+    public static class OutboundTimeConstants
+    {
+        /// <summary>
+        /// GW_1棣栨斁鍏ュ簱鏃舵晥锛�16灏忔椂锛�
+        /// </summary>
+        public const int OUTBOUND_HOURS_GW1_FIRST = 16;
+
+        /// <summary>
+        /// GW_1浜屾斁鍏ュ簱鏃舵晥锛�24灏忔椂锛�
+        /// </summary>
+        public const int OUTBOUND_HOURS_GW1_SECOND = 24;
+
+        /// <summary>
+        /// CW_1鍑哄簱鏃舵晥锛�12灏忔椂锛�
+        /// </summary>
+        public const int OUTBOUND_HOURS_CW1 = 12;
+    }
+}
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/StockConstants.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/StockConstants.cs
new file mode 100644
index 0000000..5b49831
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/StockConstants.cs
@@ -0,0 +1,58 @@
+namespace WIDESEA_Common.Constants
+{
+    /// <summary>
+    /// 搴撳瓨涓嶮ES鐩稿叧甯搁噺
+    /// </summary>
+    public static class StockConstants
+    {
+        /// <summary>
+        /// 榛樿鐗╂枡缂栫爜
+        /// </summary>
+        public const string MATERIAL_CODE = "鐢佃姱";
+
+        /// <summary>
+        /// 榛樿鐗╂枡鍚嶇О
+        /// </summary>
+        public const string MATERIAL_NAME = "鐢佃姱";
+
+        /// <summary>
+        /// 榛樿鍗曚綅
+        /// </summary>
+        public const string UNIT = "PCS";
+
+        /// <summary>
+        /// 榛樿鍒涘缓鑰�
+        /// </summary>
+        public const string SYSTEM_USER = "system";
+
+        /// <summary>
+        /// AGV鍒涘缓鑰�
+        /// </summary>
+        public const string AGV_USER = "AGV";
+
+        /// <summary>
+        /// 鑷姩浠诲姟鍒涘缓鑰�
+        /// </summary>
+        public const string SYSTEM_AUTO_USER = "system_auto";
+
+        /// <summary>
+        /// 榛樿璁㈠崟鍙�
+        /// </summary>
+        public const string DEFAULT_ORDER_NO = "111";
+
+        /// <summary>
+        /// MES璁惧缂栫爜
+        /// </summary>
+        public const string MES_EQUIPMENT_CODE = "STK-GROUP-001";
+
+        /// <summary>
+        /// MES璧勬簮缂栫爜
+        /// </summary>
+        public const string MES_RESOURCE_CODE = "STK-GROUP-001";
+
+        /// <summary>
+        /// 缁勭洏鎿嶄綔绫诲瀷锛�0浠h〃缁勭洏锛�
+        /// </summary>
+        public const int MES_BIND_OPERATION_TYPE = 0;
+    }
+}
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/TaskAddressConstants.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/TaskAddressConstants.cs
new file mode 100644
index 0000000..4d1a8f9
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Common/Constants/TaskAddressConstants.cs
@@ -0,0 +1,33 @@
+namespace WIDESEA_Common.Constants
+{
+    /// <summary>
+    /// 浠诲姟鍦板潃甯搁噺
+    /// </summary>
+    public static class TaskAddressConstants
+    {
+        /// <summary>
+        /// 榛樿/涓浆鍦板潃
+        /// </summary>
+        public const string DEFAULT_ADDRESS = "10080";
+
+        /// <summary>
+        /// 楂樻俯1鍙峰嚭搴撳湴鍧�鍒楄〃锛堣疆璇級
+        /// </summary>
+        public static readonly string[] GW1_ADDRESSES = { "11001", "11010" };
+
+        /// <summary>
+        /// 楂樻俯2鍙峰嚭搴撳湴鍧�
+        /// </summary>
+        public const string GW2_ADDRESS = "CWSC1";
+
+        /// <summary>
+        /// 甯告俯1鍙峰嚭搴撳湴鍧�
+        /// </summary>
+        public const string CW1_ADDRESS = "22001";
+
+        /// <summary>
+        /// 鍒嗗搴撳嚭搴撳湴鍧�
+        /// </summary>
+        public const string GRADING_OUTBOUND_ADDRESS = "10081";
+    }
+}
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
index 2b27518..0b87683 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
@@ -1,4 +1,5 @@
 锘縰sing SqlSugar;
+using WIDESEA_Common.Constants;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Core;
 using WIDESEA_DTO.MES;
@@ -123,12 +124,12 @@
                 var now = DateTime.Now;
                 var details = stock.Details.Select(item => new Dt_StockInfoDetail
                 {
-                    MaterielCode = "鐢佃姱",
-                    MaterielName = "鐢佃姱",
+                    MaterielCode = StockConstants.MATERIAL_CODE,
+                    MaterielName = StockConstants.MATERIAL_NAME,
                     StockQuantity = item.Quantity,
-                    Unit = "PCS",
-                    Creater = "system",
-                    OrderNo = "111",
+                    Unit = StockConstants.UNIT,
+                    Creater = StockConstants.SYSTEM_USER,
+                    OrderNo = StockConstants.DEFAULT_ORDER_NO,
                     ProductionDate = now.ToString(),
                     EffectiveDate = now.AddYears(1).ToString(),
                     SerialNumber = item.CellBarcode,
@@ -139,10 +140,10 @@
                 var bindRequest = new BindContainerRequest
                 {
                     ContainerCode = stock?.TargetPalletNo,
-                    EquipmentCode = "STK-GROUP-001",
-                    ResourceCode = "STK-GROUP-001",
+                    EquipmentCode = StockConstants.MES_EQUIPMENT_CODE,
+                    ResourceCode = StockConstants.MES_RESOURCE_CODE,
                     LocalTime = now,
-                    OperationType = 0, // 0浠h〃缁勭洏
+                    OperationType = StockConstants.MES_BIND_OPERATION_TYPE,
                     ContainerSfcList = details.Select(d => new ContainerSfcItem
                     {
                         Sfc = d.SerialNumber,
@@ -166,7 +167,7 @@
                         PalletCode = stock.TargetPalletNo,
                         WarehouseId = stock.Roadway == "娉ㄦ恫缁勭洏鏈烘鎵�" ? (await _warehouseService.Db.Queryable<Dt_Warehouse>().FirstAsync(w => w.WarehouseCode == "GW1")).WarehouseId : 0,
                         StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.GetHashCode(),
-                        Creater = "system",
+                        Creater = StockConstants.SYSTEM_USER,
                         Details = details
                     };
                     result = StockInfoService.Repository.AddData(entity, x => x.Details);
@@ -215,7 +216,7 @@
                             PalletCode = stock.TargetPalletNo,
                             WarehouseId = sourceStock.WarehouseId,
                             StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.GetHashCode(),
-                            Creater = "system",
+                            Creater = StockConstants.SYSTEM_USER,
                         };
 
                         var newId = StockInfoService.Repository.AddData(newStock);
@@ -241,8 +242,8 @@
                     // 璋冪敤MES瑙g粦婧愭墭鐩樼數鑺�
                     var unbindRequest = new UnBindContainerRequest
                     {
-                        EquipmentCode = "STK-GROUP-001",
-                        ResourceCode = "STK-GROUP-001",
+                        EquipmentCode = StockConstants.MES_EQUIPMENT_CODE,
+                        ResourceCode = StockConstants.MES_RESOURCE_CODE,
                         LocalTime = DateTime.Now,
                         ContainCode = stock.SourcePalletNo,
                         SfcList = detailEntities.Select(d => d.SerialNumber).ToList()
@@ -261,10 +262,10 @@
                     var bindRequest = new BindContainerRequest
                     {
                         ContainerCode = stock.TargetPalletNo,
-                        EquipmentCode = "STK-GROUP-001",
-                        ResourceCode = "STK-GROUP-001",
+                        EquipmentCode = StockConstants.MES_EQUIPMENT_CODE,
+                        ResourceCode = StockConstants.MES_RESOURCE_CODE,
                         LocalTime = DateTime.Now,
-                        OperationType = 0,
+                        OperationType = StockConstants.MES_BIND_OPERATION_TYPE,
                         ContainerSfcList = detailEntities.Select(d => new ContainerSfcItem
                         {
                             Sfc = d.SerialNumber,
@@ -324,8 +325,8 @@
                     // 璋冪敤MES瑙g粦鐢佃姱
                     var unbindRequest = new UnBindContainerRequest
                     {
-                        EquipmentCode = "STK-GROUP-001",
-                        ResourceCode = "STK-GROUP-001",
+                        EquipmentCode = StockConstants.MES_EQUIPMENT_CODE,
+                        ResourceCode = StockConstants.MES_RESOURCE_CODE,
                         LocalTime = DateTime.Now,
                         ContainCode = stock.SourcePalletNo,
                         SfcList = detailEntities.Select(d => d.SerialNumber).ToList()
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index e06a6cf..f64135c 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -4,6 +4,7 @@
 using SqlSugar;
 using System.DirectoryServices.Protocols;
 using System.Text.Json;
+using WIDESEA_Common.Constants;
 using WIDESEA_Common.LocationEnum;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
@@ -146,7 +147,7 @@
         private string DetermineTargetAddress(string roadway, Dictionary<string, List<string>> addressMap)
         {
             if (string.IsNullOrWhiteSpace(roadway))
-                return "10080";
+                return TaskAddressConstants.DEFAULT_ADDRESS;
 
             string? matchedPrefix = null;
             foreach (var kvp in addressMap)
@@ -159,10 +160,10 @@
             }
 
             if (matchedPrefix == null)
-                return "10080";
+                return TaskAddressConstants.DEFAULT_ADDRESS;
 
             if (!addressMap.TryGetValue(matchedPrefix, out var addresses) || addresses == null || addresses.Count == 0)
-                return "10080";
+                return TaskAddressConstants.DEFAULT_ADDRESS;
 
             if (addresses.Count == 1)
                 return addresses[0];
@@ -180,9 +181,9 @@
             {
                 return remark switch
                 {
-                    "GW_1" => _roundRobinService.GetNextAddress("GW_1", new List<string> { "11001", "11010" }),
-                    "GW_2" => "CWSC1",
-                    "CW_1" => "22001",
+                    StockRemarkConstants.GW1 => _roundRobinService.GetNextAddress(StockRemarkConstants.GW1, TaskAddressConstants.GW1_ADDRESSES.ToList()),
+                    StockRemarkConstants.GW2 => TaskAddressConstants.GW2_ADDRESS,
+                    StockRemarkConstants.CW1 => TaskAddressConstants.CW1_ADDRESS,
                     _ => DetermineTargetAddress(roadway, addressMap)
                 };
             }
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
index b5af9c9..89fae08 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
@@ -4,6 +4,7 @@
 using SqlSugar;
 using System.DirectoryServices.Protocols;
 using System.Text.Json;
+using WIDESEA_Common.Constants;
 using WIDESEA_Common.LocationEnum;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
@@ -137,8 +138,8 @@
                         PalletType = stock.PalletType,
                         SourceAddress = stock.LocationCode,
                         CurrentAddress = stock.LocationCode,
-                        NextAddress = "10080",
-                        TargetAddress = "10081",
+                        NextAddress = TaskAddressConstants.DEFAULT_ADDRESS,
+                        TargetAddress = TaskAddressConstants.GRADING_OUTBOUND_ADDRESS,
                         Roadway = stock.LocationDetails.RoadwayNo,
                         TaskType = TaskTypeEnum.Outbound.GetHashCode(),
                         TaskStatus = TaskStatusEnum.New.GetHashCode(),
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
index e4ed527..d4fde20 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
@@ -4,6 +4,7 @@
 using SqlSugar;
 using System.DirectoryServices.Protocols;
 using System.Text.Json;
+using WIDESEA_Common.Constants;
 using WIDESEA_Common.LocationEnum;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
@@ -199,29 +200,29 @@
                     {
                         if (stockInfo.Remark.IsNullOrEmpty())
                         {
-                            stockInfo.OutboundDate = now.AddHours(16);
-                            stockInfo.Remark = "GW_1";
+                            stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST);
+                            stockInfo.Remark = StockRemarkConstants.GW1;
                         }
-                        else if (stockInfo.Remark == "GW_1")
+                        else if (stockInfo.Remark == StockRemarkConstants.GW1)
                         {
-                            stockInfo.OutboundDate = now.AddHours(24);
-                            stockInfo.Remark = "GW_2";
+                            stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_SECOND);
+                            stockInfo.Remark = StockRemarkConstants.GW2;
                         }
                         else
                         {
-                            stockInfo.OutboundDate = now.AddHours(16);
+                            stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST);
                         }
                     }
                     else if (task.Roadway.Contains("CW"))
                     {
-                        if (stockInfo.Remark == "GW_2")
+                        if (stockInfo.Remark == StockRemarkConstants.GW2)
                         {
-                            stockInfo.OutboundDate = now.AddHours(12);
-                            stockInfo.Remark = "CW_1";
+                            stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1);
+                            stockInfo.Remark = StockRemarkConstants.CW1;
                         }
                         else
                         {
-                            stockInfo.OutboundDate = now.AddHours(12);
+                            stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1);
                         }
                     }
                     else

--
Gitblit v1.9.3