1
wangxinhui
2025-06-10 3443d00c1c23f84d8559e802a27eb9ba7ff0858a
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs
@@ -1,4 +1,5 @@
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using MailKit.Search;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,6 +9,7 @@
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.WareHouseEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
@@ -237,8 +239,8 @@
            }
            Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
            List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
            List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo }).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo, }).ToList();
            List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo }).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo }).ToList();
            Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x=>x.WarehouseId== outboundOrder.WarehouseId);
            List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
            List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
            foreach (var item in groupDetails)
@@ -253,6 +255,13 @@
                    throw new Exception($"未找到可分配库存");
                }
                List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out float residueQuantity);
                if (warehouse.WarehouseCode==WarehouseEnum.HA152.ToString())
                {
                    if (needQuantity< autoAssignStocks.Count)
                    {
                        throw new Exception($"系统超时,请稍后再试");
                    }
                }
                item.LockQuantity += needQuantity - residueQuantity;
                outStocks.AddRange(autoAssignStocks);
                float assignQuantity = needQuantity - residueQuantity;