From dfcbfe430bf6a5f40f46f5d9cf8ecd5d3e9359ff Mon Sep 17 00:00:00 2001 From: mahao Date: Mon, 11 Sep 2023 14:34:51 +0800 Subject: [PATCH 1/9] up --- .../MaiDanBBACSaSeCompareExportService.cs | 86 +------ .../MaiDanHBPOSaSeCompareExportService.cs | 86 +------ .../Report/PubSaSeCompareExportService.cs | 237 ++++++------------ .../Report/SaSeCompareExportBaseService.cs | 135 +++++++++- 4 files changed, 209 insertions(+), 335 deletions(-) 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 f3d83a47..853699be 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 @@ -72,7 +72,8 @@ namespace SettleAccount.Job.Services.Report var seStartDateTime = DateTime.Parse(strSeStartDateTime); var seEndDateTime = DateTime.Parse(strSeEndDateTime); var filename = exportName.FirstOrDefault(); - var pubSaSeCompareDiffs = GetSaSeCompareData(version, seStartDateTime, seEndDateTime); + //var pubSaSeCompareDiffs = GetSaSeCompareData(version, seStartDateTime, seEndDateTime); + var pubSaSeCompareDiffs = GetSaSeCompareDataJis(EnumBusinessType.MaiDanJianBBAC, version, seStartDateTime, seEndDateTime); HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); @@ -93,6 +94,7 @@ namespace SettleAccount.Job.Services.Report #region 结算数据处理 HandleSaDetails(pubSaSeCompareDiffs, businessType, version); + HandleSaDetailsMain(pubSaSeCompareDiffs, businessType, version); #endregion if (string.IsNullOrEmpty(lu) == false) @@ -115,87 +117,5 @@ namespace SettleAccount.Job.Services.Report Notify(); return id.ToString(); } - - #region 私有方法 - /// - /// 获取结算与发运比对数据 - /// - public List GetSaSeCompareData(int version, DateTime seStartDateTime, DateTime seEndDateTime) - { - //结算 - var saGroup = from sa in _settleAccountDbContext.Set() - where sa.BusinessType == businessType && sa.Version == version - group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem - select new - { - groupItem.Key.PN, - groupItem.Key.CustomerPartCodeNoSpace, - Qty = groupItem.Sum(t => t.Qty), - LU = groupItem.Max(t => t.LU), - 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.CustomerPartCodeNoSpace } into groupItem - select new - { - groupItem.Key.PN, - 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) - }; - var saSeCompareLeft = from sa in saGroup - join se in seGroup - on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } - into temp - from se in temp.DefaultIfEmpty() - select new SaSeCompareDiff() - { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, - CustomerOfflineTime = sa.SettleDate, - PN = sa.PN, - SAQty = sa.Qty, - SEQty = se.Qty, - ToLocCode = se.ToLoc, - ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.CustomerPartCodeNoSpace, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.CustomerPartCodeNoSpace, - SaFactoryPartCode = sa.PartCode, - CustomerPartCode = sa.LU, - }; - var saSeCompareRight = from se in seGroup - join sa in saGroup - on new { se.PN, se.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } - into temp - from sa in temp.DefaultIfEmpty() - select new SaSeCompareDiff() - { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, - CustomerOfflineTime = sa.SettleDate, - PN = se.PN, - SAQty = sa.Qty, - SEQty = se.Qty, - ToLocCode = se.ToLoc, - ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.CustomerPartCodeNoSpace, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.CustomerPartCodeNoSpace, - SaFactoryPartCode = sa.PartCode, - CustomerPartCode = sa.LU ?? se.LU - }; - var saSeCompareFullJoin = saSeCompareLeft.Union(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 42d1f5cf..5bbb8c18 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 @@ -72,7 +72,8 @@ namespace SettleAccount.Job.Services.Report var seStartDateTime = DateTime.Parse(strSeStartDateTime); var seEndDateTime = DateTime.Parse(strSeEndDateTime); var filename = exportName.FirstOrDefault(); - var pubSaSeCompareDiffs = GetSaSeCompareData(version, seStartDateTime, seEndDateTime); + //var pubSaSeCompareDiffs = GetSaSeCompareData(version, seStartDateTime, seEndDateTime); + var pubSaSeCompareDiffs = GetSaSeCompareDataJis(EnumBusinessType.MaiDanJianHBPO, version, seStartDateTime, seEndDateTime); HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); @@ -93,6 +94,7 @@ namespace SettleAccount.Job.Services.Report #region 结算数据处理 HandleSaDetails(pubSaSeCompareDiffs, businessType, version); + HandleSaDetailsMain(pubSaSeCompareDiffs, businessType, version); #endregion if (string.IsNullOrEmpty(lu) == false) @@ -115,87 +117,5 @@ namespace SettleAccount.Job.Services.Report Notify(); return id.ToString(); } - - #region 私有方法 - /// - /// 获取结算与发运比对数据 - /// - public List GetSaSeCompareData(int version, DateTime seStartDateTime, DateTime seEndDateTime) - { - //结算 - var saGroup = from sa in _settleAccountDbContext.Set() - where sa.BusinessType == businessType && sa.Version == version - group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem - select new - { - groupItem.Key.PN, - groupItem.Key.CustomerPartCodeNoSpace, - Qty = groupItem.Sum(t => t.Qty), - LU = groupItem.Max(t => t.LU), - 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.CustomerPartCodeNoSpace } into groupItem - select new - { - groupItem.Key.PN, - 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) - }; - var saSeCompareLeft = from sa in saGroup - join se in seGroup - on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } - into temp - from se in temp.DefaultIfEmpty() - select new SaSeCompareDiff() - { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, - CustomerOfflineTime = sa.SettleDate, - PN = sa.PN, - SAQty = sa.Qty, - SEQty = se.Qty, - ToLocCode = se.ToLoc, - ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.CustomerPartCodeNoSpace, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.CustomerPartCodeNoSpace, - SaFactoryPartCode = sa.PartCode, - CustomerPartCode = sa.LU - }; - 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 SaSeCompareDiff() - { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, - CustomerOfflineTime = sa.SettleDate, - PN = se.PN, - SAQty = sa.Qty, - SEQty = se.Qty, - ToLocCode = se.ToLoc, - ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.CustomerPartCodeNoSpace, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.CustomerPartCodeNoSpace, - SaFactoryPartCode = sa.PartCode, - CustomerPartCode = sa.LU ?? se.LU - }; - var saSeCompareFullJoin = saSeCompareLeft.Union(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 f2ff3796..5d26eb4c 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 @@ -6,6 +6,7 @@ using System.Linq; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.SignalR; using Microsoft.OpenApi.Extensions; +using SettleAccount.Bases; using SettleAccount.Domain.BQ; using SettleAccount.Job.SignalR; using ShardingCore.Extensions; @@ -34,18 +35,6 @@ namespace SettleAccount.Job.Services.Report /// private readonly SettleAccountDbContext _settleAccountDbContext; /// - /// 替换件关系仓储 - /// - private readonly INormalEfCoreRepository _tbRePartsRelationshipRepository; - /// - /// PUB二次比对仓储 - /// - private readonly INormalEfCoreRepository _pubSeCDetailRepository; - /// - /// Pub结算发运对比Dapper - /// - private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository; - /// /// 文件容器 /// private readonly IBlobContainer _fileContainer; @@ -60,16 +49,10 @@ namespace SettleAccount.Job.Services.Report public PubSaSeCompareExportService( IHubContext hubContext, SettleAccountDbContext settleAccountDbContext, - INormalEfCoreRepository tbRePartsRelationshipRepository, - INormalEfCoreRepository pubSeCDetailRepository, - PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, IBlobContainer fileContainer, IObjectMapper objectMapper) : base(hubContext, settleAccountDbContext) { _settleAccountDbContext = settleAccountDbContext; - _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; - _pubSeCDetailRepository = pubSeCDetailRepository; - _pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; _fileContainer = fileContainer; _objectMapper = objectMapper; } @@ -102,7 +85,7 @@ namespace SettleAccount.Job.Services.Report } var filename = exportName.FirstOrDefault(); //var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime); - var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, version, DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime)); + var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, version); HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); @@ -123,7 +106,6 @@ namespace SettleAccount.Job.Services.Report #region 结算数据处理 HandleSaDetails(pubSaSeCompareDiffs, businessType, version); - HandleSaDetailsMain(pubSaSeCompareDiffs, businessType, version); #endregion @@ -183,99 +165,12 @@ namespace SettleAccount.Job.Services.Report /// /// 获取比对数据 /// - [Obsolete] - private List GetSaSeCompareDataOld(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) - { - //印度件LU对比 - if (businessType == EnumBusinessType.YinDuJian) - { - return GetSaSeCompareDataYinDu(version, seStartDateTime, seEndDateTime); - } - //结算 - var saGroup = from sa in _settleAccountDbContext.Set() - where sa.BusinessType == businessType && sa.Version == version - group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem - select new - { - groupItem.Key.PN, - groupItem.Key.CustomerPartCodeNoSpace, - Qty = groupItem.Sum(t => t.Qty), - LU = groupItem.Max(t => t.LU), - 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.CustomerPartCodeNoSpace } into groupItem - select new - { - groupItem.Key.PN, - 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), - ToLocCode = groupItem.Max(t => t.ToLocCode), - ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) - }; - var saSeCompareLeft = from sa in saGroup - join se in seGroup - on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } - into temp - from se in temp.DefaultIfEmpty() - select new SaSeCompareDiff() - { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, - CustomerOfflineTime = sa.SettleDate, - PN = sa.PN, - SAQty = sa.Qty, - SEQty = se.Qty, - ToLocCode = se.ToLocCode, - ToErpLocCode = se.ToErpLocCode, - SeCustomerPartCode = se.CustomerPartCodeNoSpace, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.CustomerPartCodeNoSpace, - SaFactoryPartCode = sa.PartCode, - CustomerPartCode = sa.LU - }; - var saSeCompareRight = from se in seGroup - join sa in saGroup - on new { se.PN, se.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } - into temp - from sa in temp.DefaultIfEmpty() - select new SaSeCompareDiff() - { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, - CustomerOfflineTime = sa.SettleDate, - PN = se.PN, - SAQty = sa.Qty, - SEQty = se.Qty, - ToLocCode = se.ToLocCode, - ToErpLocCode = se.ToErpLocCode, - SeCustomerPartCode = se.CustomerPartCodeNoSpace, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.CustomerPartCodeNoSpace, - SaFactoryPartCode = sa.PartCode, - CustomerPartCode = sa.LU ?? se.LU - }; - - var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); - return saSeCompareFullJoin; - } - - /// - /// 获取比对数据 - /// - private List GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) + private List GetSaSeCompareData(EnumBusinessType businessType, int version) { //印度件LU对比 if (businessType == EnumBusinessType.YinDuJian) { - return GetSaSeCompareDataYinDu(version, seStartDateTime, seEndDateTime); + return GetSaSeCompareDataYinDu(version); } //结算 var saGroup = from sa in _settleAccountDbContext.Set() @@ -289,7 +184,7 @@ namespace SettleAccount.Job.Services.Report Version = groupItem.Max(t => t.Version), LU = groupItem.Max(t => t.LU), SettleDate = groupItem.Max(t => t.SettleDate), - PartCode = groupItem.Max(t => t.PartCode), + PartCode = groupItem.Max(t => t.PartCode) }; var saGroupByVersion = from sa in _settleAccountDbContext.Set() where sa.BusinessType == businessType && sa.Version == version @@ -302,7 +197,7 @@ namespace SettleAccount.Job.Services.Report Version = groupItem.Max(t => t.Version), LU = groupItem.Max(t => t.LU), SettleDate = groupItem.Max(t => t.SettleDate), - PartCode = groupItem.Max(t => t.PartCode), + PartCode = groupItem.Max(t => t.PartCode) }; //发运 var seGroup = from se in _settleAccountDbContext.Set() @@ -384,21 +279,35 @@ namespace SettleAccount.Job.Services.Report /// /// 获取比对数据 /// - private List GetSaSeCompareDataYinDu(int version, DateTime seStartDateTime, DateTime seEndDateTime) + private List GetSaSeCompareDataYinDu(int version) { + //结算 var saGroup = from sa in _settleAccountDbContext.Set() - where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version + where sa.BusinessType == EnumBusinessType.YinDuJian group sa by new { sa.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + Version = groupItem.Max(t => t.Version), LU = groupItem.Max(t => t.LU), SettleDate = groupItem.Max(t => t.SettleDate), - PartCode = groupItem.Max(t => t.PartCode), + PartCode = groupItem.Max(t => t.PartCode) }; + var saGroupByVersion = from sa in _settleAccountDbContext.Set() + where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version + group sa by new { sa.CustomerPartCodeNoSpace } into groupItem + select new + { + groupItem.Key.CustomerPartCodeNoSpace, + Qty = groupItem.Sum(t => t.Qty), + Version = groupItem.Max(t => t.Version), + LU = groupItem.Max(t => t.LU), + SettleDate = groupItem.Max(t => t.SettleDate), + PartCode = groupItem.Max(t => t.PartCode) + }; + //发运 var seGroup = from se in _settleAccountDbContext.Set() - where se.BusinessType == EnumBusinessType.YinDuJian && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime group se by new { se.CustomerPartCodeNoSpace } into groupItem select new { @@ -412,48 +321,62 @@ namespace SettleAccount.Job.Services.Report ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) }; - var saSeCompareLeft = from sa in saGroup - join se in seGroup - on sa.CustomerPartCodeNoSpace equals se.CustomerPartCodeNoSpace - into temp - from se in temp.DefaultIfEmpty() - select new SaSeCompareDiff() - { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, - CustomerOfflineTime = sa.SettleDate, - SAQty = sa.Qty, - SEQty = se.Qty, - ToLocCode = se.ToLocCode, - ToErpLocCode = se.ToErpLocCode, - SeCustomerPartCode = se.CustomerPartCodeNoSpace, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.CustomerPartCodeNoSpace, - SaFactoryPartCode = sa.PartCode, - CustomerPartCode = sa.LU - }; - var saSeCompareRight = from se in seGroup - join sa in saGroup - on se.CustomerPartCodeNoSpace equals sa.CustomerPartCodeNoSpace - into temp - from sa in temp.DefaultIfEmpty() - select new SaSeCompareDiff() - { - WmsBillNum = se.WmsBillNum, - ShippingDate = se.ShippingDate, - CustomerOfflineTime = sa.SettleDate, - SAQty = sa.Qty, - SEQty = se.Qty, - ToLocCode = se.ToLocCode, - ToErpLocCode = se.ToErpLocCode, - SeCustomerPartCode = se.CustomerPartCodeNoSpace, - SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.CustomerPartCodeNoSpace, - SaFactoryPartCode = sa.PartCode, - CustomerPartCode = sa.LU ?? se.LU - }; - var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); - return saSeCompareFullJoin; + //有结算无发运 + var haveSaNotHaveSeList = (from sa in saGroup + join se in seGroup + on sa.CustomerPartCodeNoSpace equals se.CustomerPartCodeNoSpace + into temp + from se in temp.DefaultIfEmpty() + where se.CustomerPartCodeNoSpace == null + select new SaSeCompareDiff() + { + Version = sa.Version, + CustomerOfflineTime = sa.SettleDate, + SAQty = sa.Qty, + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU + }).ToList(); + //无结算有发运 + var notHaveSaHaveSeList = (from se in seGroup + join sa in saGroup + on se.CustomerPartCodeNoSpace equals sa.CustomerPartCodeNoSpace + into temp + from sa in temp.DefaultIfEmpty() + where sa.CustomerPartCodeNoSpace == null + select new SaSeCompareDiff() + { + WmsBillNum = se.WmsBillNum, + ShippingDate = se.ShippingDate, + SEQty = se.Qty, + ToLocCode = se.ToLocCode, + ToErpLocCode = se.ToErpLocCode, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, + SeFactoryPartCode = se.FactoryPartCode, + CustomerPartCode = se.LU + }).ToList(); + + //有结算有发运 + var haveSaHaveSeList = (from sa in saGroupByVersion + from se in seGroup + where sa.CustomerPartCodeNoSpace == se.CustomerPartCodeNoSpace + select new SaSeCompareDiff() + { + Version = sa.Version, + WmsBillNum = se.WmsBillNum, + ShippingDate = se.ShippingDate, + CustomerOfflineTime = sa.SettleDate, + SAQty = sa.Qty, + SEQty = se.Qty, + ToLocCode = se.ToLocCode, + ToErpLocCode = se.ToErpLocCode, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, + SeFactoryPartCode = se.FactoryPartCode, + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU + }).ToList(); + return haveSaHaveSeList.Union(haveSaNotHaveSeList).Union(notHaveSaHaveSeList).ToList(); } #endregion } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs index 4ab4e2b9..7e660bcc 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs @@ -1,10 +1,10 @@ +using System; using System.Collections.Generic; using System.Linq; using EFCore.BulkExtensions; using Magicodes.ExporterAndImporter.Core.Extension; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.SignalR; -using Microsoft.EntityFrameworkCore; using SettleAccount.Bases; using SettleAccount.Domain.BQ; using SettleAccount.Job.SignalR; @@ -35,9 +35,120 @@ namespace SettleAccount.Job.Services.Report _settleAccountDbContext = settleAccountDbContext; } - public virtual void HandlePubSaSeCompareDiffList(List pubSaSeCompareDiffs) + /// + /// 获取结算、发运比对数据 + /// + public List GetSaSeCompareDataJis(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) + where TSaDetail : SA_BASE + where TSeDetail : JisSeBase + { + //结算 + var saGroup = from sa in _settleAccountDbContext.Set() + where sa.BusinessType == businessType + group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem + select new + { + groupItem.Key.PN, + groupItem.Key.CustomerPartCodeNoSpace, + Qty = groupItem.Sum(t => t.Qty), + Version = groupItem.Max(t => t.Version), + LU = groupItem.Max(t => t.LU), + SettleDate = groupItem.Max(t => t.SettleDate), + PartCode = groupItem.Max(t => t.PartCode) + }; + var saGroupByVersion = from sa in _settleAccountDbContext.Set() + where sa.BusinessType == businessType && sa.Version == version + group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem + select new + { + groupItem.Key.PN, + groupItem.Key.CustomerPartCodeNoSpace, + Qty = groupItem.Sum(t => t.Qty), + Version = groupItem.Max(t => t.Version), + LU = groupItem.Max(t => t.LU), + SettleDate = groupItem.Max(t => t.SettleDate), + PartCode = groupItem.Max(t => t.PartCode) + }; + //发运 + var seGroup = from se in _settleAccountDbContext.Set() + group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem + select new + { + groupItem.Key.PN, + 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), + ToLocCode = groupItem.Max(t => t.ToLoc), + ToErpLocCode = groupItem.Max(t => t.ErpToLoc) + }; + + //有结算无发运 + var haveSaNotHaveSeList = (from sa in saGroup + join se in seGroup + on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } + into temp + from se in temp.DefaultIfEmpty() + where se.PN == null + select new SaSeCompareDiff() + { + Version = sa.Version, + CustomerOfflineTime = sa.SettleDate, + PN = sa.PN, + SAQty = sa.Qty, + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU + }).ToList(); + //无结算有发运 + var notHaveSaHaveSeList = (from se in seGroup + join sa in saGroup + on new { se.PN, se.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } + into temp + from sa in temp.DefaultIfEmpty() + where sa.PN == null + select new SaSeCompareDiff() + { + WmsBillNum = se.WmsBillNum, + ShippingDate = se.ShippingDate, + PN = se.PN, + SEQty = se.Qty, + ToLocCode = se.ToLocCode, + ToErpLocCode = se.ToErpLocCode, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, + SeFactoryPartCode = se.FactoryPartCode, + CustomerPartCode = se.LU + }).ToList(); + + //有结算有发运 + var haveSaHaveSeList = (from sa in saGroupByVersion + from se in seGroup + where sa.PN == se.PN && sa.CustomerPartCodeNoSpace == se.CustomerPartCodeNoSpace + select new SaSeCompareDiff() + { + Version = sa.Version, + WmsBillNum = se.WmsBillNum, + ShippingDate = se.ShippingDate, + CustomerOfflineTime = sa.SettleDate, + PN = sa.PN, + SAQty = sa.Qty, + SEQty = se.Qty, + ToLocCode = se.ToLocCode, + ToErpLocCode = se.ToErpLocCode, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, + SeFactoryPartCode = se.FactoryPartCode, + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU + }).ToList(); + return haveSaHaveSeList.Union(haveSaNotHaveSeList).Union(notHaveSaHaveSeList).ToList(); + } + + public virtual void HandlePubSaSeCompareDiffList(List saSeCompareDiffs) { - pubSaSeCompareDiffs.ForEach(p => + saSeCompareDiffs.ForEach(p => { p.Category = (string.IsNullOrEmpty(p.SaCustomerPartCode), string.IsNullOrEmpty(p.SeCustomerPartCode)) switch { @@ -77,16 +188,16 @@ namespace SettleAccount.Job.Services.Report /// /// 二次比对 /// - public virtual List HandleSecondCompare(List pubSaSeCompareDiffs, EnumBusinessType businessType) + public virtual List HandleSecondCompare(List saSeCompareDiffs, EnumBusinessType businessType) { //二次匹配上的记录 var secondMatchHaveSaHaveSes = new List(); //有结算无发运 和 无结算有发运 - var haveSaNotHaveSeUnionNotHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe || t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); + var haveSaNotHaveSeUnionNotHaveSaHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe || t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); //有结算无发运 - var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); + var haveSaNotHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); //无结算有发运 - var notHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); + var notHaveSaHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); //二次对比(替换发运数据的厂内零件号) var repFactoryPartCodes = haveSaNotHaveSeUnionNotHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList(); @@ -133,12 +244,12 @@ namespace SettleAccount.Job.Services.Report /// 结算数据处理 /// 写入库位、替换零件号 /// - public virtual void HandleSaDetails(List pubSaSeCompareDiffs, EnumBusinessType businessType, int version) + public virtual void HandleSaDetails(List saSeCompareDiffs, EnumBusinessType businessType, int version) where TCanSa : SA_CAN_BASE where TNotSa : SA_NOT_BASE { //写入库位、替换零件号 - var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); + var haveSaHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); if (haveSaHaveSes.Any()) { //可结算单 @@ -174,12 +285,12 @@ namespace SettleAccount.Job.Services.Report } /// - /// 处理发运数据 + /// 处理结算数据 /// 结算、发运对比上的数据修改结算数据状态 /// - public virtual void HandleSaDetailsMain(List pubSaSeCompareDiffs, EnumBusinessType businessType, int version) where T : SA_BASE + public virtual void HandleSaDetailsMain(List saSeCompareDiffs, EnumBusinessType businessType, int version) where T : SA_BASE { - var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); + var haveSaHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); if (haveSaHaveSes.Any()) { //结算详情 From ee68f0af2e971ab8647b41bb182bd37703754f68 Mon Sep 17 00:00:00 2001 From: mahao Date: Mon, 11 Sep 2023 14:35:30 +0800 Subject: [PATCH 2/9] up --- .../Services/Report/MaiDanBBACSaSeCompareExportService.cs | 1 - .../Services/Report/MaiDanHBPOSaSeCompareExportService.cs | 1 - 2 files changed, 2 deletions(-) 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 853699be..66c8f827 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 @@ -72,7 +72,6 @@ namespace SettleAccount.Job.Services.Report var seStartDateTime = DateTime.Parse(strSeStartDateTime); var seEndDateTime = DateTime.Parse(strSeEndDateTime); var filename = exportName.FirstOrDefault(); - //var pubSaSeCompareDiffs = GetSaSeCompareData(version, seStartDateTime, seEndDateTime); var pubSaSeCompareDiffs = GetSaSeCompareDataJis(EnumBusinessType.MaiDanJianBBAC, version, seStartDateTime, seEndDateTime); HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); 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 5bbb8c18..a443cf23 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 @@ -72,7 +72,6 @@ namespace SettleAccount.Job.Services.Report var seStartDateTime = DateTime.Parse(strSeStartDateTime); var seEndDateTime = DateTime.Parse(strSeEndDateTime); var filename = exportName.FirstOrDefault(); - //var pubSaSeCompareDiffs = GetSaSeCompareData(version, seStartDateTime, seEndDateTime); var pubSaSeCompareDiffs = GetSaSeCompareDataJis(EnumBusinessType.MaiDanJianHBPO, version, seStartDateTime, seEndDateTime); HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); From 5e09c01ab821fb228dfc646d2c278e4b6080c2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 11 Sep 2023 14:58:12 +0800 Subject: [PATCH 3/9] =?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/HBPO_BA_SERVICE.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs index 4614b6d6..1979b445 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs @@ -302,6 +302,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] + [UnitOfWork(false)] /// 发票重开列表 /// /// @@ -314,11 +315,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result }); } - - - var invBilllist = new List(); - var adjlist = ObjectMapper.Map, List>(p_list); if (adjlist == null && adjlist.Count == 0) { @@ -451,6 +448,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] + [UnitOfWork(false)] /// 发票重开列表 /// /// From 3434e6676cbd40818b3628a844b36587a05d7c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 11 Sep 2023 15:22:06 +0800 Subject: [PATCH 4/9] =?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/INVOICE_SERVICE.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs index 5f8e2709..0a83ba5e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs @@ -454,19 +454,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ls.Add(invnot); } var entity= nolist.FirstOrDefault(); - var disList = lsC.Select(p => p.SettleGroupNum).Distinct().ToList(); + var disList = mgroup.Select(p => p.SettleGroupNum).Distinct().ToList(); - for (int i = 0; i < disList.Count; i++) - { - ls[i].SettleGroupNum = disList[i]; - } + for (int i = 0; i < lineC; i++) { ls[i].RealInvBillNum = entity.RealInvBillNum; ls[i].InvDate = entity.InvDate; ls[i].InvBillNum = entity.InvBillNum; ls[i].InvGroupNum = entity.InvGroupNum; - ls[i].SettleGroupNum = entity.SettleGroupNum; + // ls[i].SettleGroupNum = entity.SettleGroupNum; ls[i].SettleLU = lsC[i].LU; ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString(); } @@ -476,11 +473,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ls[i].InvDate = entity.InvDate; ls[i].InvBillNum = entity.InvBillNum; ls[i].InvGroupNum = entity.InvGroupNum; - ls[i].SettleGroupNum = entity.SettleGroupNum; + // ls[i].SettleGroupNum = entity.SettleGroupNum; ls[i].NotSettleLU = lsN[i].LU; ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString(); } + for (int i = 0; i < disList.Count; i++) + { + ls[i].SettleGroupNum = disList[i]; + } + + //if (lineC > lineN)//可结大于不可结行数时 From 3487385995098b8b16e7dc6a46a341400b9a3ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 11 Sep 2023 15:33:43 +0800 Subject: [PATCH 5/9] =?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 --- .../Bases/ADJ_SERVICE.cs | 2 +- .../Entities/BQ/BBAC_BA_SERVICE.cs | 40 +++++++++---------- .../Entities/BQ/BBAC_PD_SERVICE.cs | 2 +- .../Entities/BQ/HBPO_BA_SERVICE.cs | 7 +--- .../Entities/BQ/PUB_BA_SERVICE.cs | 6 ++- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs index 21ff965b..10192c0c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs @@ -182,7 +182,7 @@ public class ADJ_SERVICE : BASE_SERVICE { if (p_list.Count == 0) { - throw new UserFriendlyException($"导入数据为空"); + throw new UserFriendlyException($"导入数据为空","400"); } foreach (var itm in p_list) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs index 19a8939b..a5a73071 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs @@ -105,7 +105,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ if (settle == null) { - throw new UserFriendlyException($"选择发票:{p_invbillnum}对应的可结算单不在请检查!"); + throw new UserFriendlyException($"选择发票:{p_invbillnum}对应的可结算单不在请检查!","400"); } version = settle.Version; @@ -113,11 +113,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { if (inv.InvoiceState == InvoiceBillState.报废) { - throw new UserFriendlyException($"选择发票:{p_invbillnum}状态为报废状态不能重开!"); + throw new UserFriendlyException($"选择发票:{p_invbillnum}状态为报废状态不能重开!", "400"); } if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票) { - throw new UserFriendlyException($"选择发票:{p_invbillnum}状态在财务审核后可以报废重开,之前不能重开可以退回!"); + throw new UserFriendlyException($"选择发票:{p_invbillnum}状态在财务审核后可以报废重开,之前不能重开可以退回!", "400"); } var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 @@ -206,7 +206,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - throw new UserFriendlyException($"不存发票号为:{p_invbillnum}发票"); + throw new UserFriendlyException($"不存发票号为:{p_invbillnum}发票", "400"); } //} //else @@ -228,7 +228,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var adjlist = ObjectMapper.Map, List>(p_list); if (adjlist == null && adjlist.Count == 0) { - throw new UserFriendlyException($"调整表无数据!"); + throw new UserFriendlyException($"调整表无数据!", "400"); } var first = p_list.FirstOrDefault(); var invbillnum = first.InvBillNum; @@ -241,7 +241,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ if(settle==null) { - throw new UserFriendlyException( $"选择发票:{invbillnum}对应的可结算单不粗拿在在请检查!"); + throw new UserFriendlyException( $"选择发票:{invbillnum}对应的可结算单不粗拿在在请检查!", "400"); } version=settle.Version; @@ -249,11 +249,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { if (inv.InvoiceState == InvoiceBillState.报废) { - throw new UserFriendlyException( $"选择发票:{invbillnum}状态为报废状态不能重开!"); + throw new UserFriendlyException( $"选择发票:{invbillnum}状态为报废状态不能重开!", "400"); } if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票) { - throw new UserFriendlyException( $"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前不能重开可以退回!"); + throw new UserFriendlyException( $"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前不能重开可以退回!", "400"); } var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//发票对应结算零件 // var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 @@ -334,7 +334,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - throw new UserFriendlyException( $"不存发票号为:{invbillnum}发票"); + throw new UserFriendlyException( $"不存发票号为:{invbillnum}发票", "400"); } //} //else @@ -364,7 +364,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var adjlist=ObjectMapper.Map, List>(p_list); if (adjlist == null && adjlist.Count==0) { - throw new UserFriendlyException($"调整表无数据!"); + throw new UserFriendlyException($"调整表无数据!", "400"); } var first = p_list.FirstOrDefault(); var invbillnum = first.InvBillNum; @@ -379,21 +379,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ if (settle == null) { - throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!"); + throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!", "400"); } version = settle.Version; if (inv != null) { if (inv.InvoiceState == InvoiceBillState.报废) { - throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!"); + throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400"); } if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票) { - throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!"); + throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400"); } - var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 + var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum, "400");//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count() > 0) { @@ -473,7 +473,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - throw new UserFriendlyException($"不存发票号为:{invbillnum}发票"); + throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400"); } } @@ -499,7 +499,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var adjlist = ObjectMapper.Map, List>(p_list); if (adjlist == null && adjlist.Count == 0) { - throw new UserFriendlyException($"调整表无数据!"); + throw new UserFriendlyException($"调整表无数据!", "400"); } var first = p_list.FirstOrDefault(); var invbillnum = first.InvBillNum; @@ -514,18 +514,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ if (settle == null) { - throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!"); + throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!", "400"); } version = settle.Version; if (inv != null) { if (inv.InvoiceState == InvoiceBillState.报废) { - throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!"); + throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400"); } if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票) { - throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!"); + throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400"); } var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count() > 0) @@ -641,7 +641,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - throw new UserFriendlyException($"不存发票号为:{invbillnum}发票"); + throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400"); } //} //else diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs index 08ceebf3..f0f6b483 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs @@ -58,7 +58,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var lst = ls.Where(p => (p.State == SettleBillState.已提交扣减 || p.State == SettleBillState.已扣减)); if (lst.Count() > 0) { - throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交"); + throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400"); } foreach (var item in ls) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs index 1979b445..02a3ebc5 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs @@ -367,7 +367,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ qty: itm.Qty, price: itm.Price, businessType: itm.BusinessType, - settleDate: itm.SettleDate, groupNum: itm.GroupNum, invGroupNum: itm.InvGroupNum, @@ -618,11 +617,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400"); } - //} - //else - //{ - // throw new UserFriendlyException($"不存发票号:{invbillnum}对应的结算分组号"); - //} + return new JsonResult(new { Code = 200, Message = "生成成功", Data = invBilllist }); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs index 55f78ad9..cb8c1ffb 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs @@ -49,7 +49,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _priceRepository = priceRepository; _pricebjRepository = pricebjRepository; _adjservice= adjservice; - } /// @@ -217,7 +216,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// /// - + [HttpPost] + [UnitOfWork(false)] public override async Task ReissueInvoice([FromBody] string p_invbillnum) { //var mappingList = await GetMapGroupAsync(p_invbillnum);//发票对应结算分组 @@ -331,6 +331,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ return new JsonResult(new { Code = 200, Message = "发票重开成功" }); ; } [HttpPost] + [UnitOfWork(false)] /// 发票重开列表 /// /// @@ -512,6 +513,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] + [UnitOfWork(false)] public virtual async Task ReissueInvoiceList(List p_list) { From 3ecec595ef9365e68f36f1096332bc9b6cefec6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 11 Sep 2023 15:34:00 +0800 Subject: [PATCH 6/9] =?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 --- .../SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs index cb8c1ffb..48075359 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs @@ -206,11 +206,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //} return new JsonResult(new { Code = 200, Message = "发票重开成功" }); } - - - - - // /// 发票重开 /// From a3b99f302911d8352a595e1f0fe2806d7c937c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 11 Sep 2023 15:36:32 +0800 Subject: [PATCH 7/9] =?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/HBPO_BA_SERVICE.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs index 02a3ebc5..cbc42227 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs @@ -70,18 +70,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum); if (settle == null) { - throw new UserFriendlyException( $"选择发票:{p_invbillnum}对应的可结算单不存在请检查!"); + throw new UserFriendlyException( $"选择发票:{p_invbillnum}对应的可结算单不存在请检查!","400"); } version = settle.Version; if (inv != null) { if (inv.InvoiceState == InvoiceBillState.报废) { - throw new UserFriendlyException( $"选择发票:{p_invbillnum}状态为报废状态不能重开!"); + throw new UserFriendlyException( $"选择发票:{p_invbillnum}状态为报废状态不能重开!", "400"); } if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票) { - throw new UserFriendlyException( $"选择发票:{p_invbillnum}状态在财务审核后可以报废重开,之前请退回重开!"); + throw new UserFriendlyException( $"选择发票:{p_invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400"); } var hbpolist = await _hbpoMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 @@ -162,7 +162,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - throw new UserFriendlyException( $"不存发票号为:{p_invbillnum}发票"); + throw new UserFriendlyException( $"不存发票号为:{p_invbillnum}发票", "400"); } //} //else @@ -186,7 +186,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var adjlist = ObjectMapper.Map, List>(p_list); if (adjlist == null && adjlist.Count == 0) { - throw new UserFriendlyException($"调整表无数据!"); + throw new UserFriendlyException($"调整表无数据!", "400"); } var first = p_list.FirstOrDefault(); var invbillnum = first.InvBillNum; @@ -201,18 +201,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum); if (settle == null) { - throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不存在请检查!"); + throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不存在请检查!", "400"); } version = settle.Version; if (inv != null) { if (inv.InvoiceState == InvoiceBillState.报废) { - throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!"); + throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!", "400"); } if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票) { - throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!"); + throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400"); } var hbpolist = await _hbpoMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 // var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 @@ -290,7 +290,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - throw new UserFriendlyException($"不存发票号为:{invbillnum}发票"); + throw new UserFriendlyException($"不存发票号为:{invbillnum}发票", "400"); } //} //else From e6eb90f78ae50e300fbcbd31a6141588ac965b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 11 Sep 2023 15:39:44 +0800 Subject: [PATCH 8/9] =?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 --- .../SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs index 48075359..8250d084 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs @@ -82,18 +82,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ if (settle == null) { - throw new BusinessException("8989", $"选择发票:{invbillnum}对应的可结算单不在请检查!"); + throw new UserFriendlyException( $"选择发票:{invbillnum}对应的可结算单不在请检查!","400"); } version = settle.Version; if (inv != null) { if (inv.InvoiceState == InvoiceBillState.报废) { - throw new BusinessException("8989", $"选择发票:{invbillnum}状态为报废状态不能重开!"); + throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!","400"); } if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票) { - throw new BusinessException("8989", $"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前不能重开可以退回!"); + throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前不能重开可以退回!","400"); } var publist = await _pubMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 From 9589f53c9ed97bffc6bda7337e9243a333cf14ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 11 Sep 2023 15:40:45 +0800 Subject: [PATCH 9/9] =?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 --- .../SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs index 8250d084..8abb4418 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs @@ -30,8 +30,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [Route("api/settleaccount/[controller]/[action]")] public class PUB_BA_SERVICE : BA_SERVICE { - - private readonly INormalEfCoreRepository _priceRepository; private readonly INormalEfCoreRepository _pricebjRepository; private readonly ADJ_SERVICE _adjservice; @@ -143,11 +141,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { priceList = _priceRepository.ToList();//价格单 } - - - var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); - if (errorList.Count > 0) { return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "请下载错误信息", fileName = await ExportErrorReportAsync(errorList) });