From 665cafbc8acece4c03e246882675041aea3821e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Wed, 15 Nov 2023 11:13:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/INVOICE_SERVICE.cs | 40 ------ .../BQ/Syncs/PendingDeductionService.cs | 127 +++++++++--------- 2 files changed, 63 insertions(+), 104 deletions(-) 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 731a8a80..667dd000 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 @@ -81,7 +81,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, INV_MNG invMng - ) : base(excelImportService, snowflakeIdGenerator, commonManager) { _logger = logger; @@ -136,11 +135,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { return; } - var invoiceGrpDetails = _settleAccountDbContext.Set() .Where(t => t.InvbillNum == invbillNum) .ToList(); - if (invoiceGrpDetails.Any()) { var tedSaInvs = new List(); @@ -158,7 +155,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ CreateTime = DateTime.Now, UpdateTime = DateTime.Now, }; - for (var i = 0; i < invoiceGrpDetails.Count; i++) { var invoiceGrpDetail = invoiceGrpDetails[i]; @@ -186,9 +182,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ LINE = (i + 1).ToString() }); } - tedSaInvs.FirstOrDefault().InvoiceTaxAmount += invoiceGrp.TaxDiff; - //红冲发票提交QAD if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) { @@ -317,7 +311,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { return new JsonResult(new { Code = "400", Message = "有发票没有金税发票号!" }); } - var ls = invs.Where(p => p.State != SettleBillState.商务已审核).Distinct(); if (ls.Any()) { @@ -391,9 +384,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And)); } var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); - - - var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var mdtos = ObjectMapper.Map, List>(m); var first = invs.FirstOrDefault(); @@ -468,7 +458,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号 //bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号 //bj.PartName = itm.GetProperty("PartName", "");//零件名称 - BMap.Add(bj); } @@ -507,9 +496,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ProductionGroup = itm.ProductionGroup, LineCode = itm.LineCode, ContractID = itm.ContractID, - - - }; entity.INVOICE_WAIT_DETAIL_BJ = bjquery.OrderBy(p => p.LineCode).ToList(); @@ -592,7 +578,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ }; entity.INVOICE_NOT_SETTLE = notquery.OrderBy(p => p.SettleGroupNum).ThenBy(p => p.LU).ToList(); - var lscompare = entity.INVOICE_NOT_SETTLE.GroupBy(x => new { x.InvBillNum, x.SettleGroupNum }).Select(p => new INVOICE_MAP_GROUP_DTO() { @@ -621,7 +606,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) { //List maidan = new List(); - var maiquery = from itm in m join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum select @@ -633,7 +617,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ InvbillNum = itm.InvbillNum, RealInvBillNum = itm1.RealnvBillNum }; - entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = maiquery.ToList(); List unsettle = new List(); foreach (var itm in sdtos) @@ -643,12 +626,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ GroupNum = itm.SettleGroupNum, LU = itm.LU, PN = itm.Extend1, - }); } entity.MAIDAN_HBPO_UNSETTLED_DETAIL = unsettle; } - entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); return entity; } @@ -678,7 +659,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // break; //} result.ShouldNotBeNull(); - //保存导出文件到服务器存成二进制 await _excelImportService.SaveBlobAsync( new SaveExcelImportInputDto @@ -701,14 +681,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ IExporter _csv = new CsvExporter(); ExcelExporter _excel = new ExcelExporter(); // var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false); - - var condition = input.Filters.FirstOrDefault(p => p.Column == "invbillNum"); if (condition == null) { input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And)); } - var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); var first = entities.FirstOrDefault(); var dtoDetails = ObjectMapper.Map, List>(entities); @@ -723,10 +700,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var hbpom = invdetail.MAIDAN_HBPO_INVOICE_MAP_GROUP;//买单HBPO分组对应 var hbpounsettle = invdetail.MAIDAN_HBPO_UNSETTLED_DETAIL;//买单HBPO未结 var jitunsettle = invdetail.JIT_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) { @@ -741,7 +716,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _excel.Append(detail, "发票明细"); } #endregion - // 发票分组 if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) { @@ -810,7 +784,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ p.InvDate, p.InvBillNum, p.InvGroupNum, - }).Select(p => new INVOICE_NOT_SETTLE_DTO() { LU = p.Key.LU, @@ -939,7 +912,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// [HttpPost] [DisableRequestSizeLimit] - public async Task ExcelImport([FromForm] IFormFileCollection files) { ExportImporter _exportImporter = new ExportImporter(); @@ -954,22 +926,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var newinv1= result.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); var newinv = ls.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); inv.Tax = 0.13m; - //inv.RealAmt = Math.Round(inv.Amt * newinv.Tax, 2); - //inv.TaxAmt = inv.Amt+ Math.Round(inv.Amt * newinv.Tax, 2); inv.RealnvBillNum = newinv.RealnvBillNum; - // inv.RealAmt = newinv.RealAmt; inv.TaxDiff = newinv.PreTaxDiff; inv.CreationTime = newinv1.InvoiceDate; - // inv.ClientCode = newinv.ClientCode; } - - - - - //foreach (var detail in invdetail)//明细EXTEND1字段BBAC不能占用 - //{ - // detail.Extend1 = Math.Round(detail.Amt * first.Tax, 2).ToString(); - //} 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/PendingDeductionService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs index 00859bed..48106ff2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs @@ -31,7 +31,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs _emailSender = emailSender; _dbcontext = dbcontext; - } + } [UnitOfWork(false)] public string ExportFile(Guid id, List exportName, List property) { @@ -41,13 +41,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs var email = string.Empty; // property.Where(p => p.Name == "CurrentUserEmail").FirstOrDefault().Value; var list = billList.Split(","); - - var projectList = _dbcontext.Set().Where(p => p.Project == "库位").ToList(); - var jisbbac= projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description; - var jisbbac_sy= projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description; - var yindujian= projectList.FirstOrDefault(p => p.Value == "YinDuJian").Description; - var beijian= projectList.FirstOrDefault(p => p.Value == "BeiJian").Description; - if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian" || type== "YinDuJian") + var projectList = _dbcontext.Set().Where(p => p.Project == "库位").ToList(); + var jisbbac = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description; + var jisbbac_sy = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description; + var yindujian = projectList.FirstOrDefault(p => p.Value == "YinDuJian").Description; + var beijian = projectList.FirstOrDefault(p => p.Value == "BeiJian").Description; + if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian" || type == "YinDuJian") { var jisdetail = _dbcontext.Set().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisBBAC);//jis if (jisdetail != null && jisdetail.Count() > 0) @@ -56,12 +55,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2)) { - itm.Extend2 =jisbbac; + itm.Extend2 = jisbbac; itm.Extend3 = "有结算无发运"; } if (itm.Site == "1046" && string.IsNullOrEmpty(itm.Extend2)) { - itm.Extend2 =jisbbac_sy; + itm.Extend2 = jisbbac_sy; itm.Extend3 = "有结算无发运"; } } @@ -77,10 +76,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs itm.Extend2 = jisbbac; itm.Extend3 = "有结算无发运"; } - + if (itm.Site == "1046" && string.IsNullOrEmpty(itm.Extend2)) { - itm.Extend2 =jisbbac_sy; + itm.Extend2 = jisbbac_sy; itm.Extend3 = "有结算无发运"; } } @@ -111,7 +110,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { if (string.IsNullOrEmpty(itm.Extend2)) { - itm.Extend2 =yindujian; + itm.Extend2 = yindujian; itm.Extend3 = "有结算无发运"; } } @@ -143,11 +142,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs itm.Extend3 = "有结算无发运"; } } - if(detailist.Count>0) + if (detailist.Count > 0) { Sync(detailist, EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false); } - + var mdetail = _dbcontext.Set().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianHBPO).ToList();//买单件 foreach (var itm in mdetail) { @@ -161,7 +160,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { Sync(mdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false); } - + var detailist1 = _dbcontext.Set().Where(p => list.Contains(p.BillNum)).ToList(); var zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianHBPO).ToList(); foreach (var itm in zgbbaclist) @@ -222,14 +221,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs ErpToLoc = itm.Extend2, //寄售库 ReMark = itm.Extend3 }; - var ls = query.ToList(); + var ls = query.ToList(); - foreach (var itm in ls) - { - itm.SetId(GuidGenerator.Create()); - } - var _first = p_ls.FirstOrDefault(); - bool issucess = true; + foreach (var itm in ls) + { + itm.SetId(GuidGenerator.Create()); + } + var _first = p_ls.FirstOrDefault(); + bool issucess = true; using (var transaction = _dbcontext.Database.BeginTransaction()) { try @@ -246,7 +245,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs // }; // messagelist.Add(message); //} - // _dbcontext.BulkInsert(messagelist); + // _dbcontext.BulkInsert(messagelist); _dbcontext.BulkInsert(ls, new BulkConfig() { }); var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();//同步数据的发票号 var pdList = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList();//扣减单内容 @@ -315,7 +314,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } foreach (var item in bbacinvList) { - + if (item.State == SettleBillState.已提交QAD) { item.State = SettleBillState.红冲发票; @@ -371,7 +370,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs } } } - // _emailSender.SendAsync(e) + // _emailSender.SendAsync(e) // 提交事务 transaction.Commit(); } @@ -382,60 +381,60 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs transaction.Rollback(); } } - if (issucess ==false) - { - var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); - var pdList = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList(); - if (pdList.Count > 0) + if (issucess == false) { - foreach (var item in pdList) + var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); + var pdList = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList(); + if (pdList.Count > 0) { - if (flag == true) + foreach (var item in pdList) { - item.State = SettleBillState.客户已收票; - } - else - { - item.State = SettleBillState.已扣减; + if (flag == true) + { + item.State = SettleBillState.客户已收票; + } + else + { + item.State = SettleBillState.已扣减; + } } + _dbcontext.BulkUpdate(pdList); } - _dbcontext.BulkUpdate(pdList); - } - var bbacList = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList(); - if (bbacList.Count > 0) - { - foreach (var item in bbacList) + var bbacList = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList(); + if (bbacList.Count > 0) { - if (flag == true) - { - item.State = SettleBillState.客户已收票; - } - else + foreach (var item in bbacList) { - item.State = SettleBillState.已扣减; + if (flag == true) + { + item.State = SettleBillState.客户已收票; + } + else + { + item.State = SettleBillState.已扣减; + } } + _dbcontext.BulkUpdate(bbacList); } - _dbcontext.BulkUpdate(bbacList); - } - var hbpoList = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList(); - if (hbpoList.Count > 0) - { - foreach (var item in hbpoList) + var hbpoList = _dbcontext.Set().Where(p => billList.Contains(p.BillNum)).ToList(); + if (hbpoList.Count > 0) { - if (flag == true) + foreach (var item in hbpoList) { - item.State = SettleBillState.客户已收票; - } - else - { - item.State = SettleBillState.已扣减; + if (flag == true) + { + item.State = SettleBillState.客户已收票; + } + else + { + item.State = SettleBillState.已扣减; + } } + _dbcontext.BulkUpdate(hbpoList); } - _dbcontext.BulkUpdate(hbpoList); } } - } } }