wangxinhui
2025-03-31 a6e0ea9ce13e791f3edae4edffeb3be3ccb760be
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderDetailService.cs
@@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
@@ -14,6 +15,7 @@
using WIDESEA_IRecordService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
using WIDESEA_OutboundRepository;
namespace WIDESEA_OutboundService
{
@@ -50,6 +52,12 @@
                    proStockInfoDetails.AddRange(item.proStockInfoDetails);
                }
                _stockInfoService.ProStockInfoDetailService.Repository.UpdateData(proStockInfoDetails);
                Dt_ProOutOrder proOutOrder = _proOutOrderRepository.QueryFirst(x => x.Id == proOutOrderDetails.FirstOrDefault().ProOrderId);
                if (proOutOrder.ProOrderStatus == OutOrderStatusEnum.未开始.ObjToInt())
                {
                    proOutOrder.ProOrderStatus = OutOrderStatusEnum.出库中.ObjToInt();
                    _proOutOrderRepository.UpdateData(proOutOrder);
                }
                BaseDal.UpdateData(proOutOrderDetails);
                List<Dt_OutProStockInfo> addOutStockLockInfos = outProStockInfos.Where(x => x.Id == 0).ToList();
@@ -117,12 +125,12 @@
                item.LockQtyPcs += needQty - residueQuantity;
                outStocks.AddRange(assignOutStocks);
                float assignQuantity = needQty - residueQuantity;
                bool isCanLot = !string.IsNullOrEmpty(item.PLot);
                bool isCanDate = !string.IsNullOrEmpty(item.DateCode);
                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 ? x.PLot == item.PLot : true)
                    && (isCanDate ? x.DateCode == item.DateCode : true))
                    && (isCanLot ? isCanLot : x.PLot == item.PLot)
                    && (isCanDate ? isCanDate : x.DateCode == item.DateCode))
                    .ToList();
                for (int i = 0; i < details.Count; i++)
@@ -130,19 +138,21 @@
                    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
                            && (item.PLot.IsNotEmptyOrNull() ? x.PLot == item.PLot : false)
                            && (item.DateCode.IsNotEmptyOrNull() ? x.DateCode == item.PLot : false)
                            && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity);//出库订单明细已分配数量
                            && (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
                            && (item.PLot.IsNotEmptyOrNull() ? x.PLot == item.PLot : false)
                            && (item.DateCode.IsNotEmptyOrNull() ? x.DateCode == item.PLot : false
                            && x.PalletCode == assignOutStocks[j].PalletCode)).Sum(x => x.AssignQuantity);
                            && (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
                            && (item.PLot.IsNotEmptyOrNull() ? x.PLot == item.PLot : false)
                            && (item.DateCode.IsNotEmptyOrNull() ? x.DateCode == item.PLot : false && x.PalletCode == assignOutStocks[j].PalletCode)).Sum(x => x.AssignQuantity);//出库详情已分配数量
                            && (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)//如果出库详情已分配数量小于托盘已分配数量,则可以继续添加该托盘出库信息
                        {