From e069161ee474fe9bfd6571eb293aeb7e9f4d4883 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期一, 09 三月 2026 17:30:27 +0800
Subject: [PATCH] 回库不拣选功能
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs | 87 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 1 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 96577c1..4b0d960 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"
@@ -2235,8 +2235,93 @@
if (lockInfo != null && lockInfo.SortedQuantity != lockInfo.AssignQuantity)
{
- return content.Error($"鎵樼洏{palletCode}搴撳瓨锛屽湪鍗曟嵁{lockInfo.OrderNo}閲岄潰杩樻湭鎷i�夊畬鎴愶紝涓嶅厑璁稿洖搴�");
+ // 1. 璁$畻闇�瑕佸洖婊氱殑鎬绘暟閲�
+ decimal? rollbackTotalQuantity = lockInfo.AssignQuantity - lockInfo.SortedQuantity;
+ // 纭繚鍥炴粴鏁伴噺涓烘鏁�
+ if (rollbackTotalQuantity <= 0)
+ {
+ // 娌℃湁闇�瑕佸洖婊氱殑鏁伴噺
+ stock.StockStatus = (int)StockStatusEmun.鍏ュ簱纭;
+ stock.LocationCode = "";
+ }
+
+ try
+ {
+ //澶勭悊OrderDetailIds锛屽垎鍓插苟杞崲涓篒D鍒楄〃
+ List<long> orderDetailIds = new List<long>();
+ if (!string.IsNullOrEmpty(lockInfo.OrderDetailIds))
+ {
+ orderDetailIds = lockInfo.OrderDetailIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
+ .Select(id =>
+ {
+ if (long.TryParse(id.Trim(), out long result))
+ {
+ return result;
+ }
+ return 0; // 鏃犳晥ID鏍囪涓�0
+ })
+ .Where(id => id > 0)
+ .OrderByDescending(id => id)
+ .ToList();
+ }
+
+ if (orderDetailIds.Count == 0)
+ {
+ return WebResponseContent.Instance.Error("鍗曟嵁閿佸畾鍑哄簱鍗曟槑缁咺d鏃犳晥锛屾鏌ラ攣瀹氬嚭搴撴暟鎹槸鍚︽纭�");
+ }
+
+ //鏌ヨ瀵瑰簲鐨勮鍗曟槑缁�
+ List<Dt_OutboundOrderDetail> orderDetails = _outboundRepository.Db.Queryable<Dt_OutboundOrderDetail>()
+ .Where(x => orderDetailIds.Contains(x.Id))
+ .ToList();
+
+ if (orderDetails.Count == 0)
+ {
+ return WebResponseContent.Instance.Error("鏈壘鍒板彲鍥炴粴鏄庣粏锛岃妫�鏌ュ嚭搴撳崟鏄庣粏");
+ }
+
+ decimal remainingRollbackQty = (decimal)rollbackTotalQuantity;
+ foreach (var detail in orderDetails)
+ {
+ if (remainingRollbackQty <= 0)
+ {
+ break;
+ }
+
+ // 璁$畻璇ユ槑缁嗙殑鍙洖婊氭暟閲�
+ decimal availableRollbackQty = detail.LockQuantity - detail.OverOutQuantity - detail.MoveQty;
+
+ availableRollbackQty = Math.Max(0, availableRollbackQty);
+
+ if (availableRollbackQty <= 0)
+ {
+ continue; // 璇ユ槑缁嗘棤鍙洖婊氭暟閲忥紝璺宠繃
+ }
+
+ // 璁$畻鏈瀹為檯鍥炴粴鏁伴噺锛堝彇鍙洖婊氭暟閲忓拰鍓╀綑闇�瑕佸洖婊氭暟閲忕殑杈冨皬鍊硷級
+ decimal actualRollbackQty = Math.Min(availableRollbackQty, remainingRollbackQty);
+
+ detail.LockQuantity -= actualRollbackQty;
+ detail.LockQuantity = Math.Max(0, detail.LockQuantity);
+
+ _detailRepository.UpdateData(detail);
+
+ //鏇存柊鍓╀綑闇�瑕佸洖婊氱殑鏁伴噺
+ remainingRollbackQty -= actualRollbackQty;
+ }
+
+ if (remainingRollbackQty > 0)
+ {
+ return WebResponseContent.Instance.Error($"鍓╀綑鍥炴粴鏁伴噺{remainingRollbackQty}");
+ }
+ _outboundLockInfoRepository.DeleteAndMoveIntoHty(lockInfo, WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐鍒犻櫎);
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
}
+
stock.StockStatus = (int)StockStatusEmun.鍏ュ簱纭;
stock.LocationCode = "";
}
--
Gitblit v1.9.3