diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index 7f789ccc..87b80ef1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -76,21 +76,17 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500); } var partCarryMats = carryCodesPart.Adapt>(); - partCarryMats.ForEach(x => + for (int i = 0; i < partCarryMats.Count; i++) { - x.need_qty = (int)os.pr_qty; - x.real_qty = codeQty; - }); + partCarryMats[i].need_qty = carryCodesPart[i].codeqty; + } + carryMats.AddRange(partCarryMats); } } if (carryMats.Count > 0) { carryMats.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - for (int i = 0; i < partCarryMats.Count; i++) - { - partCarryMats[i].need_qty = carryCodesPart[i].codeqty; - } carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { @@ -100,7 +96,7 @@ namespace Tnb.WarehouseMgr }) .ToList(); await _db.Insertable(carryMats).ExecuteCommandAsync(); - var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.real_qty); + var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty); carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList(); await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync();