From 75ef0dfecf2331c0828a1a182b1d3243d3041c51 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期二, 21 四月 2026 13:19:44 +0800
Subject: [PATCH] refactor: 统一日志组件为Serilog并优化相关功能
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 385b838..648454e 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -1,7 +1,8 @@
-using Microsoft.Extensions.Logging;
+//using Microsoft.Extensions.Logging;
using Quartz;
+using Serilog;
using WIDESEA_Core;
-using WIDESEAWCS_Core;
+using WIDESEAWCS_Common.Constants;
using WIDESEAWCS_Core.LogHelper;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
@@ -10,7 +11,6 @@
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_QuartzJob.StackerCrane;
using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
-using WIDESEAWCS_Common.Constants;
using WIDESEAWCS_Tasks.StackerCraneJob;
namespace WIDESEAWCS_Tasks
@@ -81,7 +81,7 @@
/// <summary>
/// 鏃ュ織璁板綍鍣�
/// </summary>
- private readonly ILogger<CommonStackerCraneJob> _logger;
+ private readonly ILogger _logger;
/// <summary>
/// 鍫嗗灈鏈鸿澶囩紪鐮�
@@ -103,7 +103,7 @@
ITaskRepository taskRepository,
IRouterService routerService,
HttpClientHelper httpClientHelper,
- ILogger<CommonStackerCraneJob> logger)
+ ILogger logger)
{
_taskService = taskService;
_taskExecuteDetailService = taskExecuteDetailService;
@@ -169,10 +169,12 @@
{
try
{
+ //QuartzLogger.Info($"CommonStackerCraneJob Execute锛氬紑濮嬫墽琛屽爢鍨涙満浠诲姟璋冨害 銆恵DateTime.Now.ToString("F")}銆�", "CommonStackerCraneJob Execute ");
// 浠� JobDataMap 鑾峰彇鍫嗗灈鏈鸿澶囧弬鏁�
bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
if (!flag || value is not CommonStackerCrane commonStackerCrane)
{
+ _logger.Information("Execute锛氬弬鏁版棤鏁堬紝鏈壘鍒� JobParams 鎴栫被鍨嬩笉鍖归厤");
// 鍙傛暟鏃犳晥锛岀洿鎺ヨ繑鍥�
QuartzLogHelper.LogWarn(_logger, "Execute锛氬弬鏁版棤鏁�", "Execute锛氬弬鏁版棤鏁�", "CommonStackerCraneJob");
return Task.CompletedTask;
@@ -193,7 +195,7 @@
// ========== 妫�鏌ユ槸鍚﹀彲浠ュ彂閫佹柊浠诲姟 ==========
//if (!commonStackerCrane.IsCanSendTask(commonStackerCrane.Communicator, commonStackerCrane.DeviceProDTOs, commonStackerCrane.DeviceProtocolDetailDTOs))
- if (commonStackerCrane.StackerCraneStatusValue != StackerCraneStatus.Normal )
+ if (commonStackerCrane.StackerCraneStatusValue != StackerCraneStatus.Normal)
{
// 鍫嗗灈鏈轰笉鍙敤锛堝姝e湪鎵ц涓婁竴浠诲姟锛夛紝鐩存帴杩斿洖
return Task.CompletedTask;
@@ -240,6 +242,10 @@
// 璁板綍寮傚父
QuartzLogHelper.LogError(_logger, ex, "Execute锛氭墽琛屽紓甯革紝璁惧: {DeviceCode}", $"鎵ц寮傚父: {ex.Message}", _deviceCode, _deviceCode);
}
+ finally
+ {
+ QuartzLogHelper.LogInfo(_logger, $"CommonStackerCraneJob Execute锛氬爢鍨涙満浠诲姟璋冨害鎵ц瀹屾垚 銆恵DateTime.Now.ToString("F")}銆�", _deviceCode);
+ }
return Task.CompletedTask;
}
--
Gitblit v1.9.3