From 9d0beb91e80a5e526ffddaf5a1c7f404915e21c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Sat, 15 Jul 2023 13:09:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=8A=B6=E6=80=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=9F=BA=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Dtos/INVOICE_GRP_DTO.cs | 3 + .../Bases/BA_SERVICE.cs | 4 +- .../Entities/BQ/BBAC_CAN_SA_SERVICE.cs | 8 - .../Entities/BQ/BBAC_NOT_SA_SERVICE.cs | 1 - .../SettleAccount.Domain/Bases/EntityBase.cs | 14 +- .../Bases/OrderNumberGenerator.cs | 2 +- .../Entities/BQ/BBAC_CAN_SA.cs | 4 +- .../Entities/BQ/HBPO_CAN_SA.cs | 4 +- .../Entities/BQ/PUB_CAN_SA.cs | 4 +- .../Entities/Managers/INV_MNG.cs | 146 ++++++++++++++++++ .../Entities/Managers/NOT_SA_MNG.cs | 50 +++++- .../src/SettleAccount.Domain/EnumBillState.cs | 4 +- 12 files changed, 210 insertions(+), 34 deletions(-) create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Managers/INV_MNG.cs 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 269d3996..a6996a89 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 @@ -135,6 +135,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public string InvGroupNum { get; set; } [Display(Name = "发票号")] public string InvbillNum { get; set; } + [Display(Name = "发票分组状态")] + public int State { set; get; } + } 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 4b420034..f16999ea 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 @@ -24,8 +24,6 @@ namespace Win.Sfs.SettleAccount.Bases { public abstract class BA_SERVICE:ApplicationService { - - private readonly INormalEfCoreRepository _repository; private readonly INormalEfCoreRepository _wRepository; private readonly INormalEfCoreRepository _sRepository; @@ -69,7 +67,7 @@ namespace Win.Sfs.SettleAccount.Bases { INVOICE_GRP_DETAIL_DTO _entity=new INVOICE_GRP_DETAIL_DTO(); - var m= await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); + var m= await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); var mdtos = ObjectMapper.Map, List>(m); var w=await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); var wdtos = ObjectMapper.Map, List>(w); 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 c0d973bd..26f082fe 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 @@ -36,8 +36,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ protected BBAC_CAN_SA_SERVICE(INormalEfCoreRepository repository, IExcelImportAppService excelImportService, INormalEfCoreRepository detailRepository) : base(repository, excelImportService, detailRepository) { } - - [HttpPost] //[Route("generateinvoice")] public async override Task GenerateInvoice(BBAC_CAN_SA_REQ_DTO input) @@ -57,12 +55,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ string invoiceBillNum = Guid.NewGuid().ToString(); List invoiceGroupNumList = new List(); List List = new List(); - - decimal sum = _itm.Value;//初始价格 List luList= _ls.Where(p => p.GroupNum == _itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类 - - foreach (var _itm1 in _dic1) { if (_itm.Key == _itm1.Key) @@ -70,10 +64,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ continue; } var grouplist=_ls.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类 - luList.AddRange(grouplist); luList = luList.Distinct().ToList(); - if (luList.Count > 20)//累加零件不超过20种 { continue; 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 fd424f27..f01a105e 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,5 +1,4 @@ using Microsoft.AspNetCore.Authorization; - using Microsoft.AspNetCore.Mvc; using SettleAccount.Domain.BQ; using System; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs index 8c0eeb03..f79d9083 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs @@ -50,7 +50,7 @@ namespace SettleAccount.Bases public string SettleBillNum { get; set; } = null!; /// - /// 1、新建 2、已有出库3、已有扣减寄售库 + /// 可结算单状态 /// [Display(Name = "状态")] public SettleBillState State { get; set; } @@ -368,6 +368,10 @@ namespace SettleAccount.Bases /// 結算分組號 /// public string GroupNum { get; set; } + /// + /// 关联结算单号 + /// + public string SettleBillNum { get; set; } //public SA_CAN_BASE(int version, decimal price, string billNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum) //{ @@ -425,7 +429,6 @@ namespace SettleAccount.Bases /// 結算分組號 /// public string GroupNum { get; set; } - //public SA_NOT_BASE(decimal price, int version, string settleBillNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum) //{ // Price = price; @@ -474,13 +477,6 @@ namespace SettleAccount.Bases /// public decimal Qty { get; set; } - - - - - - - } public class PD_BASE : FullAuditedAggregateRoot, ISBASE { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/OrderNumberGenerator.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/OrderNumberGenerator.cs index 36133d65..b779209e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/OrderNumberGenerator.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/OrderNumberGenerator.cs @@ -19,7 +19,7 @@ namespace Win.Sfs.SettleAccount.Bases private static int sequence = 0; /// - /// 如无类别 + /// 生成单号 /// /// /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs index 0f19e727..ffddc130 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs @@ -66,8 +66,8 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE ///// //[Display(Name = "结算单号")] //public string BillNum { get; set; } = null!; - [Display(Name = "关联结算单号")] - public string SettleBillNum { get; set; } = null!; + //[Display(Name = "关联结算单号")] + //public string SettleBillNum { get; set; } = null!; ///// ///// 对应字段Material ///// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs index 6895afcc..864f8366 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs @@ -68,8 +68,8 @@ public class HBPO_CAN_SA_DETAIL:SA_CAN_BASE ///// //[Display(Name = "结算单号")] //public string BillNum { get; set; } = null!; - [Display(Name = "关联结算单号")] - public string SettleBillNum { get; set; } = null!; + //[Display(Name = "关联结算单号")] + //public string SettleBillNum { get; set; } = null!; /// /// 对应字段PartNumber /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs index 58c1ff96..e6f27e44 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs @@ -63,8 +63,8 @@ public class PUB_CAN_SA_DETAIL : SA_CAN_BASE //[Display(Name = "结算单号")] //public string BillNum { get; set; } = null!; - [Display(Name = "关联结算单号")] - public string SettleBillNum { get; set; } = null!; + //[Display(Name = "关联结算单号")] + //public string SettleBillNum { get; set; } = null!; /// /// 对应字段PartNumber diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Managers/INV_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Managers/INV_MNG.cs new file mode 100644 index 00000000..f07ae541 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Managers/INV_MNG.cs @@ -0,0 +1,146 @@ +using EFCore.BulkExtensions; +using NPOI.SS.Formula.Functions; +using SettleAccount.Domain.BQ; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Domain.Services; +using Win.Sfs.Shared.RepositoryBase; + +namespace Win.Sfs.SettleAccount.Entities.Managers +{ + public class INV_MNG:DomainService + { + private readonly INormalEfCoreRepository _repository; + private readonly INormalEfCoreRepository _groupRepository; + private readonly INormalEfCoreRepository _detailRepository; + private readonly INormalEfCoreRepository _notRepository; + + + public INV_MNG + ( + + INormalEfCoreRepository repository, + INormalEfCoreRepository groupRepository, + INormalEfCoreRepository detailRepository, + INormalEfCoreRepository notRepository + + ) + { + _repository = repository; + _detailRepository = detailRepository; + _groupRepository = groupRepository; + _notRepository = notRepository; + } + public virtual async Task SetForwardState(INVOICE_GRP p_entiy,InvoiceBillState p_State) + { + var state = p_State; + switch (p_entiy.State) + { + case InvoiceBillState.财务已审核: + if (state == InvoiceBillState.商务已审核) + { + p_entiy.State = state; + } + else + { + throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态"); + } + break; + case InvoiceBillState.商务已审核: + if (state == InvoiceBillState.已开票) + { + p_entiy.State = state; + } + else + { + throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】"); + } + break; + case InvoiceBillState.已扣减: + if (state == InvoiceBillState.财务已审核) + { + p_entiy.State = state; + } + else + { + throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态"); + } + break; + } + await _repository.UpdateAsync(p_entiy); + return true; + } + + + public virtual async Task Reject(INVOICE_GRP p_entity) + { + + if (p_entity.State == InvoiceBillState.财务已审核 + || p_entity.State == InvoiceBillState.已开票 || p_entity.State == InvoiceBillState.商务已审核) + { + var entList = _repository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); + var groupList = _groupRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); + var notList = _notRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); + var detailList = _detailRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); + await _repository.DbContext.BulkDeleteAsync(entList); + await _repository.DbContext.BulkDeleteAsync(groupList); + await _repository.DbContext.BulkDeleteAsync(notList); + await _repository.DbContext.BulkDeleteAsync(detailList); + + + + } + return true; + + + //switch (p_entiy.State) + //{ + // case InvoiceBillState.财务已审核 || InvoiceBillState.已开票: + + // _repository.re + + + + // //if (state == InvoiceBillState.商务已审核) + // //{ + // // p_entiy.State = state; + // //} + // //else + // //{ + // // throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态"); + // //} + // break; + // case InvoiceBillState.商务已审核: + // if (state == InvoiceBillState.已开票) + // { + // p_entiy.State = state; + // } + // else + // { + // throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】"); + // } + // break; + // case InvoiceBillState.已扣减: + // if (state == InvoiceBillState.财务已审核) + // { + // p_entiy.State = state; + // } + // else + // { + // throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态"); + // } + // break; + //} + + } + + + + + + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Managers/NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Managers/NOT_SA_MNG.cs index 5b37ce06..d81d6836 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Managers/NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Managers/NOT_SA_MNG.cs @@ -7,6 +7,8 @@ using System.Threading.Tasks; using Volo.Abp.Domain.Services; using Volo.Abp; using Win.Sfs.Shared.RepositoryBase; +using Win.Sfs.SettleAccount.Bases; +using EFCore.BulkExtensions; namespace Win.Sfs.SettleAccount.Entities.Managers { @@ -17,23 +19,63 @@ namespace Win.Sfs.SettleAccount.Entities.Managers /// /// public class NOT_SA_MNG : DomainService - where TEntity : SA_CAN_BASE_MAIN - where TEntityDetail : SA_CAN_BASE + where TEntity : SA_CAN_BASE_MAIN,new() + where TEntityDetail : SA_CAN_BASE,new() where TNOTDetail:SA_NOT_BASE { private readonly INormalEfCoreRepository _repository; private readonly INormalEfCoreRepository _detailRepository; + private readonly INormalEfCoreRepository _notRepository; public NOT_SA_MNG ( INormalEfCoreRepository repository, - INormalEfCoreRepository detailRepository + INormalEfCoreRepository detailRepository, + INormalEfCoreRepository notRepository ) { _repository = repository; _detailRepository = detailRepository; + _notRepository = notRepository; } - public virtual async Task GenerateSettlementOrder(List p_list) + public virtual async Task GenerateSettlementOrder(List p_list,Action> p_action=null) { + var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); + TEntity _entity = new TEntity(); + _entity.BillNum = billNumber; + _entity.InvGroupNum = billNumber; + _entity.Version=DateTime.Now.Year+DateTime.Now.Month; + _entity.State =SettleBillState.未结状态; + _entity.SettleBillNum = string.Empty; + List _entityList = new List(); + foreach (var itm in p_list) + { + TEntityDetail _detailEntity = new TEntityDetail(); + { + _detailEntity.SettleBillNum = itm.SettleBillNum; + _detailEntity.BillNum = billNumber; + _detailEntity.InvGroupNum = billNumber; + _detailEntity.LU = itm.LU; + _detailEntity.PN = itm.PN; + _detailEntity.GroupNum = itm.GroupNum; + _detailEntity.KeyCode = itm.KeyCode; + _detailEntity.Price = itm.Price; + _detailEntity.Version = itm.Version; + }; + _entityList.Add(_detailEntity); + } + if (_entityList.Count > 0) + { + p_action(_entityList);//对不一样类型结算数据进行处理 + } + await _notRepository.DbContext.BulkDeleteAsync(p_list); + await _repository.DbContext.BulkInsertAsync(new List() { _entity }); + + await _repository.DbContext.BulkInsertAsync(_entityList); + + + + + return true; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs index d231bb14..d9ea9fc7 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs @@ -33,8 +33,8 @@ namespace Win.Sfs.SettleAccount public enum InvoiceBillState { - [Description("未结状态")] - 未结状态 = 0, + [Description("已开票")] + 已开票 = 1, [Description("商务已审核")] 商务已审核 = 2, [Description("财务已审核")]