From 7e9a5f7692b3bd398925c0898aa0a2334065954b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Fri, 26 Apr 2024 09:15:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0JIT=E5=BC=80=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bases/CAN_SA_SERVICE.cs | 2 +- .../BQ/Syncs/GenerateJisInvoiceService.cs | 175 ++++++--- .../BQ/Syncs/MakeCanSettlementService.cs | 339 +++++++++++------- .../Entities/BQ/Managers/INV_MNG.cs | 2 +- 4 files changed, 333 insertions(+), 185 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs index 8941ce48..ab06aed9 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs @@ -216,7 +216,7 @@ namespace Win.Sfs.SettleAccount.Bases invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_invGroupNum, string.Empty, businessType, true).ConfigureAwait(false); break; case EnumBusinessType.ZhiGongJianBBAC: - invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true).ConfigureAwait(false);//重开可以变多张发票 + invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType).ConfigureAwait(false);//重开可以变多张发票 break; case EnumBusinessType.ZhiGongJianHBPO: invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType).ConfigureAwait(false);//重开可以变多张发票 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 2d0f8e4a..501e5171 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 @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using AutoMapper; +using CodeArts.Db.Lts; using DocumentFormat.OpenXml.Presentation; using EFCore.BulkExtensions; using Microsoft.AspNetCore.Mvc; @@ -34,7 +35,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs public decimal Amt { set; get; } public decimal TaxAmt { set; get; } - public decimal Tax { set; get;} + public decimal Tax { set; get; } } @@ -116,7 +117,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } else//二次开票 { - var invs = SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); + var query = from b in _dbcontext.Set() + join a in (from d in _dbcontext.Set() + where d.BillNum == main.BillNum + select d.GroupNum).Distinct() + on b.GroupNum equals a + group b by new { b.GroupNum, b.LU } into g + select new TEMP_NOT_SA_DETAIL + { + GroupNum = g.Key.GroupNum, + LU = g.Key.LU, + Qty = g.Sum(p => p.Qty), + }; + var invs = SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, query.ToList()); if (invs.Count > 0) { main.State = SettleBillState.已开票; @@ -126,7 +139,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs _dbcontext.BulkUpdate(new List() { main }); } } - if(BussinessType== "JisHBPO") + if (BussinessType == "JisHBPO") { var main = _dbcontext.Set().FirstOrDefault(p => p.InvGroupNum == billNum); //var main = await _bbacMng.GetMainAsync(invbillNum); @@ -155,7 +168,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs Qty = d.Qty, GroupNum = d.GroupNum, Amt = Math.Round(d.Qty * p.Price, 2), - ContractDocID ="n", + ContractDocID = "n", BeginDate = p.BeginTime, EndDate = p.EndTime, PartCode = d.PartCode @@ -192,7 +205,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } else//二次开票 { - var invs = SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); + var query = from b in _dbcontext.Set() + join a in (from d in _dbcontext.Set() + where d.BillNum == main.BillNum + select d.GroupNum).Distinct() + on b.GroupNum equals a + group b by new { b.GroupNum, b.LU } into g + select new TEMP_NOT_SA_DETAIL + { + GroupNum = g.Key.GroupNum, + LU = g.Key.LU, + Qty = g.Sum(p => p.Qty), + + }; + + var invs = SecInvoice(entitys, new List(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, query.ToList()); if (invs.Count > 0) { main.State = SettleBillState.已开票; @@ -204,7 +231,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } return id.ToString(); } - public List SecInvoice(List p_list, List p_ajdlist, List dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) + public List SecInvoice(List p_list, List p_ajdlist, List dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, List p_notlist = null) where TDetail : SA_CAN_BASE { List _invls = new List(); @@ -252,39 +279,45 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs && group.BeginDate == group1.BeginDate && group.EndDate == group1.EndDate && group1.ContractDocID == group.ContractDocID + && group1.Price == group.Price + && group1.Qty == group.Qty + && group1.Amt == group.Amt ) { tempList.Add(group1); partCount++;//符合条件加入到零件中 continue; } - //partCount++; - //if (partCount > 30) - //{ - // continue; - //} + sum += group1.Amt; if (sum > 10000000) { break; } - sum += group1.Amt; tempList.Add(group1); } invoiceMap.Add(invoiceBillNum, tempList); + + var query = from itm in groups1 //更新分组 join itm1 in tempList - on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode } - equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode } into temp - from tm in temp + on + new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode, itm.Qty, itm.Price, itm.Amt } + equals + new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode, itm1.Qty, itm1.Price, itm1.Amt } + into temp + from tm in temp.DefaultIfEmpty() where tm == null select new TMEP_INV { LU = itm.LU, Amt = itm.Amt, Qty = itm.Qty, + Price = itm.Price, BeginDate = itm.BeginDate, ContractDocID = itm.ContractDocID, - EndDate = itm.EndDate + EndDate = itm.EndDate, + PartCode = itm.PartCode, + }; groups1 = query.ToList(); } @@ -297,6 +330,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs var invlist = new List(); var salist = new List(); var adjlist = new List(); + int count = invoiceMap.Keys.Count;//计算第几张发票计数器 + int i = 1; foreach (var group in invoiceMap) { var key = group.Key;//发票票号 @@ -304,9 +339,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs //反向查找结算数据 var query = from itm in dtos join itm1 in ls - on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } + on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate, itm.ContractDocID } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID } join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } - select itm2; + select itm2;//反向更新可计算数据 foreach (var itm in query) { itm.InvbillNum = key; @@ -351,27 +386,66 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { detailList.AddRange(_entityDetailList); } - List amtList = new List(); - foreach (var itm in detailList) + #region 发票不能结算的明细 + var innotls = new List(); + var sq = query.GroupBy(p => new { p.LU, p.GroupNum }) + .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = group.Key, GroupNum = p.Key.GroupNum }); + foreach (var sitm in sq) { - amtList.Add(new tempAmt() { - Amt=itm.Amt, - Tax=Math.Round(itm.Amt*0.13m,2), - TaxAmt=itm.Amt+ Math.Round(itm.Amt * 0.13m, 2) - }); + 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: group.Key + )); } - decimal amt = amtList.Sum(k => k.Amt);//金额 - decimal txtAmt = amtList.Sum(k => k.TaxAmt) ;//税后金额 - decimal readAmt = amtList.Sum(k=>k.Tax);//税额 - - //decimal amt = detailList.Sum(k => k.Amt); - //decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2); - - var contractList = ls.Select(p => p.ContractDocID).Distinct(); - var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum }) - .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct(); - //var _groupList = dtos.GroupBy(p => new { p.GroupNum }) - // .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct(); + if (innotls.Count > 0) + { + notDetialList.AddRange(innotls); + } + if (p_notlist != null && p_notlist.Count > 0) + { + var innotls1 = new List(); + + var grouplist = query.Select(p => p.GroupNum).ToList(); + + + var notlist = p_notlist.Where(p => grouplist.Contains(p.GroupNum)); + + foreach (var nitm in notlist) + { + innotls1.Add(new INVOICE_NOT_SETTLE( + guid: GuidGenerator.Create(), + version: p_version, + invGroupNum: p_InvGroupNum, + settleGroupNum: nitm.GroupNum, + lU: nitm.LU, + lU1: nitm.LU, + extend1: "不可结算", + extend2: string.Empty, + qty: nitm.Qty, + p_invbillnum: group.Key + )); + } + if (innotls.Count > 0) + { + notDetialList.AddRange(innotls1); + } + } + #endregion + decimal amt = ls.Sum(k => k.Amt);//金额 + decimal txtAmt = Math.Round(amt * 0.13m, 2);//税后金额 + decimal readAmt = amt + Math.Round(amt * 0.13m, 2);//税额 + + //var contractList = ls.Select(p => p.ContractDocID).Distinct(); + var _groupList = query.GroupBy(p => new { p.GroupNum }) + .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => Math.Round(itm.Qty * itm.Price, 2)) }).Distinct(); List group1 = new List(); foreach (var en in _groupList) { @@ -390,7 +464,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { groupList.AddRange(group1); } - var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList(); string site = lst.FirstOrDefault().Site; string clientCode = string.Empty; @@ -434,9 +507,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs _dbcontext.BulkInsert(invlist); _dbcontext.BulkInsert(groupList); _dbcontext.BulkInsert(detailList); + _dbcontext.BulkInsert(notDetialList); + if (salist.Count > 0) { - _dbcontext.BulkUpdate(salist); + _dbcontext.BulkUpdate(salist); } if (adjlist.Count > 0) { @@ -447,7 +522,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } return _invls; } - 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(); @@ -552,7 +627,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs lsby.AddRange(grouplist); var nolist = p_notlist.Where(p => !grouplist.Contains(p.GroupNum)).Select(p => p.GroupNum).ToList();//不可结分组 int count = invoiceMap.Keys.Count;//计算第几张发票计数器 - int i = 1; foreach (var itm in invoiceMap)//分组影响和 { @@ -585,14 +659,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs 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),//税后进 + 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);//税额 + decimal realAmt = detailDtos.Sum(k => k.Tax);//税额 var mapList = new List(); foreach (var groupnum in ls) @@ -738,14 +813,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs // 执行批量数据操作 if (salist.Count > 0) { - _dbcontext.BulkUpdate(salist); + _dbcontext.BulkUpdate(salist); } - _dbcontext.BulkInsert(invlist); - _dbcontext.BulkInsert(groupList); - _dbcontext.BulkInsert(detailList); + _dbcontext.BulkInsert(invlist); + _dbcontext.BulkInsert(groupList); + _dbcontext.BulkInsert(detailList); if (adjlist.Count > 0) { - _dbcontext.BulkInsert(adjlist); + _dbcontext.BulkInsert(adjlist); } if (notDetialList.Count > 0) { @@ -763,9 +838,9 @@ 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/Syncs/MakeCanSettlementService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs index 2ccd2c39..3b40dcaf 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 @@ -183,74 +183,113 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs if (part_group_small.Count > 0) { var partlist = part_group_small.Select(p => p.LU).ToList(); - var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ; - decimal sum = 0; - List details = new List(); + var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); + var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + var bbac_sa = new BBAC_CAN_SA(); + bbac_sa.SetId(Guid.NewGuid()); + bbac_sa.BillNum = billNum; + bbac_sa.InvGroupNum = billNum; + bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + bbac_sa.State = SettleBillState.未结状态; + bbac_sa.SettleBillNum = string.Empty; + bbac_sa.Site = "1040"; + bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + billList.Add(bbac_sa); foreach (var itm1 in ls) { - sum += (itm1.Qty * itm1.Price); - if (sum > 10000000) - { - var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); - var bbac_sa = new BBAC_CAN_SA(); - bbac_sa.SetId(Guid.NewGuid()); - bbac_sa.BillNum = billNum; - bbac_sa.InvGroupNum = billNum; - bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); - bbac_sa.State = SettleBillState.未结状态; - bbac_sa.SettleBillNum = string.Empty; - bbac_sa.Site = "1040"; - bbac_sa.BusinessType = EnumBusinessType.JisBBAC; - billList.Add(bbac_sa); - foreach (var itm2 in details) - { - itm2.SetBillNum(billNum); - itm2.SetGroupNum(billNum); - billDetails.Add(itm2); - } - details = new List(); - sum = itm1.Qty * itm1.Price; - } var _detailEntity = new BBAC_CAN_SA_DETAIL( - guid: GuidGenerator.Create(), - keyCode: itm1.KeyCode, - version: itm1.Version, - billNum: string.Empty, - settleBillNum: itm1.SettleBillNum, - lU: itm1.LU, - pN: itm1.PN, - site: itm1.Site, - qty: itm1.Qty, - price: itm1.Price, - category: itm1.BusinessType, - isReturn: itm1.IsReturn, - settleDate: itm1.SettleDate, - groupNum: itm1.GroupNum, - invGroupNum: string.Empty, - contactid: itm1.ContractDocID, - invbillnum: string.Empty, - partcode: itm1.PartCode - ); + guid: GuidGenerator.Create(), + keyCode: itm1.KeyCode, + version: itm1.Version, + billNum: billNum, + settleBillNum: itm1.SettleBillNum, + lU: itm1.LU, + pN: itm1.PN, + site: itm1.Site, + qty: itm1.Qty, + price: itm1.Price, + category: itm1.BusinessType, + isReturn: itm1.IsReturn, + settleDate: itm1.SettleDate, + groupNum: itm1.GroupNum, + invGroupNum: billNum, + contactid: itm1.ContractDocID, + invbillnum: string.Empty, + partcode: itm1.PartCode + ); _detailEntity.RealPartCode = itm1.RealPartCode; - details.Add(_detailEntity); - } - var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); - var bbac_sa1 = new BBAC_CAN_SA(); - bbac_sa1.SetId(Guid.NewGuid()); - bbac_sa1.BillNum = billNum1; - bbac_sa1.InvGroupNum = billNum1; - bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); - bbac_sa1.State = SettleBillState.未结状态; - bbac_sa1.SettleBillNum = string.Empty; - bbac_sa1.Site = "1040"; - bbac_sa1.BusinessType = EnumBusinessType.JisBBAC; - billList.Add(bbac_sa1); - foreach (var detail in details) - { - detail.SetBillNum(billNum1); - detail.SetGroupNum(billNum1); - billDetails.Add(detail); + billDetails.Add(_detailEntity); } + + //var partlist = part_group_small.Select(p => p.LU).ToList(); + //var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ; + //decimal sum = 0; + //List details = new List(); + //foreach (var itm1 in ls) + //{ + // sum += (itm1.Qty * itm1.Price); + // if (sum > 10000000) + // { + // var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + // var bbac_sa = new BBAC_CAN_SA(); + // bbac_sa.SetId(Guid.NewGuid()); + // bbac_sa.BillNum = billNum; + // bbac_sa.InvGroupNum = billNum; + // bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + // bbac_sa.State = SettleBillState.未结状态; + // bbac_sa.SettleBillNum = string.Empty; + // bbac_sa.Site = "1040"; + // bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + // billList.Add(bbac_sa); + // foreach (var itm2 in details) + // { + // itm2.SetBillNum(billNum); + // itm2.SetGroupNum(billNum); + // billDetails.Add(itm2); + // } + // details = new List(); + // sum = itm1.Qty * itm1.Price; + // } + // var _detailEntity = new BBAC_CAN_SA_DETAIL( + // guid: GuidGenerator.Create(), + // keyCode: itm1.KeyCode, + // version: itm1.Version, + // billNum: string.Empty, + // settleBillNum: itm1.SettleBillNum, + // lU: itm1.LU, + // pN: itm1.PN, + // site: itm1.Site, + // qty: itm1.Qty, + // price: itm1.Price, + // category: itm1.BusinessType, + // isReturn: itm1.IsReturn, + // settleDate: itm1.SettleDate, + // groupNum: itm1.GroupNum, + // invGroupNum: string.Empty, + // contactid: itm1.ContractDocID, + // invbillnum: string.Empty, + // partcode: itm1.PartCode + // ); + // _detailEntity.RealPartCode = itm1.RealPartCode; + // details.Add(_detailEntity); + //} + //var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); + //var bbac_sa1 = new BBAC_CAN_SA(); + //bbac_sa1.SetId(Guid.NewGuid()); + //bbac_sa1.BillNum = billNum1; + //bbac_sa1.InvGroupNum = billNum1; + //bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + //bbac_sa1.State = SettleBillState.未结状态; + //bbac_sa1.SettleBillNum = string.Empty; + //bbac_sa1.Site = "1040"; + //bbac_sa1.BusinessType = EnumBusinessType.JisBBAC; + //billList.Add(bbac_sa1); + //foreach (var detail in details) + //{ + // detail.SetBillNum(billNum1); + // detail.SetGroupNum(billNum1); + // billDetails.Add(detail); + //} } } } @@ -370,79 +409,113 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } if (part_group_small.Count > 0) { - - var partlist = part_group_small.Select(p => p.LU).ToList(); - var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ; - decimal sum = 0; - List details = new List(); + var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); + var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + var bbac_sa = new BBAC_CAN_SA(); + bbac_sa.SetId(Guid.NewGuid()); + bbac_sa.BillNum = billNum; + bbac_sa.InvGroupNum = billNum; + bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + bbac_sa.State = SettleBillState.未结状态; + bbac_sa.SettleBillNum = string.Empty; + bbac_sa.Site = "1046"; + bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + billList.Add(bbac_sa); foreach (var itm1 in ls) { - sum += (itm1.Qty * itm1.Price); - if (sum > 10000000) - { - var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); - var bbac_sa = new BBAC_CAN_SA(); - bbac_sa.SetId(Guid.NewGuid()); - bbac_sa.BillNum = billNum; - bbac_sa.InvGroupNum = billNum; - bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); - bbac_sa.State = SettleBillState.未结状态; - bbac_sa.SettleBillNum = string.Empty; - bbac_sa.Site = "1046"; - bbac_sa.BusinessType = EnumBusinessType.JisBBAC; - billList.Add(bbac_sa); - foreach (var itm2 in details) - { - itm2.SetBillNum(billNum); - itm2.SetGroupNum(billNum); - billDetails.Add(itm2); - } - details = new List(); - sum = itm1.Qty * itm1.Price; - } var _detailEntity = new BBAC_CAN_SA_DETAIL( - guid: GuidGenerator.Create(), - keyCode: itm1.KeyCode, - version: itm1.Version, - billNum: string.Empty, - settleBillNum: itm1.SettleBillNum, - lU: itm1.LU, - pN: itm1.PN, - site: itm1.Site, - qty: itm1.Qty, - price: itm1.Price, - category: itm1.BusinessType, - isReturn: itm1.IsReturn, - settleDate: itm1.SettleDate, - groupNum: itm1.GroupNum, - invGroupNum: string.Empty, - contactid: itm1.ContractDocID, - invbillnum: string.Empty, - partcode: itm1.PartCode - ); + guid: GuidGenerator.Create(), + keyCode: itm1.KeyCode, + version: itm1.Version, + billNum: billNum, + settleBillNum: itm1.SettleBillNum, + lU: itm1.LU, + pN: itm1.PN, + site: itm1.Site, + qty: itm1.Qty, + price: itm1.Price, + category: itm1.BusinessType, + isReturn: itm1.IsReturn, + settleDate: itm1.SettleDate, + groupNum: itm1.GroupNum, + invGroupNum: billNum, + contactid: itm1.ContractDocID, + invbillnum: string.Empty, + partcode: itm1.PartCode + ); _detailEntity.RealPartCode = itm1.RealPartCode; - details.Add(_detailEntity); - } - var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); - var bbac_sa1 = new BBAC_CAN_SA(); - bbac_sa1.SetId(Guid.NewGuid()); - bbac_sa1.BillNum = billNum1; - bbac_sa1.InvGroupNum = billNum1; - bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); - bbac_sa1.State = SettleBillState.未结状态; - bbac_sa1.SettleBillNum = string.Empty; - bbac_sa1.Site = "1046"; - bbac_sa1.BusinessType = EnumBusinessType.JisBBAC; - billList.Add(bbac_sa1); - foreach (var detail in details) - { - detail.SetBillNum(billNum1); - detail.SetGroupNum(billNum1); - billDetails.Add(detail); + billDetails.Add(_detailEntity); } - - + //var partlist = part_group_small.Select(p => p.LU).ToList(); + //var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ; + //decimal sum = 0; + //List details = new List(); + //foreach (var itm1 in ls) + //{ + // sum += (itm1.Qty * itm1.Price); + // if (sum > 10000000) + // { + // var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); + // var bbac_sa = new BBAC_CAN_SA(); + // bbac_sa.SetId(Guid.NewGuid()); + // bbac_sa.BillNum = billNum; + // bbac_sa.InvGroupNum = billNum; + // bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + // bbac_sa.State = SettleBillState.未结状态; + // bbac_sa.SettleBillNum = string.Empty; + // bbac_sa.Site = "1046"; + // bbac_sa.BusinessType = EnumBusinessType.JisBBAC; + // billList.Add(bbac_sa); + // foreach (var itm2 in details) + // { + // itm2.SetBillNum(billNum); + // itm2.SetGroupNum(billNum); + // billDetails.Add(itm2); + // } + // details = new List(); + // sum = itm1.Qty * itm1.Price; + // } + // var _detailEntity = new BBAC_CAN_SA_DETAIL( + // guid: GuidGenerator.Create(), + // keyCode: itm1.KeyCode, + // version: itm1.Version, + // billNum: string.Empty, + // settleBillNum: itm1.SettleBillNum, + // lU: itm1.LU, + // pN: itm1.PN, + // site: itm1.Site, + // qty: itm1.Qty, + // price: itm1.Price, + // category: itm1.BusinessType, + // isReturn: itm1.IsReturn, + // settleDate: itm1.SettleDate, + // groupNum: itm1.GroupNum, + // invGroupNum: string.Empty, + // contactid: itm1.ContractDocID, + // invbillnum: string.Empty, + // partcode: itm1.PartCode + // ); + // _detailEntity.RealPartCode = itm1.RealPartCode; + // details.Add(_detailEntity); + //} + //var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); + //var bbac_sa1 = new BBAC_CAN_SA(); + //bbac_sa1.SetId(Guid.NewGuid()); + //bbac_sa1.BillNum = billNum1; + //bbac_sa1.InvGroupNum = billNum1; + //bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); + //bbac_sa1.State = SettleBillState.未结状态; + //bbac_sa1.SettleBillNum = string.Empty; + //bbac_sa1.Site = "1046"; + //bbac_sa1.BusinessType = EnumBusinessType.JisBBAC; + //billList.Add(bbac_sa1); + //foreach (var detail in details) + //{ + // detail.SetBillNum(billNum1); + // detail.SetGroupNum(billNum1); + // billDetails.Add(detail); + //} } } } @@ -634,7 +707,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } if (part_group_small.Count > 0) { - var partlist = part_group_small.Select(p => p.LU).ToList(); + var partlist = part_group_small.Select(p => p.LU).ToList(); var ls = hbpo_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ; decimal sum = 0; List details = new List(); @@ -675,11 +748,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs qty: itm1.Qty, price: itm1.Price, businessType: itm1.BusinessType, - + settleDate: itm1.SettleDate, groupNum: itm1.GroupNum, invGroupNum: string.Empty, - + invbillnum: string.Empty, partcode: itm1.PartCode ); 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 38def361..bd712c99 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 @@ -1309,7 +1309,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers // List luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类 if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组 { - if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) + if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO || first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) { foreach (var _itm1 in copyDic) {