From 96b02595e833c1273a5c6ea787cec6a46f54f4fc Mon Sep 17 00:00:00 2001 From: mahao Date: Mon, 28 Aug 2023 11:54:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=94=E5=AF=B9=E5=90=8E=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=9C=89=E5=8F=91=E8=BF=90=E7=9A=84=E7=BB=93=E7=AE=97=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reports/JisBBACEidSeCompareReport.cs | 2 +- .../JisBBACSeEdiCompareExportService.cs | 4 +- .../JisHBPOSeEdiCompareExportService.cs | 6 ++- .../Report/PubSaSeCompareExportService.cs | 48 +++--------------- .../Report/SaSeCompareExportBaseService.cs | 50 +++++++++++++++++-- 5 files changed, 61 insertions(+), 49 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs index 726826db..b1bc1d92 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs @@ -13,7 +13,7 @@ public class JisBBACEidSeCompareReport } /// -/// JisBBAC Edi与发运对比导出 +/// JisBBAC Edi、发运对比导出 /// [ExcelExporter(MaxRowNumberOnASheet = 900000)] public class JisBBACEidSeCompareExport diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs index ceb05122..03accd57 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs @@ -75,9 +75,11 @@ namespace SettleAccount.Job.Services.Report LineStationcode = default, SequenceNumber = t.Max(t => t.SeqNumber), ParType = "01", + PN = t.Key.PN, + MaterialNumber = t.Key.LU, EdiQty = t.Sum(t => t.Qty), AssemblyDate = default, - MatchNumber = t.Key.LU, + MatchNumber = default, MateType = "否", DiffDesc = "WMS漏发货EDI有订单" }).ToList(); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs index 62dc32b3..4becd7db 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs @@ -72,9 +72,11 @@ namespace SettleAccount.Job.Services.Report LineStationcode = default, SequenceNumber = t.Max(t => t.SeqNumber), ParType = "01", + PN = t.Key.PN, + MaterialNumber = t.Key.LU, EdiQty = t.Sum(t => t.Qty), AssemblyDate = default, - MatchNumber = t.Key.LU, + MatchNumber = default, MateType = "否", DiffDesc = "WMS漏发货EDI有订单" }).ToList(); @@ -159,7 +161,9 @@ namespace SettleAccount.Job.Services.Report }).ToList(); haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList); + haveEdiNotHaveSeList.Reverse(); notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList); + notHaveEdiHaveSeList.Reverse(); ExcelExporter excelExporter = new ExcelExporter(); excelExporter diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs index 38ab4539..955faec2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using EFCore.BulkExtensions; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.SignalR; using Microsoft.OpenApi.Extensions; @@ -85,7 +86,7 @@ namespace SettleAccount.Job.Services.Report /// public string ExportFile(Guid id, List exportName, List property) { - var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value; + var version = int.Parse(property.Where(p => p.Name == "Version").FirstOrDefault().Value); var strBusinessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value; var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value; var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value; @@ -101,7 +102,7 @@ namespace SettleAccount.Job.Services.Report } var filename = exportName.FirstOrDefault(); //var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime); - var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, int.Parse(version), DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime)); + var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, version, DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime)); HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); @@ -117,48 +118,11 @@ namespace SettleAccount.Job.Services.Report //二次对比比对上的数据入库 var pubSeCDetailEntitys = _objectMapper.Map, List>(secondMatchHaveSaHaveSes); _settleAccountDbContext.Set().AddRange(pubSeCDetailEntitys); - //_pubSeCDetailRepository.InsertManyAsync(pubSeCDetailEntitys); } + #endregion - //var haveSaNotHaveSeFPartCodePNs = haveSaNotHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN }); - //var notHaveSaHaveSeFPartCodePNs = notHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN }); - ////二次匹配 匹配上的厂内零件号、PN - //var secondMatchFPartCodePNs = haveSaNotHaveSeFPartCodePNs.Intersect(notHaveSaHaveSeFPartCodePNs); - //if (secondMatchFPartCodePNs.Any() == true) - //{ - // pubSaSeCompareDiffs.RemoveAll(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN })); - - // foreach (var secondMatchFPartCodePN in secondMatchFPartCodePNs) - // { - // var haveSaNotHaveSe = haveSaNotHaveSes.FirstOrDefault(t => t.ReplaceFactoryPartCode == secondMatchFPartCodePN.ReplaceFactoryPartCode && t.PN == secondMatchFPartCodePN.PN); - // var notHaveSaHaveSe = notHaveSaHaveSes.FirstOrDefault(t => t.ReplaceFactoryPartCode == secondMatchFPartCodePN.ReplaceFactoryPartCode && t.PN == secondMatchFPartCodePN.PN); - // if (haveSaNotHaveSe != null && notHaveSaHaveSe != null) - // { - - // } - // secondMatchHaveSaHaveSes.Add(new PubSaSeCompareDiff() - // { - // WmsBillNum = notHaveSaHaveSe.WmsBillNum, - // ShippingDate = notHaveSaHaveSe.ShippingDate, - // SeqNumber = notHaveSaHaveSe.SeqNumber, - // PJISSeqNumber = notHaveSaHaveSe.PJISSeqNumber, - // MaterialNumber = haveSaNotHaveSe.MaterialNumber, - // MaterialDes = haveSaNotHaveSe.MaterialDes, - // CustomerOfflineTime = haveSaNotHaveSe.CustomerOfflineTime, - // SAQty = haveSaNotHaveSe.SAQty, - // SEQty = notHaveSaHaveSe.SEQty, - // MateType = haveSaNotHaveSe.MateType, - // FixPrice = haveSaNotHaveSe.FixPrice, - // PrimitiveLU = haveSaNotHaveSe.PrimitiveLU, - // ReplaceLU = haveSaNotHaveSe.ReplaceLU, - // SeLU = notHaveSaHaveSe.SeLU, - // SaLU = haveSaNotHaveSe.SaLU, - // PN = haveSaNotHaveSe.PN, - // Category = EnumPubSaSeCompareCategory.HaveSaHaveSe, - // IsRemove = false - // }); - // } - //} + #region 结算数据处理 + HandlSaDetails(pubSaSeCompareDiffs, businessType, version); #endregion if (string.IsNullOrEmpty(lu) == false) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs index e6b21b93..16078d6a 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using EFCore.BulkExtensions; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.SignalR; using SettleAccount.Domain.BQ; @@ -76,18 +77,20 @@ namespace SettleAccount.Job.Services.Report { //二次匹配上的记录 var secondMatchHaveSaHaveSes = new List(); + //有结算无发运 和 无结算有发运 + var haveSaNotHaveSeUnionNotHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe || t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); //有结算无发运 var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); //无结算有发运 var notHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); - //二次对比(替换无结算有发运数据的厂内零件号) - var repFactoryPartCodes = notHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList(); - var tbRePartsRelationships = _settleAccountDbContext.Set().Where(t => repFactoryPartCodes.Contains(t.LU) && t.BusinessType == businessType).ToList(); + //二次对比(替换发运数据的厂内零件号) + var repFactoryPartCodes = haveSaNotHaveSeUnionNotHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList(); + var tbRePartsRelationships = _settleAccountDbContext.Set().Where(t => repFactoryPartCodes.Contains(t.LU)).ToList(); tbRePartsRelationships.ForEach(tbRePartsRelationship => { - notHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t => + haveSaNotHaveSeUnionNotHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t => { t.ReplaceFactoryPartCode = tbRePartsRelationship.RepLU; }); @@ -123,6 +126,45 @@ namespace SettleAccount.Job.Services.Report return secondMatchHaveSaHaveSes; } + /// + /// 结算数据处理 + /// 写入库位、替换零件号 + /// + public virtual void HandlSaDetails(List pubSaSeCompareDiffs, EnumBusinessType businessType, int version) + { + //写入库位、替换零件号 + var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); + if (haveSaHaveSes.Any()) + { + var canSaDetails = (from sa in _settleAccountDbContext.Set() + where sa.BusinessType == businessType && sa.Version == version + select sa).ToList(); + if (canSaDetails.Any()) + { + var canSaDetailsUpdate = canSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) => + { + o.ErpLoc = i.ToErpLocCode; + o.RealPartCode = i.ReplaceFactoryPartCode; + return o; + }).ToList(); + _settleAccountDbContext.BulkUpdate(canSaDetailsUpdate); + } + var notSaDetails = (from sa in _settleAccountDbContext.Set() + where sa.BusinessType == businessType && sa.Version == version + select sa).ToList(); + if (notSaDetails.Any()) + { + var notSaDetailsUpdate = notSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) => + { + o.ErpLoc = i.ToErpLocCode; + o.RealPartCode = i.ReplaceFactoryPartCode; + return o; + }).ToList(); + _settleAccountDbContext.BulkUpdate(notSaDetailsUpdate); + } + } + } + /// /// 创建导出文件结构 ///