From 1b1f7fc400c3f1ce5984a1b5a46f08f111a7f336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Sat, 2 Sep 2023 10:32:51 +0800 Subject: [PATCH] =?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/INVOICE_GRP_DTO.cs | 107 +++++++++++- .../Bases/BA_SERVICE.cs | 112 +++++++++---- .../Entities/BQ/INVOICE_SERVICE.cs | 155 +++++++++++++++--- ...ttleAccountApplicationAutoMapperProfile.cs | 5 +- .../Entities/BQ/Managers/INV_MNG.cs | 1 + 5 files changed, 314 insertions(+), 66 deletions(-) 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 714f2f8f..e5563353 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 @@ -219,6 +219,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// 发票明细 /// public List INVOICE_WAIT_DETAIL { get; set; } + + + /// + /// 发票明细 + /// + public List INVOICE_WAIT_DETAIL_BBAC { get; set; } + + + + public List INVOICE_WAIT_DETAIL_BJ { get; set; } + /// /// 发票和结算分组对应关系 /// @@ -239,8 +250,96 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos + public class INVOICE_WAIT_DETAIL_BJ_DTO + { + + /// + ///期间 + /// + [Display(Name = "期间")] + public int Version { get; set; } + [Display(Name = "金税发票号")] + public string RealInvbillNum { get; set; } + + + [Display(Name = "发票日期")] + public DateTime? InvDate { set; get; } + + /// + ///扩展字段1 + /// + [Display(Name = "凭证号")] + public string Extend1 { get; set; } + /// + ///发票号 + /// + [Display(Name = "发票号")] + public string InvbillNum { get; set; } + /// + ///发票分组号 + /// + [Display(Name = "发票分组号")] + public string InvGroupNum { get; set; } + /// + ///零件号 + /// + [Display(Name = "客户零件号")] + public string LU { get; set; } + + /// + ///零件号 + /// + [Display(Name = "零件号")] + public string PartCode { get; set; } + + /// + ///单价 + /// + [Display(Name = "单价")] + public decimal PRICE { get; set; } + /// + ///数量 + /// + [Display(Name = "数量")] + public decimal Qty { get; set; } + /// + ///金额 + /// + [Display(Name = "金额")] + public decimal Amt { get; set; } + /// + ///业务分类 + /// + [Display(Name = "业务分类")] + public string BussiessType { get; set; } + + + /// + ///扩展字段3 + /// + [Display(Name = "价格开始日期")] + public DateTime BeginDate { get; set; } + /// + ///扩展字段4 + /// + [Display(Name = "价格结束日期")] + public DateTime EndDate { get; set; } + + + + + + + + } + + + + + - public class INVOICE_WAIT_DETAIL_EXT_DTO + + public class INVOICE_WAIT_DETAIL_BBAC_DTO { /// @@ -335,8 +434,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "发票日期")] public DateTime? InvDate { set; get; } - - /// ///发票号 /// @@ -382,8 +479,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// ///扩展字段1 /// - [Display(Name = "SA号")] - public string Extend1 { get; set; } + //[Display(Name = "SA号")] + //public string Extend1 { get; set; } /// ///扩展字段3 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs index b9be846e..320763c4 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs @@ -146,20 +146,91 @@ namespace Win.Sfs.SettleAccount.Bases [HttpPost] public virtual async Task DetailQueryAsync(INVOICE_GRP_REQ_DTO input) { - INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO(); - - var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); - var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var mdtos = ObjectMapper.Map, List>(m); - var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); - var wdtos = ObjectMapper.Map, List>(w); var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var sdtos = ObjectMapper.Map, List>(s); + if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) + { + var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); + var AMap = ObjectMapper.Map, List>(A); + var wquery = from itm in AMap + join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum + select + new INVOICE_WAIT_DETAIL_BBAC_DTO() + { + InvDate = itm1.CreationTime, + RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, + Version = itm.Version, + InvbillNum = itm.InvbillNum, + InvGroupNum = itm.InvGroupNum, + LU = itm.LU, + PartCode = itm.PartCode, + PRICE = itm.PRICE, + Qty = itm.Qty, + Amt = itm.Amt, + BussiessType = itm.BussiessType, + Extend1 = itm.Extend1, + BeginDate = itm.BeginDate, + EndDate = itm.EndDate, + }; + entity.INVOICE_WAIT_DETAIL_BBAC = AMap; + } + else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) + { + var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); + var BMap = ObjectMapper.Map, List>(B); - + var wquery = from itm in BMap + join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum + select + new INVOICE_WAIT_DETAIL_BJ_DTO() + { + InvDate = itm1.CreationTime, + RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, + Version = itm.Version, + InvbillNum = itm.InvbillNum, + InvGroupNum = itm.InvGroupNum, + LU = itm.LU, + PartCode = itm.PartCode, + PRICE = itm.PRICE, + Qty = itm.Qty, + Amt = itm.Amt, + BussiessType = itm.BussiessType, + Extend1 = itm.Extend1, + BeginDate = itm.BeginDate, + EndDate = itm.EndDate, + }; + entity.INVOICE_WAIT_DETAIL_BJ = BMap; + } + else + { + var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); + var wdtos = ObjectMapper.Map, List>(w); + var wquery = from itm in wdtos + join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum + select + new INVOICE_WAIT_DETAIL_DTO() + { + InvDate = itm1.CreationTime, + RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, + Version = itm.Version, + InvbillNum = itm.InvbillNum, + InvGroupNum = itm.InvGroupNum, + LU = itm.LU, + PartCode = itm.PartCode, + PRICE = itm.PRICE, + Qty = itm.Qty, + Amt = itm.Amt, + BussiessType = itm.BussiessType, + // Extend1 = itm.Extend1, + BeginDate = itm.BeginDate, + EndDate = itm.EndDate, + }; + entity.INVOICE_WAIT_DETAIL = wdtos; + } var notquery = from itm in sdtos join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum select @@ -174,27 +245,6 @@ namespace Win.Sfs.SettleAccount.Bases Qty = itm.Qty, Extend1 = itm.Extend1, }; - - var wquery = from itm in wdtos - join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum - select - new INVOICE_WAIT_DETAIL_DTO() - { - InvDate = itm1.CreationTime, - RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, - Version = itm.Version, - InvbillNum = itm.InvbillNum, - InvGroupNum = itm.InvGroupNum, - LU = itm.LU, - PartCode = itm.PartCode, - PRICE = itm.PRICE, - Qty = itm.Qty, - Amt = itm.Amt, - BussiessType = itm.BussiessType, - Extend1 = itm.Extend1, - BeginDate = itm.BeginDate, - EndDate = itm.EndDate, - }; var mquery = from itm in mdtos join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum select @@ -206,13 +256,8 @@ namespace Win.Sfs.SettleAccount.Bases InvGroupNum = itm.InvGroupNum, SettleGroupNum = itm.SettleGroupNum }; - - - var adjs = await _adjRepository.GetListByFilterAsync(input.Filters); var adjdtos = ObjectMapper.Map, List>(adjs); - - var adjQuery = from itm in adjdtos join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum select @@ -230,7 +275,6 @@ namespace Win.Sfs.SettleAccount.Bases }; entity.INVOICE_NOT_SETTLE = notquery.ToList(); - entity.INVOICE_WAIT_DETAIL = wquery.ToList(); entity.INVOICE_MAP_GROUP = mquery.ToList(); entity.ADJ_DETAIL = adjQuery.ToList(); return entity; 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 2cdeb8ec..909759df 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 @@ -1,6 +1,7 @@ using CodeArts.Db; using DocumentFormat.OpenXml.Bibliography; using DocumentFormat.OpenXml.Drawing.Diagrams; +using DocumentFormat.OpenXml.Spreadsheet; using EFCore.BulkExtensions; using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Csv; @@ -149,11 +150,96 @@ namespace Win.Sfs.SettleAccount.Entities.BQ public virtual async Task DetailQueryAsync(INVOICE_GRP_REQ_DTO input) { INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO(); + var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var mdtos = ObjectMapper.Map, List>(m); - var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); - var wdtos = ObjectMapper.Map, List>(w); + + if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) + { + var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); + var AMap = ObjectMapper.Map, List>(A); + var wquery = from itm in AMap + join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum + select + new INVOICE_WAIT_DETAIL_BBAC_DTO() + { + InvDate = itm1.CreationTime, + RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, + Version = itm.Version, + InvbillNum = itm.InvbillNum, + InvGroupNum = itm.InvGroupNum, + LU = itm.LU, + PartCode = itm.PartCode, + PRICE = itm.PRICE, + Qty = itm.Qty, + Amt = itm.Amt, + BussiessType = itm.BussiessType, + Extend1 = itm.Extend1, + BeginDate = itm.BeginDate, + EndDate = itm.EndDate, + }; + entity.INVOICE_WAIT_DETAIL_BBAC = AMap; + } + else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) + { + var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); + var BMap = ObjectMapper.Map, List>(B); + + var wquery = from itm in BMap + join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum + select + new INVOICE_WAIT_DETAIL_BJ_DTO() + { + InvDate = itm1.CreationTime, + RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, + Version = itm.Version, + InvbillNum = itm.InvbillNum, + InvGroupNum = itm.InvGroupNum, + LU = itm.LU, + PartCode = itm.PartCode, + PRICE = itm.PRICE, + Qty = itm.Qty, + Amt = itm.Amt, + BussiessType = itm.BussiessType, + Extend1 = itm.Extend1, + BeginDate = itm.BeginDate, + EndDate = itm.EndDate, + }; + entity.INVOICE_WAIT_DETAIL_BJ = BMap; + } + else + { + + var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); + var wdtos = ObjectMapper.Map, List>(w); + var wquery = from itm in wdtos + join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum + select + new INVOICE_WAIT_DETAIL_DTO() + { + InvDate = itm1.CreationTime, + RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, + Version = itm.Version, + InvbillNum = itm.InvbillNum, + InvGroupNum = itm.InvGroupNum, + LU = itm.LU, + PartCode = itm.PartCode, + PRICE = itm.PRICE, + Qty = itm.Qty, + Amt = itm.Amt, + BussiessType = itm.BussiessType, + //Extend1 = itm.Extend1, + BeginDate = itm.BeginDate, + EndDate = itm.EndDate, + }; + + + + entity.INVOICE_WAIT_DETAIL = wdtos; + + } + var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var sdtos = ObjectMapper.Map, List>(s); var adjs =await _adjRepository.GetListByFilterAsync(input.Filters); @@ -173,26 +259,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ Extend1 = itm.Extend1, }; - var wquery = from itm in wdtos - join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum - select - new INVOICE_WAIT_DETAIL_DTO() - { - InvDate = itm1.CreationTime, - RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, - Version = itm.Version, - InvbillNum = itm.InvbillNum, - InvGroupNum = itm.InvGroupNum, - LU = itm.LU, - PartCode = itm.PartCode, - PRICE = itm.PRICE, - Qty = itm.Qty, - Amt = itm.Amt, - BussiessType = itm.BussiessType, - Extend1 = itm.Extend1, - BeginDate = itm.BeginDate, - EndDate = itm.EndDate, - }; + var mquery = from itm in mdtos join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum select @@ -222,7 +289,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ }; entity.INVOICE_NOT_SETTLE = notquery.ToList(); - entity.INVOICE_WAIT_DETAIL = wquery.ToList(); + entity.INVOICE_MAP_GROUP = mquery.ToList(); entity.ADJ_DETAIL = adjQuery.ToList(); return entity; @@ -243,6 +310,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ byte[] result = null; result = await _excel.ExportAsByteArray(dtoDetails); + + + + + + + + + //switch (input.FileType) //{ // case 0: @@ -275,22 +351,51 @@ namespace Win.Sfs.SettleAccount.Entities.BQ IExporter _csv = new CsvExporter(); ExcelExporter _excel = new ExcelExporter(); var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); + + + + + + + + var dtoDetails = ObjectMapper.Map, List>(entities); var invdetail= await DetailQueryAsync(input); var m = invdetail.INVOICE_MAP_GROUP; var not=invdetail.INVOICE_NOT_SETTLE; var detail =invdetail.INVOICE_WAIT_DETAIL; var adj = invdetail.ADJ_DETAIL; + var bbac = invdetail.INVOICE_WAIT_DETAIL_BBAC; + var bj = invdetail.INVOICE_WAIT_DETAIL_BJ; + + var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute()?.Name ?? typeof(INVOICE_GRP_DTO).Name; string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; foreach (var itm in entities) { - var invlist = detail.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); + var mgroup =m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); - _excel.Append(invlist, "发票号" + itm.InvbillNum).SeparateBySheet(); + + + + if (entities.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) + { + var bbaclist = bbac.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); + _excel.Append(bbaclist, "发票号" + itm.InvbillNum).SeparateBySheet(); + } + else if (entities.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) + { + var bjlist = bj.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); + _excel.Append(bjlist, "发票号" + itm.InvbillNum).SeparateBySheet(); + } + else + { + var invlist = detail.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); + _excel.Append(invlist, "发票号" + itm.InvbillNum).SeparateBySheet(); + } _excel.Append(mgroup, "发票结算分组对应" + itm.InvbillNum).SeparateBySheet(); _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); _excel.Append(nolist, "结算分组零件" + itm.InvbillNum); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index 4a6aaea5..ceb8bda0 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs @@ -288,8 +288,9 @@ namespace Win.Sfs.SettleAccount private void CreateMapINVOICE_WAIT_DETAIL_EXTEND() { - CreateMap().ReverseMap(); - + CreateMap().ReverseMap(); + + CreateMap().ReverseMap(); } 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 52e3a862..02c14304 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 @@ -1964,6 +1964,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers invbill.CreationTime = DateTime.Now; invlist.Add(invbill); } + await _repository.DbContext.BulkInsertAsync(invlist); await _repository.DbContext.BulkInsertAsync(groupList); await _repository.DbContext.BulkInsertAsync(detailList);