diff --git a/code/src/Modules/BaseService/BaseService.Host/BaseServiceHostModule.cs b/code/src/Modules/BaseService/BaseService.Host/BaseServiceHostModule.cs index 40e83e97..060ed932 100644 --- a/code/src/Modules/BaseService/BaseService.Host/BaseServiceHostModule.cs +++ b/code/src/Modules/BaseService/BaseService.Host/BaseServiceHostModule.cs @@ -1,4 +1,4 @@ -using BaseService.EntityFrameworkCore; +using BaseService.EntityFrameworkCore; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; @@ -46,7 +46,7 @@ namespace BaseService typeof(AbpPermissionManagementHttpApiModule), typeof(AbpTenantManagementHttpApiModule), typeof(AbpIdentityHttpApiModule), - // typeof(BaseDataHttpApiModule), + //typeof(BaseDataHttpApiModule), //typeof(BaseDataApplicationContractsModule), //typeof(SettleAccountHttpApiModule), typeof(AbpAspNetCoreSerilogModule) @@ -101,9 +101,7 @@ namespace BaseService context.Services.Configure(options => { options.User.RequireUniqueEmail = true; - //options.Lockout.AllowedForNewUsers = true; - //options.Lockout.MaxFailedAccessAttempts = 2; - + options.Lockout.AllowedForNewUsers = true; options.Password.RequireDigit = false; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; @@ -217,8 +215,9 @@ namespace BaseService .ConventionalControllers .Create(typeof(BaseServiceApplicationModule).Assembly, opts => - { opts.RootPath = "base"; }) - ; + { + opts.RootPath = "base"; + }); }); } @@ -232,7 +231,6 @@ namespace BaseService app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseMultiTenancy(); - app.Use(async (ctx, next) => { var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService(); @@ -255,11 +253,9 @@ namespace BaseService { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API"); }); - app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); - AsyncHelper.RunSync(async () => { using (var scope = context.ServiceProvider.CreateScope()) @@ -271,4 +267,4 @@ namespace BaseService }); } } -} \ No newline at end of file +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs index 2da7b7ca..c945da62 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs @@ -833,6 +833,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "状态")] public string Extend1 { get; set; } + [Display(Name = "扩展")] + public string Extend2 { get; set; } } @@ -863,6 +865,53 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "结算零件号")] public string SettleLU { get; set; } + + + [Display(Name = "可结算数量")] + public string SettleQty { get; set; } + /// + ///可结算零件号 + /// + [Display(Name = "不结算零件号")] + public string NotSettleLU { get; set; } + + [Display(Name = "不可结数量")] + public string Qty { get; set; } + + + } + + + public class INVOICE_NOT_SETTLE_EXT_DTO1 + { + [Display(Name = "金税发票")] + public string RealInvBillNum { get; set; } + + [Display(Name = "发票日期")] + public DateTime? InvDate { set; get; } + + [Display(Name = "发票号")] + public string InvBillNum { get; set; } + /// + ///发票分组号 + /// + [Display(Name = "发票分组号")] + public string InvGroupNum { get; set; } + /// + ///结算分组号 + /// + [Display(Name = "结算分组号")] + public string SettleGroupNum { get; set; } + /// + ///可结算零件号 + /// + [Display(Name = "结算零件号")] + public string SettleLU { get; set; } + + [Display(Name = "SA号")] + public string SA { get; set; } + + [Display(Name = "可结算数量")] public string SettleQty { get; set; } /// 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 bb3c01bd..c98d5a5f 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 @@ -87,7 +87,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] public async Task GenerateInvoice([FromBody] string invbillNum) - { + { var main = await _bbacMng.GetMainAsync(invbillNum).ConfigureAwait(false); if (main != null) { 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 b5611605..227a3e9c 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 @@ -1201,6 +1201,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var sdtos = ObjectMapper.Map, List>(s);//不可结 + + + + var adjs = await _adjRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);//调整数据 var adjdtos = ObjectMapper.Map, List>(adjs);//调整数据DTO var notquery = from itm in sdtos @@ -1216,6 +1220,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ LU = itm.LU, Qty = itm.Qty, Extend1 = itm.Extend1, + Extend2 = itm.Extend2 + }; var mquery = from itm in mdtos join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum @@ -1437,89 +1443,184 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { foreach (var itm in entities) { - var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); - var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); - var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); - var lsC = nolist.Where(p => p.Extend1 == "可结算") - .GroupBy(p => new + if (first.BusinessType == EnumBusinessType.JisBBAC && first.InvGroupNum.Substring(0, 1) == "N") + { + var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); + var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); + var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); + var lsC = nolist.Where(p => p.Extend1 == "可结算") + .GroupBy(p => new + { + p.LU, + p.RealInvBillNum, + p.InvDate, + p.InvBillNum, + p.InvGroupNum, + p.Extend2 + + }).Select(p => new INVOICE_NOT_SETTLE_DTO() + { + LU = p.Key.LU, + RealInvBillNum = p.Key.RealInvBillNum, + InvDate = p.Key.InvDate, + InvBillNum = p.Key.InvBillNum, + InvGroupNum = p.Key.InvGroupNum, + Extend2 = p.Key.Extend2, + Qty = p.Sum(itm => itm.Qty) + }).ToList(); + var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList() + .GroupBy(p => new + { + p.LU, + p.RealInvBillNum, + p.InvDate, + p.InvBillNum, + p.InvGroupNum, + }).Select(p => new INVOICE_NOT_SETTLE_DTO() + { + LU = p.Key.LU, + RealInvBillNum = p.Key.RealInvBillNum, + InvDate = p.Key.InvDate, + InvBillNum = p.Key.InvBillNum, + InvGroupNum = p.Key.InvGroupNum, + Qty = p.Sum(itm => itm.Qty) + }).ToList(); + var lineC = lsC.Count; + var lineN = lsN.Count; + List ls = new List(); + for (int i = 0; i < 10000; i++) { - p.LU, - p.RealInvBillNum, - p.InvDate, - p.InvBillNum, - p.InvGroupNum, - }).Select(p => new INVOICE_NOT_SETTLE_DTO() + INVOICE_NOT_SETTLE_EXT_DTO1 invnot = new INVOICE_NOT_SETTLE_EXT_DTO1(); + invnot.RealInvBillNum = string.Empty; + invnot.InvDate = null; + invnot.InvBillNum = string.Empty; + invnot.InvGroupNum = string.Empty; + invnot.SettleGroupNum = string.Empty; + invnot.SettleLU = string.Empty; + invnot.SA = string.Empty; + invnot.SettleQty = null; + invnot.NotSettleLU = string.Empty; + invnot.Qty = string.Empty; + ls.Add(invnot); + } + var entity = nolist.FirstOrDefault(); + var disList = mgroup.Select(p => p.SettleGroupNum).Distinct().ToList(); + for (int i = 0; i < lineC; i++)//更新可结信息 { - LU = p.Key.LU, - RealInvBillNum = p.Key.RealInvBillNum, - InvDate = p.Key.InvDate, - InvBillNum = p.Key.InvBillNum, - InvGroupNum = p.Key.InvGroupNum, - Qty = p.Sum(itm => itm.Qty) - - }).ToList(); - var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList() - .GroupBy(p => new - { - p.LU, - p.RealInvBillNum, - p.InvDate, - p.InvBillNum, - p.InvGroupNum, - }).Select(p => new INVOICE_NOT_SETTLE_DTO() - { - LU = p.Key.LU, - RealInvBillNum = p.Key.RealInvBillNum, - InvDate = p.Key.InvDate, - InvBillNum = p.Key.InvBillNum, - InvGroupNum = p.Key.InvGroupNum, - Qty = p.Sum(itm => itm.Qty) - }).ToList(); - var lineC = lsC.Count; - var lineN = lsN.Count; - List ls = new List(); - for (int i = 0; i < 10000; i++) - { - INVOICE_NOT_SETTLE_EXT_DTO invnot = new INVOICE_NOT_SETTLE_EXT_DTO(); - invnot.RealInvBillNum = string.Empty; - invnot.InvDate = null; - invnot.InvBillNum = string.Empty; - invnot.InvGroupNum = string.Empty; - invnot.SettleGroupNum = string.Empty; - invnot.SettleLU = string.Empty; - invnot.SettleQty = null; - invnot.NotSettleLU = string.Empty; - invnot.Qty = string.Empty; - ls.Add(invnot); - } - var entity = nolist.FirstOrDefault(); - var disList = mgroup.Select(p => p.SettleGroupNum).Distinct().ToList(); - for (int i = 0; i < lineC; i++)//更新可结信息 - { - ls[i].RealInvBillNum = entity.RealInvBillNum; - ls[i].InvDate = entity.InvDate; - ls[i].InvBillNum = entity.InvBillNum; - ls[i].InvGroupNum = entity.InvGroupNum; - // ls[i].SettleGroupNum = entity.SettleGroupNum; - ls[i].SettleLU = lsC[i].LU; - ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString(); - } - for (int i = 0; i < lineN; i++)//更新不可结信息 - { - ls[i].RealInvBillNum = entity.RealInvBillNum; - ls[i].InvDate = entity.InvDate; - ls[i].InvBillNum = entity.InvBillNum; - ls[i].InvGroupNum = entity.InvGroupNum; - // ls[i].SettleGroupNum = entity.SettleGroupNum; - ls[i].NotSettleLU = lsN[i].LU; - ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString(); + ls[i].RealInvBillNum = entity.RealInvBillNum; + ls[i].InvDate = entity.InvDate; + ls[i].InvBillNum = entity.InvBillNum; + ls[i].InvGroupNum = entity.InvGroupNum; + ls[i].SA = lsC[i].Extend2; + ls[i].SettleLU = lsC[i].LU; + ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString(); + } + for (int i = 0; i < lineN; i++)//更新不可结信息 + { + ls[i].RealInvBillNum = entity.RealInvBillNum; + ls[i].InvDate = entity.InvDate; + ls[i].InvBillNum = entity.InvBillNum; + ls[i].InvGroupNum = entity.InvGroupNum; + // ls[i].SettleGroupNum = entity.SettleGroupNum; + ls[i].NotSettleLU = lsN[i].LU; + ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString(); + } + for (int i = 0; i < disList.Count; i++)//更新结算分组 + { + ls[i].SettleGroupNum = disList[i]; + } + _excel.Append(ls, "结算分组零件" + itm.InvbillNum); + _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); } - for (int i = 0; i < disList.Count; i++)//更新结算分组 + else { - ls[i].SettleGroupNum = disList[i]; + var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); + var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); + var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); + var lsC = nolist.Where(p => p.Extend1 == "可结算") + .GroupBy(p => new + { + p.LU, + p.RealInvBillNum, + p.InvDate, + p.InvBillNum, + p.InvGroupNum, + + }).Select(p => new INVOICE_NOT_SETTLE_DTO() + { + LU = p.Key.LU, + RealInvBillNum = p.Key.RealInvBillNum, + InvDate = p.Key.InvDate, + InvBillNum = p.Key.InvBillNum, + InvGroupNum = p.Key.InvGroupNum, + Qty = p.Sum(itm => itm.Qty) + + }).ToList(); + var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList() + .GroupBy(p => new + { + p.LU, + p.RealInvBillNum, + p.InvDate, + p.InvBillNum, + p.InvGroupNum, + }).Select(p => new INVOICE_NOT_SETTLE_DTO() + { + LU = p.Key.LU, + RealInvBillNum = p.Key.RealInvBillNum, + InvDate = p.Key.InvDate, + InvBillNum = p.Key.InvBillNum, + InvGroupNum = p.Key.InvGroupNum, + Qty = p.Sum(itm => itm.Qty) + }).ToList(); + var lineC = lsC.Count; + var lineN = lsN.Count; + List ls = new List(); + for (int i = 0; i < 10000; i++) + { + INVOICE_NOT_SETTLE_EXT_DTO invnot = new INVOICE_NOT_SETTLE_EXT_DTO(); + invnot.RealInvBillNum = string.Empty; + invnot.InvDate = null; + invnot.InvBillNum = string.Empty; + invnot.InvGroupNum = string.Empty; + invnot.SettleGroupNum = string.Empty; + invnot.SettleLU = string.Empty; + + invnot.SettleQty = null; + invnot.NotSettleLU = string.Empty; + invnot.Qty = string.Empty; + ls.Add(invnot); + } + var entity = nolist.FirstOrDefault(); + var disList = mgroup.Select(p => p.SettleGroupNum).Distinct().ToList(); + for (int i = 0; i < lineC; i++)//更新可结信息 + { + ls[i].RealInvBillNum = entity.RealInvBillNum; + ls[i].InvDate = entity.InvDate; + ls[i].InvBillNum = entity.InvBillNum; + ls[i].InvGroupNum = entity.InvGroupNum; + //ls[i].SA = bbac.FirstOrDefault(p => p.InvbillNum == entity.InvBillNum && p.LU == lsC[i].LU).Extend1; + // ls[i].SettleGroupNum = entity.SettleGroupNum; + ls[i].SettleLU = lsC[i].LU; + ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString(); + } + for (int i = 0; i < lineN; i++)//更新不可结信息 + { + ls[i].RealInvBillNum = entity.RealInvBillNum; + ls[i].InvDate = entity.InvDate; + ls[i].InvBillNum = entity.InvBillNum; + ls[i].InvGroupNum = entity.InvGroupNum; + // ls[i].SettleGroupNum = entity.SettleGroupNum; + ls[i].NotSettleLU = lsN[i].LU; + ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString(); + } + for (int i = 0; i < disList.Count; i++)//更新结算分组 + { + ls[i].SettleGroupNum = disList[i]; + } + _excel.Append(ls, "结算分组零件" + itm.InvbillNum); + _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); } - _excel.Append(ls, "结算分组零件" + itm.InvbillNum); - _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); } } else//其他业务发票调整数据 @@ -1548,9 +1649,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { var entities = await _invMng.GetMainListAsync(p_invGroupNum).ConfigureAwait(false); var entity = entities.FirstOrDefault(); - - - bool state = await _invMng.Reject(p_invGroupNum).ConfigureAwait(false); if (state == true) { @@ -1606,7 +1704,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ newmain.ExtraProperties.TryAdd("InvBillNum", details.FirstOrDefault().InvbillNum); newmain.ExtraProperties.TryAdd("IsReturn", "是"); var _dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false); - foreach (var item in details) { item.BillNum = billNum; @@ -1614,11 +1711,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } await _dbcontext.BulkInsertAsync(new List() { newmain }).ConfigureAwait(false); await _dbcontext.BulkUpdateAsync(details).ConfigureAwait(false); - } - - - [UnitOfWork(false)] [HttpPost] public virtual async Task ReturnAsync(INVOICE_GRP_DTO p_dto) @@ -1660,8 +1753,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var detial=dbcontext.Set().Where(p => p.InvbillNum == p_dto.InvbillNum).ToList(); var notsettle=dbcontext.Set().Where(p => p.InvBillNum == p_dto.InvbillNum).ToList(); var detialext = dbcontext.Set().Where(p => p.InvbillNum == p_dto.InvbillNum).ToList(); - - dbcontext.BulkDelete(invList); dbcontext.BulkDelete(invgourp); dbcontext.BulkDelete(detial); @@ -1670,10 +1761,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { dbcontext.BulkDelete(detialext); } - - } - return new JsonResult(new { Code = 200, Message = "退回成功" }); ; } @@ -1715,13 +1803,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ inv.TaxDiff = newinv.PreTaxDiff; inv.CreationTime = newinv1.InvoiceDate; inv.FileName = newinv1.FileName; - - } await _repository.DbContext.BulkUpdateAsync(invlist).ConfigureAwait(false); await _repository.DbContext.BulkUpdateAsync(invdetail).ConfigureAwait(false); return ApplicationConsts.SuccessStr; } - } } 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 7efb12a6..fa827c19 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 @@ -671,6 +671,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs foreach (var inv in invList) { var partlist = inv.Parts; + + + + if (partlist.Count > 0) { var query = from itm in partlist @@ -719,282 +723,221 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs 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 + + //if (partlist is List) + //{ + var partlist1 = partlist as List; + var sq = partlist1.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 + + + //} + //else + //{ + // 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 + //} } } - } - - 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; + _dbcontext.BulkInsert(invlist); + _dbcontext.BulkInsert(groupList); + _dbcontext.BulkInsert(detailList); - // 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); + if (adjlist.Count > 0) + { + _dbcontext.BulkInsert(adjlist); + } + if (notDetialList.Count > 0) + { + _dbcontext.BulkInsert(notDetialList); + } + _invls = invlist.Select(p => p.InvbillNum).ToList(); - //} - //_dbcontext.BulkInsert(invlist); - //_dbcontext.BulkInsert(groupList); - //_dbcontext.BulkInsert(detailList); + } + if (smalllist.Count > 0) + { + smalllist = smalllist.OrderBy(p => p.Amt).ToList(); + _invls = GenSecInvoice(smalllist, p_list, p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); + } + - //if (adjlist.Count > 0) - //{ - // _dbcontext.BulkInsert(adjlist); - //} - //if (notDetialList.Count > 0) - //{ - // _dbcontext.BulkInsert(notDetialList); - //} - //_invls = invlist.Select(p => p.InvbillNum).ToList(); + } return _invls; } @@ -1058,26 +1001,64 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs 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) + + + + if (entityList is List) { - 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 - )); + + + var entityList1 = entityList as List; + + + var sq = entityList1.GroupBy(p => new { p.LU, p.GroupNum, p.InvbillNum,p.ContractDocID }) + .Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = p.Key.InvbillNum, GroupNum = p.Key.GroupNum,SA=p.Key.ContractDocID }); + 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: sitm.SA, + qty: sitm.Qty, + p_invbillnum: sitm.InvBillNum + )); + } + if (innotls.Count > 0) + { + notDetialList.AddRange(innotls); + } } - if (innotls.Count > 0) + else { - notDetialList.AddRange(innotls); + 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); + } + + + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index c4bf73a8..c43e3610 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs @@ -263,6 +263,7 @@ namespace Win.Sfs.SettleAccount private void CreateMapINVOICE_NOT_SETTLE() { + CreateMap().ReverseMap(); CreateMap().ReverseMap();