diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs index d8b323ae..dc256bb7 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs @@ -106,7 +106,7 @@ namespace Win.Sfs.SettleAccount.Bases //[Route("export")] public virtual async Task ExportAsync(TRequestDetailInput input) { -//#if DEBUG +// #if DEBUG // Stopwatch sw = Stopwatch.StartNew(); // var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); // var dtoDetails = ObjectMapper.Map, List>(entities); @@ -186,9 +186,6 @@ namespace Win.Sfs.SettleAccount.Bases /// protected async Task> CheckInvoiceGenerationRules(List dto1s, string p_site, List p_pricelist, EnumBusinessType p_businessType) where T : SA_CAN_BASE { - - //var maxDate = p_pricelist.Max(p => p.Date); - var first = dto1s.FirstOrDefault(); var usepriceList = p_pricelist.Where(p => p.ClientCode == first.Site && p.IsCancel == false).ToList(); var errorlist = _baseservice.CheckPriceListContinuity(usepriceList); 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 210bf5cb..63cd7127 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 @@ -47,13 +47,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ > { private readonly INormalEfCoreRepository _notRepository; - private readonly INormalEfCoreRepository _priceRepository; private readonly INormalEfCoreRepository _saRepository; - - private readonly TaskJobService _service; - private readonly BBAC_CAN_SA_MNG _bbacMng; public BBAC_CAN_SA_SERVICE(IExcelImportAppService excelImportService, @@ -99,21 +95,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var entitys = await _bbacMng.GetDetalListAsync(invbillNum).ConfigureAwait(false);//可结算 List errors = new List(); var settleBillList = entitys.Select(p => p.SettleBillNum).Distinct().ToList(); - var checklist = _saRepository.Where(p => settleBillList.Contains(p.BillNum)).ToList(); - var jischeck = checklist.Where(p => p.State == "0" && p.BusinessType==EnumBusinessType.JisBBAC).ToList(); - foreach (var itm in jischeck) - { - errors.Add(new ERR_EXP_DTO() { Remark = $"版本:{itm.Version},结算单:{itm.BillNum}+此结算单JIS未比对,结算数据需要比对后才能开票!" }); - } - var mcheck = checklist.Where(p => p.StateOther == "0" && p.BusinessType == EnumBusinessType.MaiDanJianBBAC).ToList(); - foreach (var itm in mcheck) - { - errors.Add(new ERR_EXP_DTO() { Remark = $"版本:{itm.Version},结算单:{itm.BillNum}+此结算单买单未比对,结算数据需要比对后才能开票!" }); - } - if (errors.Count > 0) + + if (invbillNum.Substring(0, 1) != "N") { - return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + var checklist = _saRepository.Where(p => settleBillList.Contains(p.BillNum)).ToList(); + var jischeck = checklist.Where(p => p.State == "0" && p.BusinessType == EnumBusinessType.JisBBAC).ToList(); + foreach (var itm in jischeck) + { + errors.Add(new ERR_EXP_DTO() { Remark = $"版本:{itm.Version},结算单:{itm.BillNum}+此结算单JIS未比对,结算数据需要比对后才能开票!" }); + } + var mcheck = checklist.Where(p => p.StateOther == "0" && p.BusinessType == EnumBusinessType.MaiDanJianBBAC).ToList(); + foreach (var itm in mcheck) + { + errors.Add(new ERR_EXP_DTO() { Remark = $"版本:{itm.Version},结算单:{itm.BillNum}+此结算单买单未比对,结算数据需要比对后才能开票!" }); + } + if (errors.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + } } + var priceList = _priceRepository.Where(p => p.IsCancel == false).ToList(); //价格单 var errorList = await CheckInvoiceGenerationRules(entitys, main.Site, priceList, main.BusinessType).ConfigureAwait(false);//校验生成规则 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 c2a7e60c..3e6a6b28 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 @@ -47,8 +47,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly HBPO_CAN_SA_MNG _hbpoMng; private readonly TaskJobService _service; private readonly INormalEfCoreRepository _saRepository; - - public HBPO_CAN_SA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, @@ -93,14 +91,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ List errors = new List(); var settleBillList = entitys.Select(p => p.SettleBillNum).Distinct().ToList(); var checklist = _saRepository.Where(p => settleBillList.Contains(p.BillNum) && p.State == "0").ToList(); - foreach (var itm in checklist) - { - errors.Add(new ERR_EXP_DTO() { Remark = $"版本:{itm.Version},结算单:{itm.BillNum}此结算单未比对,结算数据需要比对后才能开票!" }); - } - if (errors.Count > 0) + if (invbillnum.Substring(0, 1) != "N") { - return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + foreach (var itm in checklist) + { + errors.Add(new ERR_EXP_DTO() { Remark = $"版本:{itm.Version},结算单:{itm.BillNum}此结算单未比对,结算数据需要比对后才能开票!" }); + } + if (errors.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + } } + #endregion var priceList = _priceRepository.Where(p => p.IsCancel == false).ToList(); //价格单 var errorList = await CheckInvoiceGenerationRules(entitys, main.Site, priceList, main.BusinessType).ConfigureAwait(false);//校验生成规则 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 7811eb33..801088cd 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 @@ -134,13 +134,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ List errors = new List(); var settleBillList = entitys.Select(p => p.SettleBillNum).Distinct().ToList(); var checklist = _saRepository.Where(p => settleBillList.Contains(p.BillNum) && p.State == "0").ToList(); - foreach (var itm in checklist) - { - errors.Add(new ERR_EXP_DTO(){ Remark = $"版本:{itm.Version},结算单:{itm.BillNum}此结算单未比对,结算数据需要比对后才能开票!" }); - } - if (errors.Count > 0) + + if (billnum.Substring(0, 1) != "N") { - return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + foreach (var itm in checklist) + { + errors.Add(new ERR_EXP_DTO() { Remark = $"版本:{itm.Version},结算单:{itm.BillNum}此结算单未比对,结算数据需要比对后才能开票!" }); + } + if (errors.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + } } #endregion var errorList = await CheckInvoiceGenerationRules(entitys, main.Site, priceList, main.BusinessType).ConfigureAwait(false);//校验生成规则 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs index 72bf696c..c089328b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs @@ -99,42 +99,93 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs var bbac_not_list= query.Select(p => p.b).ToList(); if(bbac_can_list.Count>0) { - notlist.AddRange(bbac_not_list); - var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); - var entity = new BBAC_CAN_SA(); - entity.SetId(Guid.NewGuid()); - entity.BillNum = billNumber; - entity.InvGroupNum = billNumber; - entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); - entity.State = SettleBillState.未结状态; - entity.SettleBillNum = string.Empty; - entity.Site = "1040"; - entity.BusinessType = EnumBusinessType.JisBBAC; - billList.Add(entity); - foreach (var itm in bbac_can_list) + var t1 = bbac_can_list.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); + var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); + var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); + + if (part_group_big.Count > 0) { - var _detailEntity = new BBAC_CAN_SA_DETAIL( - guid: GuidGenerator.Create(), - keyCode: itm.KeyCode, - version: itm.Version, - billNum: billNumber, - settleBillNum: itm.SettleBillNum, - lU: itm.LU, - pN: itm.PN, - site: itm.Site, - qty: itm.Qty, - price: itm.Price, - category: itm.BusinessType, - isReturn: itm.IsReturn, - settleDate: itm.SettleDate, - groupNum: itm.GroupNum, - invGroupNum: billNumber, - contactid: itm.ContractDocID, - invbillnum: string.Empty, - partcode: itm.PartCode - ); - _detailEntity.RealPartCode = itm.RealPartCode; - billDetails.Add(_detailEntity); + foreach (var itm in part_group_big) + { + var ls = bbac_can_list.Where(p => p.LU == itm.LU).ToList(); + var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + var bbac_sa = new BBAC_CAN_SA(); + bbac_sa.SetId(Guid.NewGuid()); + bbac_sa.BillNum = billNum; + bbac_sa.InvGroupNum = billNum; + bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + bbac_sa.State = SettleBillState.未结状态; + bbac_sa.SettleBillNum = string.Empty; + bbac_sa.Site = "1040"; + bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + billList.Add(bbac_sa); + foreach (var itm1 in ls) + { + var _detailEntity = new BBAC_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm1.KeyCode, + version: itm1.Version, + billNum: billNum, + settleBillNum: itm1.SettleBillNum, + lU: itm1.LU, + pN: itm1.PN, + site: itm1.Site, + qty: itm1.Qty, + price: itm1.Price, + category: itm1.BusinessType, + isReturn: itm1.IsReturn, + settleDate: itm1.SettleDate, + groupNum: itm1.GroupNum, + invGroupNum: billNum, + contactid: itm1.ContractDocID, + invbillnum: string.Empty, + partcode: itm1.PartCode + ); + _detailEntity.RealPartCode = itm1.RealPartCode; + billDetails.Add(_detailEntity); + } + } + } + if (part_group_small.Count > 0) + { + var partlist = part_group_small.Select(p => p.LU).ToList(); + var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); + var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + var bbac_sa = new BBAC_CAN_SA(); + bbac_sa.SetId(Guid.NewGuid()); + bbac_sa.BillNum = billNum; + bbac_sa.InvGroupNum = billNum; + bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + bbac_sa.State = SettleBillState.未结状态; + bbac_sa.SettleBillNum = string.Empty; + bbac_sa.Site = "1040"; + bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + billList.Add(bbac_sa); + foreach (var itm1 in ls) + { + var _detailEntity = new BBAC_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm1.KeyCode, + version: itm1.Version, + billNum: billNum, + settleBillNum: itm1.SettleBillNum, + lU: itm1.LU, + pN: itm1.PN, + site: itm1.Site, + qty: itm1.Qty, + price: itm1.Price, + category: itm1.BusinessType, + isReturn: itm1.IsReturn, + settleDate: itm1.SettleDate, + groupNum: itm1.GroupNum, + invGroupNum: billNum, + contactid: itm1.ContractDocID, + invbillnum: string.Empty, + partcode: itm1.PartCode + ); + _detailEntity.RealPartCode = itm1.RealPartCode; + billDetails.Add(_detailEntity); + } } } } @@ -175,42 +226,92 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs if (bbac_can_list.Count > 0) { notlist.AddRange(bbac_not_list); - var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); - var entity = new BBAC_CAN_SA(); - entity.SetId(Guid.NewGuid()); - entity.BillNum = billNumber; - entity.InvGroupNum = billNumber; - entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); - entity.State = SettleBillState.未结状态; - entity.SettleBillNum = string.Empty; - entity.Site = "1046"; - entity.BusinessType = EnumBusinessType.JisBBAC; - billList.Add(entity); - - foreach (var itm in bbac_can_list) + var t1 = bbac_can_list.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); + var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); + var part_group_small = t1.Where(p => p.Amt <10000000).ToList(); + if (part_group_big.Count > 0) { - var _detailEntity = new BBAC_CAN_SA_DETAIL( - guid: GuidGenerator.Create(), - keyCode: itm.KeyCode, - version: itm.Version, - billNum: billNumber, - settleBillNum: itm.SettleBillNum, - lU: itm.LU, - pN: itm.PN, - site: itm.Site, - qty: itm.Qty, - price: itm.Price, - category: itm.BusinessType, - isReturn: itm.IsReturn, - settleDate: itm.SettleDate, - groupNum: itm.GroupNum, - invGroupNum: billNumber, - contactid: itm.ContractDocID, - invbillnum: string.Empty, - partcode: itm.PartCode - ); - _detailEntity.RealPartCode = itm.RealPartCode; - billDetails.Add(_detailEntity); + foreach (var itm in part_group_big) + { + var ls= bbac_can_list.Where(p=>p.LU==itm.LU).ToList(); + var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + var bbac_sa = new BBAC_CAN_SA(); + bbac_sa.SetId(Guid.NewGuid()); + bbac_sa.BillNum = billNum; + bbac_sa.InvGroupNum = billNum; + bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + bbac_sa.State = SettleBillState.未结状态; + bbac_sa.SettleBillNum = string.Empty; + bbac_sa.Site = "1046"; + bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + billList.Add(bbac_sa); + foreach (var itm1 in ls) + { + var _detailEntity = new BBAC_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm1.KeyCode, + version: itm1.Version, + billNum: billNum, + settleBillNum: itm1.SettleBillNum, + lU: itm1.LU, + pN: itm1.PN, + site: itm1.Site, + qty: itm1.Qty, + price: itm1.Price, + category: itm1.BusinessType, + isReturn: itm1.IsReturn, + settleDate: itm1.SettleDate, + groupNum: itm1.GroupNum, + invGroupNum: billNum, + contactid: itm1.ContractDocID, + invbillnum: string.Empty, + partcode: itm1.PartCode + ); + _detailEntity.RealPartCode = itm1.RealPartCode; + billDetails.Add(_detailEntity); + } + } + } + if (part_group_small.Count > 0) + { + var partlist = part_group_small.Select(p => p.LU).ToList(); + var ls=bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); + var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + var bbac_sa = new BBAC_CAN_SA(); + bbac_sa.SetId(Guid.NewGuid()); + bbac_sa.BillNum = billNum; + bbac_sa.InvGroupNum = billNum; + bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + bbac_sa.State = SettleBillState.未结状态; + bbac_sa.SettleBillNum = string.Empty; + bbac_sa.Site = "1046"; + bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + billList.Add(bbac_sa); + foreach (var itm1 in ls) + { + var _detailEntity = new BBAC_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm1.KeyCode, + version: itm1.Version, + billNum: billNum, + settleBillNum: itm1.SettleBillNum, + lU: itm1.LU, + pN: itm1.PN, + site: itm1.Site, + qty: itm1.Qty, + price: itm1.Price, + category: itm1.BusinessType, + isReturn: itm1.IsReturn, + settleDate: itm1.SettleDate, + groupNum: itm1.GroupNum, + invGroupNum: billNum, + contactid: itm1.ContractDocID, + invbillnum: string.Empty, + partcode: itm1.PartCode + ); + _detailEntity.RealPartCode = itm1.RealPartCode; + billDetails.Add(_detailEntity); + } } } } @@ -244,7 +345,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { if (billDetails.Count > 0) { - var result = from a in _dbcontext.Set() join b in _dbcontext.Set() on new { a.KeyCode, a.BusinessType } equals new { b.KeyCode, b.BusinessType } where a.Price == 0 @@ -326,40 +426,88 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs var hbpo_not_list = query.Select(p => p.b).ToList(); if (hbpo_can_list.Count > 0) { - var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); - var entity = new HBPO_CAN_SA(); - entity.SetId(Guid.NewGuid()); - entity.BillNum = billNumber; - entity.InvGroupNum = billNumber; - entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); - entity.State = SettleBillState.未结状态; - entity.SettleBillNum = string.Empty; - entity.Site = "104T"; - entity.BusinessType =(businesstype== "JisHBPO")?EnumBusinessType.JisHBPO:EnumBusinessType.MaiDanJianHBPO ; - billList.Add(entity); - notlist.AddRange(hbpo_not_list); - foreach (var itm in hbpo_can_list) + var t1 = hbpo_can_list.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); + var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); + var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); + if (part_group_big.Count > 0) + { + foreach (var itm in part_group_big) + { + var ls = hbpo_can_list.Where(p => p.LU == itm.LU).ToList(); + var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + var bbac_sa = new HBPO_CAN_SA(); + bbac_sa.SetId(Guid.NewGuid()); + bbac_sa.BillNum = billNum; + bbac_sa.InvGroupNum = billNum; + bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + bbac_sa.State = SettleBillState.未结状态; + bbac_sa.SettleBillNum = string.Empty; + bbac_sa.Site = "1046"; + bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + billList.Add(bbac_sa); + foreach (var itm1 in ls) + { + var _detailEntity = new HBPO_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm1.KeyCode, + version: itm1.Version, + billNum: billNum, + settleBillNum: itm1.SettleBillNum, + lU: itm1.LU, + pN: itm1.PN, + site: itm1.Site, + qty: itm1.Qty, + price: itm1.Price, + businessType: itm1.BusinessType, + settleDate: itm1.SettleDate, + groupNum: itm1.GroupNum, + invGroupNum: billNum, + invbillnum: string.Empty, + partcode: itm1.PartCode + ); + _detailEntity.RealPartCode = itm1.RealPartCode; + billDetails.Add(_detailEntity); + } + } + } + if (part_group_small.Count > 0) { - var _detailEntity = new HBPO_CAN_SA_DETAIL( - guid: GuidGenerator.Create(), - keyCode: itm.KeyCode, - version: itm.Version, - billNum: billNumber, - settleBillNum: itm.SettleBillNum, - lU: itm.LU, - pN: itm.PN, - site: itm.Site, - qty: itm.Qty, - price: itm.Price, - businessType: itm.BusinessType, - settleDate: itm.SettleDate, - groupNum: itm.GroupNum, - invGroupNum: billNumber, - invbillnum: string.Empty, - partcode: itm.PartCode - ); - _detailEntity.RealPartCode = itm.RealPartCode; - billDetails.Add(_detailEntity); + var partlist = part_group_small.Select(p => p.LU).ToList(); + var ls = hbpo_can_list.Where(p => partlist.Contains(p.LU)).ToList(); + var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + var bbac_sa = new HBPO_CAN_SA(); + bbac_sa.SetId(Guid.NewGuid()); + bbac_sa.BillNum = billNum; + bbac_sa.InvGroupNum = billNum; + bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + bbac_sa.State = SettleBillState.未结状态; + bbac_sa.SettleBillNum = string.Empty; + bbac_sa.Site = "1046"; + bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + billList.Add(bbac_sa); + foreach (var itm1 in ls) + { + var _detailEntity = new HBPO_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm1.KeyCode, + version: itm1.Version, + billNum: billNum, + settleBillNum: itm1.SettleBillNum, + lU: itm1.LU, + pN: itm1.PN, + site: itm1.Site, + qty: itm1.Qty, + price: itm1.Price, + businessType: itm1.BusinessType, + settleDate: itm1.SettleDate, + groupNum: itm1.GroupNum, + invGroupNum: billNum, + invbillnum: string.Empty, + partcode: itm1.PartCode + ); + _detailEntity.RealPartCode = itm1.RealPartCode; + billDetails.Add(_detailEntity); + } } } } 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 9318d1a9..38def361 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 @@ -1028,6 +1028,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers Price = p.Key.Price, BeginDate = p.Key.BeginDate, EndDate = p.Key.EndDate + }).ToList();//汇总记录不出现重复值 var groups = dtos.GroupBy(p => new { p.PartCode, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV { @@ -1039,7 +1040,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers ContractDocID = p.Key.ContractDocID, BeginDate = p.Key.BeginDate, EndDate = p.Key.EndDate + }).ToList();//汇总记录不出现重复值 + + + //var t1 = groups1.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); + //var group= t1.Where(p => p.Amt > 10000000).ToList(); + + ////var t1 = groups1.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); + ////var t2 = groups.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); + ////foreach (var itm in t1) + ////{ + + ////} + ////foreach (var itm in t2) + ////{ + + ////} + + + + + + + Dictionary> invoiceMap = new Dictionary>();//发票和发票明细关系 foreach (var group in groups) { 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 1137a199..2ff09b82 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 @@ -349,7 +349,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false); await _repository.DbContext.BulkInsertAsync(new List() { entity }).ConfigureAwait(false); - await _repository.DbContext.BulkInsertAsync(pub_can_list).ConfigureAwait(false); + await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false); } } diff --git a/code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs b/code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs index 1222373c..a1b35a8a 100644 --- a/code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs +++ b/code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs @@ -22,6 +22,8 @@ namespace Win.Sfs.Shared.Filter public static Expression> ToLambda(this FilterCondition filterCondition) { + + var filterConditions = new List { filterCondition }; return filterConditions.ToLambda(); }