diff --git a/SlnMesnac.Business/PalletStowBusiness.cs b/SlnMesnac.Business/PalletStowBusiness.cs index b2c0005..4653b12 100644 --- a/SlnMesnac.Business/PalletStowBusiness.cs +++ b/SlnMesnac.Business/PalletStowBusiness.cs @@ -81,8 +81,6 @@ namespace SlnMesnac.Business /// private void EmptyPalletHandle() { - - //读取PLC空托盘流转信号 while (true) { diff --git a/SlnMesnac.Business/ProdCompletionBusiness.cs b/SlnMesnac.Business/ProdCompletionBusiness.cs index c6435bf..e6d84a2 100644 --- a/SlnMesnac.Business/ProdCompletionBusiness.cs +++ b/SlnMesnac.Business/ProdCompletionBusiness.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using SlnMesnac.Business.@base; using SlnMesnac.Common; using SlnMesnac.Config; @@ -7,6 +8,7 @@ using SlnMesnac.Model.dto; using SlnMesnac.Plc; using SlnMesnac.Repository.service; using SlnMesnac.Rfid; +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -14,6 +16,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using static System.Net.Mime.MediaTypeNames; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -47,29 +50,57 @@ namespace SlnMesnac.Business private readonly IMesProductPlanService _mesProductPlanService; private readonly IMesPrdBarCodeService _barCodeTaskService; - - + private readonly IMesBaseBarcodeInfoService _mesBaseBarcodeInfoService; + public readonly IMesPrdBarCodeService _mesPrdBarCodeService; + private readonly IRealPalletTaskService _realPalletTaskService; - public ProdCompletionBusiness(ILogger logger, AppConfig appConfig, List plcFactories, List rfidFactories, IMesProductPlanService mesProductPlanService, IMesPrdBarCodeService barCodeTaskService, IServiceProvider serviceProvider) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider) + 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) { + sqlSugarClient = _sqlSugarClient; _mesProductPlanService = mesProductPlanService; _barCodeTaskService = barCodeTaskService; + _realPalletTaskService = serviceProvider.GetRequiredService(); + _mesBaseBarcodeInfoService = serviceProvider.GetRequiredService(); + _mesPrdBarCodeService = serviceProvider.GetRequiredService(); + Init(); + + } + + private void test() + { + + string epc = "A123456"; + _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); + string bigCode = GenerateBigBarcode(productPlanDto, epc); + BindingBarCode(bigCode, epc); + } - - public void Init() { - DeviceOutPutHandle(); + + Task.Run(() => + { + EmptyPalletHandle(); + }); + Task.Run(() => + { + DeviceOutPutHandle(); + }); + } /// /// 设备产出逻辑处理 /// - private void DeviceOutPutHandle() + private async void DeviceOutPutHandle() { + // 读取RFID失败重试次数,超过5次推送报警 + int readRfidAmount = 0; while(true) { try @@ -78,60 +109,206 @@ namespace SlnMesnac.Business if (plc == null) { - _logger.LogInformation("读取设备产出信号,PLC连接信息为空......"); + _logger.LogInformation("读取小包出口信号,PLC连接信息为空......"); Thread.Sleep(3000); continue; } - if (plc.readInt16ByAddress(GetPlcAddressByConfigKey("设备产出")) != 1) + if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2楼码垛出口到位信号"))) { - _logger.LogInformation("等待设备产出信号触发......"); + _logger.LogInformation("等待小包出口信号触发......"); Thread.Sleep(5000); continue; } - _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); + string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorOut"); + if (string.IsNullOrEmpty(epcStr)) + { + _logger.LogError("小包出口到位信号触发,读取RFID失败......"); + //判断前一位置是否有托盘缓存 + RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault(); + if (realPalletTask != null) + { + epcStr = realPalletTask.PalletCode; + } + else + { + readRfidAmount++; + if(readRfidAmount == 5) + { + //TODO 推送报警 + _logger.LogError("小包出口到位信号触发,读取RFID失败超过5次......"); + } + Thread.Sleep(1000 * 5); + continue; + } + } + RefreshMessage($"小包出口读取到RFID条码{epcStr},开始绑定流程:"); + _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); if (productPlanDto == null) { + //TODO:没有计划的话,处理方式待定 throw new ArgumentException($"未获取到正在执行的生产计划"); } - plc.writeInt16ByAddress(GetPlcAddressByConfigKey("设备产出"), 0); - //生成小包条码 - string barCode = $"JYHB{(string.IsNullOrEmpty(productPlanDto.MaterialCode) ? "000000000" : productPlanDto.MaterialCode)}-000001"; - //if (_barCodeTasks.Count > 0) - //{ - // var info = _barCodeTasks.OrderByDescending(x => x.RecordTime).Where(x=>x.MaterialCode == productPlanDto.MaterialCode); - // if(info.Count() > 0) - // { - // var task = info.FirstOrDefault(); - - // ExtractNumber(task.BarCode, out int orFlag); - - // barCode = $"JYHB{(string.IsNullOrEmpty(productPlanDto.MaterialCode) ? "000000000" : productPlanDto.MaterialCode)}-{orFlag.ToString().PadLeft(6,'0')}"; - // } - //} - - - //RealBarCodeTask barCodeTask = new RealBarCodeTask() - //{ - // BarCode = barCode, - // PlanCode = productPlanDto.PlanCode, - // MaterialCode = productPlanDto.MaterialCode, - // RecordTime = DateTime.Now - //}; - //_barCodeTaskService.InsertBarCodeTask(barCodeTask); - - //RefreshBarCodeTaskListEvent?.Invoke(_barCodeTasks); + sqlSugarClient.AsTenant().BeginTran(); + //1.生成大条码插入mes_barcode_info; + string bigCode =GenerateBigBarcode(productPlanDto, epcStr); + //2.40个小条码及大条码绑定托盘号,小条码绑定大条码 + BindingBarCode(bigCode,epcStr); + //3.更新mes_product_plan及mes_product_order表,更新已生产数量 + + + + sqlSugarClient.AsTenant().CommitTran(); + + plc.writeBoolByAddress(GetPlcAddressByConfigKey("2楼码垛出口到位信号"), false); + readRfidAmount = 0; + } catch (Exception ex) { + sqlSugarClient.AsTenant().RollbackTran(); + // TODO:推送报警 + _logger.LogError($"DeviceOutPutHandle异常:{ex.Message}"); + } + } + } + + /// + /// 生成大条码插入mes_barcode_info; + /// + /// + /// + /// + private string GenerateBigBarcode(MesProductPlanDto productPlanDto,string epcStr) + { + + string bigBarcode = productPlanDto.PlanCode+DateTime.Now.ToString("_MMddHHmmss"); + + MesBaseBarcodeInfo mesBaseBarcodeInfo = new MesBaseBarcodeInfo(); + mesBaseBarcodeInfo.printTime = DateTime.Now; + mesBaseBarcodeInfo.printPerson = "SlnMesnac"; + mesBaseBarcodeInfo.printFlag = "1"; + mesBaseBarcodeInfo.batchFlag = "0"; + mesBaseBarcodeInfo.barcodeType = "3"; + mesBaseBarcodeInfo.barcodeInfo = bigBarcode; + mesBaseBarcodeInfo.batchCode = bigBarcode; + mesBaseBarcodeInfo.palletInfoCode = epcStr; + mesBaseBarcodeInfo.materialId = productPlanDto.MaterialId; + mesBaseBarcodeInfo.amount = 1; + mesBaseBarcodeInfo.printNumber = 1; + mesBaseBarcodeInfo.productionDate = DateTime.Now; + mesBaseBarcodeInfo.acceptedDate = DateTime.Now; + mesBaseBarcodeInfo.planCode = productPlanDto.PlanCode; + mesBaseBarcodeInfo.safeFlag = productPlanDto.SaleOrderId ==0 ?"1" : "0"; + mesBaseBarcodeInfo.saleOrderId = productPlanDto.SaleOrderId; + mesBaseBarcodeInfo.saleorderCode = productPlanDto.SaleorderCode; + mesBaseBarcodeInfo.bindStatus = "1"; + mesBaseBarcodeInfo.bindTime = DateTime.Now; + mesBaseBarcodeInfo.updateBy = "SlnMesnac"; + mesBaseBarcodeInfo.updateTime = DateTime.Now; + mesBaseBarcodeInfo.completeFlag = "1"; + mesBaseBarcodeInfo.singleFlag = "0"; + mesBaseBarcodeInfo.barcodeSpec = productPlanDto.MaterialName; + sqlSugarClient.AsTenant().GetConnection("mes").Insertable(mesBaseBarcodeInfo).ExecuteCommand(); + return bigBarcode; + } + + /// + /// 40个小条码及大条码绑定托盘号,小条码绑定大条码 + /// + /// + /// + private void BindingBarCode(string bigBarcode,string epcStr) + { + List list = _mesPrdBarCodeService.GetUseBarCodeList(); + if(list==null || list.Count == 0) + { + throw new Exception("托盘未找到可以绑定的小条码"); + }else if(list.Count > 40) + { + list = list.Take(40).ToList(); + } + foreach (var item in list) + { + item.PalletInfoCode = epcStr; + item.MesBarcodeInfo = bigBarcode; + item.BindTime = DateTime.Now; + } + sqlSugarClient.AsTenant().GetConnection("mes").Updateable(list).ExecuteCommand(); + } + + private void UpdatePlanInfoAndOrder(MesProductPlanDto productPlanDto) + { + + } + + + + + + /// + /// 空托盘进入码垛位,读取RFID备用 + /// + private async void EmptyPalletHandle() + { + //读取PLC空托盘流转信号 + while (true) + { + try + { + var plc = base.GetPlcByKey("plc"); + if (plc == null) + { + _logger.LogInformation("读取PLC空托盘码垛到位信号,PLC连接信息为空......"); + Thread.Sleep(5000); + continue; + } + if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2楼码垛到位信号"))) + { + _logger.LogInformation("等待空托盘到位信号触发......"); + Thread.Sleep(5000); + continue; + } + //读取RFID、获取当前正在执行的计划、将当前计划、工单等信息与托盘绑定 + RefreshMessage("空托盘到位信号触发成功,读取托盘RFID信息"); + + string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorPallet"); + + if (string.IsNullOrEmpty(epcStr)) + { + _logger.LogError("空托盘到位信号触发,读取RFID失败......"); + Thread.Sleep(1000*10); + continue; + } + + RefreshMessage($"空托盘RFID信息读取成功,标签信息:{epcStr}"); + + // 插入一条托盘记录 + RealPalletTask realPalletTask = new RealPalletTask() + { + PalletCode = epcStr, + RecordTime = DateTime.Now, + }; + bool result = _realPalletTaskService.Insert(realPalletTask); + if (result) + { + plc.writeBoolByAddress(GetPlcAddressByConfigKey("2楼码垛到位信号"), false); + } + + } + catch (Exception e) + { + RefreshMessage($"空托盘进入码垛位处理异常:{e.Message}"); } + Thread.Sleep(5000); } } + /// /// 根据条码提取序列 /// @@ -153,18 +330,5 @@ namespace SlnMesnac.Business } } - - - - //public void testPenCode() - //{ - - // //生成小包条码 - // string materialCode = "000000000"; - // string barCode = $"JYHB{(string.IsNullOrEmpty(materialCode) ? "000000000" : materialCode)}-000001"; - // ExtractNumber(task.BarCode, out int orFlag); - // barCode = $"JYHB{(string.IsNullOrEmpty(productPlanDto.MaterialCode) ? "000000000" : productPlanDto.MaterialCode)}-{orFlag.ToString().PadLeft(6, '0')}"; - - //} } } diff --git a/SlnMesnac.Business/ProdMgmtBusiness.cs b/SlnMesnac.Business/ProdMgmtBusiness.cs index f289814..41b9654 100644 --- a/SlnMesnac.Business/ProdMgmtBusiness.cs +++ b/SlnMesnac.Business/ProdMgmtBusiness.cs @@ -84,7 +84,7 @@ namespace SlnMesnac.Business _mesPrdBarCodeService = serviceProvider.GetRequiredService(); _configInfoBusiness = configInfoBusiness; - + } public void TestTran() @@ -122,7 +122,7 @@ namespace SlnMesnac.Business //tcpClient.Setup(new TouchSocketConfig().SetRemoteIPHost($"192.168.2.51:3000")); //tcpClient.Connect(); // byte[] reciveBuffer = await waitClient.SendThenReturnAsync(pMessagePack.m_pData, timeout); - string aaa = await ReadEpcStrByRfidKeyAsync("test"); + string aaa = await ReadEpcStrByRfidKeyAsync("secondFloorPallet"); // ReadEpcStrByRfidKey("test", out string epcStr); Console.WriteLine(aaa); //RefreshMessage($"投料校验RFID标签读取成功,标签信息:{epcStr}"); diff --git a/SlnMesnac.Business/base/BaseBusiness.cs b/SlnMesnac.Business/base/BaseBusiness.cs index 812b9de..0ed0d35 100644 --- a/SlnMesnac.Business/base/BaseBusiness.cs +++ b/SlnMesnac.Business/base/BaseBusiness.cs @@ -192,7 +192,7 @@ namespace SlnMesnac.Business.@base /// - /// 根据RFID Key读取RFID信息 + /// 使用---根据RFID Key读取RFID信息 /// /// /// @@ -203,6 +203,11 @@ namespace SlnMesnac.Business.@base { string epcStr = string.Empty; var rfidEquip = GetRfidByKey(rfidKey); + if(rfidEquip == null) + { + //TODO 推送设备报警 + return null; + } List tagInfoList =await rfidEquip.GetRFIDAsync(); epcStr = tagInfoList.OrderByDescending(x => x.Count).First().EPCstring; return epcStr; diff --git a/SlnMesnac.Model/domain/MesBaseBarcodeInfo.cs b/SlnMesnac.Model/domain/MesBaseBarcodeInfo.cs new file mode 100644 index 0000000..5ffd083 --- /dev/null +++ b/SlnMesnac.Model/domain/MesBaseBarcodeInfo.cs @@ -0,0 +1,253 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + + + +namespace SlnMesnac.Model.domain +{ + + [SugarTable("mes_base_barcode_info"), TenantAttribute("mes")] + public partial class MesBaseBarcodeInfo + { + /// + /// Desc:id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "barcode_id")] + public long barcodeId { get; set; } + + /// + /// 打印时间 + /// + [SugarColumn(ColumnName = "print_time")] + public DateTime? printTime { get; set; } + + /// + ///打印人 + /// + [SugarColumn(ColumnName = "print_person")] + public string? printPerson { get; set; } + + /// + /// 打印标识(0否1是) + /// + [SugarColumn(ColumnName = "print_flag")] + public string printFlag { get; set; } + + /// + /// 批次标识(0否,1是);在打印时,如果物料已设置,则根据物料的批次信息,如果没有设置则在此需要选择,选择物料等信息保存后同步设置物料信息。 + /// + [SugarColumn(ColumnName = "batch_flag")] + public string batchFlag { get; set; } + + /// + ///条码类型(1原材料,2半成品,3成品,4背板) + /// + [SugarColumn(ColumnName = "barcode_type")] + public string barcodeType { get; set; } + + /// + /// 条码内容;如果是按单个物料贴,则一个物料一个条码,如果是按批次贴,则条码跟批次代码相同 + /// + [SugarColumn(ColumnName = "barcode_info")] + public string barcodeInfo { get; set; } + + /// + /// 批次代码 + /// + [SugarColumn(ColumnName = "batch_code")] + public string batchCode { get; set; } + + /// + ///托盘RFID代码 + /// + [SugarColumn(ColumnName = "pallet_info_code")] + public string palletInfoCode { get; set; } + + /// + /// 绑定的物料条码(用来拆分绑定使用) + /// + [SugarColumn(ColumnName = "bind_barcode")] + public string? bindBarcode { get; set; } + + /// + /// 物料ID,关联mes_base_material_info的material_id + /// + [SugarColumn(ColumnName = "material_id")] + public long? materialId { get; set; } + + /// + ///供应商ID + /// + [SugarColumn(ColumnName = "manufacturer_id")] + public long? manufacturerId { get; set; } + + /// + /// 数量;如果是批次需要输入此字段 + /// + [SugarColumn(ColumnName = "amount")] + public decimal? amount { get; set; } + + /// + /// 成品条码,在四楼成品到五楼作为原材料时需要绑定之前的成品条码 + /// + [SugarColumn(ColumnName = "product_barcode")] + public string? productBarcode { get; set; } + + /// + /// 打印数量 + /// + [SugarColumn(ColumnName = "print_number")] + public int? printNumber { get; set; } + + /// + /// 打印机台名称,打印时获取 + /// + [SugarColumn(ColumnName = "machine_name")] + public string? machineName { get; set; } + + /// + /// 采购订单ID + /// + [SugarColumn(ColumnName = "purchase_order_id")] + public long? purchaseOrderId { get; set; } + + /// + /// 采购订单号;适合原材料入库时 + /// + [SugarColumn(ColumnName = "po_no")] + public string? poNo { get; set; } + + /// + ///生产日期;打印时根据领料单选择输入 + /// + [SugarColumn(ColumnName = "production_date")] + public DateTime? productionDate { get; set; } + + /// + ///接受日期;打印时的系统日期 + /// + [SugarColumn(ColumnName = "accepted_date")] + public DateTime? acceptedDate { get; set; } + + /// + /// 最晚出库日期;可以直接输入,也可以根据日限计算 + /// + [SugarColumn(ColumnName = "last_outstock_date")] + public DateTime? lastOutstockDate { get; set; } + + /// + /// 生产计划编号,关联mes_pd_product_plan的plan_code;适合生产出入库等 + /// + [SugarColumn(ColumnName = "plan_code")] + public string planCode { get; set; } + + /// + /// 生产计划明细编号,关联mes_product_plan_detail的plan_detail_code;适合生产出入库等 + /// + [SugarColumn(ColumnName = "plan_detail_code")] + public string? planDetailCode { get; set; } + + /// + /// 安全库存标识(1是,0否),如果销售订单是0,则此字段是安全库存 + /// + [SugarColumn(ColumnName = "safe_flag")] + public string safeFlag { get; set; } + + /// + /// 销售订单ID + /// + [SugarColumn(ColumnName = "sale_order_id")] + public long? saleOrderId { get; set; } + + /// + /// 销售订单编号;适合生产出入库等 + /// + [SugarColumn(ColumnName = "saleorder_code")] + public string saleorderCode { get; set; } + + /// + /// 项目号 + /// + [SugarColumn(ColumnName = "project_no")] + public string? projectNo { get; set; } + + /// + /// 流水号 + /// + [SugarColumn(ColumnName = "serial_number")] + public string? serialNumber { get; set; } + + /// + /// Desc: + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "remark")] + public string? remark { get; set; } + + /// + /// 绑定状态(1绑定,0解绑) + /// + [SugarColumn(ColumnName = "bind_status")] + public string? bindStatus { get; set; } + + /// + /// Desc: + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "bind_by")] + public string? bindBy { get; set; } + + /// + /// 绑定托盘时间 + /// + [SugarColumn(ColumnName = "bind_time")] + public DateTime? bindTime { get; set; } + + /// + /// Desc: + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "update_by")] + public string? updateBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "update_time")] + public DateTime? updateTime { get; set; } + + /// + /// Desc: + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "transferred_plan_detail_code")] + public string? transferredPlanDetailCode { get; set; } + + /// + /// 完整表示 + /// + [SugarColumn(ColumnName = "complete_flag")] + public string? completeFlag { get; set; } + + /// + /// Desc: + /// Default:0 + /// Nullable:False + /// + [SugarColumn(ColumnName = "single_flag")] + public string singleFlag { get; set; } + + /// + /// 物料规格 + /// + [SugarColumn(ColumnName = "barcode_spec")] + public string barcodeSpec { get; set; } + } + +} diff --git a/SlnMesnac.Repository/service/IMesBaseBarcodeInfoService.cs b/SlnMesnac.Repository/service/IMesBaseBarcodeInfoService.cs new file mode 100644 index 0000000..956ce97 --- /dev/null +++ b/SlnMesnac.Repository/service/IMesBaseBarcodeInfoService.cs @@ -0,0 +1,12 @@ +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Repository.service +{ + public interface IMesBaseBarcodeInfoService : IBaseService + { + } +} diff --git a/SlnMesnac.Repository/service/IMesPrdBarCodeService.cs b/SlnMesnac.Repository/service/IMesPrdBarCodeService.cs index f8e515b..7035ea1 100644 --- a/SlnMesnac.Repository/service/IMesPrdBarCodeService.cs +++ b/SlnMesnac.Repository/service/IMesPrdBarCodeService.cs @@ -17,10 +17,15 @@ namespace SlnMesnac.Repository.service void InsertBarCodeTask(MesPrdBarcodeInfo barcodeInfo); /// - /// 移除条码队列 + /// 查询前四十条已经喷印未绑定条码 /// - /// + /// + /// /// - // void RemoveBarCodeTask(string barCode); + List GetUseBarCodeList(); + + + + } } diff --git a/SlnMesnac.Repository/service/Impl/MesBaseBarcodeInfoServiceImpl.cs b/SlnMesnac.Repository/service/Impl/MesBaseBarcodeInfoServiceImpl.cs new file mode 100644 index 0000000..12c4c25 --- /dev/null +++ b/SlnMesnac.Repository/service/Impl/MesBaseBarcodeInfoServiceImpl.cs @@ -0,0 +1,37 @@ +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; +using System; +using System.Collections.Generic; +using System.Text; + +#region << 版 本 注 释 >> +/*-------------------------------------------------------------------- +* 版权所有 (c) 2024 WenJY 保留所有权利。 +* CLR版本:4.0.30319.42000 +* 机器名称:LAPTOP-E0N2L34V +* 命名空间:SlnMesnac.Repository.service.Impl +* 唯一标识:d439bf21-2c36-42dd-8f56-3d22411df57a +* +* 创建者:WenJY +* 电子邮箱:wenjy@mesnac.com +* 创建时间:2024-04-08 10:34:17 +* 版本:V1.0.0 +* 描述: +* +*-------------------------------------------------------------------- +* 修改人: +* 时间: +* 修改说明: +* +* 版本:V1.0.0 +*--------------------------------------------------------------------*/ +#endregion << 版 本 注 释 >> +namespace SlnMesnac.Repository.service.Impl +{ + public class MesBaseBarcodeInfoServiceImpl : BaseServiceImpl, IMesBaseBarcodeInfoService + { + public MesBaseBarcodeInfoServiceImpl(Repository rep) : base(rep) + { + } + } +} diff --git a/SlnMesnac.Repository/service/Impl/MesPrdBarCodeServiceImpl.cs b/SlnMesnac.Repository/service/Impl/MesPrdBarCodeServiceImpl.cs index a8abea9..77aa330 100644 --- a/SlnMesnac.Repository/service/Impl/MesPrdBarCodeServiceImpl.cs +++ b/SlnMesnac.Repository/service/Impl/MesPrdBarCodeServiceImpl.cs @@ -67,6 +67,28 @@ namespace SlnMesnac.Repository.service.Impl } } + /// + /// 查询前四十条已经喷印未绑定条码 + /// + /// + /// + /// + public List GetUseBarCodeList() + { + List list = null; + try + { + string sql = "select * from mes_prd_barcode_info where print_flag ='1' and pallet_info_code is null order by print_time limit 40;"; + list = _rep.Context.Ado.SqlQuery(sql); + return list; + }catch (Exception e) + { + throw new InvalidOperationException($"查询小条码队列信息异常:{e.Message}"); + } + } + + + /// /// 移除条码队列 /// diff --git a/SlnMesnac.WPF/Startup.cs b/SlnMesnac.WPF/Startup.cs index 57074a8..c0aae3a 100644 --- a/SlnMesnac.WPF/Startup.cs +++ b/SlnMesnac.WPF/Startup.cs @@ -9,6 +9,7 @@ using Autofac; using Microsoft.Extensions.Configuration; using SlnMesnac.Ioc; using SlnMesnac.Extensions; +using SlnMesnac.Generate; namespace SlnMesnac.WPF { @@ -36,6 +37,10 @@ namespace SlnMesnac.WPF }); + + services.AddSingleton(); + + //ORM services.AddSqlSugarSetup(); @@ -64,10 +69,10 @@ namespace SlnMesnac.WPF /// public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - //if (env.IsDevelopment()) - //{ - // app.UseDeveloperExceptionPage(); - //} + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } //启用Serilog中间件 app.UseSerilogExtensions(); diff --git a/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs b/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs index d76505a..68f05f0 100644 --- a/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs @@ -170,7 +170,7 @@ namespace SlnMesnac.WPF.ViewModel public ProdMgmtViewModel() { - test(); + StartProdPlanCommand = new RelayCommand(obj => StartProdPlan(obj)); StopProdPlanCommand = new RelayCommand(obj => StopProdPlan(obj)); _logger = App.ServiceProvider.GetService>(); diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json index b2627a8..345fe2f 100644 --- a/SlnMesnac.WPF/appsettings.json +++ b/SlnMesnac.WPF/appsettings.json @@ -55,11 +55,20 @@ ], "RfidConfig": [ { + // 小包码垛位RFID "configId": 1, "equipIp": "192.168.2.27", "equipPort": 20108, - "equipKey": "test", - "isFlage": true + "equipKey": "secondFloorPallet", + "isFlage": false + }, + { + // 小包出口位RFID + "configId": 2, + "equipIp": "192.168.2.28", + "equipPort": 20108, + "equipKey": "secondFloorOut", + "isFlage": false } ] //"redisConfig": "175.27.215.92:6379,password=redis@2023"