diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs index 96a94d89..079b9452 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs @@ -429,9 +429,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ }; var dtos = q.ToList(); - - var testls = dtos.Where(p => string.IsNullOrEmpty(p.LU)).ToList(); - + if (dtos != null && dtos.Count > 0) { if (invbillnum.Substring(0, 3) == "INV")//一次开票重开 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs index d61b8516..fbd7e6b8 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs @@ -31,34 +31,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO> { - - - - //[HttpPost] - //public virtual async Task RejectAsync(List p_list) - //{ - // var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList(); - // List customConditionList = new List(); - // customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) }); - // customConditionList.Add(new CustomCondition() { Name = "Type", Value = EnumBusinessType.JisBBAC.ToString() }); - // customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" }); - // var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList(); - // var lst = ls.Where(p => (p.State == SettleBillState.已提交扣减 || p.State == SettleBillState.已扣减)); - // if (lst.Count() > 0) - // { - // throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400"); - // } - // foreach (var item in ls) - // { - // item.State = SettleBillState.已提交扣减; - // } - // await _repository.DbContext.BulkUpdateAsync(ls); - // var _taskid = await _service.ExportEnqueueAsync("BBAC待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) => - // { - // }); - // return _taskid; - - //} public BBAC_PD_SERVICE(INormalEfCoreRepository bbacSecRepository, INormalEfCoreRepository hbpoSecRepository, INormalEfCoreRepository pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository repository, VmiAppService vimservice, INormalEfCoreRepository detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service) { } 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 e6e6a762..8731ecdb 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 @@ -11,6 +11,7 @@ using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.OpenApi.Writers; using SettleAccount.Domain.BQ; using ShardingCore.Extensions; using Shouldly; @@ -198,12 +199,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ bj.LU = itm.LU; bj.PartCode = itm.PartCode; bj.PRICE = itm.PRICE; - - //bj.InvGroupNum = itm.InvGroupNum; - //bj.DeliveryNumber= itm.GetProperty("DeliveryNumber", "");//交货号 - //bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号 - //bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码 - //bj.VendorName = itm.GetProperty("VendorName", "");//供应商名称 + + bj.InvGroupNum = itm.InvGroupNum; + bj.DeliveryNumber =itm.ExtraProperties["DeliveryIndexNumber"].ToSqlValue(); + //bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号 + //bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号 + //bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码 + //bj.VendorName = itm.GetProperty("VendorName", "");//供应商名称 //bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号 //bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号 //bj.PartName = itm.GetProperty("PartName", "");//零件名称 @@ -338,10 +340,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ .Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); } - if (first.BusinessType == EnumBusinessType.JisHBPO) - { - entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号 - } + if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC) { @@ -349,7 +348,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) { - entity.INVOICE_MAP_GROUP = mdtos; + List maidan = new List(); + foreach (var itm in m) + { + maidan.Add(new MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO() { + Extend1=itm.Extend1, + InvGroupNum=itm.InvGroupNum, + SettleGroupNum=itm.SettleGroupNum + }); + } + entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = maidan; + List unsettle = new List(); + foreach (var itm in notquery.ToList()) + { + unsettle.Add(new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO() { + GroupNum=itm.InvGroupNum, + LU=itm.LU, + PN=itm.Extend1, + + }); + } + } entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList(); @@ -413,132 +432,148 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var bbac = invdetail.INVOICE_WAIT_DETAIL_BBAC;//BBACJIS明细 var bj = invdetail.INVOICE_WAIT_DETAIL_BJ;//备件明细 var unsettle = invdetail.UNSETTLED_DETAIL;//全部未结明细 + var hbpom = invdetail.MAIDAN_HBPO_INVOICE_MAP_GROUP;//买单HBPO分组对应 + var hbpounsettle = invdetail.MAIDAN_HBPO_UNSETTLED_DETAIL;//买单HBPO未结 + var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute()?.Name ?? typeof(INVOICE_GRP_DTO).Name; string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; - //发票明细 +#region 发票明细 if (entities.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) { _excel.Append(bbac, "发票明细"); } else if (entities.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) { - _excel.Append(bj, "发票明细"); } else { _excel.Append(detail, "发票明细"); } + #endregion + // 发票分组 if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) { _excel.Append(m, "发票结算分组对应");//发票分组对应结算号 } - if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC ) + if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) { - _excel.Append(unsettle, "未结零件结算汇总"); + if (hbpom != null) + { + _excel.Append(hbpom, "发票结算分组对应"); + } + if (unsettle != null) + { + _excel.Append(unsettle, "未结零件汇总"); + } } - if (first.BusinessType == EnumBusinessType.JisHBPO) + if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) { - _excel.Append(unsettle, "未结零件列表"); + _excel.Append(unsettle, "未结零件结算汇总"); } - - foreach (var itm in entities) + //jis业务,发票分组对应关系,未结数据,调整数据 + if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) { - 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, + 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 + { + 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) - }).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(); + }).ToList(); + var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList() + .GroupBy(p => new + { + p.LU, + p.RealInvBillNum, + p.InvDate, + p.InvBillNum, + p.InvGroupNum, - 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(); - } - for (int i = 0; i < disList.Count; i++)//更新结算分组 - { - ls[i].SettleGroupNum = disList[i]; + }).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(); + } + for (int i = 0; i < disList.Count; i++)//更新结算分组 + { + ls[i].SettleGroupNum = disList[i]; + } + _excel.Append(ls, "结算分组零件" + itm.InvbillNum); + _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); } - if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO) + } + else//其他业务发票调整数据 + { + foreach (var itm in entities) { - _excel.Append(ls, "结算分组零件" + itm.InvbillNum); + var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); + _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); } - _excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); } - var result = _excel.ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); //保存导出文件到服务器存成二进制 @@ -622,7 +657,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ inv.RealnvBillNum = newinv.RealnvBillNum; // inv.RealAmt = newinv.RealAmt; inv.TaxDiff = newinv.PreTaxDiff; - // inv.ClientCode = newinv.ClientCode; } foreach (var detail in invdetail)