From 54da8a22c438e1495b9c5fbae75ca9d4b5ca7335 Mon Sep 17 00:00:00 2001 From: wxw <Administrator@DESKTOP-5BIMHQ3> Date: 星期一, 02 九月 2024 16:04:37 +0800 Subject: [PATCH] Merge branch 'master' into wxw --- Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs index 9c32c01..6dd80ee 100644 --- a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs +++ b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs @@ -1,4 +1,6 @@ 锘� +using Admin.NET.Core.Service; + namespace WCS.Application; /// <summary> @@ -8,9 +10,11 @@ public class WcsDeviceService : IDynamicApiController, ITransient { private readonly SqlSugarRepository<WcsDevice> _wcsDeviceRep; - public WcsDeviceService(SqlSugarRepository<WcsDevice> wcsDeviceRep) + private readonly SysCacheService _sysCacheService; + public WcsDeviceService(SqlSugarRepository<WcsDevice> wcsDeviceRep, SysCacheService sysCacheService) { _wcsDeviceRep = wcsDeviceRep; + _sysCacheService = sysCacheService; } /// <summary> @@ -202,13 +206,18 @@ .Select<WcsDeviceOutput>((a, b) => new WcsDeviceOutput() { Type = b.Type }, true) .ToListAsync(); //鑾峰彇璺烘満鐨勭姸鎬� - var listConn = PLCTaskAction.listPlcConn; foreach (var modDevice in list) { - var modUtil = listConn.FirstOrDefault(s => s != null && s.PlcId == modDevice.PlcId); - modDevice.Status = modUtil == null ? false : modUtil.Connected; + if (_sysCacheService.ExistKey("PlcConn" + modDevice.PlcId)) + { + var cachePlc = _sysCacheService.Get<WcsPlc>("PlcConn" + modDevice.PlcId); + modDevice.Status = cachePlc.IsConn; + } + else + { + modDevice.Status = false; + } } - return list; } -- Gitblit v1.8.0