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 | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs b/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs index 09b5112..72a6f4e 100644 --- a/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs +++ b/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs @@ -1,4 +1,7 @@ -锘縩amespace WCS.Application; +锘縰sing Admin.NET.Core.Service; +using Microsoft.AspNetCore.SignalR; + +namespace WCS.Application; /// <summary> /// 鎶ヨ淇℃伅琛ㄦ湇鍔� @@ -7,9 +10,13 @@ public class WcsAlarmInfoService : IDynamicApiController, ITransient { private readonly SqlSugarRepository<WcsAlarmInfo> _wcsAlarmInfoRep; - public WcsAlarmInfoService(SqlSugarRepository<WcsAlarmInfo> wcsAlarmInfoRep) + private readonly 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> @@ -25,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) @@ -46,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; } @@ -103,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(); } @@ -116,9 +124,39 @@ [HttpPost] [ApiDescriptionSettings(Name = "Reset")] [DisplayName("澶嶄綅鎶ヨ")] - public async Task Reset() + public async Task Reset(ResetInput input) { - 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