From d8db1698c125618c1b5f62b009204ddc5d4eed5a Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 19 三月 2025 20:34:08 +0800
Subject: [PATCH] 成品代码更新....

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs"
index 1941997..a368baf 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs"
@@ -25,14 +25,16 @@
         private readonly IStockService _stockInfoService;
         private readonly IBasicService _basicService;
         private readonly IOutProStockInfoService _outProStockInfoService;
+        private readonly IProOutOrderRepository _proOutOrderRepository;
         private readonly IRecordService _recordService;
-        public ProOutOrderDetailService(IProOutOrderDetailRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockInfoService, IBasicService basicService,IOutProStockInfoService outProStockInfoService, IRecordService recordService) : base(BaseDal)
+        public ProOutOrderDetailService(IProOutOrderDetailRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockInfoService, IBasicService basicService,IOutProStockInfoService outProStockInfoService, IRecordService recordService, IProOutOrderRepository proOutOrderRepository) : base(BaseDal)
         {
             _unitOfWorkManage = unitOfWorkManage;
             _stockInfoService = stockInfoService;
             _basicService = basicService;
             _outProStockInfoService = outProStockInfoService;
             _recordService = recordService;
+            _proOutOrderRepository=proOutOrderRepository;
         }
         /// <summary>
         /// 鍑哄簱搴撳瓨鍒嗛厤鍚庯紝鏇存柊鏁版嵁搴撴暟鎹�
@@ -81,17 +83,18 @@
         /// <summary>
         /// 鍒嗛厤搴撳瓨澶勭悊璐т綅鏁版嵁
         /// </summary>
-        public (List<Dt_ProStockInfo>, List<Dt_ProOutOrderDetail>, List<Dt_OutProStockInfo>, List<Dt_LocationInfo>) AssignProStockOut(int warehouseId, Dt_ProOutOrder proOutOrder)
+        public (List<Dt_ProStockInfo>, List<Dt_ProOutOrderDetail>, List<Dt_OutProStockInfo>, List<Dt_LocationInfo>) AssignProStockOut(List<Dt_ProOutOrderDetail> proOutOrderDetails)
         {
-            List<Dt_ProOutOrderDetail> OutOrderDetails = proOutOrder.Details;
-            if (!OutOrderDetails.Any())
-            {
-                throw new Exception($"鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
-            }
             List<Dt_ProStockInfo> outStocks = new List<Dt_ProStockInfo>();
             List<Dt_OutProStockInfo> outProStockInfos = new List<Dt_OutProStockInfo>();
             List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
-            List<Dt_ProOutOrderDetail> groupDetails = OutOrderDetails.GroupBy(x => new { x.SaleOrder, x.PCode, x.PVer, x.PLot, x.DateCode }).Select(x => new Dt_ProOutOrderDetail()
+            //鑾峰彇鎴愬搧璁㈠崟
+            Dt_ProOutOrder proOutOrder = _proOutOrderRepository.QueryFirst(x=>x.Id==proOutOrderDetails.FirstOrDefault().ProOrderId);
+            if (proOutOrder==null)
+            {
+                throw new Exception("鏈壘鍒版垚鍝佽鍗�");
+            }
+            List<Dt_ProOutOrderDetail> groupDetails = proOutOrderDetails.GroupBy(x => new { x.SaleOrder, x.PCode, x.PVer, x.PLot, x.DateCode }).Select(x => new Dt_ProOutOrderDetail()
             {
                 QtyPcs = x.Sum(x => x.QtyPcs) - x.Sum(x => x.OverQtyPcs),
                 SaleOrder = x.Key.SaleOrder,
@@ -104,7 +107,7 @@
             {
                 float needQty = item.QtyPcs;
                 //鏌ユ壘鍙敤搴撳瓨
-                List<Dt_ProStockInfo> stockInfoss = _stockInfoService.ProStockInfoService.GetUseableStocks(warehouseId, item);
+                List<Dt_ProStockInfo> stockInfoss = _stockInfoService.ProStockInfoService.GetUseableStocks(proOutOrder.WarehouseId, item);
                 if (!stockInfoss.Any())
                 {
                     throw new Exception("鏈壘鍒板彲鍒嗛厤搴撳瓨");
@@ -116,7 +119,7 @@
                 float assignQuantity = needQty - residueQuantity;
                 bool isCanLot = !string.IsNullOrEmpty(item.PLot);
                 bool isCanDate = !string.IsNullOrEmpty(item.DateCode);
-                List<Dt_ProOutOrderDetail> details = OutOrderDetails
+                List<Dt_ProOutOrderDetail> details = proOutOrderDetails
                     .Where(x => x.SaleOrder == item.SaleOrder && x.PCode == item.PCode && x.PVer == item.PVer
                     && (isCanLot ? x.PLot == item.PLot : true)
                     && (isCanDate ? x.DateCode == item.DateCode : true))
@@ -166,7 +169,7 @@
                 locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(locationArr));
 
             }
-            return (outStocks, OutOrderDetails, outProStockInfos, locationInfos);
+            return (outStocks, proOutOrderDetails, outProStockInfos, locationInfos);
         }
     }
 }

--
Gitblit v1.9.3