|
|
|
@ -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 << 版 本 注 释 >>
|
|
|
|
@ -70,7 +72,7 @@ namespace SlnMesnac.Business
|
|
|
|
|
_mesProductOrderService = serviceProvider.GetRequiredService<IMesProductOrderService>();
|
|
|
|
|
_baseMaterialInfoService = serviceProvider.GetRequiredService<IBaseMaterialInfoService>();
|
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void test()
|
|
|
|
@ -139,11 +141,21 @@ 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000 * 5);
|
|
|
|
|
continue;
|
|
|
|
|
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.小包出口读取RFID失败5次.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.小包出口读取RFID失败5次.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.小包出口读取RFID失败5次.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备用
|
|
|
|
|