diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/MenBanPackingRecService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/MenBanPackingRecService.cs index 6b3fb37..a733982 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/MenBanPackingRecService.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/MenBanPackingRecService.cs @@ -344,20 +344,25 @@ namespace Win.Sfs.SettleAccount.FISes var alreadyPrintIdLst = mbRecLst.Select(p => p.M100BillId).Distinct().ToList(); //未打印\已打印表id列表 var _apList = await _alreadyPrintRepository.Where(p => alreadyPrintIdLst.Contains(p.Id)).ToListAsync(); List _wpList = new List(); - foreach (var alreadyPrint in _apList) //遍历已打印表 + foreach (var alreadyPrintItem in _apList) //遍历已打印表 { - var waitPrintLst = await _waitPrintRepository.GetListAsync(r => r.HostSN2 == alreadyPrint.HostSN2 && r.BusinessType == alreadyPrint.BusinessType); + if (alreadyPrintItem.HostSN2 == 0) + { + throw new BusinessException("1001", $"批量导入断号的报文HostSN2=0,不能报废!"); + } + var waitPrintLst = await _waitPrintRepository.GetListAsync(r => r.HostSN2 == alreadyPrintItem.HostSN2 && r.BusinessType == alreadyPrintItem.BusinessType); if (waitPrintLst.Count == 0) //未打印表没有(对应已打印表)记录 { - var wp = ObjectMapper.Map(alreadyPrint); + var wp = ObjectMapper.Map(alreadyPrintItem); _wpList.Add(wp); } else if(waitPrintLst.Count == 1) //未打印表有一条记录 { - if (alreadyPrint.BillStatus == BillStatusEnum.BreakNum && waitPrintLst[0].BillStatus == BillStatusEnum.BreakNum) + if (alreadyPrintItem.BillStatus == BillStatusEnum.BreakNum && waitPrintLst[0].BillStatus == BillStatusEnum.BreakNum) { - throw new BusinessException("1001", "未打印列表和已打印列表出现都是断号的情况号码未【" + alreadyPrint.HostSN2 + "】,不能报废!"); + throw new BusinessException("1001", "未打印列表和已打印列表出现都是断号的情况号码未【" + alreadyPrintItem.HostSN2 + "】,不能报废!"); } + //未打印有一条补打的记录,忽略已打印的对应记录,将未打印记录的补打状态改成顺序打印状态 if (waitPrintLst[0].PrintType == WY.NewJit.PrintTable.PrintTypeEnum.ReplenishPrint) { waitPrintLst[0].PrintType = WY.NewJit.PrintTable.PrintTypeEnum.OrderPrint; @@ -366,7 +371,7 @@ namespace Win.Sfs.SettleAccount.FISes } else if (waitPrintLst.Count > 1) { - throw new BusinessException("1001", "未打印列表里出现大众顺序号重复号码为【"+ alreadyPrint.HostSN2+ "】请检查后在报废!"); + throw new BusinessException("1001", "未打印列表里出现大众顺序号重复号码为【"+ alreadyPrintItem.HostSN2+ "】请检查后在报废!"); } } await _alreadyPrintRepository.DeleteManyAsync(_apList); diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/ZhuHuBanPackingRecService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/ZhuHuBanPackingRecService.cs index 1dc33a1..54f364c 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/ZhuHuBanPackingRecService.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/ZhuHuBanPackingRecService.cs @@ -377,27 +377,37 @@ namespace Win.Sfs.SettleAccount.FISes ////await _zHBPrintStatusRepository.DeleteAsync(r => vins.Contains(r.VIN) && r.GroupName == groupName.GroupName); #region 删除已打印表、插入未打印表 var zhbRecLst = await _ZhuHuBanPackingListRepository.Where(p => idList.Contains(p.Id)).SelectMany(p => p.Details).ToListAsync(); - var alreadyPrintIdLst = zhbRecLst.Select(p => p.M100BillId).Distinct().ToList(); //未打印\已打印表id列表 + var alreadyPrintIdLst = zhbRecLst.Select(p => p.M100BillId).Distinct().ToList(); //ZhuHuBanPackingList.M100BillId对应 未打印\已打印表的id var _apList = await _alreadyPrintRepository.Where(p => alreadyPrintIdLst.Contains(p.Id)).ToListAsync(); List _wpList = new List(); - foreach (var ap in _apList) //遍历已打印表 + foreach (var alreadyPrintItem in _apList) //遍历已打印表 { - var waitPrintLst = await _waitPrintRepository.GetListAsync(r => r.HostSN2 == ap.HostSN2 && r.BusinessType == ap.BusinessType); + if (alreadyPrintItem.HostSN2 == 0) + { + throw new BusinessException("1001", $"批量导入断号的报文HostSN2=0,不能报废!"); + } + var waitPrintLst = await _waitPrintRepository.GetListAsync(r => r.HostSN2 == alreadyPrintItem.HostSN2 && r.BusinessType == alreadyPrintItem.BusinessType); if (waitPrintLst.Count == 0) //未打印表没有(对应已打印表)记录 { - var wp = ObjectMapper.Map(ap); + var wp = ObjectMapper.Map(alreadyPrintItem); _wpList.Add(wp); } else if (waitPrintLst.Count == 1) //未打印表有一条记录 { - if (ap.BillStatus == BillStatusEnum.BreakNum && waitPrintLst[0].BillStatus == BillStatusEnum.BreakNum) + if (alreadyPrintItem.BillStatus == BillStatusEnum.BreakNum && waitPrintLst[0].BillStatus == BillStatusEnum.BreakNum) + { + throw new BusinessException("1001", "未打印列表和已打印列表出现都是断号的情况号码未【" + alreadyPrintItem.HostSN2 + "】,不能报废!"); + } + //未打印有一条补打的记录,忽略已打印的对应记录,将未打印记录的补打状态改成顺序打印状态 + if (waitPrintLst[0].PrintType == WY.NewJit.PrintTable.PrintTypeEnum.ReplenishPrint) { - throw new BusinessException("1001", "未打印列表和已打印列表出现都是断号的情况号码未【" + ap.HostSN2 + "】,不能报废!"); + waitPrintLst[0].PrintType = WY.NewJit.PrintTable.PrintTypeEnum.OrderPrint; + await _waitPrintRepository.UpdateAsync(waitPrintLst[0]); } } else if (waitPrintLst.Count > 1) { - throw new BusinessException("1001", "未打印列表里出现大众顺序号重复号码为【" + ap.HostSN2 + "】请检查后在报废!"); + throw new BusinessException("1001", "未打印列表里出现大众顺序号重复号码为【" + alreadyPrintItem.HostSN2 + "】请检查后在报废!"); } } await _alreadyPrintRepository.DeleteManyAsync(_apList); 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 2ea9ab4..ae989ed 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 @@ -342,7 +342,7 @@ namespace WY.NewJit.MsgCheck m100Bill.SetAssemblyID(null); m100Bill.SetBillStatus(BillStatusEnum.NotMatch); //var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); - var succObj1 = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult(); + var succObj1 = _m100DomainService.InsertM100(m100Bill, true, true).GetAwaiter().GetResult(); //不匹配时,插入未知总成 var succObj2 = InsertUnknownAssembly(m100Bill); 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 c91e8b2..758b74c 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 @@ -46,38 +46,34 @@ namespace WY.NewJit.MsgCheck public async Task InsertM100(BillM100 m100Obj, bool autoSave = false, bool isBatchImportBreakNum = false) { BillM100 m100Ret = null; - //调用HostSN2方法 - BillNumberRecord billNumRec = await _billNumRecDomainSrv.GetBillNumber(m100Obj.HostSN.TryToIntNotNull(), m100Obj.ProductLine); - var normalObj = billNumRec.Datas.FirstOrDefault(itm => itm.BillNumberType == BillNumberTypeEnum.正常); - var lateObj = billNumRec.Datas.FirstOrDefault(itm => itm.BillNumberType == BillNumberTypeEnum.迟到); - var breakNumLst = billNumRec.Datas.Where(itm => itm.BillNumberType == BillNumberTypeEnum.断号).ToList(); - //更新M100 - m100Obj.HostSN2 = normalObj != null ? normalObj.HostSN2 : lateObj.HostSN2; - //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.AC_ZhuHuBan); - wpArr = new WaitPrint[3] { mbRec, zhbOtherRec, zhbRec }; - } - else - { - WaitPrint mbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.MenBan); - wpArr = new WaitPrint[1] { mbRec }; - } + if (isBatchImportBreakNum) //批量导入断号模块调用 { - foreach (var wp in wpArr) + //更新M100 + m100Obj.HostSN2 = 0; + //M100转换成WaitPrint:一个底盘、08产线插入3条记录,其它产线插入1条记录 + WaitPrint[] wpArr2 = M100ConvertToWaitPrint(m100Obj); + + foreach (var wp in wpArr2) { wp.PrintType = PrintTypeEnum.ReplenishPrint; + //wp.HostSN2 = 0; //WaitPrint的HostSN2从m100的HostSN2取值 } m100Ret = await _billM100Repository.InsertAsync(m100Obj, autoSave); //插入M100 - await _waitPrintRepository.InsertManyAsync(wpArr, autoSave); //插入未打印表 + await _waitPrintRepository.InsertManyAsync(wpArr2, autoSave); //插入未打印表 return m100Ret; } + //调用HostSN2方法 + BillNumberRecord billNumRec = await _billNumRecDomainSrv.GetBillNumber(m100Obj.HostSN.TryToIntNotNull(), m100Obj.ProductLine); + var normalObj = billNumRec.Datas.FirstOrDefault(itm => itm.BillNumberType == BillNumberTypeEnum.正常); + var lateObj = billNumRec.Datas.FirstOrDefault(itm => itm.BillNumberType == BillNumberTypeEnum.迟到); + var breakNumLst = billNumRec.Datas.Where(itm => itm.BillNumberType == BillNumberTypeEnum.断号).ToList(); + //更新M100 + m100Obj.HostSN2 = normalObj != null ? normalObj.HostSN2 : lateObj.HostSN2; + //M100转换成WaitPrint:一个底盘、08产线插入3条记录,其它产线插入1条记录 + WaitPrint[] wpArr = M100ConvertToWaitPrint(m100Obj); + //处理断号 if (breakNumLst.Count > 0) { @@ -122,9 +118,9 @@ namespace WY.NewJit.MsgCheck foreach (var item in wpArr) //遍历门板、柱护板、其它柱护板 { - var insObj = await _waitPrintRepository.FirstOrDefaultAsync(itm => - itm.HostSN2 == m100Obj.HostSN2 - && itm.BillStatus == BillStatusEnum.BreakNum + var insObj = await _waitPrintRepository.FirstOrDefaultAsync(itm => + itm.HostSN2 == m100Obj.HostSN2 + && itm.BillStatus == BillStatusEnum.BreakNum && itm.BusinessType == item.BusinessType); if (insObj != null) { @@ -143,6 +139,25 @@ namespace WY.NewJit.MsgCheck return m100Ret; } + private WaitPrint[] M100ConvertToWaitPrint(BillM100 m100Obj) + { + WaitPrint[] wpArr; + if (m100Obj.ProductLine == "08") + { + WaitPrint mbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.MenBan); + WaitPrint zhbOtherRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.OtherZhuHuBan); + WaitPrint zhbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.AC_ZhuHuBan); + wpArr = new WaitPrint[3] { mbRec, zhbOtherRec, zhbRec }; + } + else + { + WaitPrint mbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.MenBan); + wpArr = new WaitPrint[1] { mbRec }; + } + + return wpArr; + } + public async Task UpdateM100(BillM100 m100Obj, bool autoSave = false) { var m100Ret = await _billM100Repository.UpdateAsync(m100Obj, autoSave);