From 352c4922f79ce26bd4ef46ce4531c0a62d5dae08 Mon Sep 17 00:00:00 2001 From: liuyunfeng Date: Fri, 3 Nov 2023 17:34:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8F=92=E5=85=A5M100?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/ExtMethod.cs | 23 ++++ .../Services/M100CheckDomainService.cs | 35 +++-- .../MsgCheck/Services/M100DomainService.cs | 130 +++++++++++++++--- 3 files changed, 158 insertions(+), 30 deletions(-) diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs index d9ce666..cebe326 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs @@ -95,6 +95,17 @@ namespace WY.NewJit.Common } } + public static int TryToIntNotNull(this int? p_obj) + { + if (p_obj == null) + { + throw new ArgumentNullException(nameof(p_obj)); + } + return (int)p_obj; + } + + + public static double? TryToDouble(this object p_obj) { string str = p_obj.ToString(); @@ -305,6 +316,18 @@ namespace WY.NewJit.Common return false; } + //public static string Left(this string param, int length) + //{ + // string result = param.Substring(0, length); + // return result; + //} + + //public static string Right(this string param, int length) + //{ + // string result = param.Substring(param.Length - length, length); + // return result; + //} + } public class ExtCvt diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs index 5247275..e8c3f3b 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs @@ -84,6 +84,7 @@ namespace WY.NewJit.MsgCheck /// 零件配置 /// private readonly IRepository _partCfgRepository; + private readonly M100DomainService _m100DomainService; /// @@ -173,7 +174,8 @@ namespace WY.NewJit.MsgCheck Microsoft.Extensions.Configuration.IConfiguration configuration, INewJitDapperRepository newJitDapperRepository, IRepository assemblyCfgVehicleRepository, - IRepository partCfgRepository + IRepository partCfgRepository, + M100DomainService m100DomainService ) { _billM100Repository = billM100Repository; @@ -187,6 +189,7 @@ namespace WY.NewJit.MsgCheck _newJitDapperRepository = newJitDapperRepository; _assemblyCfgVehicleRepository = assemblyCfgVehicleRepository; _partCfgRepository = partCfgRepository; + _m100DomainService = m100DomainService; } #region 公共方法 @@ -338,7 +341,8 @@ namespace WY.NewJit.MsgCheck //更新单据表 m100Bill.SetAssemblyID(null); m100Bill.SetBillStatus(BillStatusEnum.NotMatch); - var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + //var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + var succObj1 = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult(); //不匹配时,插入未知总成 var succObj2 = InsertUnknownAssembly(m100Bill); @@ -392,7 +396,8 @@ namespace WY.NewJit.MsgCheck foreach (BillM100 canNotPrintObj in canNotPrintLst) { canNotPrintObj.CanNotPrint = true; - _billM100Repository.UpdateAsync(canNotPrintObj, true).GetAwaiter().GetResult(); + //_billM100Repository.UpdateAsync(canNotPrintObj, true).GetAwaiter().GetResult(); + _m100DomainService.UpdateM100(canNotPrintObj, true).GetAwaiter().GetResult(); } #endregion @@ -478,7 +483,8 @@ namespace WY.NewJit.MsgCheck if (hasPrintData) //该单据处于未解析时,已经打印 { m100Obj.NeedReplenishPrint = 1; - _billM100Repository.UpdateAsync(m100Obj, true).GetAwaiter().GetResult(); + //_billM100Repository.UpdateAsync(m100Obj, true).GetAwaiter().GetResult(); + _m100DomainService.UpdateM100(m100Obj, true).GetAwaiter().GetResult(); } #endregion @@ -490,7 +496,8 @@ namespace WY.NewJit.MsgCheck //更新单据表 m100Bill.SetAssemblyID(null); m100Bill.SetBillStatus(BillStatusEnum.NotMatch); - var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + //var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + var succObj1 = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult(); //不匹配时,插入未知总成 var succObj2 = InsertUnknownAssembly(m100Bill); @@ -535,16 +542,19 @@ namespace WY.NewJit.MsgCheck { if (isUnknowAssembly) { - succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); + //succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); + succObj = _m100DomainService.UpdateM100(m100Bill).GetAwaiter().GetResult(); } else { - succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); + //succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); + succObj = _m100DomainService.UpdateM100(m100Bill, true).GetAwaiter().GetResult(); } } else { - succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + //succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + succObj = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult(); } if (succObj == null) @@ -596,16 +606,19 @@ namespace WY.NewJit.MsgCheck { if (isUnknowAssembly) { - succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); + //succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); + succObj = _m100DomainService.UpdateM100(m100Bill).GetAwaiter().GetResult(); } else { - succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); + //succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); + succObj = _m100DomainService.UpdateM100(m100Bill, true).GetAwaiter().GetResult(); } } else { - succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + //succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + succObj = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult(); } if (succObj == null) diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100DomainService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100DomainService.cs index 39c0bf1..71446de 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100DomainService.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100DomainService.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; using WY.NewJit.PrintTable; +using WY.NewJit.Common; namespace WY.NewJit.MsgCheck { @@ -27,49 +28,118 @@ namespace WY.NewJit.MsgCheck /// private readonly IRepository _waitPrintRepository; + private readonly BillNumberRecordDomainService _billNumRecDomainSrv; + public M100DomainService( IRepository billM100Repository, ILogger logger, - IRepository waitPrintRepository + IRepository waitPrintRepository, + BillNumberRecordDomainService billNumRecDomainSrv ) { _billM100Repository = billM100Repository; _logger = logger; _waitPrintRepository = waitPrintRepository; + _billNumRecDomainSrv = billNumRecDomainSrv; } - public async Task InsertM100(BillM100 m100Obj, bool autoSave = false) + public async Task InsertM100(BillM100 m100Obj, bool autoSave = false) { - //处理断号:由生成HostSN方法提供断号数据 + //调用HostSN2方法 + BillNumberRecord billNumRec = await _billNumRecDomainSrv.GetBillNumber(m100Obj.HostSN.TryToIntNotNull(), m100Obj.ProductLine); + var normalObj = billNumRec.dic.FirstOrDefault(itm => itm.Value == BillNumberTypeEnum.正常); + var lateObj = billNumRec.dic.FirstOrDefault(itm => itm.Value == BillNumberTypeEnum.迟到); + var breaknumLst = billNumRec.dic.Where(itm => itm.Value == BillNumberTypeEnum.断号).ToList(); + //更新M100 + m100Obj.HostSN2 = normalObj.Key.TryToInt(); + //M100转换成WaitPrint:一个底盘、08产线插入3条记录,其它产线插入1条记录 + WaitPrint[] wpArr; + if (m100Obj.ProductLine == "08") + { + WaitPrint mbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.MenBan); + WaitPrint zhbOtherRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.OtherZhuHuBan); + WaitPrint zhbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.ZhuHuBan); + wpArr = new WaitPrint[3] { mbRec, zhbOtherRec, zhbRec }; + } + else + { + WaitPrint mbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.MenBan); + wpArr = new WaitPrint[1] { mbRec }; + } - var m100Ret = await _billM100Repository.InsertAsync(m100Obj, autoSave); - if (m100Ret != null) + //处理断号 + if (breaknumLst.Count > 0) { - if (m100Obj.ProductLine == "08") + List breakNumLst = new List(); + foreach (var sourceWaitPrint in wpArr) { - WaitPrint mbRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan); - WaitPrint zhbOtherRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.OtherZhuHuBan); - WaitPrint zhbRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.ZhuHuBan); - WaitPrint[] arr = new WaitPrint[3] { mbRec, zhbOtherRec, zhbRec }; - await _waitPrintRepository.InsertManyAsync(arr); + foreach (var breaknum in breaknumLst) + { + WaitPrint targetWaitPrint = new WaitPrint(GuidGenerator.Create()); + targetWaitPrint.M100Id = Guid.Parse("00000000-0000-0000-0000-000000000000"); + targetWaitPrint.BusinessType = sourceWaitPrint.BusinessType; + targetWaitPrint.ProductLine = sourceWaitPrint.ProductLine; + targetWaitPrint.OnlineTime = sourceWaitPrint.OnlineTime; + targetWaitPrint.HostSN = breaknum.ToString().Right(5).TryToIntZero(); + targetWaitPrint.KNR = null; + targetWaitPrint.VIN = null; + targetWaitPrint.VehicleModelCode = null; + targetWaitPrint.AssemblyID = null; + targetWaitPrint.BillStatus = BillStatusEnum.BreakNum; + targetWaitPrint.PrintType = PrintTypeEnum.OrderPrint; + targetWaitPrint.HostSN2 = breaknum.Key.TryToIntZero(); + targetWaitPrint.Description = null; + targetWaitPrint.ReceiveTime = null; + targetWaitPrint.CreationTime = null; + targetWaitPrint.CreatorId = null; + targetWaitPrint.LastModificationTime = null; + targetWaitPrint.LastModifierId = null; + breakNumLst.Add(targetWaitPrint); + } } - else + await _waitPrintRepository.InsertManyAsync(breakNumLst, autoSave); //插入断号 + } + //处理正常、迟到 + BillM100 m100Ret = null; + if (normalObj.Key != null) //正常 + { + m100Ret = await _billM100Repository.InsertAsync(m100Obj, autoSave); //插入M100 + await _waitPrintRepository.InsertManyAsync(wpArr, autoSave); //插入未打印表 + } + else if (lateObj.Key != null) //迟到 + { + m100Ret = await _billM100Repository.InsertAsync(m100Obj, autoSave); //插入M100 + + foreach (var item in wpArr) { - WaitPrint mbRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan); - await _waitPrintRepository.InsertAsync(mbRec); + var insObj = await _waitPrintRepository.FirstOrDefaultAsync(itm => + itm.HostSN2 == m100Obj.HostSN2 + && itm.BillStatus == BillStatusEnum.BreakNum + && itm.BusinessType == item.BusinessType); + if (insObj != null) + { + //如果未打印表有对应断号记录,将迟到记录与之合并 + Set_WaitPrint(item, insObj); + var updateRet = await _waitPrintRepository.UpdateAsync(insObj); + } + else + { + //如果未打印表没有----对应断号记录,则插入 + var insertRet = await _waitPrintRepository.InsertAsync(item, autoSave); + } } - return true; } - return false; + return m100Ret; } - public async Task UpdateM100(BillM100 m100Obj, bool autoSave = false) + public async Task UpdateM100(BillM100 m100Obj, bool autoSave = false) { var m100Ret = await _billM100Repository.UpdateAsync(m100Obj, autoSave); if (m100Ret != null) { if (m100Obj.ProductLine == "08") { + //更新已解析状态时,只涉及门板记录 WaitPrint mbRec = await _waitPrintRepository.GetAsync(itm => itm.M100Id == m100Ret.Id && itm.BusinessType == BusinessTypeEnum.MenBan); ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan, mbRec); await _waitPrintRepository.UpdateAsync(mbRec); @@ -80,9 +150,9 @@ namespace WY.NewJit.MsgCheck ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan, mbRec); await _waitPrintRepository.UpdateAsync(mbRec); } - return true; + return m100Ret; } - return false; + return null; } private WaitPrint ConvertWaitPrint(BillM100 m100Ret, BusinessTypeEnum businessType) @@ -121,5 +191,27 @@ namespace WY.NewJit.MsgCheck waitPrint.LastModifierId = m100Ret.LastModifierId; } + private void Set_WaitPrint(WaitPrint sourceWaitPrint, WaitPrint targetWaitPrint) + { + targetWaitPrint.M100Id = sourceWaitPrint.M100Id; + targetWaitPrint.BusinessType = sourceWaitPrint.BusinessType; + targetWaitPrint.ProductLine = sourceWaitPrint.ProductLine; + targetWaitPrint.OnlineTime = sourceWaitPrint.OnlineTime; + targetWaitPrint.HostSN = sourceWaitPrint.HostSN; + targetWaitPrint.KNR = sourceWaitPrint.KNR; + targetWaitPrint.VIN = sourceWaitPrint.VIN; + targetWaitPrint.VehicleModelCode = sourceWaitPrint.VehicleModelCode; + targetWaitPrint.AssemblyID = sourceWaitPrint.AssemblyID; + targetWaitPrint.BillStatus = sourceWaitPrint.BillStatus; + targetWaitPrint.PrintType = sourceWaitPrint.PrintType; + targetWaitPrint.HostSN2 = sourceWaitPrint.HostSN2; + targetWaitPrint.Description = sourceWaitPrint.Description; + targetWaitPrint.ReceiveTime = sourceWaitPrint.ReceiveTime; + targetWaitPrint.CreationTime = sourceWaitPrint.CreationTime; + targetWaitPrint.CreatorId = sourceWaitPrint.CreatorId; + targetWaitPrint.LastModificationTime = sourceWaitPrint.LastModificationTime; + targetWaitPrint.LastModifierId = sourceWaitPrint.LastModifierId; + } + } }