diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs index e9f51a5b..0c8cc7ee 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs @@ -1,6 +1,7 @@ using EFCore.BulkExtensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using NetTaste; using SettleAccount.Domain.BQ; using System; using System.Collections.Generic; @@ -17,6 +18,7 @@ using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Managers; +using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ @@ -49,7 +51,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); - await _bbacNotMng.GenerateSettlementOrder(entitys); + var errors=await _bbacNotMng.GenerateSettlementOrder(entitys); + if (errors.Count > 0) + { + + List errorlist = new List(); + foreach (var itm in errors) + { + errorlist.Add(new ERR_EXP_DTO() { Message = itm }); + } + return await ExportErrorReportAsync(errorlist); + + + } return ApplicationConsts.SuccessStr; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs index 89122e4a..38594b5d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs @@ -2,6 +2,7 @@ using EFCore.BulkExtensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using NetTaste; using SettleAccount.Domain.BQ; using System; using System.Collections.Generic; @@ -17,6 +18,7 @@ using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Managers; +using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ @@ -49,7 +51,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ public override async Task GenerateSettlementOrder(HBPO_NOT_SA_DETAIL_REQ_DTO input) { var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); - await _hbpoNotMng.GenerateSettlementOrder(entitys); + var errors=await _hbpoNotMng.GenerateSettlementOrder(entitys); + if (errors.Count > 0) + { + + List errorlist = new List(); + foreach (var itm in errors) + { + errorlist.Add(new ERR_EXP_DTO() { Message = itm }); + } + return await ExportErrorReportAsync(errorlist); + + + } return ApplicationConsts.SuccessStr; } 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 b03f715f..50bdf867 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 @@ -126,34 +126,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { if (input.BillNum.Substring(0, 1) == "C")//一次开票 { - if (main.BusinessType == EnumBusinessType.MaiDanJianHBPO) - { - var strs=await _invmng.MakeInvoice(entitys,new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true); - } - if (main.BusinessType == EnumBusinessType.BeiJian) - { - var strs = await _invmng.BJInvoice(entitys, new List(), dtos,new List(),main.Version, main.InvGroupNum,string.Empty, main.BusinessType); - } - else - { + await FirstInvoice(entitys, new List(), dtos, new List(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType); - } + } else//二次开票 { - if (main.BusinessType == EnumBusinessType.MaiDanJianHBPO) - { - var strs=await _invmng.MakeInvoice(entitys,new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true); - } - if (main.BusinessType == EnumBusinessType.BeiJian) - { - var strs = await _invmng.BJInvoice(entitys, new List(), dtos, new List(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType); - } - else - { await SecInvoice(entitys,new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); - } - } } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs index fbe2bae9..6b2e3f44 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs @@ -17,6 +17,7 @@ using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Managers; +using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ @@ -44,7 +45,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ public override async Task GenerateSettlementOrder(PUB_NOT_SA_DETAIL_REQ_DTO input) { var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); - _pubNotMng.GenerateSettlementOrder(entitys); + var errors=await _pubNotMng.GenerateSettlementOrder(entitys); + if (errors.Count > 0) + { + + List errorlist= new List(); + foreach (var itm in errors) + { + errorlist.Add(new ERR_EXP_DTO() { Message = itm }); + } + return await ExportErrorReportAsync(errorlist); + + + } return ApplicationConsts.SuccessStr; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs index a86ddf69..a884a66c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs @@ -10,6 +10,7 @@ using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.SettleAccount.Bases; using EFCore.BulkExtensions; using SettleAccount.Domain.BQ; +using Win.Sfs.SettleAccount.Bases.DomainServices; namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { @@ -25,13 +26,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers private readonly INormalEfCoreRepository _repository; private readonly INormalEfCoreRepository _detailRepository; private readonly INormalEfCoreRepository _notRepository; - + private readonly BaseDomainService _service; public BBAC_NOT_SA_MNG() { } public BBAC_NOT_SA_MNG ( - INormalEfCoreRepository repository, + BaseDomainService service, + INormalEfCoreRepository repository, INormalEfCoreRepository detailRepository, INormalEfCoreRepository notRepository ) @@ -39,9 +41,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers _repository = repository; _detailRepository = detailRepository; _notRepository = notRepository; + _service = service; + } - public virtual async Task GenerateSettlementOrder(List p_list) + public virtual async Task> GenerateSettlementOrder(List p_list) { + + + List errors = new List(); + var priceErrors = await _service.CheckPriceList(p_list); + if (priceErrors.Count > 0) + { + foreach (var itm in priceErrors) + { + errors.Add($"发货单号或交付识别号零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据"); + } + } + if (errors.Count > 0) + { + return errors; + } + + + + var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); var _entity = new BBAC_CAN_SA(); _entity.BillNum = billNumber; @@ -80,7 +103,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers await _repository.DbContext.BulkDeleteAsync(p_list); await _repository.DbContext.BulkInsertAsync(new List() { _entity }); await _repository.DbContext.BulkInsertAsync(_entityList); - return true; + return errors; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs index 0ea54b30..39c0b784 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs @@ -10,6 +10,7 @@ using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.SettleAccount.Bases; using EFCore.BulkExtensions; using SettleAccount.Domain.BQ; +using Win.Sfs.SettleAccount.Bases.DomainServices; namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { @@ -27,6 +28,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers private readonly INormalEfCoreRepository _repository; private readonly INormalEfCoreRepository _detailRepository; private readonly INormalEfCoreRepository _notRepository; + private readonly BaseDomainService _service; public HBPO_NOT_SA_MNG() { @@ -36,16 +38,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers ( INormalEfCoreRepository repository, INormalEfCoreRepository detailRepository, - INormalEfCoreRepository notRepository + INormalEfCoreRepository notRepository, + BaseDomainService service ) { _repository = repository; _detailRepository = detailRepository; _notRepository = notRepository; + _service = service; } - public virtual async Task GenerateSettlementOrder(List p_list) + public virtual async Task> GenerateSettlementOrder(List p_list) { - + List errors = new List(); + var priceErrors = await _service.CheckPriceList(p_list); + if (priceErrors.Count > 0) + { + foreach (var itm in priceErrors) + { + errors.Add($"发货单号或交付识别号零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据"); + } + } + if (errors.Count > 0) + { + return errors; + } var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); var _entity = new HBPO_CAN_SA(); @@ -81,7 +97,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers await _notRepository.DbContext.BulkDeleteAsync(p_list); await _repository.DbContext.BulkInsertAsync(new List() { _entity }); await _repository.DbContext.BulkInsertAsync(_entityList); - return true; + return errors; } 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 80ba39de..9c57a9de 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 @@ -1866,6 +1866,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers return _invls; } + + + + /// /// 重开一次开票 /// @@ -2205,9 +2209,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers return _invls; } - - - /// /// 重开二次开票 /// 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 8a84f773..7fa06984 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 @@ -10,6 +10,8 @@ using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.SettleAccount.Bases; using EFCore.BulkExtensions; using SettleAccount.Domain.BQ; +using System.Security.Cryptography; +using Win.Sfs.SettleAccount.Bases.DomainServices; namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { @@ -27,6 +29,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers private readonly INormalEfCoreRepository _repository; private readonly INormalEfCoreRepository _detailRepository; private readonly INormalEfCoreRepository _notRepository; + private readonly BaseDomainService _service; public PUB_NOT_SA_MNG() { @@ -36,50 +39,129 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers ( INormalEfCoreRepository repository, INormalEfCoreRepository detailRepository, - INormalEfCoreRepository notRepository + INormalEfCoreRepository notRepository, + BaseDomainService service ) { + _service = service; _repository = repository; _detailRepository = detailRepository; _notRepository = notRepository; } - public virtual async Task GenerateSettlementOrder(List p_list) + public virtual async Task> GenerateSettlementOrder(List p_list) { - var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); - var _entity = new PUB_CAN_SA(); - _entity.BillNum = billNumber; - _entity.InvGroupNum = billNumber; - _entity.Version = DateTime.Now.Year + DateTime.Now.Month; - _entity.State = SettleBillState.未结状态; - _entity.SettleBillNum = string.Empty; - var _entityList = new List(); - foreach (var itm in p_list) + List errors = new List(); + var query = p_list.Select(p => p.BusinessType).Distinct(); + foreach (var itm in query.ToList()) { - var _detailEntity = new PUB_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 - ); + errors.Add("选择项有不在同一业务的数据!"); + + } + if (errors.Count > 0) + { + return errors; + } + + var first= p_list.FirstOrDefault(); + if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO + || first.BusinessType == EnumBusinessType.BeiJian + ) + { + var ls = p_list.Select(p => p.GroupNum).Distinct().ToList(); + var notlist = _notRepository.Where(p => ls.Contains(p.GroupNum)).ToList();//JIT_ASN整发 + var priceErrors = await _service.CheckPriceList(notlist); + if (priceErrors.Count > 0) + { + foreach (var itm in priceErrors) + { + errors.Add($"发货单号或交付识别号零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据"); + } + } + if (errors.Count > 0) + { + return errors; + } + var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); + var _entity = new PUB_CAN_SA(); + _entity.BillNum = billNumber; + _entity.InvGroupNum = billNumber; + _entity.Version = DateTime.Now.Year + DateTime.Now.Month; + _entity.State = SettleBillState.未结状态; + _entity.SettleBillNum = string.Empty; + var _entityList = new List(); + foreach (var itm in notlist) + { + var _detailEntity = new PUB_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 + ); + + _entityList.Add(_detailEntity); + } + await _notRepository.DbContext.BulkDeleteAsync(p_list); + await _repository.DbContext.BulkInsertAsync(new List() { _entity }); + await _repository.DbContext.BulkInsertAsync(_entityList); - _entityList.Add(_detailEntity); } - await _notRepository.DbContext.BulkDeleteAsync(p_list); - await _repository.DbContext.BulkInsertAsync(new List() { _entity }); - await _repository.DbContext.BulkInsertAsync(_entityList); - return true; + else + { + var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); + var _entity = new PUB_CAN_SA(); + _entity.BillNum = billNumber; + _entity.InvGroupNum = billNumber; + _entity.Version = DateTime.Now.Year + DateTime.Now.Month; + _entity.State = SettleBillState.未结状态; + _entity.SettleBillNum = string.Empty; + var _entityList = new List(); + foreach (var itm in p_list) + { + var _detailEntity = new PUB_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 + ); + + _entityList.Add(_detailEntity); + } + await _notRepository.DbContext.BulkDeleteAsync(p_list); + await _repository.DbContext.BulkInsertAsync(new List() { _entity }); + await _repository.DbContext.BulkInsertAsync(_entityList); + + + + + } + + + return errors; + }