From 2b8a51779ff7107c9423e21935c169d6bb877d64 Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期三, 11 九月 2024 14:47:15 +0800
Subject: [PATCH] Merge branch 'master' of http://47.95.120.53:8083/r/WCSNet6
---
Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs | 44 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs b/Admin.NET/WCS.Application/Service/WcsAlarmInfo/WcsAlarmInfoService.cs
index 09b5112..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>
@@ -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,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