From 17e5dbd7bd0364e27a33f1a7dab91cf33d5dcabc Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 04 三月 2026 11:52:12 +0800
Subject: [PATCH] 增强Redis缓存服务与设备通信优化
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs
index b52c966..50b4e4e 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/QuartzNetExtension.cs
@@ -1,5 +1,7 @@
锘縰sing System.Reflection;
+using WIDESEAWCS_Common;
using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Caches;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Service;
@@ -15,19 +17,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 +44,7 @@
{
List<DispatchInfoDTO> dispatches = _dispatchInfoService.QueryDispatchInfos();
List<DeviceInfoDTO> deviceInfos = await _deviceInfoService.QueryDeviceProInfos();
+ _cacheService.RemoveByPrefix($"{RedisPrefix.System}");
deviceInfos.ForEach(x =>
{
@@ -107,6 +112,8 @@
x.Device = (IDevice)deviceInstance;
Storage.Devices.Add((IDevice)deviceInstance);
+
+ _cacheService.AddObject($"{RedisPrefix.System}:{RedisName.IDevice}:{x.DeviceName}", (IDevice)deviceInstance);
}
}
catch (Exception ex)
@@ -125,6 +132,7 @@
if (targetDevice is null) continue;
+
// 浣跨敤妯″紡鍖归厤
dispatches[i].JobParams = targetDevice switch
{
--
Gitblit v1.9.3