helongyang
2025-07-07 b7796f5e4d6594976ea948905af769eca863f27c
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesOutboundOrderService.cs
@@ -60,18 +60,19 @@
            float originalNeedQuantity = mesOutboundOrder.OrderQuantity;
            float needQuantity = originalNeedQuantity;
            //获取库存
            List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesOutboundOrder.MaterialCode, "", mesOutboundOrder.WarehouseId);
            if (!stockInfos.Any())
            {
                throw new Exception($"未找到可分配库存");
            }
            List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesOutboundOrder.MaterialCode, needQuantity, out float residueQuantity);
            mesOutboundOrder.LockQuantity += needQuantity - residueQuantity;
            if (residueQuantity>0)
            {
                throw new Exception($"库存不足");
            }
            autoAssignStocks.OrderBy(x => x.Details.FirstOrDefault()?.StockQuantity).ToList();
            outStocks.AddRange(autoAssignStocks);
            float assignQuantity = needQuantity - residueQuantity;
            float orderQuantity = mesOutboundOrder.OrderQuantity;
            for (int j = 0; j < autoAssignStocks.Count; j++)
            {
                float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesOutboundOrder.MaterialCode).Sum(x => x.AssignQuantity);//出库订单明细已分配数量