From 8457ea86ad1a74197dec74b79bc4d7138114cd69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Tue, 8 Aug 2023 10:29:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bases/BA_SERVICE.cs | 72 +- .../Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs | 9 + .../Entities/BQ/Managers/INV_MNG.cs | 659 ++++++++++++------ .../Entities/BQ/Managers/PUB_CAN_SA_MNG.cs | 9 + ...AccountDbContextModelCreatingExtensions.cs | 54 ++ 5 files changed, 539 insertions(+), 264 deletions(-) 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 3d9bf442..aab4ca3e 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 @@ -210,40 +210,46 @@ namespace Win.Sfs.SettleAccount.Bases [HttpPost] [UnitOfWork(false)] - public virtual async Task ReceivedAsync(INVOICE_GRP_REQ_DTO input) + public virtual async Task ReceivedAsync(List p_ins) { - var entity = await _invMng.GetMainAsync(input.InvbillNum); - if (entity.InvoiceState == InvoiceBillState.报废) - { - throw new BusinessException("8989", $"发票号{entity.InvbillNum}为报废状态, 不能提交!"); - } - if (entity.InvoiceState == InvoiceBillState.提交 ) - { - throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}现在为提交状态!"); - } - if (entity.State != SettleBillState.财务已审核) - { - throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}不是财务已审核状态,不能收票!"); - } - if (entity != null) - { - List customConditionList = new List(); - customConditionList.Add(new CustomCondition() { Name = "InvGroupNum", Value = entity.InvGroupNum?? string.Empty }); - var invlist= _repository.Where(p => p.InvGroupNum == entity.InvGroupNum).ToList(); - foreach (var inv in invlist) { - - if (inv.InvoiceState != InvoiceBillState.报废) - { - inv.InvoiceState = InvoiceBillState.提交; - } - } - await _repository.DbContext.BulkUpdateAsync(invlist); - var _taskid = await _service.ExportEnqueueAsync($"发票分组{entity.InvGroupNum}收票任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyymm"), string.Empty, CurrentUser, typeof(PD_SERVICE), customConditionList, (rs) => - { - - }); - return _taskid; - } + + await _invMng.ReceivedAsync(p_ins); + + + + + //var entity = await _invMng.GetMainAsync(input.InvbillNum); + //if (entity.InvoiceState == InvoiceBillState.报废) + //{ + // throw new BusinessException("8989", $"发票号{entity.InvbillNum}为报废状态, 不能提交!"); + //} + //if (entity.InvoiceState == InvoiceBillState.提交 ) + //{ + // throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}现在为提交状态!"); + //} + //if (entity.State != SettleBillState.财务已审核) + //{ + // throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}不是财务已审核状态,不能收票!"); + //} + //if (entity != null) + //{ + // List customConditionList = new List(); + // customConditionList.Add(new CustomCondition() { Name = "InvGroupNum", Value = entity.InvGroupNum?? string.Empty }); + // var invlist= _repository.Where(p => p.InvGroupNum == entity.InvGroupNum).ToList(); + // foreach (var inv in invlist) { + + // if (inv.InvoiceState != InvoiceBillState.报废) + // { + // inv.InvoiceState = InvoiceBillState.提交; + // } + // } + // await _repository.DbContext.BulkUpdateAsync(invlist); + // var _taskid = await _service.ExportEnqueueAsync($"发票分组{entity.InvGroupNum}收票任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyymm"), string.Empty, CurrentUser, typeof(PD_SERVICE), customConditionList, (rs) => + // { + + // }); + // return _taskid; + //} return ApplicationConsts.SuccessStr; } protected virtual async Task> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs index e7869440..846fe5dc 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs @@ -264,6 +264,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } + /// + /// 通过发票号获取结算数据 + /// + /// + /// + public virtual async Task> GetDetailByInbillNumAsync(List p_invs) + { + return await _detailRepository.Where(p => p_invs.Contains(p.BillNum)).ToListAsync(); + } } 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 8410deba..e68ef06f 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 @@ -36,8 +36,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers private readonly INormalEfCoreRepository _notRepository; private readonly INormalEfCoreRepository _adjRepository; - private readonly INormalEfCoreRepository _pdRepository; - + private readonly INormalEfCoreRepository _pdbbacRepository; + private readonly INormalEfCoreRepository _pdhbpoRepository; + private readonly INormalEfCoreRepository _pdpubRepository; private readonly PUB_CAN_SA_MNG _pubMng; private readonly BBAC_CAN_SA_MNG _bbacMng; private readonly HBPO_CAN_SA_MNG _hbpoMng; @@ -46,15 +47,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers PUB_CAN_SA_MNG pubMng, BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, - INormalEfCoreRepository pdRepository, - INormalEfCoreRepository repository, + INormalEfCoreRepository pdbbacRepository, + INormalEfCoreRepository pdhbpoRepository, + INormalEfCoreRepository pdpubRepository, + INormalEfCoreRepository repository, INormalEfCoreRepository groupRepository, INormalEfCoreRepository detailRepository, INormalEfCoreRepository notRepository, INormalEfCoreRepository adjRepository ) { - _pdRepository= pdRepository; + //_canRepository = canRepository; _repository = repository; _detailRepository = detailRepository; @@ -64,6 +67,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers _pubMng = pubMng; _bbacMng = bbacMng; _hbpoMng = hbpoMng; + _pdbbacRepository=pdbbacRepository; + _pdhbpoRepository=pdhbpoRepository; + _pdpubRepository =pdpubRepository; } public INV_MNG() @@ -301,246 +307,439 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// /// 发票分组号 /// - public virtual async Task ReceivedAsync(List p_invs) + public virtual async Task ReceivedAsync(List p_invs) { - //var invList = _repository.Where(p =>p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息 - //int count = invList.Select(p => p.InvGroupNum).Count(); - //if (count > 0) - //{ - // throw new UserFriendlyException($"发票不属于一个发票分组"); - //} - //var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//父发票号 - //List oldinvs = new List(); - //oldinvs.AddRange(p_invs); - //if (parentList != null && parentList.Count > 0) - //{ - // oldinvs.AddRange(parentList); - //} - //List seclist = new List(); - //List firstlist = new List(); - //var pdlist = _pdRepository.Where(p => oldinvs.Contains(p.BillNum)).ToList(); - //if (pdlist != null && pdlist.Count > 0) - //{ - // seclist = pdlist.Select(p => p.BillNum).ToList();//那些在待扣减里已经有了属于作废重开 - //} - //firstlist = p_invs.Where(p => !seclist.Contains(p)).ToList(); - + var invList = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息 + int count = invList.Select(p => p.InvGroupNum).Distinct().Count(); + if (count > 1) + { + throw new UserFriendlyException($"发票不属于一个发票分组"); + } + var lostlist = invList.Where(p => p.InvoiceState == InvoiceBillState.报废).ToList(); + if (lostlist.Count > 0) + { + var invs=lostlist.Select(p => p.InvbillNum).ToList(); + throw new UserFriendlyException($"发票{string.Join(",",invs)}"); + } + - //var inv=invList.FirstOrDefault(); - //if (inv.BusinessType == EnumBusinessType.JisBBAC) - //{ - // var namelist=invList.Select(p => p.InvbillNum).ToList(); - // var entityDetail = await _bbacMng.GetDetailByInbillNumAsync(namelist);//结算明细 - // var adjlist=_adjRepository.Where(p => namelist.Contains(p.OldInvBillNum)).ToList();//调整表明细明细 + var inv = invList.FirstOrDefault(); + if (inv.BusinessType == EnumBusinessType.JisBBAC) + { + var pdlist = _pdbbacRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单 + if (pdlist != null && pdlist.Count > 0) + { + var invs = pdlist.Select(p => p.BillNum).ToList(); + throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交"); + } + var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号 + List oldinvs = new List(); + oldinvs.AddRange(p_invs); + if (parentList != null && parentList.Count > 0) + { + oldinvs.AddRange(parentList); + } + List oldlist = new List();//以前提交过的发票 + List newlist = new List();//没有提交过的发票 + var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList(); + if (pdoldlist != null && pdoldlist.Count > 0) + { + oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号 + } + newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号 - // if (adjlist != null && adjlist.Count() > 0) - // { - // foreach (var itm in adjlist) - // { - // entityDetail.Add(new BBAC_CAN_SA_DETAIL( - // guid: GuidGenerator.Create(), - // keyCode: itm.KeyCode, - // version: itm.Version, - // billNum: itm.InvGroupNum, - // settleBillNum: itm.SettleBillNum, - // lU: itm.LU, - // pN: itm.PN, - // site: itm.Site, - // qty: itm.Qty, - // price: itm.Price, - // category: itm.BusinessType, - // isReturn: itm.Qty > 0 ? false : true, - // settleDate: itm.SettleDate, - // groupNum: itm.GroupNum, - // invGroupNum: itm.InvGroupNum, - // contactid: itm.Extend1//生产号 - // )); - // } - // } + List entityList = new List();//结算明细 + var namelist = invList.Select(p => p.InvbillNum).ToList(); + if (oldlist.Count > 0) + { + var involdList= invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList(); + var involdname=involdList.Select(p => p.InvbillNum); + var adjlist=_adjRepository.Where(p => involdname.Contains(p.InvBillNum)); + + if (adjlist != null && adjlist.Count() > 0) + { + foreach (var itm in adjlist) + { + entityList.Add(new BBAC_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.InvGroupNum, + settleBillNum: itm.SettleBillNum, + lU: itm.LU, + pN: itm.PN, + site: itm.Site, + qty: itm.Qty, + price: 0, + category: itm.BusinessType, + isReturn: itm.Qty > 0 ? false : true, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + contactid: itm.Extend1,//生产号 + invbillnum: itm.InvBillNum + + )); + } + } + } + if (newlist.Count > 0) + { + var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList(); + var entityDetail = await _bbacMng.GetDetailByInbillNumAsync(newlist);//结算明细 + var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细 + if (adjlist != null && adjlist.Count() > 0) + { + foreach (var itm in adjlist) + { + entityDetail.Add(new BBAC_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.InvGroupNum, + settleBillNum: itm.SettleBillNum, + lU: itm.LU, + pN: itm.PN, + site: itm.Site, + qty: itm.Qty, + price: 0, + category: itm.BusinessType, + isReturn: itm.Qty > 0 ? false : true, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + contactid: itm.Extend1,//生产号 + invbillnum: itm.InvBillNum + + + )); + } + } + entityList.AddRange(entityDetail); - //entityDetail.GroupBy(p =>new { - // p.LU, - // p.PN, - // p.Site, - // p.Qty, - // p.BusinessType - //}).Select(p =>new BBAC_PD_DETAIL( + } - // guid: GuidGenerator.Create(), - // keyCode: p.Key.PN.Trim()+p.Key.LU, - // version: p.Key.Version, - // billNum: string.Empty, - // lU: p.Key.LU, - // rELU: string.Empty, - // pN: p.Key.PN, - // rEPN: string.Empty, - // site: string.Empty, - // qty:p.Sum(itm=>itm.Qty), - // price: 0, - // invGroupNum: p.Key., - // settleDate: p.SettleDate, - // groupNum: p.GroupNum, - // extend1: string.Empty, - // extend2: string.Empty, - // extend3: string.Empty, - // extend4: string.Empty + var bbacmainlist = new List(); + foreach (var itm in invList) + { + var bbac = new BBAC_PD( + guid: itm.Id, + version:int.Parse(DateTime.Now.ToString("yyyyMM")), + billNum: itm.InvbillNum, + settleBillNum: itm.InvGroupNum, + state: SettleBillState.客户已收票, + invGroupNum: itm.InvGroupNum, + site: string.Empty + ); + bbacmainlist.Add( bbac ); + + } + var bbacDetail = new List(); + foreach (var itm in entityList) + { + bbacDetail.Add( + new BBAC_PD_DETAIL( + guid: itm.Id, + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.BillNum, + lU: itm.LU, + rELU: string.Empty, + pN: itm.PN, + rEPN: string.Empty, + site: itm.Site, + qty: itm.Qty, + price: 0, + invGroupNum: itm.InvGroupNum, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + extend1: string.Empty, + extend2: string.Empty, + extend3: string.Empty, + extend4: string.Empty + )); + } + await _repository.DbContext.BulkInsertAsync(bbacmainlist); + await _repository.DbContext.BulkInsertAsync(bbacDetail); + return true; + } + else if (inv.BusinessType == EnumBusinessType.JisHBPO) + { + var pdlist = _pdhbpoRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单 + if (pdlist != null && pdlist.Count > 0) + { + var invs = pdlist.Select(p => p.BillNum).ToList(); + throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交"); + } + var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号 + List oldinvs = new List(); + oldinvs.AddRange(p_invs); + if (parentList != null && parentList.Count > 0) + { + oldinvs.AddRange(parentList); + } + List oldlist = new List();//以前提交过的发票 + List newlist = new List();//没有提交过的发票 + var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList(); + if (pdoldlist != null && pdoldlist.Count > 0) + { + oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号 + } + newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号 + List entityList = new List();//结算明细 + var namelist = invList.Select(p => p.InvbillNum).ToList(); + if (oldlist.Count > 0) + { + var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList(); + var involdname = involdList.Select(p => p.InvbillNum); + var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum)); + if (adjlist != null && adjlist.Count() > 0) + { + foreach (var itm in adjlist) + { + entityList.Add(new HBPO_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.InvGroupNum, + settleBillNum: itm.SettleBillNum, + lU: itm.LU, + pN: itm.PN, + site: itm.Site, + qty: itm.Qty, + price: 0, + businessType: itm.BusinessType, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + invbillnum: itm.InvBillNum + + )); + } + } + } + if (newlist.Count > 0) + { + var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList(); + var entityDetail = await _hbpoMng.GetDetailByInbillNumAsync(newlist);//结算明细 + var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细 + if (adjlist != null && adjlist.Count() > 0) + { + foreach (var itm in adjlist) + { + entityDetail.Add(new HBPO_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.InvGroupNum, + settleBillNum: itm.SettleBillNum, + lU: itm.LU, + pN: itm.PN, + site: itm.Site, + qty: itm.Qty, + price: 0, + businessType: itm.BusinessType, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + invbillnum: itm.InvBillNum + )); + } + } + entityList.AddRange(entityDetail); - //); + } + var bbacmainlist = new List(); + foreach (var itm in invList) + { + var bbac = new HBPO_PD( + guid: itm.Id, + version: int.Parse(DateTime.Now.ToString("yyyyMM")), + billNum: itm.InvbillNum, + settleBillNum: itm.InvGroupNum, + state: SettleBillState.客户已收票, + invGroupNum: itm.InvGroupNum, + site: string.Empty + ); + bbacmainlist.Add(bbac); + } + var bbacDetail = new List(); + foreach (var itm in entityList) + { + bbacDetail.Add( + new HBPO_PD_DETAIL( + guid: itm.Id, + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.BillNum, + lU: itm.LU, + rELU: string.Empty, + pN: itm.PN, + rEPN: string.Empty, + site: itm.Site, + qty: itm.Qty, + price: 0, + invGroupNum: itm.InvGroupNum, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + extend1: string.Empty, + extend2: string.Empty, + extend3: string.Empty, + extend4: string.Empty + )); + } + await _repository.DbContext.BulkInsertAsync(bbacmainlist); + await _repository.DbContext.BulkInsertAsync(bbacDetail); + return true; + } + else + { + var pdlist = _pdpubRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单 + if (pdlist != null && pdlist.Count > 0) + { + var invs = pdlist.Select(p => p.BillNum).ToList(); + throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交"); + } + var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号 + List oldinvs = new List(); + oldinvs.AddRange(p_invs); + if (parentList != null && parentList.Count > 0) + { + oldinvs.AddRange(parentList); + } + List oldlist = new List();//以前提交过的发票 + List newlist = new List();//没有提交过的发票 + var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList(); + if (pdoldlist != null && pdoldlist.Count > 0) + { + oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号 + } + newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号 + List entityList = new List();//结算明细 + var namelist = invList.Select(p => p.InvbillNum).ToList(); + if (oldlist.Count > 0) + { + var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList(); + var involdname = involdList.Select(p => p.InvbillNum); + var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum)); + if (adjlist != null && adjlist.Count() > 0) + { + foreach (var itm in adjlist) + { + entityList.Add(new PUB_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.InvGroupNum, + settleBillNum: itm.SettleBillNum, + lU: itm.LU, + pN: itm.PN, + site: itm.Site, + qty: itm.Qty, + price: 0, + businessType: itm.BusinessType, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + invbillnum: itm.InvBillNum + + )); + } + } + } + if (newlist.Count > 0) + { + var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList(); + var entityDetail = await _pubMng.GetDetailByInbillNumAsync(newlist);//结算明细 + var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细 + if (adjlist != null && adjlist.Count() > 0) + { + foreach (var itm in adjlist) + { + entityDetail.Add(new PUB_CAN_SA_DETAIL( + guid: GuidGenerator.Create(), + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.InvGroupNum, + settleBillNum: itm.SettleBillNum, + lU: itm.LU, + pN: itm.PN, + site: itm.Site, + qty: itm.Qty, + price: 0, + businessType: itm.BusinessType, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + invGroupNum: itm.InvGroupNum, + invbillnum: itm.InvBillNum + )); + } + } + entityList.AddRange(entityDetail); - // var bbac = new BBAC_PD( - // guid: entity.Id, - // version: entity.Version, - // billNum: entity.BillNum, - // settleBillNum: entity.SettleBillNum, - // state: SettleBillState.客户已收票, - // invGroupNum: entity.InvGroupNum, - // site: entity.Site - // ); - // var bbacDetail = new List(); + } - // foreach (var itm in entityDetail) - // { - // bbacDetail.Add( - // new BBAC_PD_DETAIL( - // guid: itm.Id, - // keyCode: itm.KeyCode, - // version: itm.Version, - // billNum: itm.BillNum, - // lU: itm.LU, - // rELU: string.Empty, - // pN: itm.PN, - // rEPN: string.Empty, - // site: itm.Site, - // qty: itm.Qty, - // price: itm.Price, - // invGroupNum: itm.InvGroupNum, - // settleDate: itm.SettleDate, - // groupNum: itm.GroupNum, - // extend1: string.Empty, - // extend2: string.Empty, - // extend3: string.Empty, - // extend4: string.Empty - // )); - // await _repository.DbContext.BulkInsertAsync(new List() { bbac }); - // await _repository.DbContext.BulkInsertAsync(bbacDetail); - // return true; - // } + var bbacmainlist = new List(); + foreach (var itm in invList) + { + var pub = new PUB_PD( + guid: itm.Id, + version: int.Parse(DateTime.Now.ToString("yyyyMM")), + billNum: itm.InvbillNum, + settleBillNum: itm.InvGroupNum, + state: SettleBillState.客户已收票, + invGroupNum: itm.InvGroupNum, + site: string.Empty + ); + bbacmainlist.Add(pub); - //} - //else if (inv.BusinessType == EnumBusinessType.JisHBPO) - //{ - // var entity = await _hbpoMng.GetMainAsync(inv.InvGroupNum); - // if (entity != null) - // { + } + var bbacDetail = new List(); + foreach (var itm in entityList) + { + bbacDetail.Add( + new PUB_PD_DETAIL( + guid: itm.Id, + keyCode: itm.KeyCode, + version: itm.Version, + billNum: itm.BillNum, + lU: itm.LU, + rELU: string.Empty, + pN: itm.PN, + rEPN: string.Empty, + site: itm.Site, + qty: itm.Qty, + price: 0, + businessType:itm.BusinessType, + invGroupNum: itm.InvGroupNum, + settleDate: itm.SettleDate, + groupNum: itm.GroupNum, + extend1: string.Empty, + extend2: string.Empty, + extend3: string.Empty, + extend4: string.Empty + )); + } + await _repository.DbContext.BulkInsertAsync(bbacmainlist); + await _repository.DbContext.BulkInsertAsync(bbacDetail); + return true; - // var entityDetail = await _hbpoMng.GetDetalListAsync(inv.InvGroupNum); - // if (entityDetail != null && entityDetail.Count() > 0) - // { - // var hbpo = new HBPO_PD( - // guid: entity.Id, - // version: entity.Version, - // billNum: entity.BillNum, - // settleBillNum: entity.SettleBillNum, - // state: SettleBillState.客户已收票, - // invGroupNum: entity.InvGroupNum, - // site: entity.Site - // ); - // var hbpoDetail = new List(); - // foreach (var itm in entityDetail) - // { - // hbpoDetail.Add( - // new HBPO_PD_DETAIL( - // guid: itm.Id, - // keyCode: itm.KeyCode, - // version: itm.Version, - // billNum: itm.BillNum, - // lU: itm.LU, - // rELU: string.Empty, - // pN: itm.PN, - // rEPN: string.Empty, - // site: itm.Site, - // qty: itm.Qty, - // price: itm.Price, - // invGroupNum: itm.InvGroupNum, - // settleDate: itm.SettleDate, - // groupNum: itm.GroupNum, - // extend1: string.Empty, - // extend2: string.Empty, - // extend3: string.Empty, - // extend4: string.Empty - // )); - // } - // await _repository.DbContext.BulkInsertAsync(new List() { hbpo }); - // await _repository.DbContext.BulkInsertAsync(hbpoDetail); - - // return true; - // } - // } - //} - //else - //{ - // var entity = await _pubMng.GetMainAsync(inv.InvGroupNum); - // if (entity != null) - // { - // var entityDetail = await _pubMng.GetDetalListAsync(inv.InvGroupNum); - // if (entityDetail != null && entityDetail.Count() > 0) - // { - // var pub = new PUB_PD( - // guid: entity.Id, - // version: entity.Version, - // billNum: entity.BillNum, - // settleBillNum: entity.SettleBillNum, - // state: SettleBillState.客户已收票, - // invGroupNum: entity.InvGroupNum, - // site: entity.Site - // ); - // var pubDetail = new List(); - // foreach (var itm in entityDetail) - // { - // pubDetail.Add( - // new PUB_PD_DETAIL( - // guid: itm.Id, - // keyCode: itm.KeyCode, - // version: itm.Version, - // billNum: itm.BillNum, - // lU: itm.LU, - // rELU: string.Empty, - // pN: itm.PN, - // rEPN: string.Empty, - // site: itm.Site, - // qty: itm.Qty, - // price: itm.Price, - // invGroupNum: itm.InvGroupNum, - // settleDate: itm.SettleDate, - // groupNum: itm.GroupNum, - // extend1: string.Empty, - // extend2: string.Empty, - // extend3: string.Empty, - // extend4: string.Empty, - // businessType: itm.BusinessType - // )); - // } - // await _repository.DbContext.BulkInsertAsync(new List() { pub }); - // await _repository.DbContext.BulkInsertAsync(pubDetail); - // return true; - // } - // } - //} + } return false; } public virtual async Task Reject(INVOICE_GRP p_entity) @@ -762,7 +961,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers select itm2; foreach (var itm in query) { - itm.BillNum = key; + itm.InvbillNum = key; salist.Add(itm); } if (!string.IsNullOrEmpty(p_parentInvBillNum)) @@ -989,10 +1188,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers select itm2; foreach (var itm in query) { - itm.BillNum = key; - + itm.InvbillNum = key; salist.Add(itm); - } if (!string.IsNullOrEmpty(p_parentInvBillNum)) { @@ -1177,7 +1374,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList(); foreach (var detail in invdetails) { - detail.BillNum = key; + detail.InvbillNum = key; salist.Add(detail); } if (!string.IsNullOrEmpty(p_parentInvBillNum)) @@ -1351,12 +1548,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers return false; } - foreach (var adj in p_adjlist) - { - adj.InvBillNum = string.Join(",", invlist);//调整单更新发票信息 - } + //foreach (var adj in p_adjlist) + //{ + // adj.InvBillNum = string.Join(",", invlist);//调整单更新发票信息 + //} - _repository.DbContext.BulkUpdate(p_adjlist); + //_repository.DbContext.BulkUpdate(p_adjlist); _repository.DbContext.BulkUpdate(new List { inv }); return true; @@ -1408,7 +1605,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers //{ // adj.InvBillNum = string.Join(",", invlist); //} - _repository.DbContext.BulkUpdate(p_adjlist); + //_repository.DbContext.BulkUpdate(p_adjlist); return true; } return false; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs index 18020ba6..fe31baeb 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs @@ -256,6 +256,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers + /// + /// 通过发票号获取结算数据 + /// + /// + /// + public virtual async Task> GetDetailByInbillNumAsync(List p_invs) + { + return await _detailRepository.Where(p => p_invs.Contains(p.BillNum)).ToListAsync(); + } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs index 728ce3d7..a2129419 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs @@ -107,6 +107,9 @@ namespace Win.Sfs.SettleAccount builder.ConfigurePUB_ADJ_DETAIL(options); builder.ConfigureBBAC_ADJ_DETAIL(options); builder.ConfigureHBPO_ADJ_DETAIL(options); + builder.ConfigureBBAC_PD(options); + builder.ConfigureHBPO_PD(options); + builder.ConfigurePUB_PD(options); //大众发票导入 //builder.ConfigureInvoice(options); //builder.ConfigureInvoiceVersion(options); @@ -1209,6 +1212,57 @@ namespace Win.Sfs.SettleAccount b.Property(x => x.ConcurrencyStamp).HasMaxLength(50); }); } + private static void ConfigureBBAC_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) + { + + builder.Entity(b => + { + + b.ToTable($"{options.TablePrefix}_BBAC_PD", options.Schema); + + b.ConfigureByConvention(); + b.Property(x => x.BillNum).HasMaxLength(50); + b.Property(x => x.SettleBillNum).HasMaxLength(50); + b.Property(x => x.InvGroupNum).HasMaxLength(50); + b.Property(x => x.Site).HasMaxLength(50); + b.Property(x => x.ConcurrencyStamp).HasMaxLength(50); + }); + } + + private static void ConfigureHBPO_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) + { + + builder.Entity(b => + { + + b.ToTable($"{options.TablePrefix}_HBPO_PD", options.Schema); + + b.ConfigureByConvention(); + b.Property(x => x.BillNum).HasMaxLength(50); + b.Property(x => x.SettleBillNum).HasMaxLength(50); + b.Property(x => x.InvGroupNum).HasMaxLength(50); + b.Property(x => x.Site).HasMaxLength(50); + b.Property(x => x.ConcurrencyStamp).HasMaxLength(50); + }); + } + private static void ConfigurePUB_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) + { + + builder.Entity(b => + { + + b.ToTable($"{options.TablePrefix}_PUB_PD", options.Schema); + + b.ConfigureByConvention(); + b.Property(x => x.BillNum).HasMaxLength(50); + b.Property(x => x.SettleBillNum).HasMaxLength(50); + b.Property(x => x.InvGroupNum).HasMaxLength(50); + b.Property(x => x.Site).HasMaxLength(50); + b.Property(x => x.ConcurrencyStamp).HasMaxLength(50); + }); + } + + private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) {