From c5c3e4e538a11f2a6391e6b2613375b1f92eb20a Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 15 四月 2026 14:39:18 +0800
Subject: [PATCH] feat: 添加Quartz日志助手类并重构任务服务日志记录

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs |   48 +++++++++++++++---------------------------------
 1 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
index a8637cb..b3a4cff 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/StackerCraneCommandBuilder.cs
@@ -105,14 +105,12 @@
             {
                 if (roadway.Contains(mapping.Key))
                 {
-                    _logger.LogDebug("GetCommandType锛氬尮閰嶅贩閬� {Roadway}锛屽懡浠ょ被鍨�: {CommandType}", roadway, mapping.Value);
-                    QuartzLogger.Debug($"GetCommandType锛氬尮閰嶅贩閬� {roadway}锛屽懡浠ょ被鍨�: {mapping.Value}", roadway);
+                    QuartzLogHelper.LogDebug(_logger, "GetCommandType锛氬尮閰嶅贩閬� {Roadway}锛屽懡浠ょ被鍨�: {CommandType}", $"GetCommandType锛氬尮閰嶅贩閬� {roadway}锛屽懡浠ょ被鍨�: {mapping.Value}", roadway, roadway, mapping.Value);
                     return mapping.Value;
                 }
             }
 
-            _logger.LogDebug("GetCommandType锛氬贩閬� {Roadway} 鏈尮閰嶏紝浣跨敤榛樿鍛戒护绫诲瀷: {DefaultType}", roadway, _config.DefaultCommandType);
-            QuartzLogger.Debug($"GetCommandType锛氬贩閬� {roadway} 鏈尮閰嶏紝浣跨敤榛樿鍛戒护绫诲瀷: {_config.DefaultCommandType}", roadway);
+            QuartzLogHelper.LogDebug(_logger, "GetCommandType锛氬贩閬� {Roadway} 鏈尮閰嶏紝浣跨敤榛樿鍛戒护绫诲瀷: {DefaultType}", $"GetCommandType锛氬贩閬� {roadway} 鏈尮閰嶏紝浣跨敤榛樿鍛戒护绫诲瀷: {_config.DefaultCommandType}", roadway, roadway, _config.DefaultCommandType);
             return _config.DefaultCommandType;
         }
 
@@ -172,8 +170,7 @@
             // 鑾峰彇浠诲姟绫诲瀷鍒嗙粍
             TaskTypeGroup taskTypeGroup = task.TaskType.GetTaskTypeGroup();
 
-            _logger.LogDebug("BuildCommand锛氫换鍔″彿: {TaskNum}锛屼换鍔$被鍨嬪垎缁�: {TaskTypeGroup}", task.TaskNum, taskTypeGroup);
-            QuartzLogger.Debug($"BuildCommand锛氫换鍔″彿: {task.TaskNum}锛屼换鍔$被鍨嬪垎缁�: {taskTypeGroup}", task.Roadway);
+            QuartzLogHelper.LogDebug(_logger, "BuildCommand锛氫换鍔″彿: {TaskNum}锛屼换鍔$被鍨嬪垎缁�: {TaskTypeGroup}", $"BuildCommand锛氫换鍔″彿: {task.TaskNum}锛屼换鍔$被鍨嬪垎缁�: {taskTypeGroup}", task.Roadway, task.TaskNum, taskTypeGroup);
 
             // 鏍规嵁浠诲姟绫诲瀷鍒嗗彂鏋勫缓
             return taskTypeGroup switch
@@ -200,8 +197,7 @@
         /// <returns>濉厖濂界殑鍛戒护瀵硅薄</returns>
         private T? BuildInboundCommand<T>(Dt_Task task, T command) where T : class
         {
-            _logger.LogInformation("BuildInboundCommand锛氭瀯寤哄叆搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", task.TaskNum);
-            QuartzLogger.Info($"BuildInboundCommand锛氭瀯寤哄叆搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway);
+            QuartzLogHelper.LogInfo(_logger, "BuildInboundCommand锛氭瀯寤哄叆搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", $"BuildInboundCommand锛氭瀯寤哄叆搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway, task.TaskNum);
 
             // 纭畾浠诲姟绫诲瀷锛堢┖鎵樼洏鐢ㄧ壒娈婄被鍨嬶級
             int taskType = 0;
@@ -217,8 +213,7 @@
             if (router == null)
             {
                 // 鏈壘鍒扮珯鍙帮紝鏇存柊寮傚父淇℃伅
-                _logger.LogError("BuildInboundCommand锛氭湭鎵惧埌绔欏彴銆恵CurrentAddress}銆戜俊鎭紝浠诲姟鍙�: {TaskNum}", task.CurrentAddress, task.TaskNum);
-                QuartzLogger.Error($"BuildInboundCommand锛氭湭鎵惧埌绔欏彴銆恵task.CurrentAddress}銆戜俊鎭�", task.Roadway);
+                QuartzLogHelper.LogError(_logger, "BuildInboundCommand锛氭湭鎵惧埌绔欏彴銆恵CurrentAddress}銆戜俊鎭紝浠诲姟鍙�: {TaskNum}", $"BuildInboundCommand锛氭湭鎵惧埌绔欏彴銆恵task.CurrentAddress}銆戜俊鎭�", task.Roadway, task.CurrentAddress, task.TaskNum);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.CurrentAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鍙栬揣绔欏彴淇℃伅");
                 return null;
             }
@@ -231,8 +226,7 @@
             // 瑙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);
+                QuartzLogHelper.LogError(_logger, "BuildInboundCommand锛氬叆搴撲换鍔$粓鐐瑰湴鍧�瑙f瀽澶辫触锛岀粓鐐�: {NextAddress}锛屼换鍔″彿: {TaskNum}", $"BuildInboundCommand锛氬叆搴撲换鍔$粓鐐瑰湴鍧�瑙f瀽澶辫触锛岀粓鐐�: {task.NextAddress}", task.Roadway, task.NextAddress, task.TaskNum);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�");
                 return null;
             }
@@ -242,9 +236,7 @@
             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);
+            QuartzLogHelper.LogInfo(_logger, "BuildInboundCommand锛氬叆搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {StartRow}-{StartColumn}-{StartLayer}锛岀粓鐐�: {EndRow}-{EndColumn}-{EndLayer}锛屼换鍔″彿: {TaskNum}", $"BuildInboundCommand锛氬叆搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {router.SrmRow}-{router.SrmColumn}-{router.SrmLayer}锛岀粓鐐�: {endRow}-{endColumn}-{endLayer}", task.Roadway, router.SrmRow, router.SrmColumn, router.SrmLayer, endRow, endColumn, endLayer, task.TaskNum);
 
             return command;
         }
@@ -264,8 +256,7 @@
         /// <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);
+            QuartzLogHelper.LogInfo(_logger, "BuildOutboundCommand锛氭瀯寤哄嚭搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", $"BuildOutboundCommand锛氭瀯寤哄嚭搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway, task.TaskNum);
 
             // 纭畾浠诲姟绫诲瀷
             int taskType = 0;
@@ -280,8 +271,7 @@
             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);
+                QuartzLogHelper.LogError(_logger, "BuildOutboundCommand锛氭湭鎵惧埌绔欏彴銆恵TargetAddress}銆戜俊鎭紝浠诲姟鍙�: {TaskNum}", $"BuildOutboundCommand锛氭湭鎵惧埌绔欏彴銆恵task.TargetAddress}銆戜俊鎭�", task.Roadway, task.TargetAddress, task.TaskNum);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.TargetAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鏀捐揣绔欏彴淇℃伅");
                 return null;
             }
@@ -294,8 +284,7 @@
             // 瑙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);
+                QuartzLogHelper.LogError(_logger, "BuildOutboundCommand锛氬嚭搴撲换鍔¤捣鐐瑰湴鍧�瑙f瀽澶辫触锛岃捣鐐�: {CurrentAddress}锛屼换鍔″彿: {TaskNum}", $"BuildOutboundCommand锛氬嚭搴撲换鍔¤捣鐐瑰湴鍧�瑙f瀽澶辫触锛岃捣鐐�: {task.CurrentAddress}", task.Roadway, task.CurrentAddress, task.TaskNum);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
                 return null;
             }
@@ -305,9 +294,7 @@
             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);
+            QuartzLogHelper.LogInfo(_logger, "BuildOutboundCommand锛氬嚭搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {StartRow}-{StartColumn}-{StartLayer}锛岀粓鐐�: {EndRow}-{EndColumn}-{EndLayer}锛屼换鍔″彿: {TaskNum}", $"BuildOutboundCommand锛氬嚭搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {startRow}-{startColumn}-{startLayer}锛岀粓鐐�: {router.SrmRow}-{router.SrmColumn}-{router.SrmLayer}", task.Roadway, startRow, startColumn, startLayer, router.SrmRow, router.SrmColumn, router.SrmLayer, task.TaskNum);
 
             return command;
         }
@@ -327,14 +314,12 @@
         /// <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);
+            QuartzLogHelper.LogInfo(_logger, "BuildRelocationCommand锛氭瀯寤虹Щ搴撳懡浠わ紝浠诲姟鍙�: {TaskNum}", $"BuildRelocationCommand锛氭瀯寤虹Щ搴撳懡浠わ紝浠诲姟鍙�: {task.TaskNum}", task.Roadway, task.TaskNum);
 
             // 瑙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);
+                QuartzLogHelper.LogError(_logger, "BuildRelocationCommand锛氱Щ搴撲换鍔$粓鐐瑰湴鍧�瑙f瀽澶辫触锛岀粓鐐�: {NextAddress}锛屼换鍔″彿: {TaskNum}", $"BuildRelocationCommand锛氱Щ搴撲换鍔$粓鐐瑰湴鍧�瑙f瀽澶辫触锛岀粓鐐�: {task.NextAddress}", task.Roadway, task.NextAddress, task.TaskNum);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�");
                 return null;
             }
@@ -347,8 +332,7 @@
             // 瑙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);
+                QuartzLogHelper.LogError(_logger, "BuildRelocationCommand锛氱Щ搴撲换鍔¤捣鐐瑰湴鍧�瑙f瀽澶辫触锛岃捣鐐�: {CurrentAddress}锛屼换鍔″彿: {TaskNum}", $"BuildRelocationCommand锛氱Щ搴撲换鍔¤捣鐐瑰湴鍧�瑙f瀽澶辫触锛岃捣鐐�: {task.CurrentAddress}", task.Roadway, task.CurrentAddress, task.TaskNum);
                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
                 return null;
             }
@@ -358,9 +342,7 @@
             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);
+            QuartzLogHelper.LogInfo(_logger, "BuildRelocationCommand锛氱Щ搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {StartRow}-{StartColumn}-{StartLayer}锛岀粓鐐�: {EndRow}-{EndColumn}-{EndLayer}锛屼换鍔″彿: {TaskNum}", $"BuildRelocationCommand锛氱Щ搴撳懡浠ゆ瀯寤烘垚鍔燂紝璧风偣: {startRow}-{startColumn}-{startLayer}锛岀粓鐐�: {endRow}-{endColumn}-{endLayer}", task.Roadway, startRow, startColumn, startLayer, endRow, endColumn, endLayer, task.TaskNum);
 
             return command;
         }

--
Gitblit v1.9.3