From fe2a1e74780259605cd230e6f9c629c3dd7fdf15 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 10 四月 2026 20:19:06 +0800
Subject: [PATCH] feat: 添加消防任务支持并修复堆垛机状态处理

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs |  274 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 248 insertions(+), 26 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
index 71b334a..edf399a 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
@@ -1,6 +1,8 @@
-锘縰sing System;
+using Microsoft.Extensions.Logging;
+using System;
 using System.Diagnostics.CodeAnalysis;
 using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core.LogHelper;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob.Models;
@@ -10,177 +12,397 @@
 namespace WIDESEAWCS_Tasks
 {
     /// <summary>
-    /// 鍫嗗灈鏈哄懡浠ゆ瀯寤哄櫒锛氬皝瑁呬换鍔″埌鍛戒护瀵硅薄鐨勮浆鎹笌鍦板潃瑙f瀽銆�
+    /// 鍫嗗灈鏈哄懡浠ゆ瀯寤哄櫒 - 灏佽浠诲姟鍒板懡浠ゅ璞$殑杞崲涓庡湴鍧�瑙f瀽
     /// </summary>
+    /// <remarks>
+    /// 鏍稿績鑱岃矗锛�
+    /// 1. 鏍规嵁宸烽亾绫诲瀷閫夋嫨鍛戒护鏍煎紡锛堟爣鍑嗗懡浠�/鎴愬瀷鍛戒护锛�
+    /// 2. 鏋勫缓鍏ュ簱銆佸嚭搴撱�佺Щ搴撲换鍔$殑鍛戒护瀵硅薄
+    /// 3. 瑙f瀽浠诲姟鍦板潃锛堣-鍒�-灞傛牸寮忥級鍒板懡浠ゅ潗鏍�
+    /// 4. 鏌ヨ璺敱淇℃伅锛岀‘瀹氬爢鍨涙満鐨勫彇璐�/鏀捐揣绔欏彴
+    ///
+    /// 鍦板潃鏍煎紡绾﹀畾锛氬湴鍧�瀛楃涓叉牸寮忎负 "琛�-鍒�-灞�"锛屼緥濡� "1-2-3" 琛ㄧず绗�1琛屻�佺2鍒椼�佺3灞傘��
+    /// </remarks>
     public class StackerCraneCommandBuilder
     {
+        /// <summary>
+        /// 浠诲姟鏈嶅姟
+        /// </summary>
         private readonly ITaskService _taskService;
+
+        /// <summary>
+        /// 璺敱鏈嶅姟
+        /// </summary>
         private readonly IRouterService _routerService;
+
+        /// <summary>
+        /// 鍫嗗灈鏈哄懡浠ら厤缃�
+        /// </summary>
         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>
+        /// 灏嗕换鍔¤浆鎹负鍫嗗灈鏈哄懡浠�
+        /// </summary>
+        /// <remarks>
+        /// 鏍规嵁宸烽亾绫诲瀷閫夋嫨涓嶅悓鐨勫懡浠ゆ瀯寤虹瓥鐣ャ��
+        /// </remarks>
+        /// <param name="task">浠诲姟瀵硅薄</param>
+        /// <returns>鍫嗗灈鏈哄懡浠ゅ璞★紝杞崲澶辫触杩斿洖 null</returns>
         public object? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task)
         {
-            string commandType = GetCommandType(task.Roadway);
-            return commandType switch
-            {
-                "Formation" => BuildCommand(task, CreateFormationCommand(task)),
-                _ => BuildCommand(task, CreateStandardCommand(task))
-            };
+            return  BuildCommand(task, CreateStandardCommand(task));
+            // 鏍规嵁宸烽亾鑾峰彇鍛戒护绫诲瀷
+            //string commandType = GetCommandType(task.Roadway);
+
+            //_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>
+        /// 鏍规嵁宸烽亾鑾峰彇鍛戒护绫诲瀷
+        /// </summary>
+        /// <remarks>
+        /// 閬嶅巻閰嶇疆涓殑鏄犲皠鍏崇郴锛屾壘鍒板尮閰嶇殑鍛戒护绫诲瀷銆�
+        /// 濡傛灉涓嶅尮閰嶄换浣曟槧灏勶紝杩斿洖榛樿鍛戒护绫诲瀷銆�
+        /// </remarks>
+        /// <param name="roadway">宸烽亾缂栫爜</param>
+        /// <returns>鍛戒护绫诲瀷锛圫tandard 鎴� Formation锛�</returns>
         private string GetCommandType(string roadway)
         {
             foreach (var mapping in _config.RoadwayCommandMapping)
             {
                 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;
         }
 
+        /// <summary>
+        /// 鍒涘缓鏍囧噯鍛戒护
+        /// </summary>
+        /// <remarks>
+        /// 鐢ㄤ簬鏍囧噯鍫嗗灈鏈猴紙GW銆丆W 寮�澶村贩閬擄級銆�
+        /// </remarks>
+        /// <param name="task">浠诲姟瀵硅薄</param>
+        /// <returns>鏍囧噯鍛戒护瀵硅薄</returns>
         private static StackerCraneTaskCommand CreateStandardCommand(Dt_Task task)
         {
             return new StackerCraneTaskCommand
             {
-                TaskNum = task.TaskNum,
-                WorkType = 1,
-                WorkAction = 1
+                TaskNum = task.TaskNum,   // 浠诲姟鍙�
+                WorkType = 1,             // 浣滀笟绫诲瀷
+                //WorkAction = 1            // 浣滀笟鎸囦护锛氬紑濮嬫墽琛�
             };
         }
 
+        /// <summary>
+        /// 鍒涘缓鎴愬瀷鍛戒护
+        /// </summary>
+        /// <remarks>
+        /// 鐢ㄤ簬鎴愬瀷鍫嗗灈鏈猴紙HC 寮�澶村贩閬擄級銆�
+        /// 鍖呭惈鏉$爜瀛楁锛岀敤浜庣數姹犺拷婧��
+        /// </remarks>
+        /// <param name="task">浠诲姟瀵硅薄</param>
+        /// <returns>鎴愬瀷鍛戒护瀵硅薄</returns>
         private static FormationStackerCraneTaskCommand CreateFormationCommand(Dt_Task task)
         {
             return new FormationStackerCraneTaskCommand
             {
-                Barcode = task.PalletCode,
-                TaskNum = task.TaskNum,
-                WorkType = 1,
-                WorkAction = 1,
-                FireAlarm = 0,
-                HeartBeat = 0,
-                FieldName = string.Empty
+                Barcode = task.PalletCode,   // 鎵樼洏鏉$爜
+                TaskNum = task.TaskNum,      // 浠诲姟鍙�
+                WorkType = 1,               // 浣滀笟绫诲瀷
+                WorkAction = 1,             // 浣滀笟鎸囦护锛氬紑濮嬫墽琛�
+                FireAlarm = 0,              // 鐏锛氭甯�
+                HeartBeat = 0,              // 蹇冭烦
+                FieldName = string.Empty     // 淇濈暀瀛楁
             };
         }
 
+        /// <summary>
+        /// 鏋勫缓鍛戒护锛堥�氱敤锛�
+        /// </summary>
+        /// <remarks>
+        /// 鏍规嵁浠诲姟绫诲瀷锛堝叆搴�/鍑哄簱/绉诲簱锛夎皟鐢ㄧ浉搴旂殑鏋勫缓鏂规硶銆�
+        /// </remarks>
+        /// <typeparam name="T">鍛戒护绫诲瀷</typeparam>
+        /// <param name="task">浠诲姟瀵硅薄</param>
+        /// <param name="command">鍒濆鍛戒护瀵硅薄</param>
+        /// <returns>濉厖濂界殑鍛戒护瀵硅薄</returns>
         private T? BuildCommand<T>(Dt_Task task, T command) where T : class
         {
+            // 鑾峰彇浠诲姟绫诲瀷鍒嗙粍
             TaskTypeGroup taskTypeGroup = task.TaskType.GetTaskTypeGroup();
 
+            _logger.LogDebug("BuildCommand锛氫换鍔″彿: {TaskNum}锛屼换鍔$被鍨嬪垎缁�: {TaskTypeGroup}", task.TaskNum, taskTypeGroup);
+            QuartzLogger.Debug($"BuildCommand锛氫换鍔″彿: {task.TaskNum}锛屼换鍔$被鍨嬪垎缁�: {taskTypeGroup}", task.Roadway);
+
+            // 鏍规嵁浠诲姟绫诲瀷鍒嗗彂鏋勫缓
             return taskTypeGroup switch
             {
-                TaskTypeGroup.InboundGroup => BuildInboundCommand(task, command),
-                TaskTypeGroup.OutbondGroup => BuildOutboundCommand(task, command),
-                TaskTypeGroup.RelocationGroup => BuildRelocationCommand(task, command),
-                _ => command
+                TaskTypeGroup.InboundGroup => BuildInboundCommand(task, command),    // 鍏ュ簱
+                TaskTypeGroup.OutbondGroup => BuildOutboundCommand(task, command),  // 鍑哄簱
+                TaskTypeGroup.RelocationGroup => BuildRelocationCommand(task, command),  // 绉诲簱
+                _ => command  // 鏈煡绫诲瀷锛岃繑鍥炲師鍛戒护
             };
         }
 
+        /// <summary>
+        /// 鏋勫缓鍏ュ簱鍛戒护
+        /// </summary>
+        /// <remarks>
+        /// 鍏ュ簱浠诲姟闇�瑕侊細
+        /// 1. 鏌ヨ鍫嗗灈鏈哄彇璐х珯鍙帮紙鏍规嵁褰撳墠鍦板潃鍜屼换鍔$被鍨嬶級
+        /// 2. 璁剧疆璧峰鍧愭爣锛堟潵鑷珯鍙帮級
+        /// 3. 瑙f瀽鐩爣鍦板潃锛岃缃粓鐐瑰潗鏍�
+        /// </remarks>
+        /// <typeparam name="T">鍛戒护绫诲瀷</typeparam>
+        /// <param name="task">浠诲姟瀵硅薄</param>
+        /// <param name="command">鍛戒护瀵硅薄</param>
+        /// <returns>濉厖濂界殑鍛戒护瀵硅薄</returns>
         private T? BuildInboundCommand<T>(Dt_Task task, T command) where T : class
         {
-            Dt_Router? router = _routerService.QueryNextRoute(task.CurrentAddress, task.Roadway, task.TaskType);
+            _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;
+            }
+            else
+                taskType = task.TaskType;
+
+            // 鏌ヨ鍫嗗灈鏈哄彇璐х珯鍙拌矾鐢�
+            Dt_Router? router = _routerService.QueryNextRoute(task.CurrentAddress, task.Roadway, taskType);
             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;
             }
 
+            // 璁剧疆璧峰鍧愭爣锛堟潵鑷矾鐢遍厤缃級
             SetCommandProperty(command, "StartRow", Convert.ToInt16(router.SrmRow));
             SetCommandProperty(command, "StartColumn", Convert.ToInt16(router.SrmColumn));
             SetCommandProperty(command, "StartLayer", Convert.ToInt16(router.SrmLayer));
 
+            // 瑙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;
             }
 
+            // 璁剧疆缁堢偣鍧愭爣
             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;
         }
 
+        /// <summary>
+        /// 鏋勫缓鍑哄簱鍛戒护
+        /// </summary>
+        /// <remarks>
+        /// 鍑哄簱浠诲姟闇�瑕侊細
+        /// 1. 鏌ヨ鍫嗗灈鏈烘斁璐х珯鍙帮紙鏍规嵁鐩爣鍦板潃鍜屼换鍔$被鍨嬶級
+        /// 2. 璁剧疆缁堢偣鍧愭爣锛堟潵鑷珯鍙帮級
+        /// 3. 瑙f瀽璧峰鍦板潃锛岃缃捣鐐瑰潗鏍�
+        /// </remarks>
+        /// <typeparam name="T">鍛戒护绫诲瀷</typeparam>
+        /// <param name="task">浠诲姟瀵硅薄</param>
+        /// <param name="command">鍛戒护瀵硅薄</param>
+        /// <returns>濉厖濂界殑鍛戒护瀵硅薄</returns>
         private T? BuildOutboundCommand<T>(Dt_Task task, T command) where T : class
         {
-            Dt_Router? router = _routerService.QueryNextRoute(task.Roadway, task.TargetAddress, task.TaskType);
+            _logger.LogInformation("BuildOutboundCommand锛氭瀯寤哄嚭搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", task.TaskNum);
+            QuartzLogger.Info($"BuildOutboundCommand锛氭瀯寤哄嚭搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway);
+
+            // 纭畾浠诲姟绫诲瀷
+            int taskType = 0;
+            if (task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty)
+            {
+                taskType = 100;
+            }
+            else
+                taskType = task.TaskType;
+
+            // 鏌ヨ鍫嗗灈鏈烘斁璐х珯鍙拌矾鐢�
+            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;
             }
 
+            // 璁剧疆缁堢偣鍧愭爣锛堟潵鑷矾鐢遍厤缃級
             SetCommandProperty(command, "EndRow", Convert.ToInt16(router.SrmRow));
             SetCommandProperty(command, "EndColumn", Convert.ToInt16(router.SrmColumn));
             SetCommandProperty(command, "EndLayer", Convert.ToInt16(router.SrmLayer));
 
+            // 瑙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;
             }
 
+            // 璁剧疆璧风偣鍧愭爣
             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;
         }
 
+        /// <summary>
+        /// 鏋勫缓绉诲簱鍛戒护
+        /// </summary>
+        /// <remarks>
+        /// 绉诲簱浠诲姟闇�瑕侊細
+        /// 1. 瑙f瀽鐩爣鍦板潃锛堟柊鐨勫簱浣嶏級
+        /// 2. 瑙f瀽璧峰鍦板潃锛堝師鏉ョ殑搴撲綅锛�
+        /// 3. 璁剧疆璧锋鍧愭爣
+        /// </remarks>
+        /// <typeparam name="T">鍛戒护绫诲瀷</typeparam>
+        /// <param name="task">浠诲姟瀵硅薄</param>
+        /// <param name="command">鍛戒护瀵硅薄</param>
+        /// <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;
             }
 
+            // 璁剧疆缁堢偣鍧愭爣
             SetCommandProperty(command, "EndRow", endRow);
             SetCommandProperty(command, "EndColumn", endColumn);
             SetCommandProperty(command, "EndLayer", endLayer);
 
+            // 瑙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;
             }
 
+            // 璁剧疆璧风偣鍧愭爣
             SetCommandProperty(command, "StartRow", startRow);
             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;
         }
 
+        /// <summary>
+        /// 璁剧疆鍛戒护灞炴�у�硷紙閫氳繃鍙嶅皠锛�
+        /// </summary>
+        /// <remarks>
+        /// 浣跨敤鍙嶅皠鍔ㄦ�佽缃懡浠ゅ璞$殑灞炴�у�笺��
+        /// </remarks>
+        /// <typeparam name="T">鍛戒护绫诲瀷</typeparam>
+        /// <param name="command">鍛戒护瀵硅薄</param>
+        /// <param name="propertyName">灞炴�у悕绉�</param>
+        /// <param name="value">灞炴�у��</param>
         private static void SetCommandProperty<T>(T command, string propertyName, object value) where T : class
         {
             var property = typeof(T).GetProperty(propertyName);
             property?.SetValue(command, value);
         }
 
+        /// <summary>
+        /// 瑙f瀽鍦板潃瀛楃涓�
+        /// </summary>
+        /// <remarks>
+        /// 鍦板潃鏍煎紡锛氳-鍒�-灞傦紝渚嬪 "1-2-3" 琛ㄧず绗�1琛屻�佺2鍒椼�佺3灞傘��
+        /// </remarks>
+        /// <param name="address">鍦板潃瀛楃涓�</param>
+        /// <param name="row">瑙f瀽鍑虹殑琛屽潗鏍�</param>
+        /// <param name="column">瑙f瀽鍑虹殑鍒楀潗鏍�</param>
+        /// <param name="layer">瑙f瀽鍑虹殑灞傚潗鏍�</param>
+        /// <returns>瑙f瀽鎴愬姛杩斿洖 true</returns>
         private static bool TryParseAddress(string address, out short row, out short column, out short layer)
         {
             row = column = layer = 0;
 
-            string[] parts = address.Split("-");
+            // 鎸� "-" 鍒嗛殧鍦板潃
+            string[] parts = address.Split('-');
             if (parts.Length != 3)
             {
                 return false;
             }
 
+            // 瑙f瀽鍚勯儴鍒嗕负 short 绫诲瀷
             return short.TryParse(parts[0], out row)
                 && short.TryParse(parts[1], out column)
                 && short.TryParse(parts[2], out layer);

--
Gitblit v1.9.3