From aaa6795327f76649b6cf5829fb731b498ec92845 Mon Sep 17 00:00:00 2001 From: mahao Date: Fri, 21 Jul 2023 14:55:51 +0800 Subject: [PATCH] =?UTF-8?q?PUB=E7=BB=93=E7=AE=97=E4=B8=8E=E5=8F=91?= =?UTF-8?q?=E8=BF=90=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/EdiSeCompareService.cs | 88 +++++++++++++++++++ .../Reports/PubSaSeCompareDiff.cs | 15 ++-- .../Report/PubSaSeCompareDapperRepository.cs | 3 +- .../Report/BBACEdiSeCompareExportService.cs | 46 ++++++++++ .../Report/HBPOEdiSeCompareExportService.cs | 46 ++++++++++ .../Report/PubSaSeCompareExportService.cs | 84 +++++++++++------- .../SettleAccountJobModule.cs | 12 +++ 7 files changed, 252 insertions(+), 42 deletions(-) create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/EdiSeCompareService.cs create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/BBACEdiSeCompareExportService.cs create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HBPOEdiSeCompareExportService.cs diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/EdiSeCompareService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/EdiSeCompareService.cs new file mode 100644 index 00000000..80e82e32 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/EdiSeCompareService.cs @@ -0,0 +1,88 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.OpenApi.Extensions; +using SettleAccount.Job.Services.Report; +using TaskJob.EventArgs; +using Volo.Abp.Application.Services; +using Win.Sfs.SettleAccount.Entities.BQ.Dtos; +using Win.Sfs.SettleAccount.Entities.TaskJobs; + +namespace Win.Sfs.SettleAccount.Entities.BQ; + +/// +/// Edi与发运对比服务 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class EdiSeCompareService : ApplicationService +{ + /// + /// 任务服务 + /// + private readonly TaskJobService _taskJobService; + + public EdiSeCompareService(TaskJobService taskJobService) + { + _taskJobService = taskJobService; + } + + #region 对比 + /// + /// BBACEdi与发运比对 + /// + [HttpPost] + public async Task BBACEdiSeCompare(PubSaSeCompareRequestDto pubSaSeCompareRequestDto) + { + var businessTypeDisplayName = pubSaSeCompareRequestDto.BusinessType.ToString(); + DisplayAttribute attributeOfType = pubSaSeCompareRequestDto.BusinessType.GetAttributeOfType(); + if (attributeOfType != null) + { + businessTypeDisplayName = attributeOfType.Name; + } + var projectName = $"{businessTypeDisplayName}结算与发运数据对比"; + + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Version", Value = pubSaSeCompareRequestDto.Version }); + customConditionList.Add(new CustomCondition() { Name = "BusinessType", Value = ((int)pubSaSeCompareRequestDto.BusinessType).ToString() }); + customConditionList.Add(new CustomCondition() { Name = "LU", Value = pubSaSeCompareRequestDto.LU }); + customConditionList.Add(new CustomCondition() { Name = "PN", Value = pubSaSeCompareRequestDto.PN }); + customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName }); + + var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, pubSaSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(BBACEdiSeCompareExportService), customConditionList, (rs) => + { + }); + return _taskid; + } + + /// + /// HBPOEdi与发运比对 + /// + [HttpPost] + public async Task HBPOEdiSeCompare(PubSaSeCompareRequestDto pubSaSeCompareRequestDto) + { + var businessTypeDisplayName = pubSaSeCompareRequestDto.BusinessType.ToString(); + DisplayAttribute attributeOfType = pubSaSeCompareRequestDto.BusinessType.GetAttributeOfType(); + if (attributeOfType != null) + { + businessTypeDisplayName = attributeOfType.Name; + } + var projectName = $"{businessTypeDisplayName}结算与发运数据对比"; + + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Version", Value = pubSaSeCompareRequestDto.Version }); + customConditionList.Add(new CustomCondition() { Name = "BusinessType", Value = ((int)pubSaSeCompareRequestDto.BusinessType).ToString() }); + customConditionList.Add(new CustomCondition() { Name = "LU", Value = pubSaSeCompareRequestDto.LU }); + customConditionList.Add(new CustomCondition() { Name = "PN", Value = pubSaSeCompareRequestDto.PN }); + customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName }); + + var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, pubSaSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(HBPOEdiSeCompareExportService), customConditionList, (rs) => + { + }); + return _taskid; + } + #endregion + +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs index d0ec83ee..51850420 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs @@ -68,9 +68,12 @@ public class PubSaSeCompareDiff /// /// 差异数量 /// - [ExporterHeader(DisplayName = "差异数量")] - public decimal DiffQty { set; get; } + [Display(Name = "差异数量")] + public decimal DiffQty => SAQty - SEQty; + /// + /// 匹配类型 + /// [Display(Name = "匹配类型")] public string MateType { get; set; } @@ -98,12 +101,6 @@ public class PubSaSeCompareDiff [Display(Name = "零件号")] public string SeLU { set; get; } - /// - /// 生产号 - /// - [Display(Name = "生产号")] - public string SePN { set; get; } - /// /// 零件号 /// @@ -114,7 +111,7 @@ public class PubSaSeCompareDiff /// 生产号 /// [Display(Name = "生产号")] - public string SaPN { set; get; } + public string PN { set; get; } /// /// 类型 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs index 4f344b02..7491316f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs @@ -38,9 +38,8 @@ public class PubSaSeCompareDapperRepository : DapperRepository + /// BBACEdi与发运对比导出服务 + /// + public class BBACEdiSeCompareExportService : ITransientDependency, IExportJob + { + /// + /// 文件容器 + /// + private readonly IBlobContainer _fileContainer; + + /// + /// AutoMapper + /// + private readonly IObjectMapper _objectMapper; + + /// + /// 构造 + /// + public BBACEdiSeCompareExportService( + IBlobContainer fileContainer, + IObjectMapper objectMapper) + { + _fileContainer = fileContainer; + _objectMapper = objectMapper; + } + + /// + /// 导出 + /// + public string ExportFile(Guid id, List exportName, List property) + { + return ""; + } + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HBPOEdiSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HBPOEdiSeCompareExportService.cs new file mode 100644 index 00000000..56bfd61d --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HBPOEdiSeCompareExportService.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using TaskJob.EventArgs; +using TaskJob.Interfaces; +using Volo.Abp.BlobStoring; +using Volo.Abp.DependencyInjection; +using Volo.Abp.ObjectMapping; +using Win.Sfs.BaseData.ImportExcelCommon; + +namespace SettleAccount.Job.Services.Report +{ + /// + /// HBPOEdi与发运对比导出服务 + /// + public class HBPOEdiSeCompareExportService : ITransientDependency, IExportJob + { + /// + /// 文件容器 + /// + private readonly IBlobContainer _fileContainer; + + /// + /// AutoMapper + /// + private readonly IObjectMapper _objectMapper; + + /// + /// 构造 + /// + public HBPOEdiSeCompareExportService( + IBlobContainer fileContainer, + IObjectMapper objectMapper) + { + _fileContainer = fileContainer; + _objectMapper = objectMapper; + } + + /// + /// 导出 + /// + public string ExportFile(Guid id, List exportName, List property) + { + return ""; + } + } +} 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 e81438cd..8bca57d3 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 @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using EmptyFiles; +using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Excel; using Microsoft.OpenApi.Extensions; using NetTopologySuite.Operation.Buffer; @@ -31,38 +32,34 @@ namespace SettleAccount.Job.Services.Report public class PubSaSeCompareExportService : ITransientDependency, IExportJob { /// - /// Pub结算明细仓储 + /// 替换件关系仓储 /// - private readonly INormalEfCoreRepository _pubSaDetailRepository; + private readonly INormalEfCoreRepository _tbRePartsRelationshipRepository; /// - /// Pub发运数据仓储 + /// Pub结算发运对比Dapper /// - private readonly INormalEfCoreRepository _pubSeDetailRepository; + private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository; /// - /// 替换件关系仓储 + /// 文件容器 /// - private readonly INormalEfCoreRepository _tbRePartsRelationshipRepository; - - private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository; - private readonly IBlobContainer _fileContainer; + /// + /// AutoMapper + /// private readonly IObjectMapper _objectMapper; /// /// 构造 /// - public PubSaSeCompareExportService(INormalEfCoreRepository pubSaDetailRepository, - INormalEfCoreRepository pubSeDetailRepository, + public PubSaSeCompareExportService( INormalEfCoreRepository tbRePartsRelationshipRepository, PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, IBlobContainer fileContainer, IObjectMapper objectMapper) { - _pubSaDetailRepository = pubSaDetailRepository; - _pubSeDetailRepository = pubSeDetailRepository; _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; _pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; _fileContainer = fileContainer; @@ -107,39 +104,64 @@ namespace SettleAccount.Job.Services.Report }); //有结算有发运 - var haveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); + var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); //有结算无发运 - var haveSaNotHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); + var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); //无结算有发运 - var notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); + var notHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); - haveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); - haveSaNotHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); - notHaveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); + haveSaHaveSes.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); + haveSaNotHaveSes.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); + notHaveSaHaveSes.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SeLU); #region 二次对比 //二次对比(替换零件号) - var repLUs = notHaveSaHaveSe.Select(t => t.SeLU).Distinct().ToList(); + var repLUs = notHaveSaHaveSes.Select(t => t.SeLU).Distinct().ToList(); var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && ((int)t.BusinessType).ToString() == businessType).Result; tbRePartsRelationships.ForEach(tbRePartsRelationship => { - notHaveSaHaveSe.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t => + notHaveSaHaveSes.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t => { t.ReplaceLU = tbRePartsRelationship.LU; }); }); + var haveSaNotHaveSeLUPNs = haveSaNotHaveSes.Select(t => new { t.ReplaceLU, t.PN }); + var notHaveSaHaveSeLUPNs = notHaveSaHaveSes.Select(t => new { t.ReplaceLU, t.PN }); + //二次匹配 匹配上的零件号 + var secondMatchLUPNs = haveSaNotHaveSeLUPNs.Intersect(notHaveSaHaveSeLUPNs); + if (secondMatchLUPNs.Any() == true) + { + pubSaSeCompareDiffs.RemoveAll(t => secondMatchLUPNs.Contains(new { t.ReplaceLU, t.PN })); - var haveSaNotHaveSeReplaceLU = haveSaNotHaveSe.Select(t => t.ReplaceLU); - var notHaveSaHaveSeReplaceLU = notHaveSaHaveSe.Select(t => t.ReplaceLU); - //此次匹配上的零件号 - var secondMatchReplaceLU = notHaveSaHaveSeReplaceLU.Intersect(notHaveSaHaveSeReplaceLU); - //if (secondMatchReplaceLU) - //{ - - //} - + foreach (var secondMatchLUPN in secondMatchLUPNs) + { + var haveSaNotHaveSe = haveSaNotHaveSes.FirstOrDefault(t => t.ReplaceLU == secondMatchLUPN.ReplaceLU && t.PN == secondMatchLUPN.PN); + var notHaveSaHaveSe = notHaveSaHaveSes.FirstOrDefault(t => t.ReplaceLU == secondMatchLUPN.ReplaceLU && t.PN == secondMatchLUPN.PN); + pubSaSeCompareDiffs.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 + }); + } + } #endregion @@ -149,7 +171,7 @@ namespace SettleAccount.Job.Services.Report } if (string.IsNullOrEmpty(pn) == false) { - pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.SaPN == pn || p.SePN == pn); + pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn); } //结算核对明细 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs index 14bdd971..f7c77c44 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs @@ -40,6 +40,9 @@ namespace Win.Sfs.SettleAccount GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute{ Attempts = 0}); context.Services.AddTransient(); + context.Services.AddTransient(); + context.Services.AddTransient(); + context.Services.AddTransient(); context.Services.AddTransient(); @@ -86,6 +89,15 @@ namespace Win.Sfs.SettleAccount { return implementationFactory.GetService(); } + if (key.Equals(typeof(BBACEdiSeCompareExportService).FullName)) + { + return implementationFactory.GetService(); + } + if (key.Equals(typeof(HBPOEdiSeCompareExportService).FullName)) + { + return implementationFactory.GetService(); + } + if (key.Equals(typeof(InvoiceSettledDiffExportService).FullName)) {