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/ProOutOrderDetailService.cs | 174 ++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 120 insertions(+), 54 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs"
index 4e89f26..2acec89 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs"
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
+using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
@@ -45,12 +46,15 @@
{
try
{
+ //鏇存柊搴撳瓨灞炴��
_stockInfoService.ProStockInfoService.Repository.UpdateData(proStockInfos);
List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
foreach (var item in proStockInfos)
{
proStockInfoDetails.AddRange(item.proStockInfoDetails);
}
+ //鏇存柊搴撳瓨鏄庣粏
+ proStockInfoDetails.ForEach(x => x.ProOutDetailStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt());
_stockInfoService.ProStockInfoDetailService.Repository.UpdateData(proStockInfoDetails);
Dt_ProOutOrder proOutOrder = _proOutOrderRepository.QueryFirst(x => x.Id == proOutOrderDetails.FirstOrDefault().ProOrderId);
if (proOutOrder.ProOrderStatus == OutOrderStatusEnum.鏈紑濮�.ObjToInt())
@@ -102,16 +106,88 @@
{
throw new Exception("鏈壘鍒版垚鍝佽鍗�");
}
- List<Dt_ProOutOrderDetail> groupDetails = proOutOrderDetails.GroupBy(x => new { x.SaleOrder, x.PCode, x.PVer, x.PLot, x.DateCode }).Select(x => new Dt_ProOutOrderDetail()
- {
- QtyPcs = x.Sum(x => x.QtyPcs) - x.Sum(x => x.OverQtyPcs),
- SaleOrder = x.Key.SaleOrder,
- PCode = x.Key.PCode,
- PVer = x.Key.PVer,
- PLot = x.Key.PLot,
- DateCode = x.Key.DateCode,
- }).ToList();
- foreach (var item in groupDetails)
+ //List<Dt_ProOutOrderDetail> groupDetails = proOutOrderDetails.GroupBy(x => new { x.SaleOrder, x.PCode, x.PVer, x.PLot, x.DateCode }).Select(x => new Dt_ProOutOrderDetail()
+ //{
+ // QtyPcs = x.Sum(x => x.QtyPcs) - x.Sum(x => x.OverQtyPcs),
+ // SaleOrder = x.Key.SaleOrder,
+ // PCode = x.Key.PCode,
+ // PVer = x.Key.PVer,
+ // PLot = x.Key.PLot,
+ // DateCode = x.Key.DateCode,
+ //}).ToList();
+ //foreach (var item in groupDetails)
+ //{
+ // float needQty = item.QtyPcs;
+ // //鏌ユ壘鍙敤搴撳瓨
+ // List<Dt_ProStockInfo> stockInfoss = _stockInfoService.ProStockInfoService.GetUseableStocks(proOutOrder.WarehouseId, item);
+ // if (!stockInfoss.Any())
+ // {
+ // throw new Exception("鏈壘鍒板彲鍒嗛厤搴撳瓨");
+ // }
+ // //鑾峰彇鍑哄簱搴撳瓨
+ // List<Dt_ProStockInfo> assignOutStocks = _stockInfoService.ProStockInfoService.GetOutboundStocks(stockInfoss, item, needQty, out float residueQuantity);
+ // item.LockQtyPcs += needQty - residueQuantity;
+ // if (item.QtyPcs> item.LockQtyPcs)
+ // {
+ // throw new Exception($"浜у搧缂栫爜{item.PCode}鍙垎閰嶆暟閲忎笉瓒�,鍙敤鏁伴噺{item.LockQtyPcs}");
+ // }
+ // outStocks.AddRange(assignOutStocks);
+ // float assignQuantity = needQty - residueQuantity;
+ // bool isCanLot = string.IsNullOrEmpty(item.PLot);
+ // bool isCanDate = string.IsNullOrEmpty(item.DateCode);
+ // List<Dt_ProOutOrderDetail> details = proOutOrderDetails
+ // .Where(x =>x.PCode == item.PCode && x.PVer == item.PVer
+ // && (isCanLot ? isCanLot : x.PLot == item.PLot)
+ // && (isCanDate ? isCanDate : x.DateCode == item.DateCode))
+ // .ToList();
+
+ // for (int i = 0; i < details.Count; i++)
+ // {
+ // float orderQuantity = details[i].QtyPcs;
+ // for (int j = 0; j < assignOutStocks.Count; j++)
+ // {
+ // //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
+ // float detailAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer
+ // && (isCanLot ? isCanLot : x.PLot == item.PLot)
+ // && (isCanDate ? isCanDate : x.DateCode == item.DateCode)
+ // && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity);
+
+ // float palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer
+ // && (isCanLot ? isCanLot : x.PLot == item.PLot)
+ // && (isCanDate ? isCanDate : x.DateCode == item.DateCode)
+ // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity);
+ // //鍑哄簱璇︽儏宸插垎閰嶆暟閲�
+ // palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer
+ // && (isCanLot ? isCanLot : x.PLot == item.PLot)
+ // && (isCanDate ? isCanDate : x.DateCode == item.DateCode)
+ // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲�
+ // float palletOutboundQuantity = assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity);
+ // if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭�
+ // {
+ // float orderDetailNeedQuantity = details[i].QtyPcs - detailAssignQuantity;
+ // if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity)
+ // {
+ // details[i].LockQtyPcs += assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity;
+ // Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, details[i], assignOutStocks[j], assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity);
+ // outProStockInfos.Add(outStockLockInfo);
+ // }
+ // else
+ // {
+ // Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, details[i], assignOutStocks[j], details[i].QtyPcs - details[i].LockQtyPcs);
+ // outProStockInfos.Add(outStockLockInfo);
+ // details[i].LockQtyPcs = details[i].QtyPcs;
+ // break;
+ // }
+
+ // }
+ // }
+ // }
+ // List<string> locationArr = outStocks.Select(x => x.LocationCode).ToList();
+
+ // locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(locationArr));
+
+ //}
+ foreach (var item in proOutOrderDetails)
{
float needQty = item.QtyPcs;
//鏌ユ壘鍙敤搴撳瓨
@@ -123,56 +199,46 @@
//鑾峰彇鍑哄簱搴撳瓨
List<Dt_ProStockInfo> assignOutStocks = _stockInfoService.ProStockInfoService.GetOutboundStocks(stockInfoss, item, needQty, out float residueQuantity);
item.LockQtyPcs += needQty - residueQuantity;
+ if (item.QtyPcs > item.LockQtyPcs)
+ {
+ throw new Exception($"浜у搧缂栫爜{item.PCode},鐗堟湰{item.PVer.Substring(0, 1)}鍙垎閰嶆暟閲忎笉瓒�,鍙敤鏁伴噺{item.LockQtyPcs}");
+ }
outStocks.AddRange(assignOutStocks);
- float assignQuantity = needQty - residueQuantity;
+ //鍒嗛厤鍑哄簱鐨凱CS鏁伴噺
+ float assignQuantity = needQty;
bool isCanLot = string.IsNullOrEmpty(item.PLot);
bool isCanDate = string.IsNullOrEmpty(item.DateCode);
- List<Dt_ProOutOrderDetail> details = proOutOrderDetails
- .Where(x => x.SaleOrder == item.SaleOrder && x.PCode == item.PCode && x.PVer == item.PVer
- && (isCanLot ? isCanLot : x.PLot == item.PLot)
- && (isCanDate ? isCanDate : x.DateCode == item.DateCode))
- .ToList();
-
- for (int i = 0; i < details.Count; i++)
+ //璁㈠崟鏄庣粏鐨勫嚭搴揚CS鏁伴噺
+ float orderQuantity = item.QtyPcs;
+ for (int j = 0; j < assignOutStocks.Count; j++)
{
- float orderQuantity = details[i].QtyPcs;
- for (int j = 0; j < assignOutStocks.Count; j++)
- {
- //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
- float detailAssignQuantity = outProStockInfos.Where(x => x.SaleOrder == item.SaleOrder && x.PCode == item.PCode && x.PVer == item.PVer
- && (isCanLot ? isCanLot : x.PLot == item.PLot)
- && (isCanDate ? isCanDate : x.DateCode == item.DateCode)
- && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity);
-
- float palletAssignQuantity = outProStockInfos.Where(x => x.SaleOrder == item.SaleOrder && x.PCode == item.PCode && x.PVer == item.PVer
- && (isCanLot ? isCanLot : x.PLot == item.PLot)
- && (isCanDate ? isCanDate : x.DateCode == item.DateCode)
- && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity);
- //鍑哄簱璇︽儏宸插垎閰嶆暟閲�
- palletAssignQuantity = outProStockInfos.Where(x => x.SaleOrder == item.SaleOrder && x.PCode == item.PCode && x.PVer == item.PVer
- && (isCanLot ? isCanLot : x.PLot == item.PLot)
- && (isCanDate ? isCanDate : x.DateCode == item.DateCode)
- && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲�
- float palletOutboundQuantity = assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity);
- if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭�
+ //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
+ float detailAssignQuantity = outProStockInfos.Where(x => x.OrderDetailId == item.Id).Sum(x => x.AssignQuantity);
+ ////鍑哄簱璇︽儏宸插垎閰嶆暟閲�
+ //float palletAssignQuantity = outProStockInfos.Where(x => x.PCode == item.PCode && x.PVer == item.PVer
+ // && (isCanLot ? isCanLot : x.PLot == item.PLot)
+ // && (isCanDate ? isCanDate : x.DateCode == item.DateCode)
+ // && x.PalletCode == assignOutStocks[j].PalletCode).Sum(x => x.AssignQuantity);
+ ////鍑哄簱璇︽儏宸插垎閰嶆暟閲�
+ //float palletOutboundQuantity = assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity);
+ //if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭�
+ //{
+ float orderDetailNeedQuantity = item.QtyPcs - detailAssignQuantity;
+ if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity))
{
- float orderDetailNeedQuantity = details[i].QtyPcs - detailAssignQuantity;
- if (orderDetailNeedQuantity > assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity)
- {
- details[i].LockQtyPcs += assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity;
- Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, details[i], assignOutStocks[j], assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity) - palletAssignQuantity);
- outProStockInfos.Add(outStockLockInfo);
- }
- else
- {
- Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, details[i], assignOutStocks[j], details[i].QtyPcs - details[i].LockQtyPcs);
- outProStockInfos.Add(outStockLockInfo);
- details[i].LockQtyPcs = details[i].QtyPcs;
- break;
- }
-
+ item.LockQtyPcs += assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity);
+ Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, item, assignOutStocks[j], assignOutStocks[j].proStockInfoDetails.Sum(x => x.OutboundQuantity));
+ outProStockInfos.Add(outStockLockInfo);
}
- }
+ else
+ {
+ Dt_OutProStockInfo outStockLockInfo = _outProStockInfoService.GetOutStockLockInfo(proOutOrder, item, assignOutStocks[j], item.QtyPcs - detailAssignQuantity);
+ outProStockInfos.Add(outStockLockInfo);
+ item.LockQtyPcs = item.QtyPcs;
+ break;
+ }
+
+ //}
}
List<string> locationArr = outStocks.Select(x => x.LocationCode).ToList();
--
Gitblit v1.9.3