From b1404f7bc9945d91e292791a868cbb306cf7935d Mon Sep 17 00:00:00 2001
From: liudl <673013083@qq.com>
Date: 星期一, 20 一月 2025 09:58:28 +0800
Subject: [PATCH] 11111111111

---
 Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs b/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs
index 5860a85..72a6f4e 100644
--- a/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs
+++ b/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs
@@ -1,4 +1,5 @@
-锘縰sing Microsoft.AspNetCore.SignalR;
+锘縰sing Admin.NET.Core.Service;
+using Microsoft.AspNetCore.SignalR;
 
 namespace WCS.Application;
 
@@ -10,11 +11,12 @@
 {
     private readonly SqlSugarRepository<WcsAlarmInfo> _wcsAlarmInfoRep;
     private readonly IHubContext<PlcHub, IPlcHub> _plcHubContext;
-
-    public WcsAlarmInfoService(SqlSugarRepository<WcsAlarmInfo> wcsAlarmInfoRep, IHubContext<PlcHub, IPlcHub> plcHubContext)
+    private readonly SysDictDataService _dictDataService;
+    public WcsAlarmInfoService(SqlSugarRepository<WcsAlarmInfo> wcsAlarmInfoRep, IHubContext<PlcHub, IPlcHub> plcHubContext, SysDictDataService dictDataService)
     {
         _wcsAlarmInfoRep = wcsAlarmInfoRep;
         _plcHubContext = plcHubContext;
+        _dictDataService = dictDataService;
     }
 
     /// <summary>
@@ -30,7 +32,7 @@
         input.SearchKey = input.SearchKey?.Trim();
         var query = _wcsAlarmInfoRep.AsQueryable()
             .WhereIF(!string.IsNullOrEmpty(input.SearchKey), u =>
-                u.PlcIP.Contains(input.SearchKey)
+                u.StationNum.Contains(input.SearchKey)
             )
             .WhereIF(!string.IsNullOrWhiteSpace(input.PlcIP), u => u.PlcIP.Contains(input.PlcIP.Trim()))
             .WhereIF(input.Status.HasValue, u => u.Status == input.Status)
@@ -51,6 +53,7 @@
     public async Task<long> Add(AddWcsAlarmInfoInput input)
     {
         var entity = input.Adapt<WcsAlarmInfo>();
+        entity.Status = YesNoEnum.N;
         await _wcsAlarmInfoRep.InsertAsync(entity);
         return entity.Id;
     }
@@ -108,7 +111,7 @@
     public async Task<List<WcsAlarmInfoOutput>> List([FromQuery] PageWcsAlarmInfoInput input)
     {
         return await _wcsAlarmInfoRep.AsQueryable()
-            //.WhereIF(!input.Status.IsNullOrEmpty(), s => s.Status == input.Status)
+            .WhereIF(!input.Status.IsNullOrEmpty(), s => s.Status == input.Status)
             .Select<WcsAlarmInfoOutput>().ToListAsync();
     }
 
@@ -121,11 +124,38 @@
     [HttpPost]
     [ApiDescriptionSettings(Name = "Reset")]
     [DisplayName("澶嶄綅鎶ヨ")]
-    public async Task Reset()
+    public async Task Reset(ResetInput input)
     {
         //娴嬭瘯鎺ㄦ暟鎹敤鐨�
-        await _plcHubContext.Clients.All.PublicAlarm(new WcsAlarmInfoOutput() { Id = new Random().Next(), StationNum = "205", AlarmCode = "MB102", AlarmName = "鏈夌墿鍝侀伄鎸�", AlarmTime = DateTime.Now });
-        //throw Oops.Bah("寮�鍙戜腑");
+        //await _plcHubContext.Clients.All.PublicAlarm(new List<WcsAlarmInfo>() { new WcsAlarmInfo() { Id = 100, StationNum = "260", AlarmCode = "MB102", AlarmName = "鏈夌墿鍝侀伄鎸�", AlarmTime = DateTime.Now, Status = YesNoEnum.Y } });
+        //await _plcHubContext.Clients.All.PublicAlarm(new WcsAlarmInfo() { Id = 100, StationNum = "260", AlarmCode = "MB102", AlarmName = "鏈夌墿鍝侀伄鎸�", AlarmTime = DateTime.Now, Status = YesNoEnum.Y });
+        var modPlc = await _wcsAlarmInfoRep.Context.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (input.layer.ToString() + "灞傛墭鐩樿緭閫佺嚎")).FirstAsync();
+        if (modPlc == null)
+            throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+        var listDict = await _dictDataService.GetDataList("reset_alarm");
+        var value = listDict.FirstOrDefault(s => s.Code == input.layer.ToString());
+        if (value == null)
+            throw Oops.Bah("鏈壘鍒板浣嶅湴鍧�锛岃鍦ㄥ瓧鍏哥鐞嗕腑璁剧疆");
+        PLCUtil modUtil = new PLCUtil(modPlc);
+        //switch (input.layer)
+        //{
+        //    case 1:
+        //        modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, value.Value, "1");
+        //        break;
+        //    case 2:
+        //        {
+        //            modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, value.Value, "1");
+        //        }
+        //        break;
+        //    case 3:
+        //        modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, value.Value, "1");
+        //        break;
+        //    default:
+        //        break;
+        //}
+
+        modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, value.Value, "1");
+        modUtil.Close();
 
     }
 

--
Gitblit v1.8.0