From e4a391c581aaca1fa7b0239bc96375d0c0cb8de6 Mon Sep 17 00:00:00 2001
From: yangpeixing <yangpeixing@hnkhzn.com>
Date: 星期三, 04 二月 2026 08:55:49 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs |   55 +++++++++++++++++++++++++++----------------------------
 1 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
index 55c8af9..191af24 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
@@ -434,6 +434,7 @@
                 throw new Exception($"璇峰嬁鍚屾椂鎿嶄綔澶氫釜鍗曟嵁鏄庣粏");
             }
             Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+            List<Dt_OutboundOrderDetail> dt_OutboundOrderDetails = _outboundRepository.OutboundOrderDetailRepository.QueryData(x => x.OrderId == outboundOrder.Id);
             List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
             List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo, x.LocationName }).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo, LocationName = x.Key.LocationName }).ToList();
             List<Dt_Warehouse> warehouse = new List<Dt_Warehouse>();
@@ -502,13 +503,13 @@
                 List<IStockInfoService.residueQuantity> newResidueQuantitys = new List<IStockInfoService.residueQuantity>();
                 if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS")))
                 {
-                    autoAssignStocks = _stockService.StockInfoService.DWANDYSGetOutboundStocks(stockInfos,groupDetails, out List<IStockInfoService.residueQuantity> residueQuantitys);
+                    autoAssignStocks = _stockService.StockInfoService.DWANDYSGetOutboundStocks(stockInfos, dt_OutboundOrderDetails, out List<IStockInfoService.residueQuantity> residueQuantitys);
                     newResidueQuantitys.AddRange(residueQuantitys);
                     outStocks.AddRange(autoAssignStocks);
                 }
                 foreach(var residueQuantity in newResidueQuantitys)
                 {
-                    foreach (var item in groupDetails)
+                    foreach (var item in dt_OutboundOrderDetails)
                     {
                         if(residueQuantity.MaterielCode == item.MaterielCode && residueQuantity.BatchNo == item.BatchNo)
                         {
@@ -520,7 +521,7 @@
 
                             decimal assignQuantity = needQuantity -  residueQuantity.NewNeendQuantity;
 
-                            List<Dt_OutboundOrderDetail> details = outboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList();
+                            List<Dt_OutboundOrderDetail> details = dt_OutboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList();
 
                             for (int i = 0; i < details.Count; i++)
                             {
@@ -577,7 +578,7 @@
                 }
                 newResidueQuantitys = new List<IStockInfoService.residueQuantity>();
             }
-            return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos);
+            return (outStocks, dt_OutboundOrderDetails, outStockLockInfos, locationInfos);
         }
 
         private (bool, string) CheckSelectStockDeital(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
@@ -672,15 +673,15 @@
                 return WebResponseContent.Instance.Error("璇ュ嚭搴撳崟鎹潪ERP鎺ㄩ�侊紝鏃犳硶鍙栨秷");
             }
             string ids ="";
-            foreach (var item in outboundOrderDetails)
+            try
             {
-                ids = item.LinId;
-                var postContent = new MultipartFormDataContent();
-                postContent.Add(new StringContent(ids), "ids");
-                string result = string.Empty;
-                HttpClient client = null;
-                try
+                foreach (var item in outboundOrderDetails)
                 {
+                    ids = item.LinId;
+                    var postContent = new MultipartFormDataContent();
+                    postContent.Add(new StringContent(ids), "ids");
+                    string result = string.Empty;
+                    HttpClient client = null;
                     using (client = new HttpClient())
                     {
                         // 2. 鍙戦�佽姹�
@@ -707,26 +708,24 @@
                         _outboundRepository.OutboundOrderRepository.DeleteAndMoveIntoHty(outboundOrder, OperateType.浜哄伐鍙栨秷);
                     }
                     _unitOfWorkManage.CommitTran();
-                    // 鍋囪ERP杩斿洖鎴愬姛鏃惰繑鍥炴垚鍔熷搷搴�
-                    return WebResponseContent.Instance.OK(result);
-
                 }
-                catch (HttpRequestException ex)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    // 澶勭悊HTTP璇锋眰鐩稿叧寮傚父
-                    return WebResponseContent.Instance.Error($"HTTP璇锋眰閿欒: {ex.Message}");
-                    
-                }
-                catch (Exception ex)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    // 澶勭悊鍏朵粬寮傚父
-                    return WebResponseContent.Instance.Error($"澶勭悊澶辫触: {ex.Message}");
-                }
+                // 鍋囪ERP杩斿洖鎴愬姛鏃惰繑鍥炴垚鍔熷搷搴�
+                return WebResponseContent.Instance.OK();
 
             }
-            return WebResponseContent.Instance.OK();
+            catch (HttpRequestException ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                // 澶勭悊HTTP璇锋眰鐩稿叧寮傚父
+                return WebResponseContent.Instance.Error($"HTTP璇锋眰閿欒: {ex.Message}");
+
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                // 澶勭悊鍏朵粬寮傚父
+                return WebResponseContent.Instance.Error($"澶勭悊澶辫触: {ex.Message}");
+            }
         }
 
     }

--
Gitblit v1.9.3