From 5189c42ee1b15ba8c54fd258102b4c7262a2e6c7 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期一, 30 三月 2026 11:40:11 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs |   56 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 45 insertions(+), 11 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
index 81372d7..894adab 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
@@ -330,7 +330,19 @@
                     foreach (var detail in materielCalc.Details)
                     {
                         if (remainingToLock <= 0) break;
-                        decimal maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity-detail.LockQuantity;
+                        decimal maxLockableQty = 0;
+                        if (detail.LockQuantity > detail.OverOutQuantity && detail.OverOutQuantity > 0)
+                        {
+                             maxLockableQty = detail.OrderQuantity - detail.LockQuantity;
+                        }
+                        else if(detail.OverOutQuantity > 0)
+                        {
+                            maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity;
+                        }
+                        else
+                        {
+                            maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity;
+                        }
                         if (maxLockableQty <= 0) continue;
                         decimal currentLockQty = Math.Min(remainingToLock, maxLockableQty);
                         detail.LockQuantity += currentLockQty;
@@ -1364,9 +1376,18 @@
 
                         Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode;
 
-                        List<Dt_OutStockLockInfo> stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
-                                x.OrderNo == request.OrderNo &&
-                                x.MaterielCode == stockInfoDetail.MaterielCode).Where(supWhere).Where(wareWhere).ToList();
+                        var idStr = outboundOrderDetails.First().Id.ToString();
+
+                        var stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
+                            (x.OrderDetailIds == idStr ||
+                             x.OrderDetailIds.StartsWith(idStr + ",") ||
+                             x.OrderDetailIds.EndsWith("," + idStr) ||
+                             x.OrderDetailIds.Contains("," + idStr + ",")) &&
+                            x.OrderNo == request.OrderNo &&
+                            x.MaterielCode == stockInfoDetail.MaterielCode)
+                            .Where(supWhere)
+                            .Where(wareWhere)
+                            .ToList();
                         if (stockLockInfos != null && stockLockInfos.Any())
                         {
                             _outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩鍒犻櫎);
@@ -1792,9 +1813,18 @@
 
                         Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode;
 
-                        List<Dt_OutStockLockInfo> stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
-                                x.OrderNo == request.OrderNo &&
-                                x.MaterielCode == stockDetail.MaterielCode).Where(supWhere).Where(wareWhere).ToList();
+                        var idStr = outboundOrderDetails.First().Id.ToString();
+
+                        var stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
+                            (x.OrderDetailIds == idStr ||
+                             x.OrderDetailIds.StartsWith(idStr + ",") ||
+                             x.OrderDetailIds.EndsWith("," + idStr) ||
+                             x.OrderDetailIds.Contains("," + idStr + ",")) &&
+                            x.OrderNo == request.OrderNo &&
+                            x.MaterielCode == stockDetail.MaterielCode)
+                            .Where(supWhere)
+                            .Where(wareWhere)
+                            .ToList();
                         if (stockLockInfos != null && stockLockInfos.Any())
                         {
                             _outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩鍒犻櫎);
@@ -2495,6 +2525,10 @@
                         return WebResponseContent.Instance.Error($"鏉$爜{request.Barcode}宸叉棤娉曟挙閿�");
                     }
                 }
+                else
+                {
+                    return WebResponseContent.Instance.Error($"鏉$爜{request.Barcode}宸叉棤娉曟挙閿�");
+                }
 
                 Dt_OutStockLockInfo lockInfo = _outboundLockInfoRepository.QueryFirst(x =>
                     x.OrderNo == request.OrderNo &&
@@ -2502,13 +2536,13 @@
                     x.MaterielCode == historyDetail.MaterielCode &&
                     x.PalletCode == stockInfo.PalletCode);
 
+                if (lockInfo == null)
+                {
+                    return WebResponseContent.Instance.Error("璇ユ墭鐩樺凡鍏ㄩ儴鎷i�夊畬,涓嶅厑璁告挙閿�");
+                }
                 _unitOfWorkManage.BeginTran();
                 try
                 {
-                    if(lockInfo == null)
-                    {
-                        return WebResponseContent.Instance.Error("璇ユ墭鐩樺凡鍏ㄩ儴鎷i�夊畬,涓嶅厑璁告挙閿�");
-                    }
                     bool isUnpack = historyDetail.OperateType == "鎷嗗寘-鍘熷璁板綍";
                     if (isUnpack)
                     {

--
Gitblit v1.9.3