From 6650ac5aa0df00caf7e07ba2cf55272c3655780b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Fri, 8 Sep 2023 16:22:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Dtos/INVOICE_GRP_DTO.cs | 2 +- .../Bases/CAN_SA_SERVICE.cs | 4 +- .../Entities/BQ/BBAC_BA_SERVICE.cs | 2 +- .../Entities/BQ/BBAC_CAN_SA_SERVICE.cs | 2 +- .../Entities/BQ/HBPO_BA_SERVICE.cs | 2 +- .../Entities/BQ/HBPO_CAN_SA_SERVICE.cs | 2 +- .../Entities/BQ/INVOICE_SERVICE.cs | 276 ++++++++++-------- .../Entities/BQ/PUB_BA_SERVICE.cs | 2 +- .../Entities/BQ/PUB_CAN_SA_SERVICE.cs | 4 +- 9 files changed, 166 insertions(+), 130 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 1f7b77a5..056ced23 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 @@ -657,7 +657,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public string LU { get; set; } [Display(Name = "数量")] - public string Qty { get; set; } + public decimal? Qty { get; set; } /// ///不可结算零件号 /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs index 7e37ee37..9b62c79c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs @@ -259,9 +259,9 @@ namespace Win.Sfs.SettleAccount.Bases protected async Task> CheckInvoiceGenerationRules(List dto1s, List p_pricelist,EnumBusinessType p_businessType) where T : SA_CAN_BASE { - var maxDate = p_pricelist.Max(p => p.Date); + //var maxDate = p_pricelist.Max(p => p.Date); - var prices = p_pricelist.Where(p => p.Date == maxDate).ToList(); + var prices = p_pricelist.Where(p => p.IsCancel == false).ToList(); var inner = from d in dto1s join p in prices on d.LU equals p.LU 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 ec0a6cb1..23fbd21b 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 @@ -150,7 +150,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); //var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList(); //var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算 - var priceList = _priceRepository.ToList();//价格单 + var priceList = _priceRepository.Where(p=>p.IsCancel==false).ToList();//价格单 // priceList.GroupBy(p => new { p.BeginTime, p.EndTime }).Select(p => p.First()); 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 681d6545..184cc433 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 @@ -94,7 +94,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" }); } var entitys = await _bbacMng.GetDetalListAsync(invbillNum);//可结算 - var priceList = _priceRepository.ToList(); + var priceList = _priceRepository.Where(p => p.IsCancel == false).ToList(); var datetime = priceList.Select(p => p.Date).Max(); var prices = priceList.Where(p => p.Date == datetime).ToList(); ;//价格单 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 be53ba10..696e6d0a 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 @@ -239,7 +239,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); //var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList(); //var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算 - var priceList = _priceRepository.ToList();//价格单 + var priceList = _priceRepository.Where(p=>p.IsCancel==false).ToList();//价格单 var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); if (errorList.Count() > 0) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs index 7549e87b..801b203c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs @@ -88,7 +88,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" }); } var entitys = await _hbpoMng.GetDetalListAsync(invbillnum); - var priceList = _priceRepository.ToList();//价格单 + var priceList = _priceRepository.Where(p => p.IsCancel == false).ToList(); //价格单 var errorList = await CheckInvoiceGenerationRules(entitys, priceList, main.BusinessType);//校验生成规则 if (errorList.Count() > 0) { 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 34b87e8c..063e18b4 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 @@ -350,6 +350,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var materialList = await _baseservice.GetMaterialList(); + + + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); var dtoDetails = ObjectMapper.Map, List>(entities); var invdetail= await DetailQueryAsync(input); @@ -379,139 +382,172 @@ namespace Win.Sfs.SettleAccount.Entities.BQ 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(); - var lsC =nolist.Where(p => p.Extend1 == "可结算").ToList(); - var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList(); - // var r = (from t1 in lsC - // join t2 in lsN on new { t1.LU, t1.SettleGroupNum } - // equals new { t2.LU, t2.SettleGroupNum } - - // into temp - // from tm in temp.DefaultIfEmpty() - // select new INVOICE_NOT_SETTLE_EXT_DTO - // { - // RealInvBillNum = t1.RealInvBillNum, - // InvDate = t1.InvDate, - // InvBillNum = t1.InvBillNum, - // InvGroupNum = t1.InvGroupNum, - // SettleGroupNum = t1.SettleGroupNum, - // SettleLU = t1.LU, - // NotSettleLU = tm == null ? string.Empty : tm.LU, - // Qty = tm == null ? string.Empty : tm.Qty - - // } - // ) - //.Union - //(from t2 in lsN - // join t1 in lsC - // on new { t2.LU, t2.SettleGroupNum } - // equals new { t1.LU, t1.SettleGroupNum } - // into temp - // from tm in temp.DefaultIfEmpty() - // where tm == null - // select new INVOICE_NOT_SETTLE_EXT_DTO - // { - // RealInvBillNum = t2.RealInvBillNum, - // InvDate = t2.InvDate, - // InvBillNum = t2.InvBillNum, - // InvGroupNum = t2.InvGroupNum, - // SettleGroupNum = t2.SettleGroupNum, - // SettleLU = string.Empty, - // NotSettleLU = t2.LU, - // Qty = t2.Qty - - // } - // ); - - //_excel.Append(r.OrderBy(p=>p.SettleGroupNum).ToList(), "结算分组零件" + itm.InvbillNum); - - - + var lsC = nolist.Where(p => p.Extend1 == "可结算") + .GroupBy(p => new + { + p.LU, + p.RealInvBillNum, + p.InvDate, + p.InvBillNum, + p.InvGroupNum, + + }).Select(p => new INVOICE_NOT_SETTLE_DTO() { + LU =p.Key.LU, + RealInvBillNum =p.Key.RealInvBillNum, + InvDate =p.Key.InvDate, + InvBillNum =p.Key.InvBillNum, + InvGroupNum =p.Key.InvGroupNum, + Qty=p.Sum(itm=>itm.Qty) + + }).ToList(); + + var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList() + .GroupBy(p => new + { + p.LU, + p.RealInvBillNum, + p.InvDate, + p.InvBillNum, + p.InvGroupNum, + + }).Select(p => new INVOICE_NOT_SETTLE_DTO() + { + LU = p.Key.LU, + RealInvBillNum = p.Key.RealInvBillNum, + InvDate = p.Key.InvDate, + InvBillNum = p.Key.InvBillNum, + InvGroupNum = p.Key.InvGroupNum, + Qty = p.Sum(itm => itm.Qty) + }).ToList(); var lineC = lsC.Count; var lineN = lsN.Count; List ls = new List(); - if (lineC > lineN)//可结大于不可结行数时 + + for (int i = 0; i < 10000; i++) { - for (int number = 0; number < lineC; number++) - { - if (number + 1 > lineN) - { - INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); - - - entity.RealInvBillNum = lsC[number].RealInvBillNum; - entity.InvDate = lsC[number].InvDate; - entity.InvBillNum = lsC[number].InvBillNum; - entity.InvGroupNum = lsC[number].InvGroupNum; - entity.SettleGroupNum = lsC[number].SettleGroupNum; - entity.SettleLU = lsC[number].LU; - entity.SettleQty = lsC[number].Qty; - entity.NotSettleLU = string.Empty; - entity.Qty = string.Empty; - ls.Add(entity); - - } - else - { - INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); - entity.RealInvBillNum = lsC[number].RealInvBillNum; - entity.InvDate = lsC[number].InvDate; - entity.InvBillNum = lsC[number].InvBillNum; - entity.InvGroupNum = lsC[number].InvGroupNum; - entity.SettleGroupNum = lsC[number].SettleGroupNum; - entity.SettleLU = lsC[number].LU; - entity.SettleQty= lsC[number].Qty; - entity.NotSettleLU = lsN[number].LU; - entity.Qty = lsN[number].Qty; - ls.Add(entity); - } - } + INVOICE_NOT_SETTLE_EXT_DTO invnot = new INVOICE_NOT_SETTLE_EXT_DTO(); + invnot.RealInvBillNum = string.Empty; + invnot.InvDate = null; + invnot.InvBillNum = string.Empty; + invnot.InvGroupNum = string.Empty; + invnot.SettleGroupNum = string.Empty; + invnot.SettleLU = string.Empty; + invnot.SettleQty = null; + invnot.NotSettleLU = string.Empty; + invnot.Qty = string.Empty; + ls.Add(invnot); } - else + var entity= nolist.FirstOrDefault(); + var disList = lsC.Select(p => p.SettleGroupNum).Distinct().ToList(); + + for (int i = 0; i < disList.Count; i++) { - for (int number = 0; number < lineN; number++) - { - if (number + 1 > lineC)//不可结大于可结行数时 - { - INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); - entity.RealInvBillNum = lsN[number].RealInvBillNum; - entity.InvDate = lsN[number].InvDate; - entity.InvBillNum = lsN[number].InvBillNum; - entity.InvGroupNum = lsN[number].InvGroupNum; - entity.SettleGroupNum = lsN[number].SettleGroupNum; - entity.SettleLU = string.Empty; - entity.SettleQty = string.Empty; - entity.NotSettleLU = lsN[number].LU; - entity.Qty = lsN[number].Qty; - ls.Add(entity); - } - else - { - INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); - entity.RealInvBillNum = lsN[number].RealInvBillNum; - entity.InvDate = lsN[number].InvDate; - entity.InvBillNum = lsN[number].InvBillNum; - entity.InvGroupNum = lsN[number].InvGroupNum; - entity.SettleGroupNum = lsN[number].SettleGroupNum; - entity.SettleLU = lsC[number].LU; - entity.NotSettleLU = lsN[number].LU; - entity.Qty = lsN[number].Qty; - entity.SettleQty = lsC[number].Qty; - ls.Add(entity); - } - } + ls[i].SettleGroupNum = disList[i]; } - - var disList= ls.Select(p => p.SettleGroupNum).Distinct().ToList(); - foreach (var de in ls) + for (int i = 0; i < lineC; i++) { - de.SettleGroupNum = string.Empty; + 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].SettleLU = lsC[i].LU; + ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString(); } - for (int i = 0; i < disList.Count; i++) + for (int i = 0; i < lineN; i++) { - ls[i].SettleGroupNum = disList[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].NotSettleLU = lsN[i].LU; + ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString(); } + + + + //if (lineC > lineN)//可结大于不可结行数时 + //{ + // for (int number = 0; number < lineC; number++) + // { + // if (number + 1 > lineN) + // { + // INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); + // entity.RealInvBillNum = lsC[number].RealInvBillNum; + // entity.InvDate = lsC[number].InvDate; + // entity.InvBillNum = lsC[number].InvBillNum; + // entity.InvGroupNum = lsC[number].InvGroupNum; + // entity.SettleGroupNum = lsC[number].SettleGroupNum; + // entity.SettleLU = lsC[number].LU; + // entity.SettleQty = lsC[number].Qty == null ? string.Empty : lsC[number].Qty.ToString(); + // entity.NotSettleLU = string.Empty; + // entity.Qty = string.Empty; + // ls.Add(entity); + + // } + // else + // { + // INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); + // entity.RealInvBillNum = lsC[number].RealInvBillNum; + // entity.InvDate = lsC[number].InvDate; + // entity.InvBillNum = lsC[number].InvBillNum; + // entity.InvGroupNum = lsC[number].InvGroupNum; + // entity.SettleGroupNum = lsC[number].SettleGroupNum; + // entity.SettleLU = lsC[number].LU; + // entity.SettleQty= lsC[number].Qty==null?string.Empty:lsC[number].Qty.ToString(); + // entity.NotSettleLU = lsN[number].LU; + // entity.Qty = lsN[number].Qty == null ? string.Empty : lsC[number].Qty.ToString(); + // ls.Add(entity); + // } + // } + //} + //else + //{ + // for (int number = 0; number < lineN; number++) + // { + // if (number + 1 > lineC)//不可结大于可结行数时 + // { + // INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); + // entity.RealInvBillNum = lsN[number].RealInvBillNum; + // entity.InvDate = lsN[number].InvDate; + // entity.InvBillNum = lsN[number].InvBillNum; + // entity.InvGroupNum = lsN[number].InvGroupNum; + // entity.SettleGroupNum = lsN[number].SettleGroupNum; + // entity.SettleLU = string.Empty; + // entity.SettleQty = string.Empty; + // entity.NotSettleLU = lsN[number].LU; + // entity.Qty = lsN[number].Qty == null ? string.Empty : lsN[number].Qty.ToString(); + // ls.Add(entity); + // } + // else + // { + // INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); + // entity.RealInvBillNum = lsN[number].RealInvBillNum; + // entity.InvDate = lsN[number].InvDate; + // entity.InvBillNum = lsN[number].InvBillNum; + // entity.InvGroupNum = lsN[number].InvGroupNum; + // entity.SettleGroupNum = lsN[number].SettleGroupNum; + // entity.SettleLU = lsC[number].LU; + // entity.NotSettleLU = lsN[number].LU; + // entity.Qty = lsN[number].Qty == null ? string.Empty : lsN[number].Qty.ToString(); ; + // entity.SettleQty = lsC[number].Qty == null ? string.Empty : lsC[number].Qty.ToString(); ; + // ls.Add(entity); + // } + // } + //} + + //var disList= ls.Select(p => p.SettleGroupNum).Distinct().ToList(); + //foreach (var de in ls) + //{ + // de.SettleGroupNum = string.Empty; + //} + //for (int i = 0; i < disList.Count; i++) + //{ + // ls[i].SettleGroupNum = disList[i]; + //} _excel.Append(ls, "结算分组零件" + itm.InvbillNum); _excel.Append(mgroup, "发票结算分组对应" + itm.InvbillNum).SeparateBySheet(); _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); 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 c23aeb93..90d9c5b1 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 @@ -271,7 +271,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); //var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList(); //var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算 - var priceList = _priceRepository.ToList();//价格单 + var priceList = _priceRepository.Where(p=>p.IsCancel==false).ToList();//价格单 var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); if (errorList.Count > 0) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs index 2c46017a..da1143dd 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs @@ -81,7 +81,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ List priceList = new List(); if (main.BusinessType == EnumBusinessType.BeiJian) { - var priceListbj = _pricebjRepository.ToList();//价格单 + var priceListbj = _pricebjRepository.Where(p => p.IsCancel == false).ToList(); //价格单 foreach (var itm in priceListbj) { priceList.Add(new PriceList() { LU = itm.LU, BeginTime = itm.BeginDate, EndTime = itm.EndDate, Price = itm.Price }); @@ -89,7 +89,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - priceList = _priceRepository.ToList();//价格单 + priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单 } var errorList = await CheckInvoiceGenerationRules(entitys, priceList, main.BusinessType);//校验生成规则 if (errorList.Count() > 0)