From 02fdb8204bee8c7edb67544946e452ad0396f90c Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期一, 15 十二月 2025 15:42:04 +0800
Subject: [PATCH] Update OutboundService.cs
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs | 84 ++++++++++++++++++++++++++++++++----------
1 files changed, 64 insertions(+), 20 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 72b1b1c..f2f1977 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"
@@ -97,15 +97,31 @@
if (outStockLockInfo != null)
{
outStockLockInfo = item;
+ Dt_Task? task = tasks.FirstOrDefault(x => x.PalletCode == item.PalletCode);
+ if (task != null)
+ {
+ outStockLockInfo.TaskNum = task.TaskNum;
+ }
}
else
{
+ Dt_Task? task = tasks.FirstOrDefault(x => x.PalletCode == item.PalletCode);
+ if (task != null)
+ {
+ item.TaskNum = task.TaskNum;
+ }
materielCalc.OutStockLockInfos.Add(item);
}
outStockLockInfos.Add(item);
}
-
- tasks.AddRange(materielPickedDetails.Tasks);
+ foreach (var item in materielPickedDetails.Tasks)
+ {
+ Dt_Task? task = tasks.FirstOrDefault(x => x.PalletCode == item.PalletCode);
+ if (task == null)
+ {
+ tasks.Add(item);
+ }
+ }
pickedDetails.AddRange(materielPickedDetails.PickedDetails);
@@ -353,9 +369,11 @@
decimal availableQuantity = availableStockMap.GetValueOrDefault(stock.Id, 0);
if (availableQuantity <= 0) continue;
+ // 璁$畻璇ユ墭鐩樺彲鍒嗛厤鏁伴噺
decimal allocateQuantity = Math.Min(remainingQuantity, availableQuantity);
(decimal ActualAllocatedQuantity, List<Dt_OutStockLockInfo> LockInfoList) actualAllocated = AllocateStockQuantity(stock, allocateQuantity, availableQuantity, outboundOrder, firstDetail, request, lockStockMap.GetValueOrDefault(stock.Id, new List<Dt_OutStockLockInfo>()), stockDetailMap);
+ // 鏈鍒嗛厤鐨勬暟閲�
decimal actualAllocatedQuantity = actualAllocated.ActualAllocatedQuantity;
if (actualAllocatedQuantity > 0)
@@ -502,7 +520,7 @@
// 璁$畻鎬诲簱瀛樻暟閲�
decimal totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity);
- List<Dt_OutStockLockInfo> outStockLockInfos = allocatedData.Where(x => x.StockId == stockInfo.Id).ToList();
+ List<Dt_OutStockLockInfo> outStockLockInfos = allocatedData.Where(x => x.StockId == stockInfo.Id && x.MaterielCode == materielCalc.MaterielCode).ToList();
// 璁$畻宸插垎閰嶆暟閲�
decimal allocatedQuantity = outStockLockInfos.Sum(x => x.AllocatedQuantity);
@@ -510,7 +528,6 @@
lockStockMap[stockInfo.Id] = outStockLockInfos;
}
-
return (availableStockMap, lockStockMap);
}
@@ -560,7 +577,7 @@
// 鏇存柊鍒嗛厤鍑哄簱閲�
decimal beforeAssignQuantity = totalAllocatedQuantity; // 鏈鍒嗛厤鍓嶇殑鎬荤疮璁¢噺
- lockInfo.AssignQuantity += actualAllocatedQuantity; // 绱姞鏈鍒嗛厤鏁伴噺
+ lockInfo.AssignQuantity += actualAllocatedQuantity; // 鏈鍒嗛厤鏁伴噺
lockInfo.AllocatedQuantity = beforeAssignQuantity; // 璁板綍鏈鍒嗛厤鍓嶇殑鎬荤疮璁¢噺
lockInfoList.Add(lockInfo);
@@ -789,16 +806,7 @@
return WebResponseContent.Instance.Error($"鍑哄簱鍗� {request.OrderNo} 涓嶅瓨鍦�");
}
- // 5. 鏌ユ壘鍑哄簱鍗曟槑缁嗕俊鎭�
- List<Dt_OutboundOrderDetail> outboundOrderDetails = FindMatchingOutboundDetails(outboundOrder.Id, stockDetail);
- if (!outboundOrderDetails.Any())
- {
- response.Success = false;
- response.Message = $"鏈壘鍒板尮閰嶇殑鍑哄簱鍗曟槑缁嗭紝鐗╂枡锛歿stockDetail.MaterielCode}锛屾壒娆★細{stockDetail.BatchNo}";
- return WebResponseContent.Instance.Error($"鏈壘鍒板尮閰嶇殑鍑哄簱鍗曟槑缁嗭紝鐗╂枡锛歿stockDetail.MaterielCode}锛屾壒娆★細{stockDetail.BatchNo}");
- }
-
- // 6. 鏌ユ壘閿佸畾璁板綍
+ // 5. 鏌ユ壘閿佸畾璁板綍
Dt_OutStockLockInfo lockInfo = _outboundLockInfoService.Repository.QueryFirst(x =>
x.OrderNo == request.OrderNo &&
x.StockId == stockInfo.Id &&
@@ -810,6 +818,25 @@
response.Success = false;
response.Message = $"璇ュ簱瀛樻病鏈夊垎閰嶅嚭搴撻噺锛屾潯鐮侊細{request.Barcode}";
return WebResponseContent.Instance.Error($"璇ュ簱瀛樻病鏈夊垎閰嶅嚭搴撻噺锛屾潯鐮侊細{request.Barcode}");
+ }
+
+ // 鎵惧嚭宸插垎閰嶇殑璁㈠崟鏄庣粏Id
+ List<int> detailIds = new List<int>();
+ string[] ids = lockInfo.OrderDetailIds.Split(",");
+ foreach (string id in ids)
+ {
+ if (int.TryParse(id, out int detailId))
+ {
+ detailIds.Add(detailId);
+ }
+ }
+ // 6. 鏌ユ壘鍑哄簱鍗曟槑缁嗕俊鎭�
+ List<Dt_OutboundOrderDetail> outboundOrderDetails = FindMatchingOutboundDetails(outboundOrder.Id, stockDetail, detailIds);
+ if (!outboundOrderDetails.Any())
+ {
+ response.Success = false;
+ response.Message = $"鏈壘鍒板尮閰嶇殑鍑哄簱鍗曟槑缁嗭紝鐗╂枡锛歿stockDetail.MaterielCode}锛屾壒娆★細{stockDetail.BatchNo}";
+ return WebResponseContent.Instance.Error($"鏈壘鍒板尮閰嶇殑鍑哄簱鍗曟槑缁嗭紝鐗╂枡锛歿stockDetail.MaterielCode}锛屾壒娆★細{stockDetail.BatchNo}");
}
// 7. 璁$畻瀹為檯鍑哄簱閲�
@@ -824,6 +851,13 @@
response.Success = false;
response.Message = $"鏃犳硶鍑哄簱锛屾潯鐮侊細{request.Barcode}锛屽簱瀛橈細{stockDetail.StockQuantity}锛屽凡鍑哄簱锛歿totalAllocatedQuantity}锛屽垎閰嶉噺锛歿lockInfo.AssignQuantity}锛屾槑缁嗗墿浣欙細{detailRemainingQuantity}";
return WebResponseContent.Instance.Error($"鏃犳硶鍑哄簱锛屾潯鐮侊細{request.Barcode}锛屽簱瀛橈細{stockDetail.StockQuantity}锛屽凡鍑哄簱锛歿totalAllocatedQuantity}锛屽垎閰嶉噺锛歿lockInfo.AssignQuantity}锛屾槑缁嗗墿浣欙細{detailRemainingQuantity}");
+ }
+
+ if (actualOutboundQuantity + lockInfo.SortedQuantity > lockInfo.AssignQuantity)
+ {
+ response.Success = false;
+ response.Message = $"鏃犳硶鍑哄簱锛屾潯鐮侊細{request.Barcode}锛屽簱瀛橈細{stockDetail.StockQuantity}锛屽嚭搴撻噺{actualOutboundQuantity + lockInfo.SortedQuantity}澶т簬鍒嗛厤閲弡lockInfo.AssignQuantity}";
+ return WebResponseContent.Instance.Error($"鏃犳硶鍑哄簱锛屾潯鐮侊細{request.Barcode}锛屽簱瀛橈細{stockDetail.StockQuantity}锛屽嚭搴撻噺{actualOutboundQuantity + lockInfo.SortedQuantity}澶т簬鍒嗛厤閲弡lockInfo.AssignQuantity}");
}
// 8. 鍒ゆ柇鏄惁闇�瑕佹媶鍖咃紙褰撳嚭搴撴暟閲忓皬浜庡簱瀛樻暟閲忔椂闇�瑕佹媶鍖咃級
@@ -867,14 +901,21 @@
lockInfo.SortedQuantity = lockInfo.SortedQuantity + actualOutboundQuantity;
- // 鏇存柊閿佸畾璁板綍
- _outboundLockInfoService.Repository.UpdateData(lockInfo);
+ if (lockInfo.SortedQuantity == lockInfo.AssignQuantity)
+ {
+ _outboundLockInfoService.Repository.DeleteAndMoveIntoHty(lockInfo, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+ }
+ else
+ {
+ // 鏇存柊閿佸畾璁板綍
+ _outboundLockInfoService.Repository.UpdateData(lockInfo);
+ }
// 鏇存柊鍑哄簱鍗曟槑缁嗙殑宸插嚭搴撴暟閲�
_detailService.Repository.UpdateData(updateDetails);
// 鏇存柊閿佸畾璁板綍鐨勭疮璁″凡鍑哄簱鏁伴噺锛堥渶瑕佹洿鏂拌鎵樼洏璇ョ墿鏂欑殑鎵�鏈夌浉鍏宠褰曪級
- UpdateLockInfoAllocatedQuantity(stockInfo.Id, stockDetail.MaterielCode, stockDetail.BatchNo, actualOutboundQuantity);
+ //UpdateLockInfoAllocatedQuantity(stockInfo.Id, stockDetail.MaterielCode, stockDetail.BatchNo, actualOutboundQuantity);
// 鎻愪氦浜嬪姟
_unitOfWorkManage.CommitTran();
@@ -904,6 +945,8 @@
if (CheckOutboundOrderCompleted(request.OrderNo))
{
UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
+
+ //todo: 鍥炰紶MES
}
}
catch (Exception ex)
@@ -929,11 +972,11 @@
/// <param name="orderId"></param>
/// <param name="stockDetail"></param>
/// <returns></returns>
- private List<Dt_OutboundOrderDetail> FindMatchingOutboundDetails(int orderId, Dt_StockInfoDetail stockDetail)
+ private List<Dt_OutboundOrderDetail> FindMatchingOutboundDetails(int orderId, Dt_StockInfoDetail stockDetail, List<int> detailIds)
{
List<Dt_OutboundOrderDetail> details = _detailService.Repository.QueryData(x =>
x.OrderId == orderId &&
- x.MaterielCode == stockDetail.MaterielCode && x.OrderQuantity - x.MoveQty > x.OverOutQuantity);
+ x.MaterielCode == stockDetail.MaterielCode && x.OrderQuantity - x.MoveQty > x.OverOutQuantity && detailIds.Contains(x.Id));
// 绮剧‘鍖归厤锛氬鐞唍ull鍊肩殑鎵规銆佷緵搴斿晢銆佷粨搴�
List<Dt_OutboundOrderDetail> exactMatches = details.Where(x =>
@@ -1008,6 +1051,7 @@
{
// 鏇存柊鍘熷簱瀛樻槑缁�
stockDetail.StockQuantity = remainingQuantity;
+ //stockDetail.Barcode = newBarcode;
stockDetail.Remark = $"鎷嗗寘鍚庢洿鏂帮紝鍘熸潯鐮侊細{request.Barcode}锛屾柊鏁伴噺锛歿remainingQuantity}锛屾搷浣滆�咃細{request.Operator}";
_stockDetailService.Repository.UpdateData(stockDetail);
}
--
Gitblit v1.9.3