From 695571c6009ecbc12e7d4a4fb147df7967a1260e Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 07 七月 2025 20:21:19 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesPPOutboundOrderDetailService.cs | 190 ++++++++++++++++-------------------------------
1 files changed, 65 insertions(+), 125 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesPPOutboundOrderDetailService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesPPOutboundOrderDetailService.cs"
index 2f8ea48..eb95355 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesPPOutboundOrderDetailService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesPPOutboundOrderDetailService.cs"
@@ -24,18 +24,74 @@
private readonly IOutStockLockInfoService _outStockLockInfoService;
private readonly IBasicService _basicService;
private readonly IRecordService _recordService;
- private readonly IOutboundService _outboundService;
-
+ private readonly IMesPPOutboundOrderService _mesPPOutboundOrderService;
public IMesPPOutboundOrderDetailRepository Repository => BaseDal;
- public MesPPOutboundOrderDetailService(IMesPPOutboundOrderDetailRepository BaseDal, IBasicRepository basicRepository, IOutboundService outboundService, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IBasicService basicService, IRecordService recordService) : base(BaseDal)
+ public MesPPOutboundOrderDetailService(IMesPPOutboundOrderDetailRepository BaseDal,IMesPPOutboundOrderService mesPPOutboundOrderService ,IBasicRepository basicRepository, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IBasicService basicService, IRecordService recordService) : base(BaseDal)
{
_basicRepository = basicRepository;
_stockService = stockService;
_outStockLockInfoService = outStockLockInfoService;
_basicService = basicService;
_recordService = recordService;
- _outboundService = outboundService;
+ _mesPPOutboundOrderService=mesPPOutboundOrderService;
+ }
+
+ public (List<Dt_StockInfo>, List<Dt_MesPPOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>, Dt_MesPPOutboundOrder mesPPOutboundOrder) AssignStockOutbound(List<Dt_MesPPOutboundOrderDetail> mesPPOutboundOrderDetails)
+ {
+ List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
+
+ List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
+ List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
+ Dt_MesPPOutboundOrder OutboundOrder = BaseDal.Db.Queryable<Dt_MesPPOutboundOrder>().Where(x => x.Id == mesPPOutboundOrderDetails.FirstOrDefault().OrderId).First();
+ float originalNeedQuantity = OutboundOrder.OrderQuantity;
+
+ float needQuantity = originalNeedQuantity;
+ //Dt_MesPPOutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+
+ List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(OutboundOrder.MaterialCode, "", mesPPOutboundOrderDetails.FirstOrDefault()?.CarrierCode ?? "", OutboundOrder.WarehouseId);
+ if (!stockInfos.Any())
+ {
+ throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨");
+ }
+ List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, OutboundOrder.MaterialCode, needQuantity, out float residueQuantity);
+ OutboundOrder.LockQuantity += needQuantity - residueQuantity;
+ autoAssignStocks.OrderBy(x => x.Details.FirstOrDefault()?.StockQuantity).ToList();
+ outStocks.AddRange(autoAssignStocks);
+ float assignQuantity = needQuantity - residueQuantity;
+
+ float orderQuantity = OutboundOrder.OrderQuantity;
+
+ for (int j = 0; j < autoAssignStocks.Count; j++)
+ {
+ float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == OutboundOrder.MaterialCode).Sum(x => x.AssignQuantity);//鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
+
+ float palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == OutboundOrder.MaterialCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲�
+
+ float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity);
+ if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭�
+ {
+ float orderDetailNeedQuantity = OutboundOrder.OrderQuantity - detailAssignQuantity;
+ if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity)
+ {
+ OutboundOrder.LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity;
+ //Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity);
+ Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, autoAssignStocks[j], assignQuantity);
+ outStockLockInfos.Add(outStockLockInfo);
+ }
+ else
+ {
+ //Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, autoAssignStocks[j], OutboundOrder.OrderQuantity - OutboundOrder.LockQuantity);
+ Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(OutboundOrder, autoAssignStocks[j], assignQuantity);
+ outStockLockInfos.Add(outStockLockInfo);
+ OutboundOrder.LockQuantity = OutboundOrder.OrderQuantity;
+ break;
+ }
+ }
+ }
+ locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()));
+
+ return (outStocks, mesPPOutboundOrderDetails, outStockLockInfos, locationInfos, OutboundOrder);
}
/// <summary>
@@ -48,7 +104,7 @@
/// <param name="locationStatus"></param>
/// <param name="tasks"></param>
/// <returns></returns>
- public WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null)
+ public WebResponseContent LockOutboundStockDataUpdate(Dt_MesPPOutboundOrder mesPPOutboundOrder, List<Dt_StockInfo> stockInfos, List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null)
{
try
{
@@ -79,6 +135,10 @@
{
_outStockLockInfoService.Repository.UpdateData(updateOutStockLockInfos);
}
+ if (mesPPOutboundOrder != null)
+ {
+ _mesPPOutboundOrderService.UpdateData(mesPPOutboundOrder);
+ }
_recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, locationStatus, LocationChangeType.OutboundAssignLocation, "", tasks?.Select(x => x.TaskNum).ToList());
_basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus);
@@ -90,125 +150,5 @@
}
}
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="outboundOrderDetails"></param>
- /// <returns></returns>
- public (List<Dt_StockInfo>, List<Dt_MesPPOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(List<Dt_MesPPOutboundOrderDetail> outboundOrderDetails)
- {
- if (!outboundOrderDetails.Any())
- {
- throw new Exception($"鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
- }
-
- if (outboundOrderDetails.GroupBy(x => x.OrderId).Count() > 1)
- {
- throw new Exception($"璇峰嬁鍚屾椂鎿嶄綔澶氫釜鍗曟嵁鏄庣粏");
- }
- Dt_MesPPOutboundOrder mesPPOutboundOrder = BaseDal.Db.Queryable<Dt_MesPPOutboundOrder>().Where(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId).First();
- List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
-
- List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
- List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
-
-
- List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesPPOutboundOrder.MaterialCode, "", outboundOrderDetails.FirstOrDefault()?.CarrierCode ?? "", mesPPOutboundOrder.WarehouseId);
- if (!stockInfos.Any())
- {
- throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨");
- }
- float originalNeedQuantity = mesPPOutboundOrder.OrderQuantity;
-
- float needQuantity = originalNeedQuantity;
- List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesPPOutboundOrder.MaterialCode, needQuantity, out float residueQuantity);
- mesPPOutboundOrder.LockQuantity += needQuantity - residueQuantity;
- outStocks.AddRange(autoAssignStocks);
- float assignQuantity = needQuantity - residueQuantity;
-
- float orderQuantity = mesPPOutboundOrder.OrderQuantity;
- for (int j = 0; j < autoAssignStocks.Count; j++)
- {
- float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPOutboundOrder.MaterialCode).Sum(x => x.AssignQuantity);//鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
-
- float palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPOutboundOrder.MaterialCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲�
-
- float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity);
- if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭�
- {
- float orderDetailNeedQuantity = mesPPOutboundOrder.OrderQuantity - detailAssignQuantity;
- if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity)
- {
- mesPPOutboundOrder.LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity;
- Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity);
- outStockLockInfos.Add(outStockLockInfo);
- }
- else
- {
- Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, autoAssignStocks[j], mesPPOutboundOrder.OrderQuantity - mesPPOutboundOrder.LockQuantity);
- outStockLockInfos.Add(outStockLockInfo);
- mesPPOutboundOrder.LockQuantity = mesPPOutboundOrder.OrderQuantity;
- break;
- }
- }
- }
- locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()));
-
- return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos);
- }
-
-
- public (List<Dt_StockInfo>, Dt_MesPPOutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_MesPPOutboundOrderDetail mesPPOutboundOrder)
- {
- List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
-
- List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
- List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
-
- //float originalNeedQuantity = mesPPOutboundOrder.OrderQuantity;
-
- //float needQuantity = originalNeedQuantity;
-
- //List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesPPOutboundOrder.MaterialCode, "", mesPPOutboundOrder.Details.FirstOrDefault()?.CarrierCode ?? "", mesPPOutboundOrder.WarehouseId);
- //if (!stockInfos.Any())
- //{
- // throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨");
- //}
- //List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesPPOutboundOrder.MaterialCode, needQuantity, out float residueQuantity);
- //mesPPOutboundOrder.LockQuantity += needQuantity - residueQuantity;
- //outStocks.AddRange(autoAssignStocks);
- //float assignQuantity = needQuantity - residueQuantity;
-
- //float orderQuantity = mesPPOutboundOrder.OrderQuantity;
- //for (int j = 0; j < autoAssignStocks.Count; j++)
- //{
- // float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPOutboundOrder.MaterialCode).Sum(x => x.AssignQuantity);//鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
-
- // float palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesPPOutboundOrder.MaterialCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲�
-
- // float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity);
- // if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭�
- // {
- // float orderDetailNeedQuantity = mesPPOutboundOrder.OrderQuantity - detailAssignQuantity;
- // if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity)
- // {
- // mesPPOutboundOrder.LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity;
- // Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity);
- // outStockLockInfos.Add(outStockLockInfo);
- // }
- // else
- // {
- // Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(mesPPOutboundOrder, autoAssignStocks[j], mesPPOutboundOrder.OrderQuantity - mesPPOutboundOrder.LockQuantity);
- // outStockLockInfos.Add(outStockLockInfo);
- // mesPPOutboundOrder.LockQuantity = mesPPOutboundOrder.OrderQuantity;
- // break;
- // }
- // }
- //}
- //locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()));
-
- return (outStocks, mesPPOutboundOrder, outStockLockInfos, locationInfos);
- }
}
}
--
Gitblit v1.9.3