From ce1292c9cf37195b6abd2699dfc5d6cb3e143c9b Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 23:38:19 +0800
Subject: [PATCH] feat(MES): 添加MES接口相关实体和DTO JS扩展文件至JSX格式并更新配置

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs |   89 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 72 insertions(+), 17 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
index d7b8602..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,9 @@
+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;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob.Models;
@@ -39,19 +42,27 @@
         private readonly StackerCraneCommandConfig _config;
 
         /// <summary>
+        /// 鏃ュ織璁板綍鍣�
+        /// </summary>
+        private readonly ILogger _logger;
+
+        /// <summary>
         /// 鏋勯�犲嚱鏁�
         /// </summary>
         /// <param name="taskService">浠诲姟鏈嶅姟</param>
         /// <param name="routerService">璺敱鏈嶅姟</param>
         /// <param name="config">鍛戒护閰嶇疆</param>
+        /// <param name="logger">鏃ュ織璁板綍鍣�</param>
         public StackerCraneCommandBuilder(
             ITaskService taskService,
             IRouterService routerService,
-            StackerCraneCommandConfig config)
+            StackerCraneCommandConfig config,
+            ILogger logger)
         {
             _taskService = taskService;
             _routerService = routerService;
             _config = config;
+            _logger = logger;
         }
 
         /// <summary>
@@ -64,15 +75,19 @@
         /// <returns>鍫嗗灈鏈哄懡浠ゅ璞★紝杞崲澶辫触杩斿洖 null</returns>
         public object? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task)
         {
+            return  BuildCommand(task, CreateStandardCommand(task));
             // 鏍规嵁宸烽亾鑾峰彇鍛戒护绫诲瀷
-            string commandType = GetCommandType(task.Roadway);
+            //string commandType = GetCommandType(task.Roadway);
 
-            // 鏍规嵁鍛戒护绫诲瀷璋冪敤鐩稿簲鐨勬瀯寤烘柟娉�
-            return commandType switch
-            {
-                "Formation" => BuildCommand(task, CreateFormationCommand(task)),  // 鎴愬瀷鍛戒护
-                _ => BuildCommand(task, CreateStandardCommand(task))              // 鏍囧噯鍛戒护
-            };
+            //_logger.LogInformation("ConvertToStackerCraneTaskCommand锛氭瀯寤哄懡浠わ紝浠诲姟鍙�: {TaskNum}锛屽贩閬�: {Roadway}锛屽懡浠ょ被鍨�: {CommandType}", task.TaskNum, task.Roadway, commandType);
+            //QuartzLogger.Info($"鏋勫缓鍛戒护锛屼换鍔″彿: {task.TaskNum}锛屽贩閬�: {task.Roadway}锛屽懡浠ょ被鍨�: {commandType}", task.Roadway);
+
+            //// 鏍规嵁鍛戒护绫诲瀷璋冪敤鐩稿簲鐨勬瀯寤烘柟娉�
+            //return commandType switch
+            //{
+            //    "Formation" => BuildCommand(task, CreateFormationCommand(task)),  // 鎴愬瀷鍛戒护
+            //    _ => BuildCommand(task, CreateStandardCommand(task))              // 鏍囧噯鍛戒护
+            //};
         }
 
         /// <summary>
@@ -90,10 +105,14 @@
             {
                 if (roadway.Contains(mapping.Key))
                 {
+                    _logger.LogDebug("GetCommandType锛氬尮閰嶅贩閬� {Roadway}锛屽懡浠ょ被鍨�: {CommandType}", roadway, mapping.Value);
+                    QuartzLogger.Debug($"GetCommandType锛氬尮閰嶅贩閬� {roadway}锛屽懡浠ょ被鍨�: {mapping.Value}", roadway);
                     return mapping.Value;
                 }
             }
 
+            _logger.LogDebug("GetCommandType锛氬贩閬� {Roadway} 鏈尮閰嶏紝浣跨敤榛樿鍛戒护绫诲瀷: {DefaultType}", roadway, _config.DefaultCommandType);
+            QuartzLogger.Debug($"GetCommandType锛氬贩閬� {roadway} 鏈尮閰嶏紝浣跨敤榛樿鍛戒护绫诲瀷: {_config.DefaultCommandType}", roadway);
             return _config.DefaultCommandType;
         }
 
@@ -110,8 +129,8 @@
             return new StackerCraneTaskCommand
             {
                 TaskNum = task.TaskNum,   // 浠诲姟鍙�
-                WorkType = 1,             // 浣滀笟绫诲瀷
-                WorkAction = 1            // 浣滀笟鎸囦护锛氬紑濮嬫墽琛�
+                WorkType = StackerCraneConst.WorkTypeInbound,  // 浣滀笟绫诲瀷锛氬叆搴�
+                //WorkAction = StackerCraneWorkActionEnum.StartTask  // 浣滀笟鎸囦护锛氬紑濮嬫墽琛�
             };
         }
 
@@ -130,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     // 淇濈暀瀛楁
             };
         }
@@ -152,6 +171,9 @@
         {
             // 鑾峰彇浠诲姟绫诲瀷鍒嗙粍
             TaskTypeGroup taskTypeGroup = task.TaskType.GetTaskTypeGroup();
+
+            _logger.LogDebug("BuildCommand锛氫换鍔″彿: {TaskNum}锛屼换鍔$被鍨嬪垎缁�: {TaskTypeGroup}", task.TaskNum, taskTypeGroup);
+            QuartzLogger.Debug($"BuildCommand锛氫换鍔″彿: {task.TaskNum}锛屼换鍔$被鍨嬪垎缁�: {taskTypeGroup}", task.Roadway);
 
             // 鏍规嵁浠诲姟绫诲瀷鍒嗗彂鏋勫缓
             return taskTypeGroup switch
@@ -178,11 +200,14 @@
         /// <returns>濉厖濂界殑鍛戒护瀵硅薄</returns>
         private T? BuildInboundCommand<T>(Dt_Task task, T command) where T : class
         {
-            // 纭畾浠诲姟绫诲瀷锛堢┖鎵樼洏鐢ㄧ壒娈婄被鍨� 100锛�
+            _logger.LogInformation("BuildInboundCommand锛氭瀯寤哄叆搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", task.TaskNum);
+            QuartzLogger.Info($"BuildInboundCommand锛氭瀯寤哄叆搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway);
+
+            // 纭畾浠诲姟绫诲瀷锛堢┖鎵樼洏鐢ㄧ壒娈婄被鍨嬶級
             int taskType = 0;
             if (task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty)
             {
-                taskType = 100;
+                taskType = StackerCraneConst.EmptyPalletTaskType;
             }
             else
                 taskType = task.TaskType;
@@ -192,6 +217,8 @@
             if (router == null)
             {
                 // 鏈壘鍒扮珯鍙帮紝鏇存柊寮傚父淇℃伅
+                _logger.LogError("BuildInboundCommand锛氭湭鎵惧埌绔欏彴銆恵CurrentAddress}銆戜俊鎭紝浠诲姟鍙�: {TaskNum}", task.CurrentAddress, task.TaskNum);
+                QuartzLogger.Error($"BuildInboundCommand锛氭湭鎵惧埌绔欏彴銆恵task.CurrentAddress}銆戜俊鎭�", task.Roadway);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.CurrentAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鍙栬揣绔欏彴淇℃伅");
                 return null;
             }
@@ -204,6 +231,8 @@
             // 瑙f瀽鐩爣鍦板潃锛堝簱浣嶅湴鍧�锛�
             if (!TryParseAddress(task.NextAddress, out short endRow, out short endColumn, out short endLayer))
             {
+                _logger.LogError("BuildInboundCommand锛氬叆搴撲换鍔$粓鐐瑰湴鍧�瑙f瀽澶辫触锛岀粓鐐�: {NextAddress}锛屼换鍔″彿: {TaskNum}", task.NextAddress, task.TaskNum);
+                QuartzLogger.Error($"BuildInboundCommand锛氬叆搴撲换鍔$粓鐐瑰湴鍧�瑙f瀽澶辫触锛岀粓鐐�: {task.NextAddress}", task.Roadway);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�");
                 return null;
             }
@@ -212,6 +241,10 @@
             SetCommandProperty(command, "EndRow", endRow);
             SetCommandProperty(command, "EndColumn", endColumn);
             SetCommandProperty(command, "EndLayer", endLayer);
+
+            _logger.LogInformation("BuildInboundCommand锛氬叆搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {StartRow}-{StartColumn}-{StartLayer}锛岀粓鐐�: {EndRow}-{EndColumn}-{EndLayer}锛屼换鍔″彿: {TaskNum}",
+                router.SrmRow, router.SrmColumn, router.SrmLayer, endRow, endColumn, endLayer, task.TaskNum);
+            QuartzLogger.Info($"BuildInboundCommand锛氬叆搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {router.SrmRow}-{router.SrmColumn}-{router.SrmLayer}锛岀粓鐐�: {endRow}-{endColumn}-{endLayer}", task.Roadway);
 
             return command;
         }
@@ -231,11 +264,14 @@
         /// <returns>濉厖濂界殑鍛戒护瀵硅薄</returns>
         private T? BuildOutboundCommand<T>(Dt_Task task, T command) where T : class
         {
+            _logger.LogInformation("BuildOutboundCommand锛氭瀯寤哄嚭搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", task.TaskNum);
+            QuartzLogger.Info($"BuildOutboundCommand锛氭瀯寤哄嚭搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway);
+
             // 纭畾浠诲姟绫诲瀷
             int taskType = 0;
             if (task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty)
             {
-                taskType = 100;
+                taskType = StackerCraneConst.EmptyPalletTaskType;
             }
             else
                 taskType = task.TaskType;
@@ -244,6 +280,8 @@
             Dt_Router? router = _routerService.QueryNextRoute(task.Roadway, task.TargetAddress, taskType);
             if (router == null)
             {
+                _logger.LogError("BuildOutboundCommand锛氭湭鎵惧埌绔欏彴銆恵TargetAddress}銆戜俊鎭紝浠诲姟鍙�: {TaskNum}", task.TargetAddress, task.TaskNum);
+                QuartzLogger.Error($"BuildOutboundCommand锛氭湭鎵惧埌绔欏彴銆恵task.TargetAddress}銆戜俊鎭�", task.Roadway);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.TargetAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鏀捐揣绔欏彴淇℃伅");
                 return null;
             }
@@ -256,6 +294,8 @@
             // 瑙f瀽璧峰鍦板潃锛堝簱浣嶅湴鍧�锛�
             if (!TryParseAddress(task.CurrentAddress, out short startRow, out short startColumn, out short startLayer))
             {
+                _logger.LogError("BuildOutboundCommand锛氬嚭搴撲换鍔¤捣鐐瑰湴鍧�瑙f瀽澶辫触锛岃捣鐐�: {CurrentAddress}锛屼换鍔″彿: {TaskNum}", task.CurrentAddress, task.TaskNum);
+                QuartzLogger.Error($"BuildOutboundCommand锛氬嚭搴撲换鍔¤捣鐐瑰湴鍧�瑙f瀽澶辫触锛岃捣鐐�: {task.CurrentAddress}", task.Roadway);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
                 return null;
             }
@@ -264,6 +304,10 @@
             SetCommandProperty(command, "StartRow", startRow);
             SetCommandProperty(command, "StartColumn", startColumn);
             SetCommandProperty(command, "StartLayer", startLayer);
+
+            _logger.LogInformation("BuildOutboundCommand锛氬嚭搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {StartRow}-{StartColumn}-{StartLayer}锛岀粓鐐�: {EndRow}-{EndColumn}-{EndLayer}锛屼换鍔″彿: {TaskNum}",
+                startRow, startColumn, startLayer, router.SrmRow, router.SrmColumn, router.SrmLayer, task.TaskNum);
+            QuartzLogger.Info($"BuildOutboundCommand锛氬嚭搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {startRow}-{startColumn}-{startLayer}锛岀粓鐐�: {router.SrmRow}-{router.SrmColumn}-{router.SrmLayer}", task.Roadway);
 
             return command;
         }
@@ -283,9 +327,14 @@
         /// <returns>濉厖濂界殑鍛戒护瀵硅薄</returns>
         private T? BuildRelocationCommand<T>(Dt_Task task, T command) where T : class
         {
+            _logger.LogInformation("BuildRelocationCommand锛氭瀯寤虹Щ搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", task.TaskNum);
+            QuartzLogger.Info($"BuildRelocationCommand锛氭瀯寤虹Щ搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway);
+
             // 瑙f瀽鐩爣鍦板潃
             if (!TryParseAddress(task.NextAddress, out short endRow, out short endColumn, out short endLayer))
             {
+                _logger.LogError("BuildRelocationCommand锛氱Щ搴撲换鍔$粓鐐瑰湴鍧�瑙f瀽澶辫触锛岀粓鐐�: {NextAddress}锛屼换鍔″彿: {TaskNum}", task.NextAddress, task.TaskNum);
+                QuartzLogger.Error($"BuildRelocationCommand锛氱Щ搴撲换鍔$粓鐐瑰湴鍧�瑙f瀽澶辫触锛岀粓鐐�: {task.NextAddress}", task.Roadway);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�");
                 return null;
             }
@@ -298,6 +347,8 @@
             // 瑙f瀽璧峰鍦板潃
             if (!TryParseAddress(task.CurrentAddress, out short startRow, out short startColumn, out short startLayer))
             {
+                _logger.LogError("BuildRelocationCommand锛氱Щ搴撲换鍔¤捣鐐瑰湴鍧�瑙f瀽澶辫触锛岃捣鐐�: {CurrentAddress}锛屼换鍔″彿: {TaskNum}", task.CurrentAddress, task.TaskNum);
+                QuartzLogger.Error($"BuildRelocationCommand锛氱Щ搴撲换鍔¤捣鐐瑰湴鍧�瑙f瀽澶辫触锛岃捣鐐�: {task.CurrentAddress}", task.Roadway);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
                 return null;
             }
@@ -307,6 +358,10 @@
             SetCommandProperty(command, "StartColumn", startColumn);
             SetCommandProperty(command, "StartLayer", startLayer);
 
+            _logger.LogInformation("BuildRelocationCommand锛氱Щ搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {StartRow}-{StartColumn}-{StartLayer}锛岀粓鐐�: {EndRow}-{EndColumn}-{EndLayer}锛屼换鍔″彿: {TaskNum}",
+                startRow, startColumn, startLayer, endRow, endColumn, endLayer, task.TaskNum);
+            QuartzLogger.Info($"BuildRelocationCommand锛氱Щ搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {startRow}-{startColumn}-{startLayer}锛岀粓鐐�: {endRow}-{endColumn}-{endLayer}", task.Roadway);
+
             return command;
         }
 

--
Gitblit v1.9.3