From eb85d3f36be0b84b8a9783944e7db70aa4bb1127 Mon Sep 17 00:00:00 2001 From: helongyang <647556386@qq.com> Date: 星期一, 22 九月 2025 18:56:27 +0800 Subject: [PATCH] 出库优化 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs | 29 ++++++++++++++++++++++------- 1 files changed, 22 insertions(+), 7 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs" index fc6cb0c..43506f3 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs" @@ -238,11 +238,19 @@ while (needQuantity > 0) { Dt_StockInfo stockInfo = stockInfos[index]; - float useableStockQuantity = stockInfo.Details.Where(x => x.MaterielCode == materielCode).Sum(x => x.StockQuantity - x.OutboundQuantity); - if (useableStockQuantity < needQuantity && useableStockQuantity>0) + // 璁$畻鍙敤搴撳瓨鏃惰浆鎹负decimal + decimal useableStockQuantity = stockInfo.Details + .Where(x => x.MaterielCode == materielCode) + .Sum(x => (decimal)x.StockQuantity - (decimal)x.OutboundQuantity); + + // 灏唍eedQuantity杞崲涓篸ecimal杩涜姣旇緝 + if (useableStockQuantity < (decimal)needQuantity && useableStockQuantity > 0) { - stockInfo.Details.ForEach(x => x.OutboundQuantity = x.StockQuantity); - needQuantity -= useableStockQuantity; + stockInfo.Details.ForEach(x => + x.OutboundQuantity = x.StockQuantity); + + // 浣跨敤decimal杩涜璁$畻鍚庡啀杞洖float + needQuantity = (float)((decimal)needQuantity - useableStockQuantity); } else { @@ -250,14 +258,20 @@ { if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == materielCode) { - if (x.StockQuantity - x.OutboundQuantity >= needQuantity) + // 灏嗙浉鍏冲�艰浆鎹负decimal杩涜绮剧‘璁$畻 + decimal currentStock = (decimal)x.StockQuantity; + decimal currentOutbound = (decimal)x.OutboundQuantity; + decimal currentNeed = (decimal)needQuantity; + decimal available = currentStock - currentOutbound; + + if (available >= currentNeed) { - x.OutboundQuantity += needQuantity; + x.OutboundQuantity = (float)(currentOutbound + currentNeed); needQuantity = 0; } else { - needQuantity -= (x.StockQuantity - x.OutboundQuantity); + needQuantity = (float)(currentNeed - available); x.OutboundQuantity = x.StockQuantity; } } @@ -266,6 +280,7 @@ outStocks.Add(stockInfo); index++; } + } else { -- Gitblit v1.9.3