From f7f6ae1da7eedea704b2cd21c29bcbd8d35326ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Thu, 19 Oct 2023 13:22:33 +0800 Subject: [PATCH] [CI SKIP] --- .../Entities/BQ/BBAC_CAN_SA_SERVICE.cs | 140 +++++++++--------- .../Entities/BQ/HBPO_CAN_SA_SERVICE.cs | 139 +++++++++-------- .../BQ/Syncs/GenerateJisInvoiceService.cs | 93 ++---------- .../Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs | 17 +++ 4 files changed, 176 insertions(+), 213 deletions(-) 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 9d941a8d..9a76fb2d 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 @@ -101,85 +101,83 @@ namespace Win.Sfs.SettleAccount.Entities.BQ return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); } - //List customConditionList = new List(); - //customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillNum }); - //customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() }); - - - //await _bbacMng.SetWaitingState(invbillNum); - //var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) => - //{ - //}).ConfigureAwait(false); - - - - if (await _bbacMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false)) + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillNum }); + customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() }); + await _bbacMng.SetWaitingState(invbillNum); + var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) => { - var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); - var notQuery = await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync().ConfigureAwait(false); - var dto1s = ObjectMapper.Map, List>(entitys); - var q = from d in dto1s - join p in priceList on d.LU equals p.LU - where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site - select new TEMP_CAN_SA_DETAIL - { - SettleBillNum = d.SettleBillNum, - Site = d.Site, - Version = d.Version, - Price = p.Price, - BillNum = d.BillNum, - SettleDate = d.SettleDate, - InvGroupNum = d.InvGroupNum, - LU = d.LU, - MaterialDesc = d.MaterialDesc, - PN = d.PN, - Qty = d.Qty, - GroupNum = d.GroupNum, - Amt = Math.Round(d.Qty * p.Price, 2), - ContractDocID = d.ContractDocID, - BeginDate = p.BeginTime, - EndDate = p.EndTime, - PartCode = d.PartCode - }; - var dtos = q.ToList(); + }).ConfigureAwait(false); - if (dtos != null && dtos.Count > 0) - { - if (invbillNum.Substring(0, 1) == "C")//一次开票 - { - var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL - { - KeyCode = p.KeyCode, - Version = p.Version, - SettleBillNum = p.SettleBillNum, - LU = p.LU, - PN = p.PN, - Site = p.Site, - Qty = p.Qty, - Price = p.Price, - BusinessType = p.BusinessType, - IsReturn = "", - InvGroupNum = p.InvGroupNum, - SettleDate = p.SettleDate, - GroupNum = p.GroupNum, - ContractDocID = string.Empty, - PartCode = p.PartCode + return new JsonResult(new { Code = 200, Message = "生成发票任务" }); - }).ToList();//不能结算 - await FirstInvoice(entitys, new List(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); - } - else//二次开票 - { - await SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); - } - } - } + //if (await _bbacMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false)) + //{ + // var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); + // var notQuery = await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync().ConfigureAwait(false); + // var dto1s = ObjectMapper.Map, List>(entitys); + // var q = from d in dto1s + // join p in priceList on d.LU equals p.LU + // where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site + // select new TEMP_CAN_SA_DETAIL + // { + // SettleBillNum = d.SettleBillNum, + // Site = d.Site, + // Version = d.Version, + // Price = p.Price, + // BillNum = d.BillNum, + // SettleDate = d.SettleDate, + // InvGroupNum = d.InvGroupNum, + // LU = d.LU, + // MaterialDesc = d.MaterialDesc, + // PN = d.PN, + // Qty = d.Qty, + // GroupNum = d.GroupNum, + // Amt = Math.Round(d.Qty * p.Price, 2), + // ContractDocID = d.ContractDocID, + // BeginDate = p.BeginTime, + // EndDate = p.EndTime, + // PartCode = d.PartCode + // }; + // var dtos = q.ToList(); + + // if (dtos != null && dtos.Count > 0) + // { + // if (invbillNum.Substring(0, 1) == "C")//一次开票 + // { + // var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL + // { + // KeyCode = p.KeyCode, + // Version = p.Version, + // SettleBillNum = p.SettleBillNum, + // LU = p.LU, + // PN = p.PN, + // Site = p.Site, + // Qty = p.Qty, + // Price = p.Price, + // BusinessType = p.BusinessType, + // IsReturn = "", + // InvGroupNum = p.InvGroupNum, + // SettleDate = p.SettleDate, + // GroupNum = p.GroupNum, + // ContractDocID = string.Empty, + // PartCode = p.PartCode + + // }).ToList();//不能结算 + // await FirstInvoice(entitys, new List(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); + // } + // else//二次开票 + // { + // await SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); + // } + // } + //} } else { return new JsonResult(new { Code = 400, Message = "不存在可结算单记录" }); } - return new JsonResult(new { Code = 200, Message = "生成成功" }); + } } } 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 fc4adc53..90a55140 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 @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using SettleAccount.Domain.BQ; +using SettleAccount.Job.Services; +using TaskJob.EventArgs; using Volo.Abp.Uow; using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; @@ -14,8 +16,10 @@ 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.Entities.BQ.Syncs; using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.Prices; +using Win.Sfs.SettleAccount.Entities.TaskJobs; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ @@ -40,6 +44,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly INormalEfCoreRepository _notRepository; private readonly INormalEfCoreRepository _priceRepository; private readonly HBPO_CAN_SA_MNG _hbpoMng; + private readonly TaskJobService _service; + + public HBPO_CAN_SA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, @@ -50,13 +57,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ INormalEfCoreRepository notRepository, INormalEfCoreRepository priceRepository, HBPO_CAN_SA_MNG hbpoMng, - BaseDomainService baseservice + BaseDomainService baseservice, + TaskJobService service ) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng, baseservice) { _priceRepository = priceRepository; _notRepository = notRepository; _hbpoMng = hbpoMng; + _service = service; } /// /// 生成发票 @@ -83,68 +92,80 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); } - if (await _hbpoMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false)) + + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillnum }); + customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() }); + await _hbpoMng.SetWaitingState(invbillnum); + var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) => { - var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); - var notQuery = _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToList(); - var dto1s = ObjectMapper.Map, List>(entitys); - var q = from d in dto1s - join p in priceList on d.LU equals p.LU - where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site - select new TEMP_CAN_SA_DETAIL - { - SettleBillNum = d.SettleBillNum, - Site = d.Site, - Version = d.Version, - Price = p.Price, - BillNum = d.BillNum, - SettleDate = d.SettleDate, - InvGroupNum = d.InvGroupNum, - LU = d.LU, - MaterialDesc = d.MaterialDesc, - PN = d.PN, - Qty = d.Qty, - GroupNum = d.GroupNum, - Amt = Math.Round(d.Qty * p.Price, 2), - ContractDocID = "no", - BeginDate = p.BeginTime, - EndDate = p.EndTime, - PartCode = d.PartCode + }).ConfigureAwait(false); - }; - var dtos = q.ToList(); - if (dtos != null && dtos.Count > 0) - { - if (invbillnum.Substring(0, 1) == "C")//一次开票 - { - var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL - { - KeyCode = p.KeyCode, - Version = p.Version, - SettleBillNum = p.SettleBillNum, - LU = p.LU, - PN = p.PN, - Site = p.Site, - Qty = p.Qty, - Price = p.Price, - BusinessType = p.BusinessType, - IsReturn = "", - InvGroupNum = p.InvGroupNum, - SettleDate = p.SettleDate, - GroupNum = p.GroupNum, - ContractDocID = string.Empty, - PartCode = p.PartCode + return new JsonResult(new { Code = 200, Message = "生成发票任务" }); - }).ToList();//不能结算 - var falg = await FirstInvoice(entitys, new List(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); - } - else//二次开票 - { - var flag = await SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); - } - } - } + //if (await _hbpoMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false)) + //{ + // var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); + // var notQuery = _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToList(); + // var dto1s = ObjectMapper.Map, List>(entitys); + // var q = from d in dto1s + // join p in priceList on d.LU equals p.LU + // where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site + // select new TEMP_CAN_SA_DETAIL + // { + // SettleBillNum = d.SettleBillNum, + // Site = d.Site, + // Version = d.Version, + // Price = p.Price, + // BillNum = d.BillNum, + // SettleDate = d.SettleDate, + // InvGroupNum = d.InvGroupNum, + // LU = d.LU, + // MaterialDesc = d.MaterialDesc, + // PN = d.PN, + // Qty = d.Qty, + // GroupNum = d.GroupNum, + // Amt = Math.Round(d.Qty * p.Price, 2), + // ContractDocID = "no", + // BeginDate = p.BeginTime, + // EndDate = p.EndTime, + // PartCode = d.PartCode + + // }; + // var dtos = q.ToList(); + // if (dtos != null && dtos.Count > 0) + // { + // if (invbillnum.Substring(0, 1) == "C")//一次开票 + // { + // var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL + // { + // KeyCode = p.KeyCode, + // Version = p.Version, + // SettleBillNum = p.SettleBillNum, + // LU = p.LU, + // PN = p.PN, + // Site = p.Site, + // Qty = p.Qty, + // Price = p.Price, + // BusinessType = p.BusinessType, + // IsReturn = "", + // InvGroupNum = p.InvGroupNum, + // SettleDate = p.SettleDate, + // GroupNum = p.GroupNum, + // ContractDocID = string.Empty, + // PartCode = p.PartCode + + // }).ToList();//不能结算 + // var falg = await FirstInvoice(entitys, new List(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); + // } + // else//二次开票 + // { + // var flag = await SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); + // } + + // } + //} } else { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs index 6a091635..5944cc01 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs @@ -11,6 +11,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.EntityFrameworkCore; using SettleAccount.Bases; using SettleAccount.Domain.BQ; +using ShardingCore.Sharding.MergeContexts; using TaskJob.EventArgs; using TaskJob.Interfaces; using Volo.Abp.Application.Services; @@ -35,82 +36,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs public GenerateJisInvoiceService(SettleAccountDbContext dbcontext) { _dbcontext = dbcontext; + } - - //public string Make(string billNum) - - //{ - // var main = _dbcontext.Set().FirstOrDefault(p => p.InvGroupNum == billNum); - // //var main = await _bbacMng.GetMainAsync(invbillNum); - // if (main != null) - // { - // var entitys = _dbcontext.Set().Where(p => p.InvGroupNum == billNum).ToList();//可结算 - // var priceList = _dbcontext.Set().Where(p => p.IsCancel == false).ToList();//价格表 - // var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); - // var notQuery = _dbcontext.Set().Where(p => p.SettleBillNum == main.SettleBillNum); - // var dto1s = ObjectMapper.Map, List>(entitys); - // var q = from d in dto1s - // join p in priceList on d.LU equals p.LU - // where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site - // select new TEMP_CAN_SA_DETAIL - // { - // SettleBillNum = d.SettleBillNum, - // Site = d.Site, - // Version = d.Version, - // Price = p.Price, - // BillNum = d.BillNum, - // SettleDate = d.SettleDate, - // InvGroupNum = d.InvGroupNum, - // LU = d.LU, - // MaterialDesc = d.MaterialDesc, - // PN = d.PN, - // Qty = d.Qty, - // GroupNum = d.GroupNum, - // Amt = Math.Round(d.Qty * p.Price, 2), - // ContractDocID = d.ContractDocID, - // BeginDate = p.BeginTime, - // EndDate = p.EndTime, - // PartCode = d.PartCode - // }; - // var dtos = q.ToList(); - - // if (dtos != null && dtos.Count > 0) - // { - // if (billNum.Substring(0, 1) == "C")//一次开票 - // { - // var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL - // { - // KeyCode = p.KeyCode, - // Version = p.Version, - // SettleBillNum = p.SettleBillNum, - // LU = p.LU, - // PN = p.PN, - // Site = p.Site, - // Qty = p.Qty, - // Price = p.Price, - // BusinessType = p.BusinessType, - // IsReturn = "", - // InvGroupNum = p.InvGroupNum, - // SettleDate = p.SettleDate, - // GroupNum = p.GroupNum, - // ContractDocID = string.Empty, - // PartCode = p.PartCode - - // }).ToList();//不能结算 - // FirstInvoice(entitys, new List(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); - // } - // else//二次开票 - // { - // SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); - // } - // } - // } - //} - - - - - public string ExportFile(Guid id, List exportName, List property) { var billNum = property.Where(p => p.Name == "BillNum").FirstOrDefault().Value; @@ -506,8 +433,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs return _invls; } - [UnitOfWork(false)] - public List FirstInvoice(List p_list, List p_adjlist, List dtos, List p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) + + public List FirstInvoice( List p_list, List p_adjlist, List dtos, List p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) where TDetail : SA_CAN_BASE { List _invls = new List(); @@ -795,18 +722,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs // 执行批量数据操作 if (salist.Count > 0) { - _dbcontext.BulkUpdateAsync(salist).ConfigureAwait(false); + _dbcontext.BulkUpdate(salist); } - _dbcontext.BulkInsertAsync(invlist).ConfigureAwait(false); - _dbcontext.BulkInsertAsync(groupList).ConfigureAwait(false); - _dbcontext.BulkInsertAsync(detailList).ConfigureAwait(false); + _dbcontext.BulkInsert(invlist); + _dbcontext.BulkInsert(groupList); + _dbcontext.BulkInsert(detailList); if (adjlist.Count > 0) { - _dbcontext.BulkInsertAsync(adjlist).ConfigureAwait(false); + _dbcontext.BulkInsert(adjlist); } if (notDetialList.Count > 0) { - _dbcontext.BulkInsertAsync(notDetialList).ConfigureAwait(false); + _dbcontext.BulkInsert(notDetialList); } // 提交事务 // transaction.Commit(); 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 3fc5e8d4..dbb5ec7f 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 @@ -217,6 +217,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers return false; ; } + public virtual async Task SetWaitingState(string billNum) + { + + var entity = await GetMainAsync(billNum).ConfigureAwait(false); + if (entity != null) + { + entity.State = SettleBillState.发票生成中; + await _repository.UpdateAsync(entity).ConfigureAwait(false); + return true; + } + return false; + ; + } + + + /// /// 获得所有明细 /// @@ -265,6 +281,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { return await _detailRepository.Where(p => p_invs.Contains(p.InvbillNum)).ToListAsync().ConfigureAwait(false); } + }