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 |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 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 ac08ba2..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
             {
@@ -414,7 +429,7 @@
                 var requestBody = new
                 {
                     msgtype = "text",
-                    text = new { content = "灏忔磱涓讳汉璇�: 灏忔磱瑕佸拰灏忓澶╀笅绗竴鏈�鏈�濂�" },
+                    text = new { content = "閽夐拤娑堟伅鎺ㄩ��" },
                 };
                 var jsonBody = JsonConvert.SerializeObject(requestBody);
                 var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");

--
Gitblit v1.9.3