From b690250002ee04f4309e6a90fd16fbfd9bd959e2 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 01 五月 2026 23:11:23 +0800
Subject: [PATCH] feat(router): 添加托盘操作页面路由
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 64 +++++++++----------------------
1 files changed, 19 insertions(+), 45 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 984336f..efaf9b7 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;
@@ -111,43 +111,13 @@
_logger = logger;
// 鍔犺浇閰嶇疆鏂囦欢
- _config = LoadConfig();
+ //_config = LoadConfig();
// 鍒濆鍖栦换鍔¢�夋嫨鍣�
_taskSelector = new StackerCraneTaskSelector(taskService, routerService, httpClientHelper, _logger);
// 鍒濆鍖栧懡浠ゆ瀯寤哄櫒
- _commandBuilder = new StackerCraneCommandBuilder(taskService, routerService, _config, _logger);
- }
-
- /// <summary>
- /// 鍔犺浇閰嶇疆鏂囦欢锛堜紭鍏堢骇锛氶厤缃枃浠� > 榛樿閰嶇疆锛�
- /// </summary>
- /// <remarks>
- /// 浠庡簲鐢ㄧ▼搴忕洰褰曚笅鐨� StackerCraneJob/stackercrane-command-config.json 璇诲彇閰嶇疆銆�
- /// 濡傛灉鏂囦欢涓嶅瓨鍦ㄦ垨瑙f瀽澶辫触锛屼娇鐢ㄩ粯璁ら厤缃��
- /// </remarks>
- /// <returns>鍫嗗灈鏈哄懡浠ら厤缃�</returns>
- private static StackerCraneCommandConfig LoadConfig()
- {
- try
- {
- // 鏋勯�犻厤缃枃浠惰矾寰�
- string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StackerCraneJob", "stackercrane-command-config.json");
- if (File.Exists(configPath))
- {
- // 璇诲彇骞惰В鏋� JSON 閰嶇疆
- string json = File.ReadAllText(configPath);
- return System.Text.Json.JsonSerializer.Deserialize<StackerCraneCommandConfig>(json) ?? new StackerCraneCommandConfig();
- }
- }
- catch (Exception ex)
- {
- // 閰嶇疆鍔犺浇澶辫触锛屼娇鐢ㄩ粯璁ら厤缃�
- Console.WriteLine($"閰嶇疆鍔犺浇澶辫触: {ex.Message}锛屼娇鐢ㄩ粯璁ら厤缃�");
- }
-
- return new StackerCraneCommandConfig();
+ _commandBuilder = new StackerCraneCommandBuilder(taskService, routerService, _logger);
}
/// <summary>
@@ -169,12 +139,13 @@
{
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)
{
// 鍙傛暟鏃犳晥锛岀洿鎺ヨ繑鍥�
- QuartzLogHelper.LogWarn(_logger, "Execute锛氬弬鏁版棤鏁�", "Execute锛氬弬鏁版棤鏁�", "CommonStackerCraneJob");
+ QuartzLogHelper.LogInfo(_logger, "Execute锛氬弬鏁版棤鏁�", "CommonStackerCraneJob");
return Task.CompletedTask;
}
@@ -193,7 +164,7 @@
// ========== 妫�鏌ユ槸鍚﹀彲浠ュ彂閫佹柊浠诲姟 ==========
//if (!commonStackerCrane.IsCanSendTask(commonStackerCrane.Communicator, commonStackerCrane.DeviceProDTOs, commonStackerCrane.DeviceProtocolDetailDTOs))
- if (commonStackerCrane.StackerCraneStatusValue != StackerCraneStatus.Normal )
+ if (commonStackerCrane.StackerCraneStatusValue != StackerCraneStatus.Normal)
{
// 鍫嗗灈鏈轰笉鍙敤锛堝姝e湪鎵ц涓婁竴浠诲姟锛夛紝鐩存帴杩斿洖
return Task.CompletedTask;
@@ -214,7 +185,6 @@
if (stackerCraneTaskCommand == null)
{
// 鍛戒护鏋勫缓澶辫触
- QuartzLogHelper.LogWarn(_logger, "Execute锛氬懡浠ゆ瀯寤哄け璐ワ紝璁惧: {DeviceCode}锛屼换鍔″彿: {TaskNum}", $"鍛戒护鏋勫缓澶辫触锛屼换鍔″彿: {task.TaskNum}", _deviceCode, _deviceCode, task.TaskNum);
return Task.CompletedTask;
}
@@ -222,23 +192,27 @@
bool sendFlag = SendStackerCraneCommand(commonStackerCrane, stackerCraneTaskCommand);
if (sendFlag)
{
- Task.Delay(1000).Wait();
+ Thread.Sleep(1000);
commonStackerCrane.SetValue(StackerCraneDBName.WorkAction, (short)StackerCraneWorkActionEnum.StartTask);
// 鍙戦�佹垚鍔燂紝鏇存柊鐘舵��
commonStackerCrane.LastTaskType = task.TaskType;
_taskService.UpdateTaskStatusToNext(task.TaskNum);
- QuartzLogHelper.LogInfo(_logger, "Execute锛氬懡浠ゅ彂閫佹垚鍔燂紝璁惧: {DeviceCode}锛屼换鍔″彿: {TaskNum}", $"鍛戒护鍙戦�佹垚鍔燂紝浠诲姟鍙�: {task.TaskNum}", _deviceCode, _deviceCode, task.TaskNum);
+ QuartzLogHelper.LogInfo(_logger, $"Execute锛氬懡浠ゅ彂閫佹垚鍔燂紝璁惧: {_deviceCode}锛屼换鍔″彿: {task.TaskNum}", _deviceCode);
}
else
{
- QuartzLogHelper.LogError(_logger, "Execute锛氬懡浠ゅ彂閫佸け璐ワ紝璁惧: {DeviceCode}锛屼换鍔″彿: {TaskNum}", $"鍛戒护鍙戦�佸け璐�", _deviceCode, _deviceCode, task.TaskNum);
+ QuartzLogHelper.LogInfo(_logger, $"Execute锛氬懡浠ゅ彂閫佸け璐ワ紝璁惧: {_deviceCode}锛屼换鍔″彿: {task.TaskNum}", _deviceCode);
}
}
catch (Exception ex)
{
// 璁板綍寮傚父
- QuartzLogHelper.LogError(_logger, ex, "Execute锛氭墽琛屽紓甯革紝璁惧: {DeviceCode}", $"鎵ц寮傚父: {ex.Message}", _deviceCode, _deviceCode);
+ QuartzLogHelper.LogError(_logger, ex, $"Execute锛氭墽琛屽紓甯革紝璁惧: {_deviceCode}", $"鎵ц寮傚父: {ex.Message}", _deviceCode, _deviceCode);
+ }
+ finally
+ {
+ QuartzLogHelper.LogInfo(_logger, $"CommonStackerCraneJob Execute锛氬爢鍨涙満浠诲姟璋冨害鎵ц瀹屾垚 銆恵DateTime.Now.ToString("F")}銆�", _deviceCode);
}
return Task.CompletedTask;
@@ -262,7 +236,7 @@
if (stackerCrane != null)
{
// 璁板綍鏃ュ織
- QuartzLogHelper.LogInfo(_logger, "CommonStackerCrane_StackerCraneTaskCompletedEventHandler锛氫换鍔″畬鎴愶紝浠诲姟鍙�: {TaskNum}", $"浠诲姟瀹屾垚锛屼换鍔″彿: {e.TaskNum}", stackerCrane.DeviceCode, e.TaskNum);
+ QuartzLogHelper.LogInfo(_logger, $"CommonStackerCrane_StackerCraneTaskCompletedEventHandler锛氫换鍔″畬鎴愶紝浠诲姟鍙�: {e.TaskNum}", stackerCrane.DeviceCode);
// 鏇存柊浠诲姟鐘舵�佷负瀹屾垚
if (_taskService.StackCraneTaskCompleted(e.TaskNum).Status)
--
Gitblit v1.9.3