From 278c7a4e93b7a528bbe718b01fad8c222d54c5d5 Mon Sep 17 00:00:00 2001 From: mahao Date: Thu, 24 Aug 2023 16:23:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettleAccountApplicationModule.cs | 16 +- .../Reports/PubSaSeCompareDiff.cs | 240 +++++++----------- .../Report/PubSaSeCompareDapperRepository.cs | 1 + .../MaiDanBBACSaSeCompareExportService.cs | 207 ++++++++------- .../MaiDanHBPOSaSeCompareExportService.cs | 208 ++++++++------- .../Report/PubSaSeCompareExportService.cs | 16 +- .../Report/SaSeCompareExportBaseService.cs | 136 ++++++++++ .../SettleAccountJobAutoMapperProfile.cs | 1 + .../SettleAccountJobModule.cs | 7 +- 9 files changed, 461 insertions(+), 371 deletions(-) create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs index 31cb3d8d..8fbaa835 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs @@ -63,10 +63,6 @@ namespace Win.Sfs.SettleAccount { Func accesor = key => { - if (key.Equals(typeof(PubSaSeCompareExportService).FullName)) - { - return implementationFactory.GetService(); - } if (key.Equals(typeof(JisBBACEdiSeCompareExportService).FullName)) { return implementationFactory.GetService(); @@ -75,6 +71,18 @@ namespace Win.Sfs.SettleAccount { return implementationFactory.GetService(); } + if (key.Equals(typeof(MaiDanBBACSaSeCompareExportService).FullName)) + { + return implementationFactory.GetService(); + } + if (key.Equals(typeof(MaiDanHBPOSaSeCompareExportService).FullName)) + { + return implementationFactory.GetService(); + } + if (key.Equals(typeof(PubSaSeCompareExportService).FullName)) + { + return implementationFactory.GetService(); + } if (key.Equals(typeof(PendingDeductionService).FullName)) { return implementationFactory.GetService(); 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 4ef82f85..535125ae 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs @@ -128,14 +128,10 @@ public class PubSaSeCompareDetailExport /// /// PUB结算与发运对比明细 /// -[ExcelExporter(MaxRowNumberOnASheet = 900000)] -public class PubSaSeCompareDetailExport2 +public interface IPubSaSeCompareDetailExport { /// /// 类别 - /// 有结算有发运 - /// 有结算无发运 - /// 无结算有发运 /// [Display(Name = "类别")] [ExporterHeader(DisplayName = "类别")] @@ -143,21 +139,101 @@ public class PubSaSeCompareDetailExport2 [ValueMapping("有结算无发运", 2)] [ValueMapping("无结算有发运", 3)] public EnumPubSaSeCompareCategory Category { get; set; } + /// + /// 零件描述 + /// + [Display(Name = "零件描述")] + [ExporterHeader(DisplayName = "物料描述")] + public string PartCodeDesc { get; set; } + /// + /// 替换厂内零件号 + /// + [Display(Name = "替换厂内零件号")] + [ExporterHeader(DisplayName = "替换厂内零件号")] + public string ReplaceFactoryPartCode { get; set; } + /// + /// 结算数量 + /// + [Display(Name = "结算数量")] + [ExporterHeader(DisplayName = "结算数量")] + public decimal SAQty { get; set; } + + /// + /// 发货数量 + /// + [Display(Name = "发货数量")] + [ExporterHeader(DisplayName = "WMS发货数量")] + public decimal SEQty { get; set; } +} + +/// +/// PUB结算与发运对比汇总 +/// +[ExcelExporter(MaxRowNumberOnASheet = 900000)] +public class PubSaSeCompareSumExport +{ + /// + /// 厂内物料号 + /// + [Display(Name = "厂内物料号")] + [ExporterHeader(DisplayName = "LU")] + public string FactoryPartCode { get; set; } + + /// + /// 物料描述 + /// + [Display(Name = "物料描述")] + [ExporterHeader(DisplayName = "物料描述")] + public string PartCodeDesc { get; set; } + + /// + /// 结算数量 + /// + [Display(Name = "结算数量")] + [ExporterHeader(DisplayName = "结算数量")] + public decimal SAQty { get; set; } + + /// + /// 发货数量 + /// + [Display(Name = "发货数量")] + [ExporterHeader(DisplayName = "WMS发货数量")] + public decimal SEQty { get; set; } + + /// + /// 差异数量 + /// + [ExporterHeader(DisplayName = "差异数量")] + public decimal DiffQty => SAQty - SEQty; +} +/// +/// 直供件BBAC结算与发运对比明细 +/// +[ExcelExporter(MaxRowNumberOnASheet = 900000)] +public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport +{ + /// + /// 类别 + /// + [Display(Name = "类别")] + [ExporterHeader(DisplayName = "类别")] + [ValueMapping("有结算有发运", 1)] + [ValueMapping("有结算无发运", 2)] + [ValueMapping("无结算有发运", 3)] + public EnumPubSaSeCompareCategory Category { get; set; } /// /// Wms发货单号 /// [Display(Name = "Wms发货单号")] [ExporterHeader(DisplayName = "交货单号")] public string WmsBillNum { get; set; } - /// /// 发货日期 /// [Display(Name = "发货日期")] [ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")] - public DateTime ShippingDate { get; set; } - + public DateTime? ShippingDate { get; set; } /// /// 生产码 /// @@ -193,7 +269,7 @@ public class PubSaSeCompareDetailExport2 /// [Display(Name = "客户下线时间")] [ExporterHeader(DisplayName = "客户下线时间")] - public DateTime CustomerOfflineTime { get; set; } + public DateTime? CustomerOfflineTime { get; set; } /// /// 结算数量 @@ -201,6 +277,7 @@ public class PubSaSeCompareDetailExport2 [Display(Name = "结算数量")] [ExporterHeader(DisplayName = "结算数量")] public decimal SAQty { get; set; } + /// /// 发货数量 /// @@ -211,7 +288,7 @@ public class PubSaSeCompareDetailExport2 /// 差异数量 /// [ExporterHeader(DisplayName = "差异数量")] - public decimal DiffQty { set; get; } + public decimal DiffQty => SAQty - SEQty; /// /// 匹配类型 /// @@ -225,19 +302,7 @@ public class PubSaSeCompareDetailExport2 /// [Display(Name = "定价")] [ExporterHeader(DisplayName = "定价")] - public decimal FixPrice { get; set; } - /// - /// 日顺序号 - /// - [Display(Name = "日顺序号")] - [ExporterHeader(DisplayName = "日顺序号")] - public string SeqNumber { get; set; } - /// - /// PJIS日顺序号 - /// - [Display(Name = "PJIS日顺序号")] - [ExporterHeader(DisplayName = "PJIS日顺序号")] - public string PJISSeqNumber { get; set; } + public decimal? FixPrice { get; set; } /// /// WMS目标库位 /// @@ -253,101 +318,13 @@ public class PubSaSeCompareDetailExport2 } /// -/// PUB结算与发运对比明细 -/// -public interface IPubSaSeCompareDetailExport -{ - /// - /// 类别 - /// 有结算有发运 - /// 有结算无发运 - /// 无结算有发运 - /// - [Display(Name = "类别")] - [ExporterHeader(DisplayName = "类别")] - [ValueMapping("有结算有发运", 1)] - [ValueMapping("有结算无发运", 2)] - [ValueMapping("无结算有发运", 3)] - public EnumPubSaSeCompareCategory Category { get; set; } - /// - /// 零件描述 - /// - [Display(Name = "零件描述")] - [ExporterHeader(DisplayName = "物料描述")] - public string PartCodeDesc { get; set; } - /// - /// 替换厂内零件号 - /// - [Display(Name = "替换厂内零件号")] - [ExporterHeader(DisplayName = "替换厂内零件号")] - public string ReplaceFactoryPartCode { get; set; } - /// - /// 结算数量 - /// - [Display(Name = "结算数量")] - [ExporterHeader(DisplayName = "结算数量")] - public decimal SAQty { get; set; } - - /// - /// 发货数量 - /// - [Display(Name = "发货数量")] - [ExporterHeader(DisplayName = "WMS发货数量")] - public decimal SEQty { get; set; } -} - -/// -/// PUB结算与发运对比汇总 -/// -[ExcelExporter(MaxRowNumberOnASheet = 900000)] -public class PubSaSeCompareSumExport -{ - /// - /// 厂内物料号 - /// - [Display(Name = "厂内物料号")] - [ExporterHeader(DisplayName = "LU")] - public string FactoryPartCode { get; set; } - - /// - /// 物料描述 - /// - [Display(Name = "物料描述")] - [ExporterHeader(DisplayName = "物料描述")] - public string PartCodeDesc { get; set; } - - /// - /// 结算数量 - /// - [Display(Name = "结算数量")] - [ExporterHeader(DisplayName = "结算数量")] - public decimal SAQty { get; set; } - - /// - /// 发货数量 - /// - [Display(Name = "发货数量")] - [ExporterHeader(DisplayName = "WMS发货数量")] - public decimal SEQty { get; set; } - - /// - /// 差异数量 - /// - [ExporterHeader(DisplayName = "差异数量")] - public decimal DiffQty => SAQty - SEQty; -} - -/// -/// 直供件BBAC结算与发运对比明细 +/// 直供件HBPO结算与发运对比明细 /// [ExcelExporter(MaxRowNumberOnASheet = 900000)] -public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport +public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport { /// /// 类别 - /// 有结算有发运 - /// 有结算无发运 - /// 无结算有发运 /// [Display(Name = "类别")] [ExporterHeader(DisplayName = "类别")] @@ -355,21 +332,18 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExp [ValueMapping("有结算无发运", 2)] [ValueMapping("无结算有发运", 3)] public EnumPubSaSeCompareCategory Category { get; set; } - /// /// Wms发货单号 /// [Display(Name = "Wms发货单号")] [ExporterHeader(DisplayName = "交货单号")] public string WmsBillNum { get; set; } - /// /// 发货日期 /// [Display(Name = "发货日期")] [ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")] public DateTime? ShippingDate { get; set; } - /// /// 生产码 /// @@ -406,14 +380,12 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExp [Display(Name = "客户下线时间")] [ExporterHeader(DisplayName = "客户下线时间")] public DateTime? CustomerOfflineTime { get; set; } - /// /// 结算数量 /// [Display(Name = "结算数量")] [ExporterHeader(DisplayName = "结算数量")] public decimal SAQty { get; set; } - /// /// 发货数量 /// @@ -454,16 +426,13 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExp } /// -/// 直供件HBPO结算与发运对比明细 +/// 买单件BBAC结算与发运对比明细 /// [ExcelExporter(MaxRowNumberOnASheet = 900000)] -public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport +public class PubSaSeCompareDetailExportMaiDanJianBBAC : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport { /// /// 类别 - /// 有结算有发运 - /// 有结算无发运 - /// 无结算有发运 /// [Display(Name = "类别")] [ExporterHeader(DisplayName = "类别")] @@ -483,12 +452,11 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp [Display(Name = "发货日期")] [ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")] public DateTime? ShippingDate { get; set; } - /// /// 生产码 /// [Display(Name = "生产码")] - [ExporterHeader(DisplayName = "ASN发货单号")] + [ExporterHeader(DisplayName = "索引号")] public string PN { get; set; } /// /// 客户零件号 @@ -520,12 +488,14 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp [Display(Name = "客户下线时间")] [ExporterHeader(DisplayName = "客户下线时间")] public DateTime? CustomerOfflineTime { get; set; } + /// /// 结算数量 /// [Display(Name = "结算数量")] [ExporterHeader(DisplayName = "结算数量")] public decimal SAQty { get; set; } + /// /// 发货数量 /// @@ -569,13 +539,10 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp /// 买单件HBPO结算与发运对比明细 /// [ExcelExporter(MaxRowNumberOnASheet = 900000)] -public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExport +public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport { /// /// 类别 - /// 有结算有发运 - /// 有结算无发运 - /// 无结算有发运 /// [Display(Name = "类别")] [ExporterHeader(DisplayName = "类别")] @@ -583,21 +550,18 @@ public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExpo [ValueMapping("有结算无发运", 2)] [ValueMapping("无结算有发运", 3)] public EnumPubSaSeCompareCategory Category { get; set; } - /// /// Wms发货单号 /// [Display(Name = "Wms发货单号")] [ExporterHeader(DisplayName = "交货单号")] public string WmsBillNum { get; set; } - /// /// 发货日期 /// [Display(Name = "发货日期")] [ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")] public DateTime? ShippingDate { get; set; } - /// /// 生产码 /// @@ -689,9 +653,6 @@ public class PubSaSeCompareDetailExportBeiJian : PubSaSeCompareDetailExport, IPu { /// /// 类别 - /// 有结算有发运 - /// 有结算无发运 - /// 无结算有发运 /// [Display(Name = "类别")] [ExporterHeader(DisplayName = "类别")] @@ -699,21 +660,18 @@ public class PubSaSeCompareDetailExportBeiJian : PubSaSeCompareDetailExport, IPu [ValueMapping("有结算无发运", 2)] [ValueMapping("无结算有发运", 3)] public EnumPubSaSeCompareCategory Category { get; set; } - /// /// Wms发货单号 /// [Display(Name = "Wms发货单号")] [ExporterHeader(DisplayName = "交货单号")] public string WmsBillNum { get; set; } - /// /// 发货日期 /// [Display(Name = "发货日期")] [ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")] public DateTime? ShippingDate { get; set; } - /// /// 生产码 /// @@ -804,9 +762,6 @@ public class PubSaSeCompareDetailExportYinDuJian : PubSaSeCompareDetailExport, I { /// /// 类别 - /// 有结算有发运 - /// 有结算无发运 - /// 无结算有发运 /// [Display(Name = "类别")] [ExporterHeader(DisplayName = "类别")] @@ -814,21 +769,18 @@ public class PubSaSeCompareDetailExportYinDuJian : PubSaSeCompareDetailExport, I [ValueMapping("有结算无发运", 2)] [ValueMapping("无结算有发运", 3)] public EnumPubSaSeCompareCategory Category { get; set; } - /// /// Wms发货单号 /// [Display(Name = "Wms发货单号")] [ExporterHeader(DisplayName = "交货单号")] public string WmsBillNum { get; set; } - /// /// 发货日期 /// [Display(Name = "发货日期")] [ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")] public DateTime? ShippingDate { get; set; } - /// /// 生产码 /// 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 c9bcaf50..67910449 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 @@ -42,6 +42,7 @@ public class PubSaSeCompareDapperRepository : DapperRepository /// 买单件BBAC结算、发运对比导出服务 /// - public class MaiDanBBACSaSeCompareExportService : ITransientDependency, IExportJob + public class MaiDanBBACSaSeCompareExportService : SaSeCompareExportBaseService, ITransientDependency, IExportJob { /// - /// HubContext + /// 业务类型 /// - private readonly IHubContext _hubContext; + private readonly EnumBusinessType businessType = EnumBusinessType.MaiDanJianBBAC; /// /// 文件容器 /// private readonly IBlobContainer _fileContainer; /// + /// AutoMapper + /// + private readonly IObjectMapper _objectMapper; + /// /// DbContext /// private readonly SettleAccountDbContext _settleAccountDbContext; @@ -43,10 +48,10 @@ namespace SettleAccount.Job.Services.Report IHubContext hubContext, IBlobContainer fileContainer, IObjectMapper objectMapper, - SettleAccountDbContext settleAccountDbContext) + SettleAccountDbContext settleAccountDbContext) : base(hubContext) { - _hubContext = hubContext; _fileContainer = fileContainer; + _objectMapper = objectMapper; _settleAccountDbContext = settleAccountDbContext; } @@ -61,109 +66,27 @@ namespace SettleAccount.Job.Services.Report var strSeStartDateTime = property.Where(p => p.Name == "SeStartDateTime").FirstOrDefault().Value; var strSeEndDateTime = property.Where(p => p.Name == "SeEndDateTime").FirstOrDefault().Value; + var businessTypeDisplayName = businessType.GetAttributeOfType()?.Name ?? businessType.ToString(); var seStartDateTime = DateTime.Parse(strSeStartDateTime); var seEndDateTime = DateTime.Parse(strSeEndDateTime); var filename = exportName.FirstOrDefault(); - //有EDI无发运 - var haveEdiNotHaveSeList = _settleAccountDbContext.Set().Where(t => t.IsHaveSeData == false) - .GroupBy(t => new { t.LU, t.PN }) - .Select(t => new JisBBACEidSeCompareExport() - { - Category = "JIS", - CarModeCode = default, - LineStationcode = default, - SequenceNumber = t.Max(t => t.SeqNumber), - ParType = "01", - EdiQty = t.Sum(t => t.Qty), - AssemblyDate = default, - MatchNumber = default, - MateType = "否", - DiffDesc = "WMS漏发货EDI有订单" - }).ToList(); - //无EDI有发运 - var notHaveEdiHaveSeList = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == false) - .GroupBy(t => new { t.LU, t.PN }) - .Select(t => new JisBBACEidSeCompareExport() - { - Category = "JIS", - WmsBillNum = t.Max(t => t.BillNum), - MESConfigCode = t.Max(t => t.MESConfigCode), - ShippingDate = t.Max(t => t.BillTime), - PN = t.Max(t => t.PN), - Seq = t.Max(t => t.Seq), - PjsNum = t.Max(t => t.PjsNum), - MaterialNumber = t.Max(t => t.CustPartCode), - MaterialDes = t.Max(t => t.PartDesc), - SEQty = t.Sum(t => t.Qty), - InjectionCode = t.Max(t => t.InjectionCode), - MateType = "否", - DiffDesc = "WMS有发货EDI无订单" - }).ToList(); - //有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), - 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 - select new - { - groupItem.Key.PN, - groupItem.Key.LU, - Qty = groupItem.Sum(t => t.Qty), - BillNum = groupItem.Max(t => t.BillNum), - MESConfigCode = groupItem.Max(t => t.MESConfigCode), - BillTime = groupItem.Max(t => t.BillTime), - Seq = groupItem.Max(t => t.Seq), - PjsNum = groupItem.Max(t => t.PjsNum), - CustPartCode = groupItem.Max(t => t.CustPartCode), - PartDesc = groupItem.Max(t => t.PartDesc), - InjectionCode = groupItem.Max(t => t.InjectionCode) - }; - 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 - select new JisBBACEidSeCompareExport() - { - Category = "JIS", - WmsBillNum = se.BillNum, - CarModeCode = default, - LineStationcode = default, - SequenceNumber = edi.SeqNumber, - ParType = "01", - MESConfigCode = se.MESConfigCode, - ShippingDate = se.BillTime, - PN = se.PN, - Seq = se.Seq, - PjsNum = se.PjsNum, - MaterialNumber = se.CustPartCode, - MaterialDes = se.PartDesc, - SEQty = se.Qty, - EdiQty = edi.Qty, - AssemblyDate = default, - MatchNumber = default, - InjectionCode = se.InjectionCode, - MateType = se.Qty == edi.Qty ? "是" : "否", - DiffDesc = "WMS有发货EDI有订单" - }).ToList(); + var pubSaSeCompareDiffs = GetSaSeCompareData(int.Parse(version), seStartDateTime, seEndDateTime); + + HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); - haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList); - notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList); + if (string.IsNullOrEmpty(lu) == false) + { + pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu); + } + if (string.IsNullOrEmpty(pn) == false) + { + pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn); + } + pubSaSeCompareDiffs = pubSaSeCompareDiffs.OrderBy(t => t.Category).ToList(); - ExcelExporter excelExporter = new ExcelExporter(); - excelExporter - .Append(haveEdiNotHaveSeList, $"BBACEDI数据和发货对比") - .SeparateBySheet() - .Append(notHaveEdiHaveSeList, $"BBAC发货和EDI数据对比"); + var items = _objectMapper.Map, List>(pubSaSeCompareDiffs); + var excelExporter = BindExcelExporter(items, businessTypeDisplayName); var result = excelExporter.ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); @@ -174,9 +97,83 @@ namespace SettleAccount.Job.Services.Report } #region 私有方法 - private void Notify() + /// + /// 获取结算与发运比对数据 + /// + public List GetSaSeCompareData(int version, DateTime seStartDateTime, DateTime seEndDateTime) { - this._hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", ""); + //结算 + var saGroup = from sa in _settleAccountDbContext.Set() + where sa.BusinessType == businessType && sa.Version == version + group sa by new { sa.PN, sa.LU } into groupItem + select new + { + groupItem.Key.PN, + groupItem.Key.LU, + Qty = groupItem.Sum(t => t.Qty), + Price = groupItem.Max(t => t.Price), + SettleDate = groupItem.Max(t => t.SettleDate), + PartCode = groupItem.Max(t => t.PartCode), + }; + //发运 + 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 + select new + { + groupItem.Key.PN, + groupItem.Key.LU, + Qty = groupItem.Sum(t => t.Qty), + 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) + }; + var saSeCompareLeft = (from sa in saGroup + join se in seGroup + on new { sa.PN, sa.LU } equals new { se.PN, se.LU } + into temp + from se in temp.DefaultIfEmpty() + select new PubSaSeCompareDiff() + { + WmsBillNum = se.WmsBillNum, + ShippingDate = se.ShippingDate, + CustomerOfflineTime = sa.SettleDate, + PN = sa.PN, + SAQty = sa.Qty, + SEQty = se.Qty, + FixPrice = sa.Price, + ToLocCode = se.ToLoc, + ToErpLocCode = se.ErpToLoc, + SeCustomerPartCode = se.LU, + SeFactoryPartCode = se.FactoryPartCode, + SaCustomerPartCode = sa.LU, + SaFactoryPartCode = sa.PartCode + }); + var saSeCompareRight = (from se in seGroup + join sa in saGroup + on new { se.PN, se.LU } equals new { sa.PN, sa.LU } + into temp + from sa in temp.DefaultIfEmpty() + select new PubSaSeCompareDiff() + { + WmsBillNum = se.WmsBillNum, + ShippingDate = se.ShippingDate, + CustomerOfflineTime = sa.SettleDate, + PN = se.PN, + SAQty = sa.Qty, + SEQty = se.Qty, + FixPrice = sa.Price, + ToLocCode = se.ToLoc, + ToErpLocCode = se.ErpToLoc, + SeCustomerPartCode = se.LU, + SeFactoryPartCode = se.FactoryPartCode, + SaCustomerPartCode = sa.LU, + SaFactoryPartCode = sa.PartCode + }); + var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList(); + return saSeCompareFullJoin; } #endregion } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs index c193de5e..0fa9c1f5 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs @@ -1,9 +1,10 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Linq.Dynamic.Core; -using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.SignalR; +using Microsoft.OpenApi.Extensions; using SettleAccount.Domain.BQ; using SettleAccount.Job.SignalR; using Shouldly; @@ -15,23 +16,28 @@ using Volo.Abp.ObjectMapping; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount.Reports; +using static NPOI.HSSF.Util.HSSFColor; namespace SettleAccount.Job.Services.Report { /// /// 买单件HBPO结算、发运对比导出服务 /// - public class MaiDanHBPOSaSeCompareExportService : ITransientDependency, IExportJob + public class MaiDanHBPOSaSeCompareExportService : SaSeCompareExportBaseService, ITransientDependency, IExportJob { /// - /// HubContext + /// 业务类型 /// - private readonly IHubContext _hubContext; + private readonly EnumBusinessType businessType = EnumBusinessType.MaiDanJianHBPO; /// /// 文件容器 /// private readonly IBlobContainer _fileContainer; /// + /// AutoMapper + /// + private readonly IObjectMapper _objectMapper; + /// /// DbContext /// private readonly SettleAccountDbContext _settleAccountDbContext; @@ -43,10 +49,10 @@ namespace SettleAccount.Job.Services.Report IHubContext hubContext, IBlobContainer fileContainer, IObjectMapper objectMapper, - SettleAccountDbContext settleAccountDbContext) + SettleAccountDbContext settleAccountDbContext) : base(hubContext) { - _hubContext = hubContext; _fileContainer = fileContainer; + _objectMapper = objectMapper; _settleAccountDbContext = settleAccountDbContext; } @@ -61,109 +67,27 @@ namespace SettleAccount.Job.Services.Report var strSeStartDateTime = property.Where(p => p.Name == "SeStartDateTime").FirstOrDefault().Value; var strSeEndDateTime = property.Where(p => p.Name == "SeEndDateTime").FirstOrDefault().Value; + var businessTypeDisplayName = businessType.GetAttributeOfType()?.Name ?? businessType.ToString(); var seStartDateTime = DateTime.Parse(strSeStartDateTime); var seEndDateTime = DateTime.Parse(strSeEndDateTime); var filename = exportName.FirstOrDefault(); - //有EDI无发运 - var haveEdiNotHaveSeList = _settleAccountDbContext.Set().Where(t => t.IsHaveSeData == false) - .GroupBy(t => new { t.LU, t.PN }) - .Select(t => new JisBBACEidSeCompareExport() - { - Category = "JIS", - CarModeCode = default, - LineStationcode = default, - SequenceNumber = t.Max(t => t.SeqNumber), - ParType = "01", - EdiQty = t.Sum(t => t.Qty), - AssemblyDate = default, - MatchNumber = default, - MateType = "否", - DiffDesc = "WMS漏发货EDI有订单" - }).ToList(); - //无EDI有发运 - var notHaveEdiHaveSeList = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == false) - .GroupBy(t => new { t.LU, t.PN }) - .Select(t => new JisBBACEidSeCompareExport() - { - Category = "JIS", - WmsBillNum = t.Max(t => t.BillNum), - MESConfigCode = t.Max(t => t.MESConfigCode), - ShippingDate = t.Max(t => t.BillTime), - PN = t.Max(t => t.PN), - Seq = t.Max(t => t.Seq), - PjsNum = t.Max(t => t.PjsNum), - MaterialNumber = t.Max(t => t.CustPartCode), - MaterialDes = t.Max(t => t.PartDesc), - SEQty = t.Sum(t => t.Qty), - InjectionCode = t.Max(t => t.InjectionCode), - MateType = "否", - DiffDesc = "WMS有发货EDI无订单" - }).ToList(); - //有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), - 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 - select new - { - groupItem.Key.PN, - groupItem.Key.LU, - Qty = groupItem.Sum(t => t.Qty), - BillNum = groupItem.Max(t => t.BillNum), - MESConfigCode = groupItem.Max(t => t.MESConfigCode), - BillTime = groupItem.Max(t => t.BillTime), - Seq = groupItem.Max(t => t.Seq), - PjsNum = groupItem.Max(t => t.PjsNum), - CustPartCode = groupItem.Max(t => t.CustPartCode), - PartDesc = groupItem.Max(t => t.PartDesc), - InjectionCode = groupItem.Max(t => t.InjectionCode) - }; - 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 - select new JisBBACEidSeCompareExport() - { - Category = "JIS", - WmsBillNum = se.BillNum, - CarModeCode = default, - LineStationcode = default, - SequenceNumber = edi.SeqNumber, - ParType = "01", - MESConfigCode = se.MESConfigCode, - ShippingDate = se.BillTime, - PN = se.PN, - Seq = se.Seq, - PjsNum = se.PjsNum, - MaterialNumber = se.CustPartCode, - MaterialDes = se.PartDesc, - SEQty = se.Qty, - EdiQty = edi.Qty, - AssemblyDate = default, - MatchNumber = default, - InjectionCode = se.InjectionCode, - MateType = se.Qty == edi.Qty ? "是" : "否", - DiffDesc = "WMS有发货EDI有订单" - }).ToList(); + var pubSaSeCompareDiffs = GetSaSeCompareData(int.Parse(version), seStartDateTime, seEndDateTime); + + HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); - haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList); - notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList); + if (string.IsNullOrEmpty(lu) == false) + { + pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu); + } + if (string.IsNullOrEmpty(pn) == false) + { + pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn); + } + pubSaSeCompareDiffs = pubSaSeCompareDiffs.OrderBy(t => t.Category).ToList(); - ExcelExporter excelExporter = new ExcelExporter(); - excelExporter - .Append(haveEdiNotHaveSeList, $"BBACEDI数据和发货对比") - .SeparateBySheet() - .Append(notHaveEdiHaveSeList, $"BBAC发货和EDI数据对比"); + var items = _objectMapper.Map, List>(pubSaSeCompareDiffs); + var excelExporter = BindExcelExporter(items, businessTypeDisplayName); var result = excelExporter.ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); @@ -174,9 +98,83 @@ namespace SettleAccount.Job.Services.Report } #region 私有方法 - private void Notify() + /// + /// 获取结算与发运比对数据 + /// + public List GetSaSeCompareData(int version, DateTime seStartDateTime, DateTime seEndDateTime) { - this._hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", ""); + //结算 + var saGroup = from sa in _settleAccountDbContext.Set() + where sa.BusinessType == businessType && sa.Version == version + group sa by new { sa.PN, sa.LU } into groupItem + select new + { + groupItem.Key.PN, + groupItem.Key.LU, + Qty = groupItem.Sum(t => t.Qty), + Price = groupItem.Max(t => t.Price), + SettleDate = groupItem.Max(t => t.SettleDate), + PartCode = groupItem.Max(t => t.PartCode), + }; + //发运 + 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 + select new + { + groupItem.Key.PN, + groupItem.Key.LU, + Qty = groupItem.Sum(t => t.Qty), + 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) + }; + var saSeCompareLeft = (from sa in saGroup + join se in seGroup + on new { sa.PN, sa.LU } equals new { se.PN, se.LU } + into temp + from se in temp.DefaultIfEmpty() + select new PubSaSeCompareDiff() + { + WmsBillNum = se.WmsBillNum, + ShippingDate = se.ShippingDate, + CustomerOfflineTime = sa.SettleDate, + PN = sa.PN, + SAQty = sa.Qty, + SEQty = se.Qty, + FixPrice = sa.Price, + ToLocCode = se.ToLoc, + ToErpLocCode = se.ErpToLoc, + SeCustomerPartCode = se.LU, + SeFactoryPartCode = se.FactoryPartCode, + SaCustomerPartCode = sa.LU, + SaFactoryPartCode = sa.PartCode + }); + var saSeCompareRight = (from se in seGroup + join sa in saGroup + on new { se.PN, se.LU } equals new { sa.PN, sa.LU } + into temp + from sa in temp.DefaultIfEmpty() + select new PubSaSeCompareDiff() + { + WmsBillNum = se.WmsBillNum, + ShippingDate = se.ShippingDate, + CustomerOfflineTime = sa.SettleDate, + PN = se.PN, + SAQty = sa.Qty, + SEQty = se.Qty, + FixPrice = sa.Price, + ToLocCode = se.ToLoc, + ToErpLocCode = se.ErpToLoc, + SeCustomerPartCode = se.LU, + SeFactoryPartCode = se.FactoryPartCode, + SaCustomerPartCode = sa.LU, + SaFactoryPartCode = sa.PartCode + }); + var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList(); + return saSeCompareFullJoin; } #endregion } 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 eab8b716..eecc0b30 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 @@ -283,14 +283,6 @@ namespace SettleAccount.Job.Services.Report excelExporter = BindExcelExporter(items, businessTypeDisplayName); } break; - case EnumBusinessType.MaiDanJianBBAC: - break; - case EnumBusinessType.MaiDanJianHBPO: - //{ - // var items = _objectMapper.Map, List>(pubSaSeCompareDiffs); - // excelExporter = BindExcelExporter(items, businessTypeDisplayName); - //} - break; case EnumBusinessType.BeiJian: { var items = _objectMapper.Map, List>(pubSaSeCompareDiffs); @@ -409,6 +401,7 @@ namespace SettleAccount.Job.Services.Report WmsBillNum = se.WmsBillNum, ShippingDate = se.ShippingDate, CustomerOfflineTime = sa.SettleDate, + PN = sa.PN, SAQty = sa.Qty, SEQty = se.Qty, FixPrice = sa.Price, @@ -429,6 +422,7 @@ namespace SettleAccount.Job.Services.Report WmsBillNum = se.WmsBillNum, ShippingDate = se.ShippingDate, CustomerOfflineTime = sa.SettleDate, + PN = se.PN, SAQty = sa.Qty, SEQty = se.Qty, FixPrice = sa.Price, @@ -439,7 +433,7 @@ namespace SettleAccount.Job.Services.Report SaCustomerPartCode = sa.LU, SaFactoryPartCode = sa.PartCode }); - var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); + var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList(); return saSeCompareFullJoin; } /// @@ -503,7 +497,9 @@ namespace SettleAccount.Job.Services.Report .SeparateBySheet() .Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出"); } - + /// + /// 通知 + /// private void Notify() { this._hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", ""); 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 new file mode 100644 index 00000000..36519306 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs @@ -0,0 +1,136 @@ +using System.Collections.Generic; +using System.Linq; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.SignalR; +using SettleAccount.Job.SignalR; +using Win.Sfs.SettleAccount.Enums; +using Win.Sfs.SettleAccount.Reports; + +namespace SettleAccount.Job.Services.Report +{ + public class SaSeCompareExportBaseService + { + /// + /// HubContext + /// + private readonly IHubContext _hubContext; + + public SaSeCompareExportBaseService(IHubContext hubContext) + { + _hubContext = hubContext; + } + + public virtual void HandlePubSaSeCompareDiffList(List pubSaSeCompareDiffs) + { + pubSaSeCompareDiffs.ForEach(p => + { + p.Category = (string.IsNullOrEmpty(p.SaCustomerPartCode), string.IsNullOrEmpty(p.SeCustomerPartCode)) switch + { + (false, false) => EnumPubSaSeCompareCategory.HaveSaHaveSe, + (false, true) => EnumPubSaSeCompareCategory.HaveSaNotHaveSe, + (true, false) => EnumPubSaSeCompareCategory.NotHaveSaHaveSe, + _ => EnumPubSaSeCompareCategory.None, + }; + switch (p.Category) + { + case EnumPubSaSeCompareCategory.None: + break; + case EnumPubSaSeCompareCategory.HaveSaHaveSe: + { + p.CustomerPartCode = p.SaCustomerPartCode; + p.FactoryPartCode = p.SaFactoryPartCode; + p.ReplaceFactoryPartCode = p.SaFactoryPartCode; + } + break; + case EnumPubSaSeCompareCategory.HaveSaNotHaveSe: + { + p.CustomerPartCode = p.SaCustomerPartCode; + p.FactoryPartCode = p.SaFactoryPartCode; + p.ReplaceFactoryPartCode = p.SaFactoryPartCode; + } + break; + case EnumPubSaSeCompareCategory.NotHaveSaHaveSe: + { + p.CustomerPartCode = p.SeCustomerPartCode; + p.FactoryPartCode = p.SeFactoryPartCode; + p.ReplaceFactoryPartCode = p.SeFactoryPartCode; + } + break; + default: + break; + } + }); + } + + /// + /// 创建导出文件结构 + /// + public ExcelExporter BindExcelExporter(List pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport, new() + { + //结算核对汇总 + var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() + { + FactoryPartCode = p.Key, + PartCodeDesc = p.FirstOrDefault().PartCodeDesc, + SAQty = p.Sum(t => t.SAQty), + SEQty = p.Sum(t => t.SEQty) + }).ToList(); + + //有结算有发运 + var haveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); + //有结算有发运汇总 + var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() + { + FactoryPartCode = p.Key, + PartCodeDesc = p.FirstOrDefault().PartCodeDesc, + SAQty = p.Sum(t => t.SAQty), + SEQty = p.Sum(t => t.SEQty) + }).ToList(); + //有结算无发运 + var haveSaNotHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); + //有结算无发运 + var haveSaNotHaveSeSumExports = haveSaNotHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() + { + FactoryPartCode = p.Key, + PartCodeDesc = p.FirstOrDefault().PartCodeDesc, + SAQty = p.Sum(t => t.SAQty), + SEQty = p.Sum(t => t.SEQty) + }).ToList(); + //无结算有发运 + var notHaveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); + //无结算有发运 + var notHaveSaHaveSeSumExports = notHaveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() + { + FactoryPartCode = p.Key, + PartCodeDesc = p.FirstOrDefault().PartCodeDesc, + SAQty = p.Sum(t => t.SAQty), + SEQty = p.Sum(t => t.SEQty) + }).ToList(); + + ExcelExporter excelExporter = new ExcelExporter(); + return excelExporter + .Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") + .SeparateBySheet() + .Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") + .SeparateBySheet() + + .Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发货明细输出") + .SeparateBySheet() + .Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出") + .SeparateBySheet() + + .Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") + .SeparateBySheet() + .Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出"); + } + + /// + /// 通知 + /// + public virtual void Notify() + { + _hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", ""); + } + + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs index 3ca3cbeb..e7ec5e0d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs @@ -29,6 +29,7 @@ namespace SettleAccount.Job { CreateMap(); CreateMap(); + CreateMap(); CreateMap(); CreateMap(); CreateMap(); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs index c1bc1e3e..652c5aa1 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs @@ -39,11 +39,12 @@ namespace Win.Sfs.SettleAccount ConfigureAutoMapper(); GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute{ Attempts = 0}); - context.Services.AddTransient(); context.Services.AddTransient(); - context.Services.AddTransient(); + context.Services.AddTransient();; + context.Services.AddTransient(); + context.Services.AddTransient(); + context.Services.AddTransient(); - context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); From 8a7cef051d39c4ec1c139dd8cc6679ba637bdc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Thu, 24 Aug 2023 16:40:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Dtos/BBAC_PD_DTO.cs | 18 +----- .../Entities/BQ/Dtos/INVOICE_GRP_DTO.cs | 4 +- .../Entities/BQ/BBAC_CAN_SA_SERVICE.cs | 5 +- .../SettleAccount.Domain/Bases/EntityBase.cs | 9 ++- .../Entities/BQ/BBAC_CAN_SA.cs | 3 + .../Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs | 1 + .../Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs | 1 + .../Entities/BQ/Managers/INV_MNG.cs | 59 +++++++++++++------ .../Entities/BQ/Managers/PUB_NOT_SA_MNG.cs | 2 + 9 files changed, 62 insertions(+), 40 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_PD_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_PD_DTO.cs index ad056fcc..91f42ca2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_PD_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_PD_DTO.cs @@ -136,22 +136,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// 替换生产码 /// public string REPN { get; set; } - /// - /// 键值 - /// - public string KeyCode { get; set; } - /// - /// 扩展字段1 - /// - public string Extend1 { get; set; } - /// - /// 扩展字段2 - /// - public string Extend2 { get; set; } - /// - /// 扩展字段3 - /// - public string Extend3 { get; set; } + + /// /// 客户零件号 /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs index e787eeb9..9de4b433 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs @@ -255,13 +255,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// ///零件号 /// - [Display(Name = "零件号")] + [Display(Name = "客户零件号")] public string LU { get; set; } /// ///零件号 /// - [Display(Name = "客户零件号")] + [Display(Name = "零件号")] public string PartCode { get; set; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs index eeb4f939..238fcaf7 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs @@ -30,6 +30,7 @@ using Win.Abp.Snowflakes; using Win.Sfs.SettleAccount.CommonManagers; using Volo.Abp; using Win.Sfs.SettleAccount.Entities.BQ.Temp; +using Volo.Abp.Uow; namespace Win.Sfs.SettleAccount.Entities.BQ { @@ -81,15 +82,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// [HttpPost] - + [UnitOfWork(false)] public async override Task GenerateInvoice([FromBody] string invbillNum) { var main =await _bbacMng.GetMainAsync(invbillNum); if (main != null) { - - if (main.State != SettleBillState.未结状态) { return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" }); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs index 35b9cbe3..51cede28 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs @@ -69,7 +69,14 @@ namespace SettleAccount.Bases public virtual string Site { get; set; } - + + public virtual void SetId(Guid guid) + { + Id = guid; + } + + + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs index 5b74aa7a..162af8a9 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs @@ -46,6 +46,9 @@ public class BBAC_CAN_SA : SA_CAN_BASE_MAIN Site = site; BusinessType = businessType; } + + + } [Display(Name = "BBAC可结算导入明细")] diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs index fd139484..a5928c9d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs @@ -64,6 +64,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); var _entity = new BBAC_CAN_SA(); + _entity.SetId(Guid.NewGuid()); _entity.BillNum = billNumber; _entity.InvGroupNum = billNumber; _entity.Version = DateTime.Now.Year + DateTime.Now.Month; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs index 57207ce2..c6973618 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs @@ -76,6 +76,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers _entity.State = SettleBillState.未结状态; _entity.SettleBillNum = string.Empty; _entity.BusinessType = p_list.FirstOrDefault().BusinessType; + _entity.SetId(Guid.NewGuid()); var _entityList = new List(); foreach (var itm in p_list) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs index 9fbaca26..42653b57 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs @@ -1282,14 +1282,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } if (invoiceMap.Keys.Count > 0) { - var groupList = new List(); var notDetialList = new List(); var detailList = new List(); var invlist = new List(); var salist = new List(); var adjlist = new List(); - foreach (var itm in invoiceMap)//分组影响和 { var key = itm.Key;//发票票号 @@ -1311,21 +1309,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers adjdetails.Add(detail); } } - - var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }) + var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID,p.LU }) .Select(itm => new { PartCode = itm.Key.PartCode, InvGroupNum = itm.Key.InvGroupNum, - LU = itm.Key.PartCode, + LU = itm.Key.LU, ContactDocID = itm.Key.ContractDocID, Price = itm.Key.Price, Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2), Qty = itm.Sum(k => k.Qty), BeginDate = itm.Key.BeginDate, EndDate = itm.Key.EndDate - }) - .ToList(); + }).ToList(); decimal amt = detailDtos.Sum(k => k.Amt); decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2); var mapList = new List(); @@ -1373,10 +1369,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers detailList.AddRange(_entityDetailList); } var innotls = new List(); + var sq = dtos.Where(p => itm.Value.Contains(p.GroupNum)).GroupBy(p => new { p.LU, p.GroupNum }) + .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = itm.Key, GroupNum = p.Key.GroupNum }); + + foreach (var sitm in sq) + { + innotls.Add(new INVOICE_NOT_SETTLE( + guid: GuidGenerator.Create(), + version: p_version, + invGroupNum: p_InvGroupNum, + settleGroupNum: sitm.GroupNum, + lU: sitm.LU, + lU1: sitm.LU, + extend1: string.Empty, + extend2: string.Empty, + qty: sitm.Qty, + p_invbillnum: itm.Key + )); + } if (p_notlist != null && p_notlist.Count > 0) { var groupnum = itm.Value; - var notls = p_notlist.Where(p=>groupnum.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) }); + var notls = p_notlist.Where(p => groupnum.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU }) + .Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = itm.Key }); foreach (var nitm in notls) { innotls.Add(new INVOICE_NOT_SETTLE( @@ -1384,12 +1399,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers version: p_version, invGroupNum: p_InvGroupNum, settleGroupNum: nitm.GroupNum, - lU: string.Empty, + lU: nitm.LU, lU1: nitm.LU, extend1: string.Empty, extend2: string.Empty, qty: nitm.Qty, - p_invbillnum:itm.Key + p_invbillnum: itm.Key )); } if (innotls.Count > 0) @@ -1408,9 +1423,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers invGroupNum: p_InvGroupNum, state: SettleBillState.已开票, invoiceBillState: InvoiceBillState.正常, - tax: 0, - parent: string.Empty, - preTaxDiff: 0, + tax: 0, + parent: string.Empty, + preTaxDiff: 0, taxDiff: 0, clientCode: string.Empty, realAmt: 0 @@ -1418,18 +1433,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers invlist.Add(invbill); } + if (salist.Count > 0) + { + foreach (var itm in invoiceMap)//分组影响和 + { + var key = itm.Key;//发票票号 + var ls = itm.Value;//结算分组号列表 + + string str = $" EXEC [p_Invoice_generation_change] @invbillnum = {"'" + key + "'"},@groupNum = {"'" + string.Join(",", ls) + "'"},@businessType = NULL"; + await _repository.DbContext.Database.ExecuteSqlRawAsync(str); + } + // await _repository.DbContext.BulkUpdateAsync(salist,new BulkConfig() { BatchSize=10000 }); + } await _repository.DbContext.BulkInsertAsync(invlist); await _repository.DbContext.BulkInsertAsync(groupList); await _repository.DbContext.BulkInsertAsync(detailList); - - if (salist.Count > 0) - { - await _repository.DbContext.BulkUpdateAsync(salist); - } + if (adjlist.Count > 0) { await _repository.DbContext.BulkUpdateAsync(adjlist); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs index c8a4c691..bca294e7 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs @@ -95,6 +95,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); var _entity = new PUB_CAN_SA(); + _entity.SetId(Guid.NewGuid()); _entity.BillNum = billNumber; _entity.InvGroupNum = billNumber; _entity.Version = DateTime.Now.Year + DateTime.Now.Month; @@ -134,6 +135,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); var _entity = new PUB_CAN_SA(); + _entity.SetId(Guid.NewGuid()); _entity.BillNum = billNumber; _entity.InvGroupNum = billNumber; _entity.Version = DateTime.Now.Year + DateTime.Now.Month;