diff --git a/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 b/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 index 73d141ce..6102f9e7 100644 Binary files a/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 and b/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 differ diff --git a/src/WMS.Web.Domain/Services/InStockTaskService.cs b/src/WMS.Web.Domain/Services/InStockTaskService.cs index 02493b6a..c71c14a4 100644 --- a/src/WMS.Web.Domain/Services/InStockTaskService.cs +++ b/src/WMS.Web.Domain/Services/InStockTaskService.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using NPOI.SS.Formula.Functions; using System; using System.Collections.Generic; using System.Linq; @@ -500,12 +501,19 @@ namespace WMS.Web.Domain.Services //2.1遍历任务单明细:改变已有的值和要添加的明细 foreach (var det in data_list.SelectMany(t => t.Details)) { - var order= data_list.Where(o => o.Id == det.Fid).FirstOrDefault(); + var order = data_list.Where(o => o.Id == det.Fid).FirstOrDefault(); if (order != null) { var erp_data = erp_list.FirstOrDefault(a => a.ErpDetailId == det.ErpDetailId && a.BillNo == order.SourceBillNo); if (erp_data != null) { + //如果该明细作废 则不修改了 + if (det.IsRepeal == true) + { + //操作完后剔除 + erp_removeList.Add(erp_data); + continue; + } if (erp_data.MaterialNumber == det.MaterialNumber) { //物料相同的,就改变数值 @@ -513,12 +521,12 @@ namespace WMS.Web.Domain.Services det.AccruedQty = erp_data.Qty; det.FactoryPrice = erp_data.FactoryPrice; det.DeliveredQty = erp_data.DeliveredQty; - } + } else { //老物料,应收数量修改为0 - det.AccruedQty = 0; - + det.AccruedQty = 0; + } //操作完后剔除 erp_removeList.Add(erp_data); @@ -530,8 +538,8 @@ namespace WMS.Web.Domain.Services //2.1.1当物料相同,仓库不同或者物料不同,就新增一条明细 foreach (var erp_data in erp_list) { - var order= data_list.Where(x => x.SourceBillNo == erp_data.BillNo).FirstOrDefault(); - if (order != null) + var order = data_list.Where(x => x.SourceBillNo == erp_data.BillNo).FirstOrDefault(); + if (order != null) { var IsHaveNewMaterial = order.Details.Where(x => x.ErpDetailId == erp_data.ErpDetailId && erp_data.MaterialNumber == x.MaterialNumber).Any(); if (!IsHaveNewMaterial) @@ -542,7 +550,7 @@ namespace WMS.Web.Domain.Services erp_removeList.Add(erp_data); } } - + } //去重 @@ -566,30 +574,33 @@ namespace WMS.Web.Domain.Services //当应入库数量大于实际入库数量:状态就部分入库 //当应入库数量小于等于实际入库数量:状态就已入库 var details_Groups = order.Details.Where(x => x.AccruedQty != 0).GroupBy(x => x.MaterialNumber) - .Select(x => new + .Select(x => new { MaterialNumber = x.Key, AccruedQtyTotal = x.Sum(t => t.AccruedQty), - ReceiveQtyTotal=x.Sum(t=>t.ReceiveQty), - RealityQtyTotal =x.Sum(t=>t.RealityQty) + ReceiveQtyTotal = x.Sum(t => t.ReceiveQty), + RealityQtyTotal = x.Sum(t => t.RealityQty) }).ToList(); - - bool IsAny = details_Groups.Any(d => d.RealityQtyTotal != 0 && d.AccruedQtyTotal > d.RealityQtyTotal); + + bool IsAny = details_Groups.Any(d => d.RealityQtyTotal != 0 && d.AccruedQtyTotal > d.RealityQtyTotal); if (IsAny) order.Status = InstockStatus.Part; - else if (details_Groups.Sum(x => x.ReceiveQtyTotal) <= 0 && order.Type== InstockType.Purchase) + else if (details_Groups.Sum(x => x.ReceiveQtyTotal) <= 0 && order.Type == InstockType.Purchase) order.Status = InstockStatus.Wait; else if (details_Groups.Sum(x => x.RealityQtyTotal) <= 0) - order.Status = InstockStatus.WaitInStock; - else if(details_Groups.Sum(x => x.RealityQtyTotal) >= details_Groups.Sum(x => x.AccruedQtyTotal)) + order.Status = InstockStatus.WaitInStock; + else if (details_Groups.Sum(x => x.RealityQtyTotal) >= details_Groups.Sum(x => x.AccruedQtyTotal)) order.Status = InstockStatus.Already; - + }); //2.4金蝶删除的明细,要把任务单里的明细应入库数量改为0 data_list.SelectMany(x => x.Details).Where(c => !erp_list.Any(a => a.ErpDetailId == c.ErpDetailId)).ToList().ForEach(x => { x.AccruedQty = 0; }); + //过滤掉已经作废的单据 + data_list = data_list.Where(w => w.Status != InstockStatus.Repeal).ToList(); + //2.3.提交任务单的修改 var isSuccess = await _inStockTaskRepositories.UpdateRange(data_list, isTransaction); if (!isSuccess) @@ -621,7 +632,7 @@ namespace WMS.Web.Domain.Services add_entitys.Add(dto); } //3.1提交新增 - var isSuccess = await _inStockTaskRepositories.AddRange(add_entitys, isTransaction); + var isSuccess = await _inStockTaskRepositories.AddRange(add_entitys, isTransaction); _logger.LogInformation($"金蝶数据写入:SysnDataNew6->结果:{isSuccess}" + JsonConvert.SerializeObject(add_entitys)); if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError); diff --git a/src/WMS.Web.Domain/Services/OutStockTaskService.cs b/src/WMS.Web.Domain/Services/OutStockTaskService.cs index 1521cb18..20ed5718 100644 --- a/src/WMS.Web.Domain/Services/OutStockTaskService.cs +++ b/src/WMS.Web.Domain/Services/OutStockTaskService.cs @@ -172,6 +172,13 @@ namespace WMS.Web.Domain.Services { //仓库不同 拆分成不同的 var detail = outStockTask.Details.FirstOrDefault(w => w.MaterialNumber == erp.MaterialNumber); + //如果该明细作废 则不修改了 + if (detail != null && detail.IsRepeal == true) + { + //操作完后剔除 + erp_removeList.Add(erp); + continue; + } if (detail == null) { //添加一条物料明细 @@ -211,7 +218,8 @@ namespace WMS.Web.Domain.Services outStockTask.GenerateStatus(); } } - var update_date_list = data_list.Where(w => update_ids.Contains(w.Id)).ToList(); + //过滤掉已经作废的单据 + var update_date_list = data_list.Where(w => update_ids.Contains(w.Id) && w.Status != OutStockStatus.Repeal).ToList(); //2.2.提交修改 var isSuccess = await _outStockTaskRepositories.EditEntityList(update_date_list, isTransaction); if (!isSuccess)