From 64a04dce5ffc427484b0af82db18c69371c068d6 Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 28 Aug 2024 16:39:57 +0800 Subject: [PATCH] =?UTF-8?q?change-=E5=AE=8C=E5=96=842=E6=A5=BC=E5=B0=8F?= =?UTF-8?q?=E5=8C=85=E4=BA=A7=E5=87=BA=E5=8F=AB=E6=96=99=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/ProdCompletionBusiness.cs | 290 +++++++++--------- SlnMesnac.Business/ProdMgmtBusiness.cs | 16 +- SlnMesnac.Model/domain/DmsRealtimeStatus.cs | 57 ++++ .../domain/DmsRealtimeStatusHistory.cs | 69 +++++ SlnMesnac.Model/dto/DmsRealTimeDto.cs | 34 ++ .../service/Impl/MesProductPlanServiceImpl.cs | 4 +- SlnMesnac.WPF/Dto/MachineStatusDto.cs | 4 +- SlnMesnac.WPF/Page/DevMonitorPage.xaml | 11 +- SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs | 48 ++- .../Page/Window/InputDialogWindow.xaml | 26 ++ .../Page/Window/InputDialogWindow.xaml.cs | 38 +++ SlnMesnac.WPF/SlnMesnac.WPF.csproj | 3 + SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs | 2 +- SlnMesnac.WPF/appsettings.json | 10 +- 14 files changed, 441 insertions(+), 171 deletions(-) create mode 100644 SlnMesnac.Model/domain/DmsRealtimeStatus.cs create mode 100644 SlnMesnac.Model/domain/DmsRealtimeStatusHistory.cs create mode 100644 SlnMesnac.Model/dto/DmsRealTimeDto.cs create mode 100644 SlnMesnac.WPF/Page/Window/InputDialogWindow.xaml create mode 100644 SlnMesnac.WPF/Page/Window/InputDialogWindow.xaml.cs diff --git a/SlnMesnac.Business/ProdCompletionBusiness.cs b/SlnMesnac.Business/ProdCompletionBusiness.cs index a96e96a..42daeb9 100644 --- a/SlnMesnac.Business/ProdCompletionBusiness.cs +++ b/SlnMesnac.Business/ProdCompletionBusiness.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using SlnMesnac.Business.@base; using SlnMesnac.Common; @@ -21,32 +21,32 @@ using System.Threading.Tasks; using TouchSocket.Core; using static System.Net.Mime.MediaTypeNames; -#region << 版 本 注 释 >> +#region << ע >> /*-------------------------------------------------------------------- -* 版权所有 (c) 2024 WenJY 保留所有权利。 -* CLR版本:4.0.30319.42000 -* 机器名称:LAPTOP-E0N2L34V -* 命名空间:SlnMesnac.Business -* 唯一标识:f79d6d97-d9b0-4b0b-a442-e6bb1c1c79e6 +* Ȩ (c) 2024 WenJY Ȩ +* CLR汾4.0.30319.42000 +* ƣLAPTOP-E0N2L34V +* ռ䣺SlnMesnac.Business +* Ψһʶf79d6d97-d9b0-4b0b-a442-e6bb1c1c79e6 * -* 创建者:WenJY -* 电子邮箱:wenjy@mesnac.com -* 创建时间:2024-04-10 16:36:01 -* 版本:V1.0.0 -* 描述: +* ߣWenJY +* 䣺wenjy@mesnac.com +* ʱ䣺2024-04-10 16:36:01 +* 汾V1.0.0 +* * *-------------------------------------------------------------------- -* 修改人: -* 时间: -* 修改说明: +* ޸ˣ +* ʱ䣺 +* ޸˵ * -* 版本:V1.0.0 +* 汾V1.0.0 *--------------------------------------------------------------------*/ -#endregion << 版 本 注 释 >> +#endregion << ע >> namespace SlnMesnac.Business { /// - /// 设备产出业务逻辑 + /// 豸ҵ߼ /// public class ProdCompletionBusiness : BaseBusiness { @@ -61,7 +61,7 @@ namespace SlnMesnac.Business private ISqlSugarClient sqlSugarClient; - public ProdCompletionBusiness(ISqlSugarClient _sqlSugarClient,ILogger logger, AppConfig appConfig, List plcFactories, List rfidFactories, IMesProductPlanService mesProductPlanService, IMesPrdBarCodeService barCodeTaskService, IServiceProvider serviceProvider) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider) + public ProdCompletionBusiness(ISqlSugarClient _sqlSugarClient, ILogger logger, AppConfig appConfig, List plcFactories, List rfidFactories, IMesProductPlanService mesProductPlanService, IMesPrdBarCodeService barCodeTaskService, IServiceProvider serviceProvider) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider) { sqlSugarClient = _sqlSugarClient; _mesProductPlanService = mesProductPlanService; @@ -72,10 +72,10 @@ namespace SlnMesnac.Business _mesProductOrderService = serviceProvider.GetRequiredService(); _baseMaterialInfoService = serviceProvider.GetRequiredService(); Init(); - + } - private void test() + private void test() { string epc = "A123456"; @@ -85,28 +85,31 @@ namespace SlnMesnac.Business } + + private static bool isEmptyPalletHandleRunning = false; public void Init() { - - Task.Run(() => - { - EmptyPalletHandle(); - }); + + Task.Run(async () => + { + await EmptyPalletHandle(); + + }); Task.Run(() => { DeviceOutPutHandle(); }); - + } /// - /// 设备产出逻辑处理 + /// 豸߼ /// private async void DeviceOutPutHandle() { - // 读取RFID失败重试次数,超过5次推送报警 + // ȡRFIDʧԴ5ͱ int readRfidAmount = 0; - while(true) + while (true) { try { @@ -114,24 +117,32 @@ namespace SlnMesnac.Business if (plc == null) { - _logger.LogInformation("读取小包出口信号,PLC连接信息为空......"); + _logger.LogInformation("ȡСź,PLCϢΪ......"); Thread.Sleep(3000); continue; } - if (plc.readByteByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号"))!=1) + if (plc.readByteByAddress(GetPlcAddressByConfigKey("2¥Сڵλź")) != 1) + { + _logger.LogInformation("ȴСźŴ......"); + Thread.Sleep(5000); + continue; + } + string rfid = plc.readStringByAddress(GetPlcAddressByConfigKey("2¥RFIDַ"),12).Replace("\0",""); + if (!string.IsNullOrWhiteSpace(rfid)) { - _logger.LogInformation("等待小包出口信号触发......"); + _logger.LogInformation("СѾRFIDˣٶ"); Thread.Sleep(5000); continue; + } string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorOut"); if (string.IsNullOrEmpty(epcStr)) { - _logger.LogError("小包出口到位信号触发,读取RFID失败......"); - //判断前一位置是否有托盘缓存 - RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault(); + _logger.LogError("СڵλźŴ,ȡRFIDʧ......"); + //жǰһλǷ̻ + RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault(); if (realPalletTask != null) { epcStr = realPalletTask.PalletCode; @@ -139,15 +150,15 @@ namespace SlnMesnac.Business else { readRfidAmount++; - if(readRfidAmount == 5) + if (readRfidAmount == 5) { string virtualEpc = NoReadRFIDAlarm(); - _logger.LogError("小包出口到位信号触发,读取RFID失败超过5次......"); + _logger.LogError("СڵλźŴ,ȡRFIDʧܳ5......"); if (!string.IsNullOrEmpty(virtualEpc)) { epcStr = virtualEpc; - _logger.LogError("小包出口到位信号触发,读取RFID失败超过5次,生成虚拟托盘号:"+virtualEpc); + _logger.LogError("СڵλźŴ,ȡRFIDʧܳ5,̺:" + virtualEpc); } } else @@ -155,52 +166,52 @@ namespace SlnMesnac.Business Thread.Sleep(1000 * 5); continue; } - - } + + } } - RefreshMessage($"小包出口读取到RFID条码{epcStr},开始绑定流程:"); + RefreshMessage($"СڶȡRFID{epcStr},ʼ:"); _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); if (productPlanDto == null) { - //TODO:没有计划的话,处理方式待定 - throw new ArgumentException($"未获取到正在执行的生产计划"); + //TODO:ûмƻĻ,ʽ + throw new ArgumentException($"δȡִеƻ"); } - #region 开启事务 + #region sqlSugarClient.AsTenant().BeginTran(); - //1.生成大条码插入mes_barcode_info; - string bigCode =GenerateBigBarcode(productPlanDto, epcStr); - //2.40个小条码及大条码绑定托盘号,小条码绑定大条码 - BindingBarCode(bigCode,epcStr); - //3.更新mes_product_plan及mes_product_order表,更新已生产数量 + //1.ɴmes_barcode_info + string bigCode = GenerateBigBarcode(productPlanDto, epcStr); + //2.40С뼰̺ţС󶨴 + BindingBarCode(bigCode, epcStr); + //3.mes_product_planmes_product_order UpdatePlanInfoAndOrder(productPlanDto); - // 删除正在使用的数据库托盘号 + // ɾʹõݿ̺ RealPalletTask realPallet = _realPalletTaskService.Query(x => x.PalletCode == epcStr).FirstOrDefault(); if (realPallet != null) { sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPallet).ExecuteCommand(); } - // 写入PLC RFID号供调度使用 - plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), epcStr); - plc.writeByteByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号"),2); - readRfidAmount = 0; + // дPLC RFIDŹʹ + plc.writeStringByAddress(GetPlcAddressByConfigKey("2¥RFIDַ"), epcStr); + // plc.writeByteByAddress(GetPlcAddressByConfigKey("2¥Сڵλź"), 2); + readRfidAmount = 0; sqlSugarClient.AsTenant().CommitTran(); #endregion } catch (Exception ex) { sqlSugarClient.AsTenant().RollbackTran(); - - _logger.LogError($"DeviceOutPutHandle异常:{ex.Message}"); + + _logger.LogError($"DeviceOutPutHandle쳣:{ex.Message}"); } Thread.Sleep(1000 * 5); } } /// - /// 推送报警,并生成虚拟托盘号暂时使用,虚拟托盘号储存到报警信息,人工处理可以将虚拟托盘号替换为正常托盘号 - /// 返回生产的虚拟托盘号 + /// ͱ,̺ʱʹã̺Ŵ浽Ϣ˹Խ̺滻Ϊ̺ + /// ̺ /// private string NoReadRFIDAlarm() { @@ -210,13 +221,13 @@ namespace SlnMesnac.Business 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); + // бҳ豸ı¼ûб¼߱¼ѽ¼ + 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; @@ -224,8 +235,8 @@ namespace SlnMesnac.Business dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime; dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason; dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason; - dmsRecordAlarmTime.AlarmData = WarnStatusEnum.小包出口读取RFID失败5次.ToString(); - dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest+";;虚拟托盘号为:"+epcStr; + dmsRecordAlarmTime.AlarmData = WarnStatusEnum.СڶȡRFIDʧ5.ToString(); + dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest + ";;̺Ϊ:" + epcStr; dmsRecordAlarmTime.CreateBy = "SlnMesnac"; dmsRecordAlarmTime.CreateTime = DateTime.Now; @@ -238,20 +249,20 @@ namespace SlnMesnac.Business dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime; dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason; dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason; - dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.小包出口读取RFID失败5次.ToString(); - dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest + ";;虚拟托盘号为:" + epcStr; + 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(); + 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); + DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().First(x => x.AlarmRuleId == warnRuleId); if (dmsRecordAlarmInfo != null) { dmsRecordAlarmInfo.UpdateTime = DateTime.Now; @@ -259,15 +270,16 @@ namespace SlnMesnac.Business } sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand(); sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand(); - + } sqlSugarClient.AsTenant().CommitTran(); return epcStr; - }catch(Exception ex) + } + catch (Exception ex) { sqlSugarClient.AsTenant().RollbackTran(); - _logger.LogError($"NoReadRFIDAlarm异常:{ex.Message}"); + _logger.LogError($"NoReadRFIDAlarm쳣:{ex.Message}"); return ""; } @@ -275,15 +287,15 @@ namespace SlnMesnac.Business /// - /// 生成大条码插入mes_barcode_info; + /// ɴmes_barcode_info /// /// /// /// - private string GenerateBigBarcode(MesProductPlanDto productPlanDto,string epcStr) + private string GenerateBigBarcode(MesProductPlanDto productPlanDto, string epcStr) { - - string bigBarcode = productPlanDto.PlanCode+DateTime.Now.ToString("_MMddHHmmss"); + + string bigBarcode = productPlanDto.PlanCode + DateTime.Now.ToString("_MMddHHmmss"); MesBaseBarcodeInfo mesBaseBarcodeInfo = new MesBaseBarcodeInfo(); mesBaseBarcodeInfo.printTime = DateTime.Now; mesBaseBarcodeInfo.printPerson = "SlnMesnac"; @@ -299,40 +311,40 @@ namespace SlnMesnac.Business mesBaseBarcodeInfo.productionDate = DateTime.Now; mesBaseBarcodeInfo.acceptedDate = DateTime.Now; mesBaseBarcodeInfo.planCode = productPlanDto.PlanCode; - mesBaseBarcodeInfo.safeFlag = productPlanDto.SaleOrderId ==0 ?"1" : "0"; + mesBaseBarcodeInfo.safeFlag = productPlanDto.SaleOrderId == 0 ? "1" : "0"; mesBaseBarcodeInfo.saleOrderId = productPlanDto.SaleOrderId; mesBaseBarcodeInfo.saleorderCode = productPlanDto.SaleorderCode; mesBaseBarcodeInfo.bindStatus = "1"; - mesBaseBarcodeInfo.bindTime = DateTime.Now; + mesBaseBarcodeInfo.bindTime = DateTime.Now; mesBaseBarcodeInfo.updateBy = "SlnMesnac"; - mesBaseBarcodeInfo.updateTime = DateTime.Now; - mesBaseBarcodeInfo.completeFlag = "1"; - mesBaseBarcodeInfo.singleFlag = "0"; + mesBaseBarcodeInfo.updateTime = DateTime.Now; + mesBaseBarcodeInfo.completeFlag = "1"; + mesBaseBarcodeInfo.singleFlag = "0"; var materialInfo = _baseMaterialInfoService.Query(x => x.MaterialId == productPlanDto.MaterialId).FirstOrDefault(); - if(materialInfo != null) + if (materialInfo != null) { mesBaseBarcodeInfo.barcodeSpec = materialInfo.MaterialSpec; - } + } sqlSugarClient.AsTenant().GetConnection("mes").Insertable(mesBaseBarcodeInfo).ExecuteCommand(); return bigBarcode; } /// - /// 40个小条码及大条码绑定托盘号,小条码绑定大条码 + /// 40С뼰̺ţС󶨴 /// /// /// - private void BindingBarCode(string bigBarcode,string epcStr) + private void BindingBarCode(string bigBarcode, string epcStr) { List list = _mesPrdBarCodeService.GetUseBarCodeList(); - if(list==null || list.Count == 0) + if (list == null || list.Count == 0) { - throw new InvalidOperationException("托盘未找到可以绑定的小条码"); + throw new InvalidOperationException("δҵ԰󶨵С"); } - + if (list.Where(x => x.PrintFlag == "1").ToList().Count < 40) { - // TODO推送低级别报警 + // TODO͵ͼ𱨾 PrintLessThan40Alarm(); } foreach (var item in list) @@ -347,44 +359,44 @@ namespace SlnMesnac.Business private void UpdatePlanInfoAndOrder(MesProductPlanDto productPlanDto) { - MesProductPlan productPlan = _mesProductPlanService.Query(x => x.PlanCode == productPlanDto.PlanCode).FirstOrDefault(); - if(productPlan == null) + MesProductPlan productPlan = _mesProductPlanService.Query(x => x.PlanCode == productPlanDto.PlanCode).FirstOrDefault(); + if (productPlan == null) { - throw new InvalidOperationException("未找到该生产计划!"); + throw new InvalidOperationException("δҵƻ!"); } MesProductOrder productOrder = _mesProductOrderService.Query(x => x.ProductOrderId == productPlan.ProductOrderId).FirstOrDefault(); if (productPlan == null) { - throw new InvalidOperationException("未找到该生产计划对应的生产工单!"); + throw new InvalidOperationException("δҵƻӦ!"); } - #region 更新生产计划 + #region ƻ if (productPlan.CompleteAmount == 0) { productPlan.RealBeginTime = DateTime.Now; } productPlan.CompleteAmount++; - if(productPlan.CompleteAmount == productPlan.PlanAmount) + if (productPlan.CompleteAmount == productPlan.PlanAmount) { - + productPlan.RealEndTime = DateTime.Now; - productPlan.PlanStatus = Model.enums.PlanStatusEnum.已完成; + productPlan.PlanStatus = Model.enums.PlanStatusEnum.; } productPlan.UpdateTime = DateTime.Now; productPlan.UpdateBy = "SlnMesnac"; sqlSugarClient.AsTenant().GetConnection("mes").Updateable(productPlan).ExecuteCommand(); #endregion - #region 更新生产工单 - + #region + if (productOrder.CompleteAmount == 0) { - + productOrder.RealBeginTime = DateTime.Now; } productOrder.CompleteAmount++; - if(productOrder.CompleteAmount== productOrder.PlanAmount) + if (productOrder.CompleteAmount == productOrder.PlanAmount) { - + productOrder.RealEndTime = DateTime.Now; productOrder.OrderStatus = "2"; } @@ -396,8 +408,8 @@ namespace SlnMesnac.Business } /// - /// 小包产出绑定托盘,小包喷码数量小于40低级别报警 - /// 返回生产的虚拟托盘号 + /// С̣СС40ͼ𱨾 + /// ̺ /// private void PrintLessThan40Alarm() { @@ -405,8 +417,8 @@ namespace SlnMesnac.Business { sqlSugarClient.AsTenant().BeginTran(); - // 有报警,找出该设备的报警记录,如果没有报警记录或者报警记录已结束,则新增报警记录 - int warnRuleId = int.Parse(WarnStatusEnum.托盘绑定时已喷码数不足40.GetDescription()); + // бҳ豸ı¼ûб¼߱¼ѽ¼ + int warnRuleId = int.Parse(WarnStatusEnum.̰ʱ40.GetDescription()); DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().First(x => x.AlarmRuleId == warnRuleId); if (dmsRecordAlarmTime == null) { @@ -419,7 +431,7 @@ namespace SlnMesnac.Business dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime; dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason; dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason; - dmsRecordAlarmTime.AlarmData = WarnStatusEnum.托盘绑定时已喷码数不足40.ToString(); + dmsRecordAlarmTime.AlarmData = WarnStatusEnum.̰ʱ40.ToString(); dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest; dmsRecordAlarmTime.CreateBy = "SlnMesnac"; dmsRecordAlarmTime.CreateTime = DateTime.Now; @@ -433,7 +445,7 @@ namespace SlnMesnac.Business dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime; dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason; dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason; - dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.托盘绑定时已喷码数不足40.ToString(); + dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.̰ʱ40.ToString(); dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest; dmsRecordAlarmInfo.CreateBy = "SlnMesnac"; dmsRecordAlarmInfo.CreateTime = DateTime.Now; @@ -458,23 +470,23 @@ namespace SlnMesnac.Business } sqlSugarClient.AsTenant().CommitTran(); - + } catch (Exception ex) { sqlSugarClient.AsTenant().RollbackTran(); - _logger.LogError($"PrintLessThan40Alarm异常:{ex.Message}"); - + _logger.LogError($"PrintLessThan40Alarm쳣:{ex.Message}"); + } } /// - /// 空托盘进入码垛位,读取RFID备用 + /// ̽λ,ȡRFID /// - private async void EmptyPalletHandle() + private async Task EmptyPalletHandle() { - //读取PLC空托盘流转信号 + //ȡPLCתź while (true) { try @@ -482,71 +494,75 @@ namespace SlnMesnac.Business var plc = base.GetPlcByKey("plc"); if (plc == null) { - _logger.LogInformation("读取PLC空托盘码垛到位信号,PLC连接信息为空......"); + _logger.LogInformation("ȡPLC⵽λź,PLCϢΪ......"); + Thread.Sleep(5000); + continue; + } + if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2¥⵽λź"))) + { + _logger.LogInformation("ȴ̵λźŴ......"); Thread.Sleep(5000); continue; } - if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2楼码垛到位信号"))) + + RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault(); + if (realPalletTask != null) { - _logger.LogInformation("等待空托盘到位信号触发......"); + _logger.LogInformation("̵λźŴ,Ѿжȡ̣ٶȡ......"); Thread.Sleep(5000); continue; } - //读取RFID、获取当前正在执行的计划、将当前计划、工单等信息与托盘绑定 - RefreshMessage("空托盘到位信号触发成功,读取托盘RFID信息"); + //ȡRFIDȡǰִеļƻǰƻϢ̰ + RefreshMessage("̵λźŴɹ,ȡRFIDϢ"); string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorPallet"); if (string.IsNullOrEmpty(epcStr)) { - _logger.LogError("空托盘到位信号触发,读取RFID失败......"); - Thread.Sleep(1000*10); + _logger.LogError("̵λźŴ,ȡRFIDʧ......"); + Thread.Sleep(1000 * 10); continue; } - RefreshMessage($"空托盘RFID信息读取成功,标签信息:{epcStr}"); + RefreshMessage($"RFIDϢȡɹǩϢ{epcStr}"); - // 插入一条托盘记录 - RealPalletTask realPalletTask = new RealPalletTask() + // һ̼¼ + realPalletTask = new RealPalletTask() { PalletCode = epcStr, RecordTime = DateTime.Now, }; - bool result = _realPalletTaskService.Insert(realPalletTask); - if (result) - { - plc.writeBoolByAddress(GetPlcAddressByConfigKey("2楼码垛到位信号"), false); - } - + _realPalletTaskService.Insert(realPalletTask); + } catch (Exception e) { - RefreshMessage($"空托盘进入码垛位处理异常:{e.Message}"); + RefreshMessage($"̽λ쳣{e.Message}"); } - Thread.Sleep(1000*5); + Thread.Sleep(1000 * 10); } } /// - /// 根据条码提取序列 + /// ȡ /// /// /// /// - private void ExtractNumber(string barCode,out int result) + private void ExtractNumber(string barCode, out int result) { string pattern = @"\b0*(\d{1,6})\b$"; Match match = Regex.Match(barCode, pattern); if (match.Success) { - result = Convert.ToInt32(match.Groups[1].Value)+1; + result = Convert.ToInt32(match.Groups[1].Value) + 1; } else { - throw new InvalidOperationException($"通过条码:{barCode}提取当前序列异常:未找到匹配的数字"); + throw new InvalidOperationException($"ͨ:{barCode}ȡǰ쳣:δҵƥ"); } } diff --git a/SlnMesnac.Business/ProdMgmtBusiness.cs b/SlnMesnac.Business/ProdMgmtBusiness.cs index abb946b..e3e4277 100644 --- a/SlnMesnac.Business/ProdMgmtBusiness.cs +++ b/SlnMesnac.Business/ProdMgmtBusiness.cs @@ -84,9 +84,11 @@ namespace SlnMesnac.Business _mesPrdBarCodeService = serviceProvider.GetRequiredService(); _configInfoBusiness = configInfoBusiness; - + //testRFID(); + } + public void TestTran() { try @@ -127,7 +129,6 @@ namespace SlnMesnac.Business Console.WriteLine(aaa); //RefreshMessage($"投料校验RFID标签读取成功,标签信息:{epcStr}"); - } #region 委托事件 @@ -392,13 +393,16 @@ namespace SlnMesnac.Business //2.生成小包条码 GenerateBarcode(40); - + //BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "系统运行时长").FirstOrDefault(); + //configInfo.ConfigValue = "0"; + //sqlSugarClient.AsTenant().GetConnection("local").Updateable(configInfo).ExecuteCommand(); + //_configInfoBusiness.RefreshConfigInfo(); + + sqlSugarClient.AsTenant().CommitTran(); //3.清空投料系统运行时间 BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "系统运行时长").FirstOrDefault(); configInfo.ConfigValue = "0"; - sqlSugarClient.AsTenant().GetConnection("local").Updateable(configInfo).ExecuteCommand(); - _configInfoBusiness.RefreshConfigInfo(); - sqlSugarClient.AsTenant().CommitTran(); + _configInfoBusiness.UpdateConfigInfo(configInfo); } } diff --git a/SlnMesnac.Model/domain/DmsRealtimeStatus.cs b/SlnMesnac.Model/domain/DmsRealtimeStatus.cs new file mode 100644 index 0000000..ac8231a --- /dev/null +++ b/SlnMesnac.Model/domain/DmsRealtimeStatus.cs @@ -0,0 +1,57 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Security.Principal; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + /// + /// 设备状态信息 + /// + [SugarTable("dms_realtime_status")] + public class DmsRealtimeStatus + { + /// + /// 状态ID + /// + [SugarColumn(ColumnName = "status_id", IsPrimaryKey = true, IsIdentity = true)] + public long StatusId { get; set; } + + /// + /// 设备状态编号 + /// + [SugarColumn(ColumnName = "status_code")] + public string StatusCode { get; set; } + + /// + /// 设备状态名称 + /// + [SugarColumn(ColumnName = "status_name")] + public string StatusName { get; set; } + + /// + /// 设备状态值 + /// + [SugarColumn(ColumnName = "status_value")] + public string StatusValue { get; set; } + + /// + /// 所属设备id + /// + [SugarColumn(ColumnName = "device_id")] + public long? DeviceId { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "creat_time")] + public DateTime? CreatTime { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "update_time")] + public DateTime? UpdateTime { get; set; } + } +} diff --git a/SlnMesnac.Model/domain/DmsRealtimeStatusHistory.cs b/SlnMesnac.Model/domain/DmsRealtimeStatusHistory.cs new file mode 100644 index 0000000..5255b75 --- /dev/null +++ b/SlnMesnac.Model/domain/DmsRealtimeStatusHistory.cs @@ -0,0 +1,69 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Security.Principal; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + /// + /// 设备状态历史记录 + /// + [SugarTable("dms_realtime_status_history")] + public class DmsRealtimeStatusHistory + { + /// + /// 历史记录ID + /// + [SugarColumn(ColumnName = "history_id", IsPrimaryKey = true, IsIdentity = true)] + public long HistoryId { get; set; } + + /// + /// 状态ID + /// + [SugarColumn(ColumnName = "status_id")] + public long StatusId { get; set; } + + /// + /// 设备状态编号 + /// + [SugarColumn(ColumnName = "status_code")] + public string StatusCode { get; set; } + + /// + /// 设备状态名称 + /// + [SugarColumn(ColumnName = "status_name")] + public string StatusName { get; set; } + + /// + /// 设备状态值 + /// + [SugarColumn(ColumnName = "status_value")] + public string StatusValue { get; set; } + + /// + /// 所属设备id + /// + [SugarColumn(ColumnName = "device_id")] + public long? DeviceId { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "creat_time")] + public DateTime? CreatTime { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "update_time")] + public DateTime? UpdateTime { get; set; } + + /// + /// 同步时间 + /// + [SugarColumn(ColumnName = "sync_time")] + public DateTime SyncTime { get; set; } + } +} diff --git a/SlnMesnac.Model/dto/DmsRealTimeDto.cs b/SlnMesnac.Model/dto/DmsRealTimeDto.cs new file mode 100644 index 0000000..2329e63 --- /dev/null +++ b/SlnMesnac.Model/dto/DmsRealTimeDto.cs @@ -0,0 +1,34 @@ +using System; + +#region << 版 本 注 释 >> +/*-------------------------------------------------------------------- +* 版权所有 (c) 2024 WenJY 保留所有权利。 +* CLR版本:4.0.30319.42000 +* 机器名称:LAPTOP-E0N2L34V +* 命名空间:SlnMesnac.Model.dto +* 唯一标识:496f8d2b-70e3-4a05-ae18-a9b0fcd06b82 +* +* 创建者:WenJY +* 电子邮箱:wenjy@mesnac.com +* 创建时间:2024-03-27 21:58:35 +* 版本:V1.0.0 +* 描述: +* +*-------------------------------------------------------------------- +* 修改人: +* 时间: +* 修改说明: +* +* 版本:V1.0.0 +*--------------------------------------------------------------------*/ +#endregion << 版 本 注 释 >> +namespace SlnMesnac.Model.dto +{ + /// + /// 采集设备状态 + /// + public class DmsRealTimeDto + { + + } +} \ No newline at end of file diff --git a/SlnMesnac.Repository/service/Impl/MesProductPlanServiceImpl.cs b/SlnMesnac.Repository/service/Impl/MesProductPlanServiceImpl.cs index 564e1e5..f9320ef 100644 --- a/SlnMesnac.Repository/service/Impl/MesProductPlanServiceImpl.cs +++ b/SlnMesnac.Repository/service/Impl/MesProductPlanServiceImpl.cs @@ -121,7 +121,9 @@ namespace SlnMesnac.Repository.service.Impl } catch (Exception e) { - throw new InvalidOperationException($"获取已开始的第一条生产计划异常:{e.Message}"); + productPlanDto = null; + return null; + //throw new InvalidOperationException($"获取已开始的第一条生产计划异常:{e.Message}"); } } diff --git a/SlnMesnac.WPF/Dto/MachineStatusDto.cs b/SlnMesnac.WPF/Dto/MachineStatusDto.cs index 6e0b251..8e1b50a 100644 --- a/SlnMesnac.WPF/Dto/MachineStatusDto.cs +++ b/SlnMesnac.WPF/Dto/MachineStatusDto.cs @@ -17,9 +17,11 @@ namespace SlnMesnac.WPF.Dto //设备运行状态 public bool status { get; set; } - //报警类型 public WarnStatusEnum warnStatus { get; set; } = WarnStatusEnum.无报警; + + //设备实时状态采集点 + // public List<> realTimeList { get; set; } } diff --git a/SlnMesnac.WPF/Page/DevMonitorPage.xaml b/SlnMesnac.WPF/Page/DevMonitorPage.xaml index ef42ce6..0e016c7 100644 --- a/SlnMesnac.WPF/Page/DevMonitorPage.xaml +++ b/SlnMesnac.WPF/Page/DevMonitorPage.xaml @@ -18,12 +18,17 @@ - - -