From e5341a4c162c5e1506c5223b914eec99486cab47 Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Tue, 23 Jul 2024 17:20:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8F=91=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettleAccountHttpApiHostModule.cs | 3 + .../BQ/Syncs/GenerateJisInvoiceService.cs | 581 ++++++++++++------ .../Entities/BQ/VmiAppService.cs | 20 + .../Entities/BQ/INVOICE_GRP.cs | 4 +- 4 files changed, 434 insertions(+), 174 deletions(-) diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccountHttpApiHostModule.cs b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccountHttpApiHostModule.cs index e8063213..5f8b4a5c 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccountHttpApiHostModule.cs +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccountHttpApiHostModule.cs @@ -71,6 +71,9 @@ namespace Win.Sfs.SettleAccount public override void ConfigureServices(ServiceConfigurationContext context) { + //IServiceCollection Services = new ServiceCollection(); + //Services.GetConfiguration(); + // System.AbpStringExtensions.ToCamelCase(System.String, Boolean)' var configuration = context.Services.GetConfiguration(); 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 cedbba01..480304e3 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 @@ -5,6 +5,8 @@ using System.Text; using System.Threading.Tasks; using AutoMapper; using CodeArts.Db.Lts; +using DocumentFormat.OpenXml.Bibliography; +using DocumentFormat.OpenXml.Drawing.Diagrams; using DocumentFormat.OpenXml.Presentation; using EFCore.BulkExtensions; using Microsoft.AspNetCore.Mvc; @@ -18,6 +20,7 @@ using TaskJob.EventArgs; using TaskJob.Interfaces; using Volo.Abp.Application.Services; using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; using Volo.Abp.Uow; using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases.DomainServices; @@ -281,7 +284,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs List invoiceGroupNumList = new List();//每个发票对应的结算分组号 List List = new List(); decimal sum = itm.Value;//初始分组合计金额 - + if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组 { if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) @@ -292,7 +295,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { invoiceGroupNumList.Add(itm.Key); continue; - } + } sum += _itm1.Value; if (sum > 10000000) { @@ -321,7 +324,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { break; } - + sum += _itm1.Value; if (sum > 10000000) { @@ -540,26 +543,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { _dbcontext.BulkUpdate(salist); //带库位发票 - var detailext=salist.GroupBy(p => new { p.InvbillNum, p.InvGroupNum, p.PartCode,p.LU,p.Price, p.ErpLoc,p.BusinessType }) + var detailext = salist.GroupBy(p => new { p.InvbillNum, p.InvGroupNum, p.PartCode, p.LU, p.Price, p.ErpLoc, p.BusinessType }) .Select(p => new INVOICE_DETAIL_EXT { - Version=p_version, - InvbillNum= p.Key.InvbillNum, - InvGroupNum= p.Key.InvGroupNum, - PartCode=p.Key.PartCode, - PRICE= p.Key.Price, - ErpLoc=p.Key.ErpLoc, - Qty = p.Sum(k => k.Qty), - BussiessType=p.Key.BusinessType, - Amt = Math.Round(p.Sum(k => k.Qty) * p.Key.Price, 2),//税前 - LU=p.Key.LU - + Version = p_version, + InvbillNum = p.Key.InvbillNum, + InvGroupNum = p.Key.InvGroupNum, + PartCode = p.Key.PartCode, + PRICE = p.Key.Price, + ErpLoc = p.Key.ErpLoc, + Qty = p.Sum(k => k.Qty), + BussiessType = p.Key.BusinessType, + Amt = Math.Round(p.Sum(k => k.Qty) * p.Key.Price, 2),//税前 + LU = p.Key.LU + } ).ToList(); foreach (var itm in detailext) { itm.SetId(GuidGenerator.Create()); - itm.CreationTime = DateTime.Now; + itm.CreationTime = DateTime.Now; } _dbcontext.BulkInsert(detailext); } @@ -613,177 +616,403 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs EndDate = itm.Key.EndDate }).ToList(); - List biglist = new List(); - List smalllist = new List(); - foreach (var itm in groupDtos)//分类1000W以上或1000W以下 + if (groupDtos.Sum(p => p.Amt) < 10000000) { - if (itm.Amt > 10000000) + var ls = new List(); + var orderbyList = groupDtos.OrderBy(p => p.Qty).ToList(); + int i = 0; + int j = orderbyList.Count - 1; + while (i <= j) { - biglist.Add(itm); - } - else - { - smalllist.Add(itm); + if (i == j) + { + ls.Add(orderbyList[i]); + } + else + { + ls.Add(orderbyList[i]); + ls.Add(orderbyList[j]); + } + i++; + j--; } + _invls = GenSecInvoice(orderbyList, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); + + + } - var groupList = new List(); - var notDetialList = new List(); - var detailList = new List(); - var invlist = new List(); - var salist = new List(); - var adjlist = new List(); - foreach (var big in biglist)//单条大于1000W的开票 + else { - var list = p_list.Where(p => p.InvGroupNum == big.InvGroupNum && p.PartCode == big.PartCode && p.Price == big.Price && p.LU == big.LU); - var gener = new InvoiceGeneratorSame(); - gener.GenerateInvoices(p_list); - var invList = gener.Invoices; - foreach (var inv in invList) + List biglist = new List(); + List smalllist = new List(); + foreach (var itm in groupDtos)//分类1000W以上或1000W以下 { - var partlist = inv.Parts; - if (partlist.Count > 0) + if (itm.Amt > 10000000) { - var query = from itm in partlist - join itm1 in dtos on itm.Id equals itm1.Id - select itm1; - var Dtos = query.ToList(); - var detailDtos = Dtos.GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })//明细 - .Select(itm => new - { - PartCode = itm.Key.PartCode, - InvGroupNum = itm.Key.InvGroupNum, - LU = itm.Key.LU, - ContactDocID = itm.Key.ContractDocID, - Price = itm.Key.Price, - Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税前 - Tax = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2),//税 - TaxAmt = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2) + Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税后进 - Qty = itm.Sum(k => k.Qty), - BeginDate = itm.Key.BeginDate, - EndDate = itm.Key.EndDate - }).ToList(); - - decimal amt = detailDtos.Sum(k => k.Amt);//金额 - decimal txtAmt = detailDtos.Sum(k => k.TaxAmt);//税后金额 - decimal realAmt = detailDtos.Sum(k => k.Tax);//税额 - - - var invoicegrup = partlist.Select(p => p.GroupNum); - var mapList = new List(); - foreach (var groupnum in invoicegrup) - { - mapList.Add(new INVOICE_MAP_GROUP( - guid: GuidGenerator.Create(), - version: p_version, - invbillNum: inv.InvBillNum, - invGroupNum: p_InvGroupNum, - settleGroupNum: groupnum, - amt: 0, - extend1: string.Empty, - extend2: string.Empty - ) - ); - } - if (mapList.Count > 0) - { - groupList.AddRange(mapList); - } - var innotls = new List(); - var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) - .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum }); - foreach (var sitm in sq) - { - innotls.Add(new INVOICE_NOT_SETTLE( - guid: GuidGenerator.Create(), - version: p_version, - invGroupNum: p_InvGroupNum, - settleGroupNum: sitm.GroupNum, - lU: sitm.LU, - lU1: sitm.LU, - extend1: "可结算", - extend2: string.Empty, - qty: sitm.Qty, - p_invbillnum: inv.InvBillNum - )); - } - if (innotls.Count > 0) + biglist.Add(itm); + } + else + { + smalllist.Add(itm); + } + } + var groupList = new List(); + var notDetialList = new List(); + var detailList = new List(); + var invlist = new List(); + var salist = new List(); + var adjlist = new List(); + foreach (var big in biglist)//单条大于1000W的开票 + { + var list = p_list.Where(p => p.InvGroupNum == big.InvGroupNum && p.PartCode == big.PartCode && p.Price == big.Price && p.LU == big.LU); + var gener = new InvoiceGeneratorSame(); + gener.GenerateInvoices(p_list); + var invList = gener.Invoices; + foreach (var inv in invList) + { + var partlist = inv.Parts; + if (partlist.Count > 0) { - notDetialList.AddRange(innotls); - } + var query = from itm in partlist + join itm1 in dtos on itm.Id equals itm1.Id + select itm1; + var Dtos = query.ToList(); + var detailDtos = Dtos.GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })//明细 + .Select(itm => new + { + PartCode = itm.Key.PartCode, + InvGroupNum = itm.Key.InvGroupNum, + LU = itm.Key.LU, + ContactDocID = itm.Key.ContractDocID, + Price = itm.Key.Price, + Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税前 + Tax = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2),//税 + TaxAmt = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2) + Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税后进 + Qty = itm.Sum(k => k.Qty), + BeginDate = itm.Key.BeginDate, + EndDate = itm.Key.EndDate + }).ToList(); - #region 发票明细 - List _entityDetailList = new List(); - foreach (var detail in detailDtos) - { - _entityDetailList.Add( - new INVOICE_WAIT_DETAIL( + decimal amt = detailDtos.Sum(k => k.Amt);//金额 + decimal txtAmt = detailDtos.Sum(k => k.TaxAmt);//税后金额 + decimal realAmt = detailDtos.Sum(k => k.Tax);//税额 + + + var invoicegrup = partlist.Select(p => p.GroupNum); + var mapList = new List(); + foreach (var groupnum in invoicegrup) + { + mapList.Add(new INVOICE_MAP_GROUP( guid: GuidGenerator.Create(), version: p_version, invbillNum: inv.InvBillNum, invGroupNum: p_InvGroupNum, - lU: detail.LU, - qty: detail.Qty, - bussiessType: businessType, - amt: detail.Amt, - pRICE: detail.Price, - extend1: detail.ContactDocID, - extend2: string.Empty, - beginDate: detail.BeginDate, - endDate: detail.EndDate, - partcode: detail.PartCode - )); - } - if (_entityDetailList.Count > 0) - { - detailList.AddRange(_entityDetailList); - } - #endregion - #region 发票 - var invbill = new INVOICE_GRP - ( - guid: GuidGenerator.Create(), - realnvBillNum: string.Empty, - invbillNum: inv.InvBillNum, - amt: amt, - taxAmt: txtAmt, - fileName: string.Empty, - businessType: businessType, - invGroupNum: p_InvGroupNum, - state: SettleBillState.已开票, - invoiceBillState: InvoiceBillState.正常, - tax: 0.13m, - parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, - preTaxDiff: 0, - taxDiff: 0, - clientCode: string.Empty, - realAmt: realAmt - ); - string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; - string clientCode = string.Empty; - switch (site) - { - case "1040": - clientCode = "C001"; - break; - case "1046": - clientCode = "C171"; - break; - default: - clientCode = "C004"; - break; + settleGroupNum: groupnum, + amt: 0, + extend1: string.Empty, + extend2: string.Empty + ) + ); + } + if (mapList.Count > 0) + { + groupList.AddRange(mapList); + } + var innotls = new List(); + var sq = partlist.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) + .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum }); + foreach (var sitm in sq) + { + innotls.Add(new INVOICE_NOT_SETTLE( + guid: GuidGenerator.Create(), + version: p_version, + invGroupNum: p_InvGroupNum, + settleGroupNum: sitm.GroupNum, + lU: sitm.LU, + lU1: sitm.LU, + extend1: "可结算", + extend2: string.Empty, + qty: sitm.Qty, + p_invbillnum: inv.InvBillNum + )); + } + if (innotls.Count > 0) + { + notDetialList.AddRange(innotls); + } + + #region 发票明细 + List _entityDetailList = new List(); + foreach (var detail in detailDtos) + { + _entityDetailList.Add( + new INVOICE_WAIT_DETAIL( + guid: GuidGenerator.Create(), + version: p_version, + invbillNum: inv.InvBillNum, + invGroupNum: p_InvGroupNum, + lU: detail.LU, + qty: detail.Qty, + bussiessType: businessType, + amt: detail.Amt, + pRICE: detail.Price, + extend1: detail.ContactDocID, + extend2: string.Empty, + beginDate: detail.BeginDate, + endDate: detail.EndDate, + partcode: detail.PartCode + )); + } + if (_entityDetailList.Count > 0) + { + detailList.AddRange(_entityDetailList); + } + #endregion + #region 发票 + var invbill = new INVOICE_GRP + ( + guid: GuidGenerator.Create(), + realnvBillNum: string.Empty, + invbillNum: inv.InvBillNum, + amt: amt, + taxAmt: txtAmt, + fileName: string.Empty, + businessType: businessType, + invGroupNum: p_InvGroupNum, + state: SettleBillState.已开票, + invoiceBillState: InvoiceBillState.正常, + tax: 0.13m, + parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, + preTaxDiff: 0, + taxDiff: 0, + clientCode: string.Empty, + realAmt: realAmt + ); + string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; + string clientCode = string.Empty; + switch (site) + { + case "1040": + clientCode = "C001"; + break; + case "1046": + clientCode = "C171"; + break; + default: + clientCode = "C004"; + break; + } + invbill.ClientCode = clientCode; + invbill.Site = dtos.FirstOrDefault().Site; + invbill.CreationTime = DateTime.MinValue; + invbill.LastModificationTime = DateTime.Now; + invlist.Add(invbill); + #endregion } - invbill.ClientCode = clientCode; - invbill.Site = dtos.FirstOrDefault().Site; - invbill.CreationTime = DateTime.MinValue; - invbill.LastModificationTime = DateTime.Now; - invlist.Add(invbill); - #endregion } } + + smalllist = smalllist.OrderBy(p => p.Amt).ToList(); + _invls= GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); + + + //smalllist = smalllist.OrderBy(p => p.Amt).ToList(); + //var gener1 = new InvoiceGeneratorDiff(); + //gener1.GenerateInvoices(smalllist); + //var invList1 = gener1.Invoices; + //foreach (var inv in invList1)//小于1000W的开票 + //{ + // var partlist = inv.Parts; + // var query = from part in p_list + // join part1 in partlist on + // new { part.InvGroupNum, part.PartCode, part.LU, part.Price } equals new { part1.InvGroupNum, part1.PartCode, part1.LU, part1.Price } + // select part; + + // var entityList = query.ToList(); + + // foreach (var entity in entityList) + // { + // entity.InvbillNum = inv.InvBillNum; + // } + + // salist.AddRange(entityList); + + // if (partlist.Count > 0) + // { + // decimal amt = partlist.Sum(k => k.Amt);//金额 + // decimal txtAmt = partlist.Sum(k => k.TaxAmt);//税后金额 + // decimal realAmt = partlist.Sum(k => k.Tax);//税额 + + // var invoicegroupls = entityList.Select(p => p.GroupNum); + // var mapList = new List(); + // foreach (var groupnum in invoicegroupls) + // { + // mapList.Add(new INVOICE_MAP_GROUP( + // guid: GuidGenerator.Create(), + // version: p_version, + // invbillNum: inv.InvBillNum, + // invGroupNum: p_InvGroupNum, + // settleGroupNum: groupnum, + // amt: 0, + // extend1: string.Empty, + // extend2: string.Empty + // ) + // ); + // } + // if (mapList.Count > 0) + // { + // groupList.AddRange(mapList); + // } + // var innotls = new List(); + // var sq = entityList.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum }) + // .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum }); + // foreach (var sitm in sq) + // { + // innotls.Add(new INVOICE_NOT_SETTLE( + // guid: GuidGenerator.Create(), + // version: p_version, + // invGroupNum: p_InvGroupNum, + // settleGroupNum: sitm.GroupNum, + // lU: sitm.LU, + // lU1: sitm.LU, + // extend1: "可结算", + // extend2: string.Empty, + // qty: sitm.Qty, + // p_invbillnum: sitm.InvBillNum + // )); + // } + // if (innotls.Count > 0) + // { + // notDetialList.AddRange(innotls); + // } + + + // List _entityDetailList = new List(); + // foreach (var detail in partlist) + // { + // _entityDetailList.Add( + // new INVOICE_WAIT_DETAIL( + // guid: GuidGenerator.Create(), + // version: p_version, + // invbillNum: inv.InvBillNum, + // invGroupNum: p_InvGroupNum, + // lU: detail.LU, + // qty: detail.Qty, + // bussiessType: businessType, + // amt: detail.Amt, + // pRICE: detail.Price, + // extend1: detail.ContactDocID, + // extend2: string.Empty, + // beginDate: detail.BeginDate.Value, + // endDate: detail.EndDate.Value, + // partcode: detail.PartCode + // )); + // } + // if (_entityDetailList.Count > 0) + // { + // detailList.AddRange(_entityDetailList); + // } + // var invbill = new INVOICE_GRP + // ( + // guid: GuidGenerator.Create(), + // realnvBillNum: string.Empty, + // invbillNum: inv.InvBillNum, + // amt: amt, + // taxAmt: txtAmt, + // fileName: string.Empty, + // businessType: businessType, + // invGroupNum: p_InvGroupNum, + // state: SettleBillState.已开票, + // invoiceBillState: InvoiceBillState.正常, + // tax: 0.13m, + // parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty, + // preTaxDiff: 0, + // taxDiff: 0, + // clientCode: string.Empty, + // realAmt: realAmt + // ); + // string site = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site; + // string clientCode = string.Empty; + // switch (site) + // { + // case "1040": + // clientCode = "C001"; + // break; + // case "1046": + // clientCode = "C171"; + // break; + // default: + // clientCode = "C004"; + // break; + // } + // invbill.ClientCode = clientCode; + // invbill.Site = dtos.FirstOrDefault().Site; + // invbill.CreationTime = DateTime.MinValue; + // invbill.LastModificationTime = DateTime.Now; + // invlist.Add(invbill); + // } + //} + + + //if (salist.Count > 0) + //{ + // _dbcontext.BulkUpdate(salist); + // var detailext = salist.GroupBy(p => new { p.InvbillNum, p.InvGroupNum, p.PartCode, p.LU, p.Price, p.ErpLoc, p.BusinessType }) + // .Select(p => new INVOICE_DETAIL_EXT + // { + // Version = p_version, + // InvbillNum = p.Key.InvbillNum, + // InvGroupNum = p.Key.InvGroupNum, + // PartCode = p.Key.PartCode, + // PRICE = p.Key.Price, + // ErpLoc = p.Key.ErpLoc, + // Qty = p.Sum(k => k.Qty), + // BussiessType = p.Key.BusinessType, + // Amt = Math.Round(p.Sum(k => k.Qty) * p.Key.Price, 2),//税前 + // LU = p.Key.LU + + // } + // ).ToList(); + // foreach (var itm in detailext) + // { + // itm.SetId(GuidGenerator.Create()); + // itm.CreationTime = DateTime.Now; + // } + // _dbcontext.BulkInsert(detailext); + + + //} + //_dbcontext.BulkInsert(invlist); + //_dbcontext.BulkInsert(groupList); + //_dbcontext.BulkInsert(detailList); + + //if (adjlist.Count > 0) + //{ + // _dbcontext.BulkInsert(adjlist); + //} + //if (notDetialList.Count > 0) + //{ + // _dbcontext.BulkInsert(notDetialList); + //} + //_invls = invlist.Select(p => p.InvbillNum).ToList(); } - smalllist = smalllist.OrderBy(p => p.Amt).ToList(); + return _invls; + } + + + public List GenSecInvoice(List p_grouplist, 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, new() + { + var groupList = new List(); + var notDetialList = new List(); + var detailList = new List(); + var invlist = new List(); + var salist = new List(); + var adjlist = new List(); + List _invls = new List(); + var gener1 = new InvoiceGeneratorDiff(); - gener1.GenerateInvoices(smalllist); + gener1.GenerateInvoices(p_grouplist); var invList1 = gener1.Invoices; foreach (var inv in invList1)//小于1000W的开票 { @@ -800,8 +1029,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs entity.InvbillNum = inv.InvBillNum; } - - salist.AddRange(entityList); if (partlist.Count > 0) @@ -937,7 +1164,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs BussiessType = p.Key.BusinessType, Amt = Math.Round(p.Sum(k => k.Qty) * p.Key.Price, 2),//税前 LU = p.Key.LU - } ).ToList(); foreach (var itm in detailext) @@ -952,7 +1178,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs _dbcontext.BulkInsert(invlist); _dbcontext.BulkInsert(groupList); _dbcontext.BulkInsert(detailList); - + if (adjlist.Count > 0) { _dbcontext.BulkInsert(adjlist); @@ -964,7 +1190,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs _invls = invlist.Select(p => p.InvbillNum).ToList(); return _invls; } + + } + + + + + + + diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index bd4247d2..d2a57a51 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -1223,6 +1223,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// private async Task BeginTran(List p_list, List logList) where T : SE_BASE, new() { + IServiceCollection Services = new ServiceCollection(); + /* + * 注册 + */ + Services.GetConfiguration(); + Services.GetRequiredService(); + Services.GetRequiredService(); //var messageList = logList.Select(log => new VmiMessage { Message = JsonSerializer.Serialize(log) }).ToList(); var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; @@ -1725,6 +1732,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } reader.Close(); connection.Close(); + foreach (var item in ls) + { + if (item.BusinessType == EnumBusinessType.JisBBAC.ToString() || item.BusinessType == EnumBusinessType.JisHBPO.ToString() || item.BusinessType == EnumBusinessType.MaiDanJianHBPO.ToString() || item.BusinessType == EnumBusinessType.MaiDanJianBBAC.ToString()) + { + if (!string.IsNullOrEmpty(item.PartCode)) + { + item.PartCode = item.LU.Replace(" ", "-"); + } + } + + + } + return ls; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs index 70c91916..351a4363 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs @@ -158,6 +158,8 @@ namespace SettleAccount.Domain.BQ public string InvBillNum { set; get; } public InvoiceByDiff() { } private List parts = new List(); + + public IReadOnlyList Parts => parts.AsReadOnly(); public decimal TotalAmount => parts.Sum(p => p.Amt); public int PartCount => parts.GroupBy(p => new { p.LU, p.PartCode }).Count(); @@ -169,7 +171,7 @@ namespace SettleAccount.Domain.BQ { if (CanAddPart(part)) { - + //partCount.Add(part.PartCode); parts.Add(part); }