From d89bbfdd748109020f3255c80918d0f60b6e842c Mon Sep 17 00:00:00 2001 From: wxw <Administrator@DESKTOP-5BIMHQ3> Date: 星期五, 06 九月 2024 16:56:01 +0800 Subject: [PATCH] Merge branch 'master' into wxw --- Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs | 41 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs b/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs index a5eda3e..27f6373 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> @@ -117,9 +124,35 @@ [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: + break; + case 2: + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, value.Value, "1"); + } + break; + case 3: + break; + default: + break; + } + modUtil.Close(); + } -- Gitblit v1.8.0