From 7ca2a58962513a67e408ee395cf4f328d4ff5ddf Mon Sep 17 00:00:00 2001 From: mahao Date: Sun, 8 Oct 2023 10:51:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=8D=95=E4=B8=8D=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=8C=BA=E9=97=B4=E6=98=AF=E5=90=A6=E8=BF=9E=E7=BB=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Prices/PriceListAppService.cs | 8 +-- .../Entities/Prices/PriceListAppServiceBJ.cs | 8 +-- .../MaiDanBBACSaSeCompareExportService.cs | 70 ++++++++++++++++++- 3 files changed, 77 insertions(+), 9 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs index 05f289c2..2b461558 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs @@ -98,10 +98,10 @@ namespace Win.Sfs.SettleAccount.Entities.Prices checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, item.LU, string.Empty, $"合同号:{item.ContractNo},合同签订时间:{item.Date:yyyy-MM-dd},时间区间存在交集", string.Empty)); } - foreach (var item in CheckPriceListContinuity(newPrice)) - { - checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, item.LU, string.Empty, $"合同号:{item.ContractNo},合同签订时间:{item.Date:yyyy-MM-dd},时间区间【{item.BeginTime:yyyy-MM-dd}至{item.EndTime:yyyy-MM-dd}】不连续", string.Empty)); - } + //foreach (var item in CheckPriceListContinuity(newPrice)) + //{ + // checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, item.LU, string.Empty, $"合同号:{item.ContractNo},合同签订时间:{item.Date:yyyy-MM-dd},时间区间【{item.BeginTime:yyyy-MM-dd}至{item.EndTime:yyyy-MM-dd}】不连续", string.Empty)); + //} } if (checkList.Count > 0) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs index 45bba2cb..f7817915 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs @@ -90,10 +90,10 @@ namespace Win.Sfs.SettleAccount.Entities.Prices checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, item.LU, string.Empty, $"合同号:{item.ContractNo},合同签订时间:{item.Date:yyyy-MM-dd},时间区间存在交集", string.Empty)); } - foreach (var item in CheckPriceListContinuity(newPrice)) - { - checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, item.LU, string.Empty, $"合同号:{item.ContractNo},合同签订时间:{item.Date:yyyy-MM-dd},时间区间【{item.BeginDate:yyyy-MM-dd}至{item.EndDate:yyyy-MM-dd}】不连续", string.Empty)); - } + //foreach (var item in CheckPriceListContinuity(newPrice)) + //{ + // checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, item.LU, string.Empty, $"合同号:{item.ContractNo},合同签订时间:{item.Date:yyyy-MM-dd},时间区间【{item.BeginDate:yyyy-MM-dd}至{item.EndDate:yyyy-MM-dd}】不连续", string.Empty)); + //} } if (checkList.Count > 0) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs index b87efbb6..03af169a 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs @@ -1,11 +1,18 @@ using System; +using System.Collections; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Linq.Dynamic.Core; +using System.Runtime.CompilerServices; +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.SignalR; using Microsoft.OpenApi.Extensions; +using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; +using SettleAccount.Bases; using SettleAccount.Domain.BQ; using SettleAccount.Job.SignalR; using Shouldly; @@ -17,6 +24,7 @@ using Volo.Abp.ObjectMapping; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount.Entities.BQ; +using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Reports; namespace SettleAccount.Job.Services.Report @@ -87,10 +95,14 @@ namespace SettleAccount.Job.Services.Report pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes); //二次对比比对上的数据入库 var pubSeCDetailEntitys = _objectMapper.Map, List>(secondMatchHaveSaHaveSes); - _settleAccountDbContext.Set().AddRange(pubSeCDetailEntitys); + //_settleAccountDbContext.Set().AddRange(pubSeCDetailEntitys); } #endregion + #region 三次对比 + //pubSaSeCompareDiffs = ThreeCompare(pubSaSeCompareDiffs); + #endregion + #region 结算数据处理 HandleSaDetails(pubSaSeCompareDiffs, businessType, version); HandleSaDetailsMain(pubSaSeCompareDiffs, businessType, version); @@ -117,5 +129,61 @@ namespace SettleAccount.Job.Services.Report Notify(); return id.ToString(); } + + /// + /// 三次比对 + /// + /// + /// 不同PN下客户零件号、数量、相同为有结算有发运数据 + /// 获取有结算无发运、无结算有发运同时存在的零件号 + /// 遍历零件号 + /// 判断结算无发运和无结算有发运数据 客户零件号、数量是否完全匹配 + /// 完全匹配修改有结算无发运的数据类型为有结算有发运,去掉无结算有发运的数据 + /// + public List ThreeCompare(List saSeCompareDiffs) + { + //有结算无发运 + var haveSaNotHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); + //无结算有发运 + var notHaveSaHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); + + var haveSaNotHaveSeHashCodes = haveSaNotHaveSes.OrderBy(t => t.CustomerPartCode).GroupBy(t => t.PN).Select(t => new + { + PN = t.Key, + PartCodeHashCode = t.Select(t => t.CustomerPartCode).Aggregate((current, index) => $"{current};{index}").GetHashCode(), + QtyHashCode = t.Select(t => t.SAQty.ToString()).Aggregate((current, index) => $"{current};{index}") + }).ToList(); + + var notHaveSaHaveSeHashCodes = notHaveSaHaveSes.OrderBy(t => t.CustomerPartCode).GroupBy(t => t.PN).Select(t => new + { + PN = t.Key, + PartCodeHashCode = t.Select(t => t.CustomerPartCode).Aggregate((current, index) => $"{current};{index}").GetHashCode(), + QtyHashCode = t.Select(t => t.SEQty.ToString()).Aggregate((current, index) => $"{current};{index}") + }).ToList(); + + var matchPNs = new Dictionary(); + + haveSaNotHaveSeHashCodes.ForEach(haveSaNotHaveSeHashCode => + { + var matchPN = notHaveSaHaveSeHashCodes.FirstOrDefault(t => t.PartCodeHashCode == haveSaNotHaveSeHashCode.PartCodeHashCode && t.QtyHashCode == haveSaNotHaveSeHashCode.QtyHashCode && matchPNs.ContainsKey(t.PN) == false); + + if (matchPN != null) + { + matchPNs.Add(matchPN.PN, haveSaNotHaveSeHashCode.PN); + } + }); + + saSeCompareDiffs.RemoveAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe && matchPNs.ContainsKey(t.PN)); + + saSeCompareDiffs.Where(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe) + .Where(t => matchPNs.ContainsValue(t.PN)).ToList() + .ForEach(t => + { + t.Category = EnumPubSaSeCompareCategory.HaveSaHaveSe; + t.SEQty = t.SAQty; + }); + + return saSeCompareDiffs; + } } }