diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json index 77d7a65d..aca02dc2 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json @@ -1,6 +1,6 @@ { "App": { - "CorsOrigins": "https://*.abc.com,http://localhost:9527,http://149.223.116.5:8088" + "CorsOrigins": "https://*.abc.com,http://localhost:9527,http://149.223.116.5:8088,http://localhost:44378" }, "ConnectionStrings": { "Default": "Server=dev.ccwin-in.com,13326;Database=BJABP;User ID=sa;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True", 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 806a2584..9881a748 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 @@ -25,6 +25,7 @@ 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.Prices; using Win.Sfs.SettleAccount.Entities.TaskJobs; using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; @@ -73,6 +74,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ IExporter _excel = new ExcelExporter(); var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); + + + + + + + + + + + + + var dtoDetails = ObjectMapper.Map, List>(entities); var inner = from d in entities @@ -148,22 +162,65 @@ namespace Win.Sfs.SettleAccount.Entities.BQ input.Filters.Remove(first); } - //_detailRepository.DbContext.Set().Where(p=>p.) - var flag= await _bbacNotMng.IsCompleted().ConfigureAwait(false); - if (flag == false) + var _dbcontext = await _detailRepository.GetDbContextAsync().ConfigureAwait(false); + var pricelist = _dbcontext.Set().Where(p => p.ClientCode == "1040" && p.IsCancel == false).ToList(); + var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); + + var query = from d in entities + join p in pricelist + on d.LU equals p.LU + where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "1040" + select new + { + a = + new BBAC_CAN_SA_DETAIL() + { + ContractDocID = d.ContractDocID, + IsMaiDan = d.IsMaiDan, + Version = d.Version, + KeyCode = d.KeyCode, + Site = "1040", + BusinessType = d.BusinessType, + ErpLoc = d.ErpLoc, + CreationTime = d.CreationTime, + GroupNum = d.GroupNum, + InvGroupNum = d.InvGroupNum, + LU = d.LU, + PN = d.PN, + SettleBillNum = d.SettleBillNum, + Price = p.Price, + SettleDate = d.SettleDate, + RealPartCode = d.RealPartCode, + PartCode = d.PartCode, + Qty = d.Qty + }, + b = d + }; + var bbac_can_list = query.Select(p => p.a).ToList(); + var bbac_not_list = query.Select(p => p.b).ToList(); + if (bbac_can_list.Count > 0) { - throw new UserFriendlyException("任务生成中请等待...", "400"); + + var flag = await _bbacNotMng.IsCompleted().ConfigureAwait(false); + if (flag == false) + { + throw new UserFriendlyException("任务生成中请等待...", "400"); + } + else + { + var filters = JsonSerializer.Serialize(input.Filters); + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "condition", Value = filters }); + customConditionList.Add(new CustomCondition() { Name = "businesstype", Value = EnumBusinessType.JisBBAC.ToString() }); + var _taskid = await _service.ExportEnqueueAsync($"{EnumBusinessType.JisBBAC.ToString()}生成可结算单任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(MakeCanSettlementService), customConditionList, (rs) => + { }).ConfigureAwait(false); + } + return new JsonResult(new { Code = 200, Message = "正在生成" }); } else { - var filters = JsonSerializer.Serialize(input.Filters); - List customConditionList = new List(); - customConditionList.Add(new CustomCondition() { Name = "condition", Value = filters }); - customConditionList.Add(new CustomCondition() { Name = "businesstype", Value = EnumBusinessType.JisBBAC.ToString() }); - var _taskid = await _service.ExportEnqueueAsync($"{EnumBusinessType.JisBBAC.ToString()}生成可结算单任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(MakeCanSettlementService), customConditionList, (rs) => - { }).ConfigureAwait(false); + 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_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs index cfa0f687..cf916e0e 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 @@ -24,6 +24,7 @@ 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.Prices; using Win.Sfs.SettleAccount.Entities.TaskJobs; using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; @@ -141,20 +142,68 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { input.Filters.Remove(first); } - var flag = await _hbpoNotMng.IsCompleted().ConfigureAwait(false); - if (flag == false) + + var _dbcontext = await _detailRepository.GetDbContextAsync().ConfigureAwait(false); + var pricelist = _dbcontext.Set().Where(p => p.ClientCode == "1040" && p.IsCancel == false).ToList(); + var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); + + var query = from d in entities + join p in pricelist + on d.LU equals p.LU + where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "1040" + select new + { + a = + new HBPO_CAN_SA_DETAIL() + { + + Version = d.Version, + KeyCode = d.KeyCode, + Site = "1040", + BusinessType = d.BusinessType, + ErpLoc = d.ErpLoc, + CreationTime = d.CreationTime, + GroupNum = d.GroupNum, + InvGroupNum = d.InvGroupNum, + LU = d.LU, + PN = d.PN, + SettleBillNum = d.SettleBillNum, + Price = p.Price, + SettleDate = d.SettleDate, + RealPartCode = d.RealPartCode, + PartCode = d.PartCode, + Qty = d.Qty + }, + b = d + }; + var bbac_can_list = query.Select(p => p.a).ToList(); + var bbac_not_list = query.Select(p => p.b).ToList(); + + + + + + if (bbac_can_list.Count > 0) { - throw new UserFriendlyException("任务生成中请等待...", "400"); + var flag = await _hbpoNotMng.IsCompleted().ConfigureAwait(false); + if (flag == false) + { + throw new UserFriendlyException("任务生成中请等待...", "400"); + } + else + { + var filters = JsonSerializer.Serialize(input.Filters); + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "condition", Value = filters }); + customConditionList.Add(new CustomCondition() { Name = "businesstype", Value = EnumBusinessType.JisHBPO.ToString() }); + var _taskid = await _service.ExportEnqueueAsync($"{EnumBusinessType.JisHBPO.ToString()}生成可结算单任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(MakeCanSettlementService), customConditionList, (rs) => + { }).ConfigureAwait(false); + return new JsonResult(new { Code = 200, Message = "正在生成" }); + } } else { - var filters = JsonSerializer.Serialize(input.Filters); - List customConditionList = new List(); - customConditionList.Add(new CustomCondition() { Name = "condition", Value = filters }); - customConditionList.Add(new CustomCondition() { Name = "businesstype", Value = EnumBusinessType.JisHBPO.ToString() }); - var _taskid = await _service.ExportEnqueueAsync($"{EnumBusinessType.JisHBPO.ToString()}生成可结算单任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(MakeCanSettlementService), customConditionList, (rs) => - { }).ConfigureAwait(false); - return new JsonResult(new { Code = 200, Message = "生成成功" }); + return new JsonResult(new { Code = 400, Message = "筛选的数据都没有价格!" }); } } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs index 2eaddd0f..ab009749 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs @@ -179,6 +179,54 @@ namespace Win.Sfs.SettleAccount.Entities.BQ return new OkResult(); } + [HttpPost] + [UnitOfWork(false)] + public virtual async Task CancelToQad(List invbillNums) + { + _globalConfigOptions.IsSyncInvoiceQadState = true; + + var invoiceGrps1 = _settleAccountDbContext.Set() + .Where(t => invbillNums.Contains(t.InvbillNum) && t.State == SettleBillState.已扣减); + foreach (var itm in invoiceGrps1) + { + itm.State = SettleBillState.发票同步中; + } + await _settleAccountDbContext.BulkUpdateAsync(invoiceGrps1.ToList()).ConfigureAwait(false); + + + var invoiceGrps = _settleAccountDbContext.Set() + .Where(t => invbillNums.Contains(t.InvbillNum) && t.State == SettleBillState.发票同步中); + + + var invoiceBBACGrps = invoiceGrps.Where(p => p.BusinessType == EnumBusinessType.JisBBAC); + var invoicePubGrps = invoiceGrps.Where(p => p.BusinessType != EnumBusinessType.JisBBAC && p.BusinessType != EnumBusinessType.JisHBPO); + var invoiceHbpoGrps = invoiceGrps.Where(p => p.BusinessType == EnumBusinessType.JisHBPO); + if (invoiceBBACGrps.Any()) + { + var invlist = await invoiceBBACGrps.ToListAsync().ConfigureAwait(false); + var billinvs = invlist.Select(p => p.InvbillNum).ToList(); + //await CreateBBACTaskAsync(billinvs).ConfigureAwait(false); + await CreateBBACHongChongTaskAsync(billinvs).ConfigureAwait(false); + + } + if (invoicePubGrps.Any()) + { + var invlist = await invoicePubGrps.ToListAsync().ConfigureAwait(false); + var billinvs = invlist.Select(p => p.InvbillNum).ToList(); + await CreatePubHongChongTaskAsync(billinvs).ConfigureAwait(false); + } + if (invoiceHbpoGrps.Any()) + { + var invlist = await invoiceHbpoGrps.ToListAsync().ConfigureAwait(false); + var billinvs = invlist.Select(p => p.InvbillNum).ToList(); + await CreateHBPOHongChongTaskAsync(billinvs).ConfigureAwait(false); + } + + return new OkResult(); + } + + + //[UnitOfWork(false)] /// /// 提交到QAD 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 2beda935..9401ae78 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 @@ -67,6 +67,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs if (jis1.Count > 0)//1040 { var pricelist = _dbcontext.Set().Where(p => p.ClientCode == "1040" && p.IsCancel == false).ToList(); + + var query = from d in jis1 join p in pricelist on d.LU equals p.LU diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ReturnCanSettlement.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ReturnCanSettlement.cs index c9dc776d..18fb3177 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ReturnCanSettlement.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ReturnCanSettlement.cs @@ -31,36 +31,35 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { var entites = _dbcontext.Set().Where(p => p.BillNum == billNum).ToList(); var main = _dbcontext.Set().FirstOrDefault(p => p.BillNum == billNum); - Execute(main, entites); + Execute(main, entites); } if (BussinessType == "JisHBPO") { var entites = _dbcontext.Set().Where(p => p.BillNum == billNum).ToList(); var main = _dbcontext.Set().FirstOrDefault(p => p.BillNum == billNum); - Execute(main, entites); + Execute(main, entites); } - - return id.ToString(); } - public void Execute(TMain p_main,List p_detailList) where TMain : SA_CAN_BASE_MAIN, new() + public void Execute(TMain p_main,List p_detailList) where TMain : SA_CAN_BASE_MAIN, new() where TDetail : SA_CAN_BASE, new() + where TNOTDetail : SA_NOT_BASE, new() { - List notList = new List(); + List notList = new List(); var entites = p_detailList; var main = p_main; foreach (var itm in entites) { - var detail = new TDetail(); + var detail = new TNOTDetail(); detail.InjectFrom(itm); - detail.SetId(detail.Id); + detail.SetId(itm.Id); foreach (var extra in itm.ExtraProperties) { detail.ExtraProperties.Add(extra.Key, extra.Value);