From febaa64623e0b7ee7fdc63f9770cb6f8c2a765e3 Mon Sep 17 00:00:00 2001 From: mahao Date: Mon, 28 Aug 2023 09:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BQ/Syncs/JisBBACSeEdiCompareAppService.cs | 25 -- .../BQ/Syncs/JisHBPOSeEdiCompareAppService.cs | 18 +- .../BQ/Syncs/JisHBPOSeSyncBaseAppService.cs | 2 +- .../Reports/SaSeEdiCompareDiff.cs | 216 +++++++++++++++++- .../JisBBACSaSeEdiCompareExportService.cs | 93 +++++--- .../JisBBACSeEdiCompareExportService.cs | 16 +- .../JisHBPOSaSeEdiCompareExportService.cs | 97 +++++--- .../JisHBPOSeEdiCompareExportService.cs | 12 +- .../Report/SaSeEdiCompareExportBaseService.cs | 2 - 9 files changed, 367 insertions(+), 114 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs index 1837942f..ca0d4489 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs @@ -69,31 +69,6 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable db.BulkUpdate(ediDetails); } db.SaveChanges(); - - //var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU }).Take(1000).ToList(); - //if (keyCodes.Any()) - //{ - // var pnLus = keyCodes.GroupBy(t => t.PN).Select(t => new { t.Key, Lus = t.Where(p => p.PN == t.Key).Select(t => t.LU) }); - - // pnLus.ForEach(pnLu => - // { - // var pn = pnLu.Key; - // var lus = pnLu.Lus; - // var seDetails = db.Set().Where(t => t.PN == pn && lus.Contains(t.CustomerPartCodeNoSpace)); - // var ediDetails = db.Set().Where(t => t.PN == pn && lus.Contains(t.LU)); - // if (seDetails.Any()) - // { - // seDetails.ForEach(t => t.IsHaveEdiData = true); - // db.Set().UpdateRange(seDetails); - // } - // if (ediDetails.Any()) - // { - // ediDetails.ForEach(t => t.IsHaveSeData = true); - // db.Set().UpdateRange(ediDetails); - // } - // }); - // db.SaveChanges(); - //} } } catch (Exception) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs index 20da8e47..d9fe5bb5 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using SettleAccount.Domain.BQ; using Volo.Abp.Application.Services; +using Volo.Abp.Uow; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; @@ -28,19 +29,25 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable /// HBPO发运数据仓储 /// private readonly INormalEfCoreRepository _hbpoSeDetailRepository; - /// /// HBPOEDI数据仓储 /// private readonly INormalEfCoreRepository _hbpoSeEdiRepository; + /// + /// UnitOfWork + /// + private readonly IUnitOfWorkManager _unitOfWorkManager; public JisHBPOSeEdiCompareAppService( IServiceProvider serviceProvider, - INormalEfCoreRepository hbpoSeDetailRepository, INormalEfCoreRepository hbpoSeEdiRepository) + INormalEfCoreRepository hbpoSeDetailRepository, + INormalEfCoreRepository hbpoSeEdiRepository, + IUnitOfWorkManager unitOfWorkManager) { _serviceProvider = serviceProvider; _hbpoSeDetailRepository = hbpoSeDetailRepository; _hbpoSeEdiRepository = hbpoSeEdiRepository; + _unitOfWorkManager = unitOfWorkManager; } /// @@ -54,7 +61,8 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable var db = serviceScope.ServiceProvider.GetRequiredService(); await HandDelEdiDataAsync().ConfigureAwait(false); - lock (_lockObj) + + using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) { var seDetailGroup = db.Set().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace }); var ediDetailGroup = db.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); @@ -74,7 +82,6 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable var seDetails = seDetailsQuery.Take(5000).ToList(); var ediDetails = ediDetailsQuery.Take(5000).ToList(); - if (seDetails.Any()) { seDetails.ForEach(t => t.IsHaveEdiData = true); @@ -85,7 +92,8 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable ediDetails.ForEach(t => t.IsHaveSeData = true); db.BulkUpdate(ediDetails); } - db.SaveChanges(); + await uow.SaveChangesAsync().ConfigureAwait(false); + //db.SaveChanges(); } } catch (Exception) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs index fbb0d80e..f2b712eb 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs @@ -126,7 +126,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable t.KeyCode = t.PN + t.LU; if (t.BillTime != null) { - t.Version = int.Parse(t.BillTime?.ToString("YYYYMM")); + t.Version = int.Parse(t.BillTime?.ToString("yyyyMM")); } }); await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs index 831ecb11..0d026594 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs @@ -42,6 +42,16 @@ public class SaSeEdiCompareDiff [Display(Name = "客户下线时间")] public DateTime? CustomerOfflineTime { get; set; } /// + /// 小总成号 + /// + [Display(Name = "小总成号")] + public string AssemblyCode { get; set; } + /// + /// 注塑码 + /// + [Display(Name = "注塑码")] + public string InjectionCode { get; set; } + /// /// 结算数量 /// [Display(Name = "结算数量")] @@ -198,18 +208,78 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa [ValueMapping("无结算有发运(无EDI数据)", 6)] public EnumSaSeEdiCompareCategory Category { get; set; } /// - /// 零件描述 + /// 交货单号 /// - [Display(Name = "零件描述")] + [Display(Name = "交货单号")] + [ExporterHeader(DisplayName = "交货单号")] + public string WmsBillNum { get; set; } + /// + /// 发货日期 + /// + [Display(Name = "发货日期")] + [ExporterHeader(DisplayName = "发货日期")] + public DateTime? ShippingDate { get; set; } + /// + /// 生产码 + /// + [Display(Name = "生产码")] + [ExporterHeader(DisplayName = "订单生产码")] + public string PN { get; set; } + /// + /// 日顺序号 + /// + [Display(Name = "日顺序号")] + [ExporterHeader(DisplayName = "日顺序号")] + public string SeqNumber { get; set; } + /// + /// PJIS日顺序号 + /// + [Display(Name = "PJIS日顺序号")] + [ExporterHeader(DisplayName = "PJIS日顺序号")] + public string PJISSeqNumber { get; set; } + /// + /// 客户物料号 + /// + [Display(Name = "客户物料号")] + [ExporterHeader(DisplayName = "客户物料号")] + public string CustomerPartCode { get; set; } + /// + /// 物料描述 + /// + [Display(Name = "物料描述")] [ExporterHeader(DisplayName = "物料描述")] public string PartCodeDesc { get; set; } /// - /// 替换厂内零件号 + /// 厂内物料号 /// - [Display(Name = "替换厂内零件号")] - [ExporterHeader(DisplayName = "替换厂内零件号")] + [Display(Name = "厂内物料号")] + [ExporterHeader(DisplayName = "厂内物料号")] + public string FactoryPartCode { get; set; } + /// + /// 替换厂内物料号 + /// + [Display(Name = "替换厂内物料号")] + [ExporterHeader(DisplayName = "替换厂内物料号")] public string ReplaceFactoryPartCode { get; set; } /// + /// 客户下线时间 + /// + [Display(Name = "客户下线时间")] + [ExporterHeader(DisplayName = "客户下线时间")] + public DateTime? CustomerOfflineTime { get; set; } + /// + /// 小总成号 + /// + [Display(Name = "小总成号")] + [ExporterHeader(DisplayName = "小总成号")] + public string AssemblyCode { get; set; } + /// + /// 注塑码 + /// + [Display(Name = "注塑码")] + [ExporterHeader(DisplayName = "注塑码")] + public string InjectionCode { get; set; } + /// /// 结算数量 /// [Display(Name = "结算数量")] @@ -227,6 +297,39 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa [Display(Name = "Edi数量")] [ExporterHeader(DisplayName = "Edi数量")] public decimal EdiQty { get; set; } + /// + /// 结算与EDI量差 + /// + [ExporterHeader(DisplayName = "结算与EDI量差")] + public decimal SaEdiQty => SAQty - EdiQty; + /// + /// WMS发货与EDI数量差 + /// + [ExporterHeader(DisplayName = "WMS发货与EDI数量差")] + public decimal SeEdiQty => SEQty - EdiQty; + [Display(Name = "是否完全匹配")] + [ExporterHeader(DisplayName = "是否完全匹配")] + [ValueMapping("是", true)] + [ValueMapping("否", false)] + public bool MateType => SaEdiQty == 0 && SeEdiQty == 0; + /// + /// 定价 + /// + [Display(Name = "定价")] + [ExporterHeader(DisplayName = "定价")] + public decimal? FixPrice { get; set; } + /// + /// ERP销售库位 + /// + [Display(Name = "ERP销售库位")] + [ExporterHeader(DisplayName = "ERP销售库位")] + public string ToErpLocCode { get; set; } + /// + /// WMS发货库位 + /// + [Display(Name = "WMS发货库位")] + [ExporterHeader(DisplayName = "WMS发货库位")] + public string ToLocCode { get; set; } } /// @@ -247,18 +350,78 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa [ValueMapping("无结算有发运(无EDI数据)", 6)] public EnumSaSeEdiCompareCategory Category { get; set; } /// - /// 零件描述 + /// 交货单号 /// - [Display(Name = "零件描述")] + [Display(Name = "交货单号")] + [ExporterHeader(DisplayName = "交货单号")] + public string WmsBillNum { get; set; } + /// + /// 发货日期 + /// + [Display(Name = "发货日期")] + [ExporterHeader(DisplayName = "发货日期")] + public DateTime? ShippingDate { get; set; } + /// + /// 生产码 + /// + [Display(Name = "生产码")] + [ExporterHeader(DisplayName = "订单生产码")] + public string PN { get; set; } + /// + /// 日顺序号 + /// + [Display(Name = "日顺序号")] + [ExporterHeader(DisplayName = "日顺序号")] + public string SeqNumber { get; set; } + /// + /// PJIS日顺序号 + /// + [Display(Name = "PJIS日顺序号")] + [ExporterHeader(DisplayName = "PJIS日顺序号")] + public string PJISSeqNumber { get; set; } + /// + /// 客户物料号 + /// + [Display(Name = "客户物料号")] + [ExporterHeader(DisplayName = "客户物料号")] + public string CustomerPartCode { get; set; } + /// + /// 物料描述 + /// + [Display(Name = "物料描述")] [ExporterHeader(DisplayName = "物料描述")] public string PartCodeDesc { get; set; } /// - /// 替换厂内零件号 + /// 厂内物料号 /// - [Display(Name = "替换厂内零件号")] - [ExporterHeader(DisplayName = "替换厂内零件号")] + [Display(Name = "厂内物料号")] + [ExporterHeader(DisplayName = "厂内物料号")] + public string FactoryPartCode { get; set; } + /// + /// 替换厂内物料号 + /// + [Display(Name = "替换厂内物料号")] + [ExporterHeader(DisplayName = "替换厂内物料号")] public string ReplaceFactoryPartCode { get; set; } /// + /// 客户下线时间 + /// + [Display(Name = "客户下线时间")] + [ExporterHeader(DisplayName = "客户下线时间")] + public DateTime? CustomerOfflineTime { get; set; } + /// + /// 小总成号 + /// + [Display(Name = "小总成号")] + [ExporterHeader(DisplayName = "小总成号")] + public string AssemblyCode { get; set; } + /// + /// 注塑码 + /// + [Display(Name = "注塑码")] + [ExporterHeader(DisplayName = "注塑码")] + public string InjectionCode { get; set; } + /// /// 结算数量 /// [Display(Name = "结算数量")] @@ -276,6 +439,39 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa [Display(Name = "Edi数量")] [ExporterHeader(DisplayName = "Edi数量")] public decimal EdiQty { get; set; } + /// + /// 结算与EDI量差 + /// + [ExporterHeader(DisplayName = "结算与EDI量差")] + public decimal SaEdiQty => SAQty - EdiQty; + /// + /// WMS发货与EDI数量差 + /// + [ExporterHeader(DisplayName = "WMS发货与EDI数量差")] + public decimal SeEdiQty => SEQty - EdiQty; + [Display(Name = "是否完全匹配")] + [ExporterHeader(DisplayName = "是否完全匹配")] + [ValueMapping("是", true)] + [ValueMapping("否", false)] + public bool MateType => SaEdiQty == 0 && SeEdiQty == 0; + /// + /// 定价 + /// + [Display(Name = "定价")] + [ExporterHeader(DisplayName = "定价")] + public decimal? FixPrice { get; set; } + /// + /// ERP销售库位 + /// + [Display(Name = "ERP销售库位")] + [ExporterHeader(DisplayName = "ERP销售库位")] + public string ToErpLocCode { get; set; } + /// + /// WMS发货库位 + /// + [Display(Name = "WMS发货库位")] + [ExporterHeader(DisplayName = "WMS发货库位")] + public string ToLocCode { get; set; } } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs index 7de4df7a..23cb852d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs @@ -105,12 +105,13 @@ namespace SettleAccount.Job.Services.Report //结算 var saGroup = from sa in _settleAccountDbContext.Set() where sa.BusinessType == businessType && sa.Version == version - group sa by new { sa.PN, sa.LU } into groupItem + group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), Price = groupItem.Max(t => t.Price), SettleDate = groupItem.Max(t => t.SettleDate), PartCode = groupItem.Max(t => t.PartCode), @@ -118,59 +119,95 @@ namespace SettleAccount.Job.Services.Report //发运 var seGroup = from se in _settleAccountDbContext.Set() where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime - group se by new { se.PN, se.LU } into groupItem + group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), WmsBillNum = groupItem.Max(t => t.WmsBillNum), ShippingDate = groupItem.Max(t => t.ShippingDate), FactoryPartCode = groupItem.Max(t => t.FactoryPartCode), ToLoc = groupItem.Max(t => t.ToLoc), ErpToLoc = groupItem.Max(t => t.ErpToLoc) }; + //Edi + var ediGroup = from edi in _settleAccountDbContext.Set() + where edi.IsDeleted == false && edi.IsHaveSeData == true + group edi by new { edi.PN, edi.LU } into groupItem + select new + { + groupItem.Key.PN, + groupItem.Key.LU, + Qty = groupItem.Sum(t => t.Qty) + }; + var seEdiGroup = from se in seGroup + join edi in ediGroup + on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, CustomerPartCodeNoSpace = edi.LU } + into ediTemp + from edi in ediTemp.DefaultIfEmpty() + select new + { + se.PN, + se.CustomerPartCodeNoSpace, + se.Qty, + se.LU, + se.WmsBillNum, + se.ShippingDate, + se.FactoryPartCode, + se.ToLoc, + se.ErpToLoc, + EdiQty = edi.Qty, + EdiCustomerPartCode = edi.LU + }; var saSeCompareLeft = from sa in saGroup - join se in seGroup - on new { sa.PN, sa.LU } equals new { se.PN, se.LU } + join seEdi in seEdiGroup + on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { seEdi.PN, seEdi.CustomerPartCodeNoSpace } into temp - from se in temp.DefaultIfEmpty() + from seEdi in temp.DefaultIfEmpty() select new SaSeEdiCompareDiff() { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, + WmsBillNum = seEdi.WmsBillNum, + ShippingDate = seEdi.ShippingDate, CustomerOfflineTime = sa.SettleDate, PN = sa.PN, SAQty = sa.Qty, - SEQty = se.Qty, + SEQty = seEdi.Qty, + EdiQty = seEdi.EdiQty, FixPrice = sa.Price, - ToLocCode = se.ToLoc, - ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.LU, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + ToLocCode = seEdi.ToLoc, + ToErpLocCode = seEdi.ErpToLoc, + SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace, + SeFactoryPartCode = seEdi.FactoryPartCode, + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + EdiCustomerPartCode = seEdi.EdiCustomerPartCode, + CustomerPartCode = sa.LU }; - var saSeCompareRight = from se in seGroup + var saSeCompareRight = from seEdi in seEdiGroup join sa in saGroup - on new { se.PN, se.LU } equals new { sa.PN, sa.LU } + on new { seEdi.PN, seEdi.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } into temp from sa in temp.DefaultIfEmpty() select new SaSeEdiCompareDiff() { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, + WmsBillNum = seEdi.WmsBillNum, + ShippingDate = seEdi.ShippingDate, CustomerOfflineTime = sa.SettleDate, - PN = se.PN, + PN = seEdi.PN, SAQty = sa.Qty, - SEQty = se.Qty, + SEQty = seEdi.Qty, + EdiQty = seEdi.EdiQty, FixPrice = sa.Price, - ToLocCode = se.ToLoc, - ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.LU, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + ToLocCode = seEdi.ToLoc, + ToErpLocCode = seEdi.ErpToLoc, + SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace, + SeFactoryPartCode = seEdi.FactoryPartCode, + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + EdiCustomerPartCode = seEdi.EdiCustomerPartCode, + CustomerPartCode = sa.LU ?? seEdi.LU }; var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); return saSeCompareFullJoin; 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 446c79e0..ceb05122 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 @@ -77,13 +77,13 @@ namespace SettleAccount.Job.Services.Report ParType = "01", EdiQty = t.Sum(t => t.Qty), AssemblyDate = default, - MatchNumber = default, + MatchNumber = t.Key.LU, MateType = "否", DiffDesc = "WMS漏发货EDI有订单" }).ToList(); //无EDI有发运 var notHaveEdiHaveSeList = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == false) - .GroupBy(t => new { t.LU, t.PN }) + .GroupBy(t => new { t.CustomerPartCodeNoSpace, t.PN }) .Select(t => new JisBBACEidSeCompareExport() { Category = "JIS", @@ -112,13 +112,14 @@ namespace SettleAccount.Job.Services.Report SeqNumber = groupItem.Max(t => t.SeqNumber) }; var seGroup = from se in _settleAccountDbContext.Set() - where se.IsHaveEdiData == true && se.AssembleData >= seStartDateTime && se.AssembleData <= seEndDateTime - group se by new { se.PN, se.LU } into groupItem + where se.IsHaveEdiData == true && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime + group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), BillNum = groupItem.Max(t => t.BillNum), MESConfigCode = groupItem.Max(t => t.MESConfigCode), BillTime = groupItem.Max(t => t.BillTime), @@ -130,8 +131,7 @@ namespace SettleAccount.Job.Services.Report }; var haveEdiHaveSeList = (from edi in ediGroup join se in seGroup - on new { edi.PN, edi.LU } equals new { se.PN, se.LU } - //where edi.IsDeleted == false && edi.IsHaveSeData == true && se.IsHaveEdiData == true + on new { edi.PN, edi.LU } equals new { se.PN, LU = se.CustomerPartCodeNoSpace } select new JisBBACEidSeCompareExport() { Category = "JIS", @@ -157,7 +157,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/JisHBPOSaSeEdiCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs index 858955dc..7228d8c6 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs @@ -84,8 +84,8 @@ namespace SettleAccount.Job.Services.Report } ediSeSaCompareDiffs = ediSeSaCompareDiffs.OrderBy(t => t.Category).ToList(); - var items = _objectMapper.Map, List>(ediSeSaCompareDiffs); - var excelExporter = BindExcelExporter(items, businessTypeDisplayName); + var items = _objectMapper.Map, List>(ediSeSaCompareDiffs); + var excelExporter = BindExcelExporter(items, businessTypeDisplayName); var result = excelExporter.ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); @@ -104,12 +104,13 @@ namespace SettleAccount.Job.Services.Report //结算 var saGroup = from sa in _settleAccountDbContext.Set() where sa.BusinessType == businessType && sa.Version == version - group sa by new { sa.PN, sa.LU } into groupItem + group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), Price = groupItem.Max(t => t.Price), SettleDate = groupItem.Max(t => t.SettleDate), PartCode = groupItem.Max(t => t.PartCode), @@ -117,59 +118,95 @@ namespace SettleAccount.Job.Services.Report //发运 var seGroup = from se in _settleAccountDbContext.Set() where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime - group se by new { se.PN, se.LU } into groupItem + group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), WmsBillNum = groupItem.Max(t => t.WmsBillNum), ShippingDate = groupItem.Max(t => t.ShippingDate), FactoryPartCode = groupItem.Max(t => t.FactoryPartCode), ToLoc = groupItem.Max(t => t.ToLoc), ErpToLoc = groupItem.Max(t => t.ErpToLoc) }; + //Edi + var ediGroup = from edi in _settleAccountDbContext.Set() + where edi.IsDeleted == false && edi.IsHaveSeData == true + group edi by new { edi.PN, edi.LU } into groupItem + select new + { + groupItem.Key.PN, + groupItem.Key.LU, + Qty = groupItem.Sum(t => t.Qty) + }; + var seEdiGroup = from se in seGroup + join edi in ediGroup + on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, CustomerPartCodeNoSpace = edi.LU } + into ediTemp + from edi in ediTemp.DefaultIfEmpty() + select new + { + se.PN, + se.CustomerPartCodeNoSpace, + se.Qty, + se.LU, + se.WmsBillNum, + se.ShippingDate, + se.FactoryPartCode, + se.ToLoc, + se.ErpToLoc, + EdiQty = edi.Qty, + EdiCustomerPartCode = edi.LU + }; var saSeCompareLeft = from sa in saGroup - join se in seGroup - on new { sa.PN, sa.LU } equals new { se.PN, se.LU } + join seEdi in seEdiGroup + on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { seEdi.PN, seEdi.CustomerPartCodeNoSpace } into temp - from se in temp.DefaultIfEmpty() + from seEdi in temp.DefaultIfEmpty() select new SaSeEdiCompareDiff() { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, + WmsBillNum = seEdi.WmsBillNum, + ShippingDate = seEdi.ShippingDate, CustomerOfflineTime = sa.SettleDate, PN = sa.PN, SAQty = sa.Qty, - SEQty = se.Qty, + SEQty = seEdi.Qty, + EdiQty = seEdi.EdiQty, FixPrice = sa.Price, - ToLocCode = se.ToLoc, - ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.LU, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + ToLocCode = seEdi.ToLoc, + ToErpLocCode = seEdi.ErpToLoc, + SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace, + SeFactoryPartCode = seEdi.FactoryPartCode, + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + EdiCustomerPartCode = seEdi.EdiCustomerPartCode, + CustomerPartCode = sa.LU }; - var saSeCompareRight = from se in seGroup + var saSeCompareRight = from seEdi in seEdiGroup join sa in saGroup - on new { se.PN, se.LU } equals new { sa.PN, sa.LU } + on new { seEdi.PN, seEdi.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } into temp from sa in temp.DefaultIfEmpty() select new SaSeEdiCompareDiff() { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, + WmsBillNum = seEdi.WmsBillNum, + ShippingDate = seEdi.ShippingDate, CustomerOfflineTime = sa.SettleDate, - PN = se.PN, + PN = seEdi.PN, SAQty = sa.Qty, - SEQty = se.Qty, + SEQty = seEdi.Qty, + EdiQty = seEdi.EdiQty, FixPrice = sa.Price, - ToLocCode = se.ToLoc, - ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.LU, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + ToLocCode = seEdi.ToLoc, + ToErpLocCode = seEdi.ErpToLoc, + SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace, + SeFactoryPartCode = seEdi.FactoryPartCode, + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + EdiCustomerPartCode = seEdi.EdiCustomerPartCode, + CustomerPartCode = sa.LU ?? seEdi.LU }; var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); return saSeCompareFullJoin; 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 9ae07de1..62dc32b3 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 @@ -74,13 +74,13 @@ namespace SettleAccount.Job.Services.Report ParType = "01", EdiQty = t.Sum(t => t.Qty), AssemblyDate = default, - MatchNumber = default, + MatchNumber = t.Key.LU, MateType = "否", DiffDesc = "WMS漏发货EDI有订单" }).ToList(); //无EDI有发运 var notHaveEdiHaveSeList = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == false) - .GroupBy(t => new { t.LU, t.PN }) + .GroupBy(t => new { t.CustomerPartCodeNoSpace, t.PN }) .Select(t => new JisHBPOEidSeCompareExport() { Category = "JIS", @@ -111,12 +111,12 @@ namespace SettleAccount.Job.Services.Report SeqNumber = groupItem.Max(t => t.SeqNumber) }; var seGroup = from se in _settleAccountDbContext.Set() - where se.IsHaveEdiData == true && se.AssembleData >= seStartDateTime && se.AssembleData <= seEndDateTime - group se by new { se.PN, se.LU } into groupItem + where se.IsHaveEdiData == true && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime + group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), BillNum = groupItem.Max(t => t.BillNum), MESConfigCode = groupItem.Max(t => t.MESConfigCode), @@ -131,7 +131,7 @@ namespace SettleAccount.Job.Services.Report }; var haveEdiHaveSeList = (from edi in ediGroup join se in seGroup - on new { edi.PN, edi.LU } equals new { se.PN, se.LU } + on new { edi.PN, edi.LU } equals new { se.PN, LU = se.CustomerPartCodeNoSpace } select new JisHBPOEidSeCompareExport() { Category = "JIS", diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs index 2ff8034d..4f96fb4e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs @@ -44,7 +44,6 @@ namespace SettleAccount.Job.Services.Report case EnumSaSeEdiCompareCategory.HaveSaNotHaveSeHaveEdi: case EnumSaSeEdiCompareCategory.HaveSaNotHaveSeNotHaveEdi: { - p.CustomerPartCode = p.SaCustomerPartCode; p.FactoryPartCode = p.SaFactoryPartCode; p.ReplaceFactoryPartCode = p.SaFactoryPartCode; } @@ -52,7 +51,6 @@ namespace SettleAccount.Job.Services.Report case EnumSaSeEdiCompareCategory.NotHaveSaHaveSeHaveEdi: case EnumSaSeEdiCompareCategory.NotHaveSaHaveSeNotHaveEdi: { - p.CustomerPartCode = p.SeCustomerPartCode; p.FactoryPartCode = p.SeFactoryPartCode; p.ReplaceFactoryPartCode = p.SeFactoryPartCode; }