From 68628c6cc163cddfcc745c225a9f3f34767261ef Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期六, 22 十一月 2025 20:44:40 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs | 72 +++++++++++++++++++++++++++++++++++
1 files changed, 71 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/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 3fa61d7..954e8fc 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"
@@ -1,6 +1,7 @@
锘縰sing Microsoft.Extensions.Logging;
using SqlSugar;
using WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
@@ -22,6 +23,7 @@
private readonly IStockService _stockService;
+
private readonly IOutStockLockInfoService _outStockLockInfoService;
private readonly ILocationInfoService _locationInfoService;
private readonly IBasicService _basicService;
@@ -40,6 +42,7 @@
_locationStatusChangeRecordService = locationStatusChangeRecordService;
_outboundOrderService = outboundOrderService;
_logger = logger;
+
}
@@ -153,7 +156,7 @@
if (remainingAllocate <= 0) break;
// 璁$畻杩欎釜鏄庣粏杩橀渶瑕佸垎閰嶇殑鏁伴噺
- var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity;
+ var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity-detail.MoveQty;
if (detailNeed <= 0) continue;
// 鍒嗛厤鏁伴噺
@@ -289,5 +292,72 @@
return new PageGridData<Dt_OutboundOrderDetail> ();
}
+
+ public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
+ {
+ (bool, string) checkResult = CheckSelectStockDeital(outboundOrderDetail, stockSelectViews);
+ if (!checkResult.Item1) throw new Exception(checkResult.Item2);
+
+ Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
+ var originalNeedQuantity = outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity;
+
+ var needQuantity = originalNeedQuantity;
+
+ List<Dt_StockInfo> outStocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList());
+ var assignQuantity =0m;
+ outStocks.ForEach(x =>
+ {
+ x.Details.ForEach(v =>
+ {
+ assignQuantity += v.StockQuantity - v.OutboundQuantity;
+ });
+ });
+
+ outboundOrderDetail.LockQuantity += assignQuantity;
+ outStocks.ForEach(x =>
+ {
+ x.Details.ForEach(v =>
+ {
+ v.OutboundQuantity = v.StockQuantity;
+ });
+ });
+ needQuantity -= assignQuantity;
+ if (outboundOrderDetail.OrderQuantity > outboundOrderDetail.LockQuantity)
+ {
+ List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode, outboundOrderDetail.BatchNo,"");
+ stockInfos = stockInfos.Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode)).ToList();
+ var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(stockInfos, outboundOrderDetail.MaterielCode, needQuantity, out decimal residueQuantity);
+ outboundOrderDetail.LockQuantity += needQuantity - residueQuantity;
+ outStocks.AddRange(autoAssignStocks);
+ outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt();
+ if (residueQuantity > 0)
+ {
+ outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.AssignOverPartial.ObjToInt();
+ }
+ }
+
+ List<Dt_OutStockLockInfo> outStockLockInfos = _outStockLockInfoService.GetOutStockLockInfos(outboundOrder, outboundOrderDetail, outStocks);
+
+ List<Dt_LocationInfo> locationInfos = _locationInfoService.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList());
+
+ return (outStocks, outboundOrderDetail, outStockLockInfos, locationInfos);
+ }
+ private (bool, string) CheckSelectStockDeital(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
+ {
+ if (outboundOrderDetail == null)
+ {
+ return (false, "鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
+ }
+ if (outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt() && outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt())
+ {
+ return (false, "璇ユ槑缁嗕笉鍙搷浣�");
+ }
+ if (stockSelectViews.Sum(x => x.UseableQuantity) > outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity)
+ {
+ return (false, "閫夋嫨鏁伴噺瓒呭嚭鍗曟嵁鏁伴噺");
+ }
+ return (true, "鎴愬姛");
+ }
+
}
}
--
Gitblit v1.9.3