From d862713251342123e7705dec0690c2225c17d533 Mon Sep 17 00:00:00 2001 From: zhaoxinyu Date: Sat, 30 Dec 2023 00:45:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../appsettings.json | 5 +- .../Entities/BQ/INVOICE_SERVICE.cs | 99 +++++++++++++++---- .../Entities/BQ/InvoiceSyncQad.cs | 3 +- .../Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs | 18 +++- 4 files changed, 100 insertions(+), 25 deletions(-) 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 ebdfdecd..858bfb2a 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json @@ -6,7 +6,10 @@ "Default": "Server=dev.ccwin-in.com,13326;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True", //"SettleAccountService": "Server=dev.ccwin-in.com,13326;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;", - "SettleAccountService": "Server=dev.ccwin-in.com,13326;Database=BQ_SA;User ID=sa;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;", + + + + "SettleAccountService": "Server=10.60.101.83;Database=BQ_SA;User ID=sa;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;", "ExChangeCenterService": "Server=dev.ccwin-in.com,13326;Database=ExChangeCenter;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;", "WMSBJBMPT": "Server=dev.ccwin-in.com,6208;Database=WMS_BJBMPT_2;User ID=sa;Password=ChangkeTec@2021;Trusted_Connection=False;TrustServerCertificate=True;", 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 8da86936..ca658bb9 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 @@ -142,6 +142,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var invoiceGrpDetails = _settleAccountDbContext.Set().AsNoTracking() .Where(t => t.InvbillNum == invbillNum) .ToList(); + var invoiceGrpDetailsCopy = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(invoiceGrpDetails)); + + var invmaidanlist= await _bbacMng.GetOnlyMaiDanAsync(invbillNum); + if (invmaidanlist != null && invmaidanlist.Count() > 0) + { + var query = from itm1 in invoiceGrpDetails + join itm2 in invmaidanlist + on new { PartCode = itm1.PartCode, ContractDocID = itm1.Extend1 } + equals new { PartCode = itm2.PartCode, itm2.ContractDocID } + into temp + from j in temp.DefaultIfEmpty() + where j == null + select itm1; + invoiceGrpDetails = query.ToList(); + } + + if (invoiceGrpDetails.Any()) { var tedSaInvs = new List(); @@ -162,7 +179,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ }; List invdetials = new List(); - + var invoiceGrpDetails1 = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(invoiceGrpDetails)); foreach (var itm in invoiceGrpDetails1) { @@ -177,24 +194,52 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - if (itm.Qty > first.Qty) + if (itm.Qty >= first.Qty) { inv.Qty = itm.Qty - first.Qty;//发票总数中去除 - inv.Amt = Math.Round(itm.Qty * itm.PRICE, 2); - } - inv.BussiessType = EnumBusinessType.MaiDanJianBBAC; - if (invoiceGrp.Site == "1046") - { - inv.Extend2 = "CC16"; - } - if (invoiceGrp.Site == "1040") - { - inv.Extend2 ="CC11"; + inv.Amt = Math.Round((itm.Qty - first.Qty) * itm.PRICE, 2); } + //inv.BussiessType = EnumBusinessType.MaiDanJianBBAC; + //if (invoiceGrp.Site == "1046") + //{ + // inv.Extend2 = "CC16"; + //} + //if (invoiceGrp.Site == "1040") + //{ + // inv.Extend2 ="CC11"; + //} invdetials.Add(inv); } } + foreach (var itm in _detail) + { + var inv = new INVOICE_WAIT_DETAIL(); + + + + var first= invoiceGrpDetailsCopy.FirstOrDefault(p=>p.PartCode==itm.PartCode); + inv.InjectFrom(first); + inv.LU = itm.LU; + inv.PartCode = itm.RealPartCode; + inv.Qty = itm.Qty; + inv.PRICE = first.PRICE; + inv.Amt = Math.Round(itm.Qty * first.PRICE, 2); + inv.Extend1 = itm.ContractDocID; + inv.BussiessType = EnumBusinessType.MaiDanJianBBAC; + if (invoiceGrp.Site == "1046") + { + inv.Extend2 = "CC16"; + } + if (invoiceGrp.Site == "1040") + { + inv.Extend2 = "CC11"; + } + invdetials.Add(inv); + + + } + for (var i = 0; i < invdetials.Count; i++) { var invoiceGrpDetail = invdetials[i]; @@ -224,8 +269,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } var tedsaInvs1 = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(tedSaInvs)); var invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff; - var invafter = tedsaInvs1.Sum(p => p.InvoiceNetAmount) + tedsaInvs1.Sum(p => p.InvoiceTaxAmount); - var invdiff = invbefore - invafter; + + var a = tedsaInvs1.Sum(p => p.InvoiceNetAmount); + + var b=tedsaInvs1.Sum(p => p.InvoiceTaxAmount); + var invafter = a + b; + var invdiff = invbefore - invafter; var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1"); var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2"); line2.InvoiceTaxAmount += invdiff; @@ -239,7 +288,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false); invoiceGrp.State = SettleBillState.已提交QAD; await _repository.DbContext.BulkUpdateAsync(new List() { invoiceGrp }); - await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false); + await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode, invoiceGrp.CreationTime).ConfigureAwait(false); //await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false); // var retryPolicyAsync = Policy.Handle().WaitAndRetryAsync(new[] { @@ -299,6 +348,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { invoiceGrpDetail.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}"); } + if (invoiceGrpDetail.BussiessType == EnumBusinessType.ZhiGongJianHBPO) + { + invoiceGrpDetail.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}"); + } if (invoiceGrpDetail.BussiessType == EnumBusinessType.YinDuJian) { invoiceGrpDetail.SetProperty("ErpToLoc", "CC001"); @@ -337,7 +390,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false); invoiceGrp.State = SettleBillState.已提交QAD; await _repository.DbContext.BulkUpdateAsync(new List() { invoiceGrp }); - await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false); + await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode, invoiceGrp.CreationTime).ConfigureAwait(false); } } @@ -402,6 +455,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ inv.Qty = itm.Qty - first.Qty;//发票总数中去除 inv.Amt = Math.Round(itm.Qty * itm.PRICE, 2); } + + + + inv.BussiessType = EnumBusinessType.MaiDanJianBBAC; if (invoiceGrp.Site == "1046") { @@ -460,7 +517,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false); invoiceGrp.State = SettleBillState.已提交QAD; await _repository.DbContext.BulkUpdateAsync(new List() { invoiceGrp }); - await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false); + await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode,invoiceGrp.CreationTime).ConfigureAwait(false); } } else @@ -533,7 +590,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false); invoiceGrp.State = SettleBillState.已提交QAD; await _repository.DbContext.BulkUpdateAsync(new List() { invoiceGrp }); - await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false); + await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode,invoiceGrp.CreationTime).ConfigureAwait(false); } } @@ -542,9 +599,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 构建发票同步Qad状态表数据 /// - private async Task BindInvoiceSyncQadAsync(TEA_TASK_SUB teaTaskSub, string invoiceNumber, string sasInvoiceNumber, string customer) + private async Task BindInvoiceSyncQadAsync(TEA_TASK_SUB teaTaskSub, string invoiceNumber, string sasInvoiceNumber, string customer,DateTime dateTime) { - var invoiceSyncQad = new InvoiceSyncQad(teaTaskSub.TaskID, invoiceNumber, sasInvoiceNumber) + var invoiceSyncQad = new InvoiceSyncQad(teaTaskSub.TaskID, invoiceNumber, sasInvoiceNumber,dateTime) { TableName = teaTaskSub.TableName, @@ -552,7 +609,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ Site = teaTaskSub.Site, Customer = customer }; - + invoiceSyncQad.SetId(teaTaskSub.TaskID); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs index c7fa42bb..0b6f18d4 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs @@ -73,11 +73,12 @@ namespace SettleAccount.Domain.BQ } - public InvoiceSyncQad(Guid taskId, string invoiceNumber, string sasInvoiceNumber) + public InvoiceSyncQad(Guid taskId, string invoiceNumber, string sasInvoiceNumber,DateTime dateTime) { TaskId = taskId; InvoiceNumber = invoiceNumber; SasInvoiceNumber = sasInvoiceNumber; + CreationTime = dateTime; } public void SetId(Guid p_id) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs index 2b39bcaf..14af0fd1 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs @@ -5,8 +5,10 @@ using System.Threading.Tasks; using EFCore.BulkExtensions; using Microsoft.EntityFrameworkCore; using SettleAccount.Domain.BQ; +using SkiaSharp; using Volo.Abp; using Volo.Abp.Domain.Services; +using Win.Sfs.Shared.CurrentBranch; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ.Managers @@ -269,8 +271,20 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers .GroupBy(p=>new { p.PartCode ,p.ContractDocID }).Select(p=> new BBAC_CAN_SA_DETAIL { Qty=p.Sum(itm=>itm.Qty),PartCode=p.Key.PartCode,ContractDocID=p.Key.ContractDocID }).ToListAsync(); } - + public virtual async Task> GetOnlyMaiDanAsync(string p_invbillnum) + { + var a=_detailRepository.Where(p => p.InvbillNum == p_invbillnum && p.BusinessType != EnumBusinessType.JisBBAC); + var b= _detailRepository.Where(p => p.InvbillNum == p_invbillnum && p.BusinessType == EnumBusinessType.JisBBAC); + var result = (from itm1 in a + join itm2 in b + on new { itm1.PartCode, itm1.ContractDocID } equals new { itm2.PartCode, itm2.ContractDocID } + + into joinTable + from j in joinTable.DefaultIfEmpty() + where j == null + select new BBAC_CAN_SA_DETAIL { PartCode= itm1.PartCode,ContractDocID= itm1.ContractDocID }).Distinct(); + return result.ToList(); + } } - }