From d9e59ed2e947aff29b7c21a9b0e8b6e12d741692 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期五, 30 八月 2024 14:54:18 +0800
Subject: [PATCH] 解决冲突

---
 Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs b/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
index 0c91047..ae15fb6 100644
--- a/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
+++ b/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
@@ -1,4 +1,6 @@
 锘�
+using Admin.NET.Core.Service;
+
 namespace WCS.Application;
 
 /// <summary>
@@ -8,9 +10,11 @@
 public class WcsPlcService : IDynamicApiController, ITransient
 {
     private readonly SqlSugarRepository<WcsPlc> _wcsPlcRep;
-    public WcsPlcService(SqlSugarRepository<WcsPlc> wcsPlcRep)
+    private readonly SysCacheService _sysCacheService;
+    public WcsPlcService(SqlSugarRepository<WcsPlc> wcsPlcRep, SysCacheService sysCacheService)
     {
         _wcsPlcRep = wcsPlcRep;
+        _sysCacheService = sysCacheService;
     }
 
     /// <summary>
@@ -105,6 +109,34 @@
         return await _wcsPlcRep.AsQueryable().Select<WcsPlcOutput>().ToListAsync();
     }
 
-
+    /// <summary>
+    /// 鑾峰彇PLC杩炴帴鐘舵�佸拰鏈嶅姟鐘舵��
+    /// </summary>
+    /// <param name="input"></param>
+    /// <returns></returns>
+    [HttpGet]
+    [ApiDescriptionSettings(Name = "ListStatus")]
+    [DisplayName("鑾峰彇PLC杩炴帴鐘舵��")]
+    public async Task<dynamic> ListStatus([FromQuery] PageWcsPlcInput input)
+    {
+        var listPlc = await _wcsPlcRep.AsQueryable()
+            .Where(s => s.Type == PLCTypeEnum.StackingMachine || s.Type == PLCTypeEnum.ConveyorLine || s.Type == PLCTypeEnum.BoxConveyorLine)
+            .ToListAsync();
+        foreach (var modPlc in listPlc)
+        {
+            if (_sysCacheService.ExistKey("PlcConn" + modPlc.Id))
+            {
+                var cachePlc = _sysCacheService.Get<WcsPlc>("PlcConn" + modPlc.Id);
+                modPlc.IsConn = cachePlc.IsConn;
+            }
+            else
+            {
+                modPlc.IsConn = false;
+            }
+        }
+        //鏈嶅姟鐘舵��
+        var modService = new { PLCTaskAction.boRunningState, PLCTaskAction.boOffline, PLCTaskAction.boRefresh };
+        return new { listPlc, modService };
+    }
 
 }

--
Gitblit v1.8.0