From fe256a7afaa132910875d3dc73783d9ab2d7ace5 Mon Sep 17 00:00:00 2001
From: liulijun <liulijun@hnkhzn.com>
Date: 星期四, 12 三月 2026 18:57:44 +0800
Subject: [PATCH] 老厂排程单页面增加用纸顺序号和是否缺料

---
 项目代码/WMS/WMSServices/WIDESEA_StockService/ProStockInfoService.cs |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_StockService/ProStockInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_StockService/ProStockInfoService.cs"
index aff2f8f..b584466 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_StockService/ProStockInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_StockService/ProStockInfoService.cs"
@@ -26,5 +26,52 @@
             _stockRepository = stockRepository;
             _basicRepository = basicRepository;
         }
+        public List<Dt_ProStockInfo> GetUseableStocks(string materielCode, int warehoseId)
+        {
+            List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(warehoseId);
+
+            return BaseDal.GetStockInfos(materielCode, locationCodes);
+        }
+        public List<Dt_ProStockInfo> GetOutboundStocks(List<Dt_ProStockInfo> stockInfos, decimal needQuantity)
+        {
+            List<Dt_ProStockInfo> assignOutStocks = new List<Dt_ProStockInfo>();
+
+            decimal stockTotalQuantity = stockInfos.Select(x => x.proStockInfoDetails.Sum(v => v.StockQty-v.OutboundQuantity)).Sum(x => x);
+
+            if (stockTotalQuantity >= needQuantity)//搴撳瓨澶�
+            {
+                int index = 0;
+                while (needQuantity > 0)
+                {
+                    Dt_ProStockInfo stockInfo = stockInfos[index];
+                    decimal useableStockQuantity = stockInfo.proStockInfoDetails
+                        .Sum(x => x.StockQty - x.OutboundQuantity);
+                    if (useableStockQuantity < needQuantity && useableStockQuantity > 0)
+                    {
+                        stockInfo.proStockInfoDetails.ForEach(x => x.OutboundQuantity = x.StockQty);
+                        needQuantity -= useableStockQuantity;
+                    }
+                    else
+                    {
+                        stockInfo.proStockInfoDetails.ForEach(x =>
+                        {
+                            if (x.StockQty - x.OutboundQuantity >= needQuantity)
+                            {
+                                x.OutboundQuantity += needQuantity;
+                                needQuantity = 0;
+                            }
+                            else
+                            {
+                                needQuantity -= (x.StockQty - x.OutboundQuantity);
+                                x.OutboundQuantity = x.StockQty;
+                            }
+                        });
+                    }
+                    assignOutStocks.Add(stockInfo);
+                    index++;
+                }
+            }
+            return assignOutStocks;
+        }
     }
 }

--
Gitblit v1.9.3