add-添加运行时分级报警

dev
liuwf 3 months ago
parent 6c755133d9
commit 5ec195317f

@ -5,6 +5,7 @@ using SlnMesnac.Common;
using SlnMesnac.Config;
using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using SlnMesnac.Model.enums;
using SlnMesnac.Plc;
using SlnMesnac.Repository.service;
using SlnMesnac.Rfid;
@ -17,6 +18,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using TouchSocket.Core;
using static System.Net.Mime.MediaTypeNames;
#region << 版 本 注 释 >>
@ -139,12 +141,22 @@ namespace SlnMesnac.Business
readRfidAmount++;
if(readRfidAmount == 5)
{
//TODO 推送报警
string virtualEpc = NoReadRFIDAlarm();
_logger.LogError("小包出口到位信号触发,读取RFID失败超过5次......");
if (!string.IsNullOrEmpty(virtualEpc))
{
epcStr = virtualEpc;
_logger.LogError("小包出口到位信号触发,读取RFID失败超过5次,生成虚拟托盘号:"+virtualEpc);
}
}
else
{
Thread.Sleep(1000 * 5);
continue;
}
}
}
RefreshMessage($"小包出口读取到RFID条码{epcStr},开始绑定流程:");
@ -179,13 +191,88 @@ namespace SlnMesnac.Business
catch (Exception ex)
{
sqlSugarClient.AsTenant().RollbackTran();
// TODO:推送报警
_logger.LogError($"DeviceOutPutHandle异常:{ex.Message}");
}
Thread.Sleep(1000 * 5);
}
}
/// <summary>
/// 推送报警,并生成虚拟托盘号暂时使用,虚拟托盘号储存到报警信息,人工处理可以将虚拟托盘号替换为正常托盘号
/// <return> 返回生产的虚拟托盘号
/// </summary>
private string NoReadRFIDAlarm()
{
string epcStr;
try
{
epcStr = "TEMP" + DateTime.Now.ToString("MMddHHmm");
sqlSugarClient.AsTenant().BeginTran();
// 有报警,找出该设备的报警记录,如果没有报警记录或者报警记录已结束,则新增报警记录
int warnRuleId = int.Parse(WarnStatusEnum.RFID5.GetDescription());
DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmTime>().First(x => x.AlarmRuleId == warnRuleId);
if (dmsRecordAlarmTime == null)
{
DmsBaseAlarmRule dmsBaseAlarmRule = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsBaseAlarmRule>().First(x => x.AlarmRuleId == warnRuleId);
dmsRecordAlarmTime = new DmsRecordAlarmTime();
dmsRecordAlarmTime.DeviceId = dmsBaseAlarmRule.DeviceId;
dmsRecordAlarmTime.AlarmRuleId = warnRuleId;
dmsRecordAlarmTime.AlarmBeginTime = DateTime.Now;
dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime;
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
dmsRecordAlarmTime.AlarmData = WarnStatusEnum.RFID5.ToString();
dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest+";;虚拟托盘号为:"+epcStr;
dmsRecordAlarmTime.CreateBy = "SlnMesnac";
dmsRecordAlarmTime.CreateTime = DateTime.Now;
DmsRecordAlarmInfo dmsRecordAlarmInfo = new DmsRecordAlarmInfo();
dmsRecordAlarmInfo.DeviceId = dmsBaseAlarmRule.DeviceId;
dmsRecordAlarmInfo.AlarmRuleId = warnRuleId;
dmsRecordAlarmInfo.AlarmBeginTime = DateTime.Now;
dmsRecordAlarmInfo.AlarmStatus = "0";
dmsRecordAlarmInfo.NoticeStatus = "0";
dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime;
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.RFID5.ToString();
dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest + ";;虚拟托盘号为:" + epcStr;
dmsRecordAlarmInfo.CreateBy = "SlnMesnac";
dmsRecordAlarmInfo.CreateTime = DateTime.Now;
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmTime).ExecuteCommand();
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand();
}
else
{
dmsRecordAlarmTime.UpdateTime = DateTime.Now;
dmsRecordAlarmTime.UpdateBy = "SlnMesnac";
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x=>x.AlarmRuleId==warnRuleId);
if (dmsRecordAlarmInfo != null)
{
dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
dmsRecordAlarmInfo.UpdateBy = "SlnMesnac";
}
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
}
sqlSugarClient.AsTenant().CommitTran();
return epcStr;
}catch(Exception ex)
{
sqlSugarClient.AsTenant().RollbackTran();
_logger.LogError($"NoReadRFIDAlarm异常:{ex.Message}");
return "";
}
}
/// <summary>
/// 生成大条码插入mes_barcode_info
@ -246,6 +333,7 @@ namespace SlnMesnac.Business
if (list.Where(x => x.PrintFlag == "1").ToList().Count < 40)
{
// TODO推送低级别报警
PrintLessThan40Alarm();
}
foreach (var item in list)
{
@ -307,7 +395,79 @@ namespace SlnMesnac.Business
}
/// <summary>
/// 小包产出绑定托盘小包喷码数量小于40低级别报警
/// <return> 返回生产的虚拟托盘号
/// </summary>
private void PrintLessThan40Alarm()
{
try
{
sqlSugarClient.AsTenant().BeginTran();
// 有报警,找出该设备的报警记录,如果没有报警记录或者报警记录已结束,则新增报警记录
int warnRuleId = int.Parse(WarnStatusEnum.40.GetDescription());
DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmTime>().First(x => x.AlarmRuleId == warnRuleId);
if (dmsRecordAlarmTime == null)
{
DmsBaseAlarmRule dmsBaseAlarmRule = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsBaseAlarmRule>().First(x => x.AlarmRuleId == warnRuleId);
dmsRecordAlarmTime = new DmsRecordAlarmTime();
dmsRecordAlarmTime.DeviceId = dmsBaseAlarmRule.DeviceId;
dmsRecordAlarmTime.AlarmRuleId = warnRuleId;
dmsRecordAlarmTime.AlarmBeginTime = DateTime.Now;
dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime;
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
dmsRecordAlarmTime.AlarmData = WarnStatusEnum.40.ToString();
dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest;
dmsRecordAlarmTime.CreateBy = "SlnMesnac";
dmsRecordAlarmTime.CreateTime = DateTime.Now;
DmsRecordAlarmInfo dmsRecordAlarmInfo = new DmsRecordAlarmInfo();
dmsRecordAlarmInfo.DeviceId = dmsBaseAlarmRule.DeviceId;
dmsRecordAlarmInfo.AlarmRuleId = warnRuleId;
dmsRecordAlarmInfo.AlarmBeginTime = DateTime.Now;
dmsRecordAlarmInfo.AlarmStatus = "0";
dmsRecordAlarmInfo.NoticeStatus = "0";
dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime;
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.40.ToString();
dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest;
dmsRecordAlarmInfo.CreateBy = "SlnMesnac";
dmsRecordAlarmInfo.CreateTime = DateTime.Now;
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmTime).ExecuteCommand();
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand();
}
else
{
dmsRecordAlarmTime.UpdateTime = DateTime.Now;
dmsRecordAlarmTime.UpdateBy = "SlnMesnac";
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x => x.AlarmRuleId == warnRuleId);
if (dmsRecordAlarmInfo != null)
{
dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
dmsRecordAlarmInfo.UpdateBy = "SlnMesnac";
}
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
}
sqlSugarClient.AsTenant().CommitTran();
}
catch (Exception ex)
{
sqlSugarClient.AsTenant().RollbackTran();
_logger.LogError($"PrintLessThan40Alarm异常:{ex.Message}");
}
}
/// <summary>
/// 空托盘进入码垛位,读取RFID备用

@ -205,7 +205,7 @@ namespace SlnMesnac.Business.@base
var rfidEquip = GetRfidByKey(rfidKey);
if(rfidEquip == null)
{
//TODO 推送设备报警
return null;
}
List<TagInfo> tagInfoList =await rfidEquip.GetRFIDAsync();

@ -57,7 +57,15 @@ namespace SlnMesnac.Model.enums
2,
[Description("2010")]
,
[Description("2011")]
,
[Description("2012")]
RFID5,
[Description("2013")]
40
}
}

@ -68,7 +68,7 @@ namespace SlnMesnac.Repository.service.Impl
}
/// <summary>
/// 查询前四十条已经喷印未绑定条码
/// 查询前四十条未绑定条码
/// </summary>
/// <param name="task"></param>
/// <param name="barCodeTasks"></param>

@ -295,6 +295,21 @@ namespace SlnMesnac.WPF.Page
sqlClient.AsTenant().CommitTran();
WarningList = dmsRecordAlarmTimeService.GetMachineWarnList();
}
else
{
sqlClient.AsTenant().BeginTran();
dmsRecordAlarmTime.UpdateTime = DateTime.Now;
dmsRecordAlarmTime.UpdateBy = "SlnMesnac";
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x=>x.AlarmRuleId==warnRuleId);
if (dmsRecordAlarmInfo != null)
{
dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
dmsRecordAlarmInfo.UpdateBy = "SlnMesnac";
}
sqlClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
sqlClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
sqlClient.AsTenant().CommitTran();
}
}
@ -340,7 +355,10 @@ namespace SlnMesnac.WPF.Page
switch (result)
{
case -1:
// TODO,当前重量未找到对应配方添加报警记录推送
// 当前重量未找到对应配方添加报警记录推送,人工处理
MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.warnStatus = WarnStatusEnum.;
MachineWarnCollection(machineStatusDto);
break;
case 0: break;
@ -372,6 +390,8 @@ namespace SlnMesnac.WPF.Page
});
}
/// <summary>
/// 判断缓存区重量是否满足配方要求
/// </summary>

Loading…
Cancel
Save