From dcbd4934d063f471c01cbcf93574c2e2ac5f16b5 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 27 三月 2026 09:37:36 +0800
Subject: [PATCH] feat: 提交WCS与WMS代码调整
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs
index 9991cd6..3225212 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs
@@ -1,6 +1,9 @@
锘縰sing System.Reflection;
+using WIDESEAWCS_Common;
using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Caches;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core.LogHelper;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Service;
@@ -15,19 +18,21 @@
private readonly IDeviceInfoService _deviceInfoService;
private readonly IDispatchInfoService _dispatchInfoService;
private readonly IDeviceProtocolDetailService _deviceProtocolDetailService;
+ private readonly ICacheService _cacheService;
private readonly Storage _storage;
/// <summary>
/// 鍚姩绋嬪簭鑷姩寮�鍚皟搴︽湇鍔�
/// </summary>
/// <returns></returns>
- public QuartzNetExtension(IDeviceInfoService deviceInfoService, IDispatchInfoService dispatchInfoService, ISchedulerCenter schedulerCenter, IDeviceProtocolDetailService deviceProtocolDetailService, Storage storage)
+ public QuartzNetExtension(IDeviceInfoService deviceInfoService, IDispatchInfoService dispatchInfoService, ISchedulerCenter schedulerCenter, IDeviceProtocolDetailService deviceProtocolDetailService, Storage storage, ICacheService cacheService)
{
_deviceInfoService = deviceInfoService;
_dispatchInfoService = dispatchInfoService;
_schedulerCenter = schedulerCenter;
_deviceProtocolDetailService = deviceProtocolDetailService;
_storage = storage;
+ _cacheService = cacheService;
}
/// <summary>
@@ -40,6 +45,7 @@
{
List<DispatchInfoDTO> dispatches = _dispatchInfoService.QueryDispatchInfos();
List<DeviceInfoDTO> deviceInfos = await _deviceInfoService.QueryDeviceProInfos();
+ _cacheService.RemoveByPrefix($"{RedisPrefix.System}");
deviceInfos.ForEach(x =>
{
@@ -47,7 +53,7 @@
{
try
{
- if (!x.DeviceName.Contains("鏈烘鎵�"))
+ if (!x.DevicePlcType.Contains("Socket"))
{
#region 杩炴帴PLC
@@ -93,7 +99,7 @@
}).ToList();
// 鏍规嵁璁惧绫诲瀷鑾峰彇璁惧鍗忚璇︽儏
- List<DeviceProtocolDetailDTO> deviceProtocolDetails = _deviceProtocolDetailService.GetDeviceProtocolDetailsByDeviceType(x.DeviceType);
+ List<DeviceProtocolDetailDTO> deviceProtocolDetails = _deviceProtocolDetailService.GetDeviceProtocolDetailsByDeviceId(x.Id);
// 鍔犺浇璁惧绋嬪簭闆�
Assembly assemblyDevice = Assembly.Load($"WIDESEAWCS_QuartzJob");
@@ -107,11 +113,13 @@
x.Device = (IDevice)deviceInstance;
Storage.Devices.Add((IDevice)deviceInstance);
+
+ _cacheService.AddObject($"{RedisPrefix.System}:{RedisName.IDevice}:{x.DeviceName}", (IDevice)deviceInstance);
}
}
catch (Exception ex)
{
- Console.WriteLine("璋冨害鏈嶅姟寮�鍚紓甯�" + ex.ToString());
+ QuartzLogger.Error($"璋冨害鏈嶅姟寮�鍚紓甯�", "QuartzNetExtension", ex);
}
}
else
@@ -121,25 +129,35 @@
});
for (int i = 0; i < dispatches.Count; i++)
{
- var targetDevice = deviceInfos.FirstOrDefault(x => x.Id == dispatches[i].Id);
+ var targetDevice = deviceInfos.FirstOrDefault(x => x.DispatchId == dispatches[i].Id);
if (targetDevice is null) continue;
+
// 浣跨敤妯″紡鍖归厤
dispatches[i].JobParams = targetDevice switch
{
- { DeviceName: var name } when name.Contains("鏈烘鎵�")
+ { DevicePlcType: var type } when type.Contains("Socket")
=> new RobotCraneDevice { DeviceCode = targetDevice.DeviceCode, DeviceName = targetDevice.DeviceName, IPAddress = targetDevice.DeviceIp + ":" + targetDevice.DevicePort },
_ => targetDevice.Device
};
WebResponseContent responseContent = await _schedulerCenter.AddScheduleJobAsync(dispatches[i]);
- if (responseContent.Status) ConsoleHelper.WriteSuccessLine(dispatches[i].Name + "璋冨害鏈嶅姟娣诲姞鎴愬姛"); else ConsoleHelper.WriteErrorLine(dispatches[i].Name + "璋冨害鏈嶅姟娣诲姞澶辫触");
+ if (responseContent.Status)
+ {
+ QuartzLogger.Info($"{dispatches[i].Name}璋冨害鏈嶅姟娣诲姞鎴愬姛", "QuartzNetExtension");
+ ConsoleHelper.WriteSuccessLine(dispatches[i].Name + "璋冨害鏈嶅姟娣诲姞鎴愬姛");
+ }
+ else
+ {
+ QuartzLogger.Error($"{dispatches[i].Name}璋冨害鏈嶅姟娣诲姞澶辫触", "QuartzNetExtension");
+ ConsoleHelper.WriteErrorLine(dispatches[i].Name + "璋冨害鏈嶅姟娣诲姞澶辫触");
+ }
}
//await _schedulerCenter.StartScheduleAsync();
}
catch (Exception ex)
{
- Console.WriteLine("璋冨害鏈嶅姟寮�鍚紓甯�" + ex.ToString());
+ QuartzLogger.Error($"璋冨害鏈嶅姟寮�鍚紓甯�", "QuartzNetExtension", ex);
throw;
}
}
--
Gitblit v1.9.3