From 6641d42d35d7b9739c64fe578d69e43a39e26c16 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期六, 29 十一月 2025 09:46:49 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs | 54 ++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 46 insertions(+), 8 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/OutboundOrderDetailService.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/OutboundOrderDetailService.cs"
index 450ce11..94e20ec 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/OutboundOrderDetailService.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/OutboundOrderDetailService.cs"
@@ -66,6 +66,11 @@
var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>()
.First(x => x.Id == orderId);
+ if (!CanReassignOrder(outboundOrder))
+ {
+ throw new Exception($"璁㈠崟{outboundOrder.OrderNo}鐘舵�佷笉鍏佽閲嶆柊鍒嗛厤搴撳瓨");
+ }
+
List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
@@ -79,7 +84,7 @@
BatchNo = x.Key.BatchNo,
SupplyCode = x.Key.SupplyCode,
Details = x.ToList(),
- TotalNeedQuantity = x.Sum(v => v.OrderQuantity - v.OverOutQuantity - v.LockQuantity - v.MoveQty)
+ TotalNeedQuantity = CalculateReassignNeedQuantity(x.ToList())
})
.Where(x => x.TotalNeedQuantity > 0)
.ToList();
@@ -127,6 +132,39 @@
}
return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos);
+ }
+
+ /// <summary>
+ /// 妫�鏌ヨ鍗曟槸鍚﹀厑璁搁噸鏂板垎閰�
+ /// </summary>
+ private bool CanReassignOrder(Dt_OutboundOrder outboundOrder)
+ {
+ // 鍏佽閲嶆柊鍒嗛厤鐨勭姸鎬�
+ var allowedStatus = new[] {OutOrderStatusEnum.鏈紑濮�, OutOrderStatusEnum.鍑哄簱涓�,OutOrderStatusEnum.閮ㄥ垎瀹屾垚};
+
+ return allowedStatus.Contains((OutOrderStatusEnum)outboundOrder.OrderStatus);
+ }
+
+ /// <summary>
+ /// 閲嶆柊璁$畻闇�姹傛暟閲忥紙鑰冭檻閲嶆柊鍒嗛厤鐨勫満鏅級
+ /// </summary>
+ private decimal CalculateReassignNeedQuantity(List<Dt_OutboundOrderDetail> details)
+ {
+ decimal totalNeed = 0;
+
+ foreach (var detail in details)
+ {
+ // 鍏抽敭淇敼锛氶噸鏂板垎閰嶆椂锛屽彧鑰冭檻鏈嚭搴撶殑閮ㄥ垎锛屽拷鐣ラ攣瀹氭暟閲�
+ // 鍥犱负閿佸畾鏁伴噺鍦ㄥ洖搴撴椂宸茬粡琚噸缃�
+ decimal remainingNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.MoveQty;
+
+ if (remainingNeed > 0)
+ {
+ totalNeed += remainingNeed;
+ }
+ }
+
+ return totalNeed;
}
private (bool success, string message) DistributeLockQuantityByFIFO(
List<Dt_OutboundOrderDetail> details,
@@ -231,7 +269,7 @@
/// <summary>
/// 涓哄垎鎵瑰垎閰嶅簱瀛�
/// </summary>
- public async Task<(List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>)>
+ public async Task<(List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>)>
AssignStockForBatch(Dt_OutboundOrderDetail orderDetail, decimal batchQuantity, string batchNo)
{
if (orderDetail == null)
@@ -263,7 +301,7 @@
foreach (var item in groupDetails)
{
var needQuantity = item.TotalNeedQuantity;
-
+
// 鑾峰彇鍙敤搴撳瓨锛堟寜鍏堣繘鍏堝嚭鎺掑簭锛�
List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode);
if (!stockInfos.Any())
@@ -272,7 +310,7 @@
}
// 鍒嗛厤搴撳瓨锛堟寜鍏堣繘鍏堝嚭锛�
- var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks (stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
+ var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
// 妫�鏌ュ垎閰嶇粨鏋�
decimal allocatedQuantity = needQuantity - residueQuantity;
@@ -300,7 +338,7 @@
locationInfos.AddRange(_locationInfoService.GetLocationInfos(
outStocks.Select(x => x.LocationCode).Distinct().ToList()));
-
+
}
return (outStocks, groupDetails.SelectMany(x => x.Details).ToList(), outStockLockInfos, locationInfos);
@@ -370,13 +408,13 @@
{
return (false, $"搴撳瓨鏄庣粏ID[{stockDetail.Id}]鐨勬潯鐮佷负绌�");
}
-
+
// 鍒涘缓鍑哄簱閿佸畾淇℃伅
var lockInfo = _outStockLockInfoService.GetOutStockLockInfo(
- outboundOrder, detail, stockInfo, assignQuantity, stockDetail.Barcode,batchNo);
+ outboundOrder, detail, stockInfo, assignQuantity, stockDetail.Barcode, batchNo);
outStockLockInfos.Add(lockInfo);
-
+
// 鏇存柊鏄庣粏鐨勫凡鍒嗛厤鏁伴噺
detail.AllocatedQuantity += assignQuantity;
remainingAllocate -= assignQuantity;
--
Gitblit v1.9.3