From 5ec195317f7d8b4d9528c50d1afafa3319c7922e Mon Sep 17 00:00:00 2001 From: liuwf Date: Mon, 26 Aug 2024 14:32:01 +0800 Subject: [PATCH] =?UTF-8?q?add-=E6=B7=BB=E5=8A=A0=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E5=88=86=E7=BA=A7=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/ProdCompletionBusiness.cs | 170 +++++++++++++++++- SlnMesnac.Business/base/BaseBusiness.cs | 2 +- SlnMesnac.Model/enums/WarnStatusEnum.cs | 10 +- .../service/Impl/MesPrdBarCodeServiceImpl.cs | 2 +- SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs | 22 ++- 5 files changed, 197 insertions(+), 9 deletions(-) diff --git a/SlnMesnac.Business/ProdCompletionBusiness.cs b/SlnMesnac.Business/ProdCompletionBusiness.cs index 88ce463..a96e96a 100644 --- a/SlnMesnac.Business/ProdCompletionBusiness.cs +++ b/SlnMesnac.Business/ProdCompletionBusiness.cs @@ -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(); _baseMaterialInfoService = serviceProvider.GetRequiredService(); 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); } } + /// + /// 推送报警,并生成虚拟托盘号暂时使用,虚拟托盘号储存到报警信息,人工处理可以将虚拟托盘号替换为正常托盘号 + /// 返回生产的虚拟托盘号 + /// + 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().First(x => x.AlarmRuleId == warnRuleId); + if (dmsRecordAlarmTime == null) + { + DmsBaseAlarmRule dmsBaseAlarmRule = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().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().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 ""; + } + + } + /// /// 生成大条码插入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 } + /// + /// 小包产出绑定托盘,小包喷码数量小于40低级别报警 + /// 返回生产的虚拟托盘号 + /// + private void PrintLessThan40Alarm() + { + try + { + sqlSugarClient.AsTenant().BeginTran(); + // 有报警,找出该设备的报警记录,如果没有报警记录或者报警记录已结束,则新增报警记录 + int warnRuleId = int.Parse(WarnStatusEnum.托盘绑定时已喷码数不足40.GetDescription()); + DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().First(x => x.AlarmRuleId == warnRuleId); + if (dmsRecordAlarmTime == null) + { + DmsBaseAlarmRule dmsBaseAlarmRule = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().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().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}"); + + } + + } /// /// 空托盘进入码垛位,读取RFID备用 diff --git a/SlnMesnac.Business/base/BaseBusiness.cs b/SlnMesnac.Business/base/BaseBusiness.cs index 0ed0d35..4fcc245 100644 --- a/SlnMesnac.Business/base/BaseBusiness.cs +++ b/SlnMesnac.Business/base/BaseBusiness.cs @@ -205,7 +205,7 @@ namespace SlnMesnac.Business.@base var rfidEquip = GetRfidByKey(rfidKey); if(rfidEquip == null) { - //TODO 推送设备报警 + return null; } List tagInfoList =await rfidEquip.GetRFIDAsync(); diff --git a/SlnMesnac.Model/enums/WarnStatusEnum.cs b/SlnMesnac.Model/enums/WarnStatusEnum.cs index 351dfbb..a51c2eb 100644 --- a/SlnMesnac.Model/enums/WarnStatusEnum.cs +++ b/SlnMesnac.Model/enums/WarnStatusEnum.cs @@ -57,7 +57,15 @@ namespace SlnMesnac.Model.enums 螺旋机螺旋2变频器报警, [Description("2010")] - 磁选机设备故障报警 + 磁选机设备故障报警, + [Description("2011")] + 拆包机缓存区重量无对应配方, + + [Description("2012")] + 小包出口读取RFID失败5次, + + [Description("2013")] + 托盘绑定时已喷码数不足40 } } diff --git a/SlnMesnac.Repository/service/Impl/MesPrdBarCodeServiceImpl.cs b/SlnMesnac.Repository/service/Impl/MesPrdBarCodeServiceImpl.cs index c960160..f71a9c4 100644 --- a/SlnMesnac.Repository/service/Impl/MesPrdBarCodeServiceImpl.cs +++ b/SlnMesnac.Repository/service/Impl/MesPrdBarCodeServiceImpl.cs @@ -68,7 +68,7 @@ namespace SlnMesnac.Repository.service.Impl } /// - /// 查询前四十条已经喷印未绑定条码 + /// 查询前四十条未绑定条码 /// /// /// diff --git a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs index d06be70..f8c8c86 100644 --- a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs +++ b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs @@ -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().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 }); } + + /// /// 判断缓存区重量是否满足配方要求 ///