From 70b4bdc6f999c55b75138e013abf436100e9987b Mon Sep 17 00:00:00 2001
From: liudl <673013083@qq.com>
Date: 星期一, 23 六月 2025 15:33:16 +0800
Subject: [PATCH] 修改手自动

---
 Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs |   68 ++++++++++++++++++++++++++--------
 1 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs b/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
index 0b3cfec..7aa3764 100644
--- a/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
+++ b/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
@@ -1,11 +1,6 @@
-锘�// Admin.NET 椤圭洰鐨勭増鏉冦�佸晢鏍囥�佷笓鍒╁拰鍏朵粬鐩稿叧鏉冨埄鍧囧彈鐩稿簲娉曞緥娉曡鐨勪繚鎶ゃ�備娇鐢ㄦ湰椤圭洰搴旈伒瀹堢浉鍏虫硶寰嬫硶瑙勫拰璁稿彲璇佺殑瑕佹眰銆�
-//
-// 鏈」鐩富瑕侀伒寰� MIT 璁稿彲璇佸拰 Apache 璁稿彲璇侊紙鐗堟湰 2.0锛夎繘琛屽垎鍙戝拰浣跨敤銆傝鍙瘉浣嶄簬婧愪唬鐮佹爲鏍圭洰褰曚腑鐨� LICENSE-MIT 鍜� LICENSE-APACHE 鏂囦欢銆�
-//
-// 涓嶅緱鍒╃敤鏈」鐩粠浜嬪嵄瀹冲浗瀹跺畨鍏ㄣ�佹壈涔辩ぞ浼氱З搴忋�佷镜鐘粬浜哄悎娉曟潈鐩婄瓑娉曞緥娉曡绂佹鐨勬椿鍔紒浠讳綍鍩轰簬鏈」鐩簩娆″紑鍙戣�屼骇鐢熺殑涓�鍒囨硶寰嬬籂绾峰拰璐d换锛屾垜浠笉鎵挎媴浠讳綍璐d换锛�
-
+锘�
 using Admin.NET.Core.Service;
-using Microsoft.AspNetCore.Http;
+
 namespace WCS.Application;
 
 /// <summary>
@@ -15,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>
@@ -30,15 +27,17 @@
     [DisplayName("鍒嗛〉鏌ヨPLC")]
     public async Task<SqlSugarPagedList<WcsPlcOutput>> Page(PageWcsPlcInput input)
     {
-		input.SearchKey = input.SearchKey?.Trim();
+        input.SearchKey = input.SearchKey?.Trim();
         var query = _wcsPlcRep.AsQueryable()
             .WhereIF(!string.IsNullOrEmpty(input.SearchKey), u =>
-                u.IP.Contains(input.SearchKey)
+                u.IP.Contains(input.SearchKey) && u.Text.Contains(input.SearchKey)
             )
+            .WhereIF(input.PLCType.HasValue, u => u.PLCType == input.PLCType)
             .WhereIF(!string.IsNullOrWhiteSpace(input.IP), u => u.IP.Contains(input.IP.Trim()))
             .WhereIF(input.Type.HasValue, u => u.Type == input.Type)
+            .WhereIF(input.Enable.HasValue, u => u.Enable == input.Enable)
             .Select<WcsPlcOutput>();
-		return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
+        return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
     }
 
     /// <summary>
@@ -108,11 +107,48 @@
     [DisplayName("鑾峰彇PLC鍒楄〃")]
     public async Task<List<WcsPlcOutput>> List([FromQuery] PageWcsPlcInput input)
     {
-        return await _wcsPlcRep.AsQueryable().Select<WcsPlcOutput>().ToListAsync();
+        return await _wcsPlcRep.AsQueryable().WhereIF(input.Type != null, s => s.Type == input.Type).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, PLCTaskAction.boDemo, PLCTaskAction.boDrumReversal, PLCTaskAction.boOutLock, PLCTaskAction.boEnterLock };
+        return new { listPlc, modService };
+    }
+    /// <summary>
+    /// 鑾峰彇浣嶇疆淇℃伅
+    /// </summary>
+    /// <returns></returns>
+    [HttpGet]
+    [ApiDescriptionSettings(Name = "ListPosition")]
+    [DisplayName("鑾峰彇浣嶇疆淇℃伅")]
+    public List<PlcPositionInfo> ListPosition()
+    {
+        var list = PLCTaskAction.listPositionInfo.ToList();
+        return list;
+    }
 }

--
Gitblit v1.8.0