From 3609a43ca4d7842a839524dee1baaf4f84bc4801 Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期一, 02 九月 2024 14:41:02 +0800
Subject: [PATCH] 绑定首页服务状态
---
Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs | 49 +++++++++++++++++++++++++++++++++++--------------
1 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
index b52d4b1..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>
@@ -41,6 +45,7 @@
{
Id = u.Id,
PlcId = u.PlcId,
+ DeviceType = (DeviceTypeEnum)u.DeviceType,
PlcIdIP = plcid.IP,
Level = (DeviceLevelEnum)u.Level,
DbNumber = u.DbNumber,
@@ -121,19 +126,6 @@
}
/// <summary>
- /// 鑾峰彇璁惧淇℃伅鍒楄〃
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpGet]
- [ApiDescriptionSettings(Name = "List")]
- [DisplayName("鑾峰彇璁惧淇℃伅鍒楄〃")]
- public async Task<List<WcsDeviceOutput>> List([FromQuery] PageWcsDeviceInput input)
- {
- return await _wcsDeviceRep.AsQueryable().Select<WcsDeviceOutput>().ToListAsync();
- }
-
- /// <summary>
/// 鑾峰彇PlcId鍒楄〃
/// </summary>
/// <returns></returns>
@@ -199,5 +191,34 @@
await _wcsDeviceRep.Context.Insertable(listPosition).ExecuteCommandAsync();
}
+ /// <summary>
+ /// 鑾峰彇璁惧淇℃伅鍒楄〃
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ [HttpGet]
+ [ApiDescriptionSettings(Name = "List")]
+ [DisplayName("鑾峰彇璁惧淇℃伅鍒楄〃")]
+ public async Task<List<WcsDeviceOutput>> List([FromQuery] PageWcsDeviceInput input)
+ {
+ var list = await _wcsDeviceRep.AsQueryable()
+ .LeftJoin<WcsPlc>((a, b) => a.PlcId == b.Id)
+ .Select<WcsDeviceOutput>((a, b) => new WcsDeviceOutput() { Type = b.Type }, true)
+ .ToListAsync();
+ //鑾峰彇璺烘満鐨勭姸鎬�
+ foreach (var modDevice in list)
+ {
+ 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