pan
2025-11-25 b736d2069a049a0465a3a8814ab72afabb6a187c
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs
@@ -1,8 +1,13 @@
using WIDESEA_Common.LocationEnum;
using Microsoft.Extensions.Logging;
using SqlSugar;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicService;
using WIDESEA_IOutboundService;
using WIDESEA_IRecordService;
@@ -16,16 +21,17 @@
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        public IRepository<Dt_OutboundOrderDetail> Repository => BaseDal;
        private readonly IStockService _stockService;
        private readonly IOutStockLockInfoService _outStockLockInfoService;
        private readonly ILocationInfoService _locationInfoService;
        private readonly IBasicService _basicService;
        private readonly IRecordService _recordService;
        private readonly IOutboundOrderService _outboundOrderService;
        private readonly ILocationStatusChangeRecordService _locationStatusChangeRecordService;
        public OutboundOrderDetailService(IRepository<Dt_OutboundOrderDetail> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IBasicService basicService, IRecordService recordService, ILocationInfoService locationInfoService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IOutboundOrderService outboundOrderService) : base(BaseDal)
        private readonly ILogger<OutboundOrderDetailService> _logger;
        public OutboundOrderDetailService(IRepository<Dt_OutboundOrderDetail> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IBasicService basicService, IRecordService recordService, ILocationInfoService locationInfoService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IOutboundOrderService outboundOrderService, ILogger<OutboundOrderDetailService> logger) : base(BaseDal)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _stockService = stockService;
@@ -35,13 +41,16 @@
            _locationInfoService = locationInfoService;
            _locationStatusChangeRecordService = locationStatusChangeRecordService;
            _outboundOrderService = outboundOrderService;
            _logger = logger;
        }
        /// <summary>
        /// åˆ†é…å‡ºåº“库存  æŒ‰å…ˆè¿›å…ˆå‡ºåŽŸåˆ™åˆ†é…
        /// </summary>
        public (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails)
        public (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>)
       AssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails)
        {
            if (!outboundOrderDetails.Any())
            {
@@ -53,8 +62,9 @@
                throw new Exception("请勿同时操作多个单据明细");
            }
            var orderId = outboundOrderDetails.First().OrderId;
            var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>()
                .First(x => x.Id == outboundOrderDetails.First().OrderId);
                .First(x => x.Id == orderId);
            List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
            List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
@@ -62,13 +72,14 @@
            // æŒ‰ç‰©æ–™å’Œæ‰¹æ¬¡åˆ†ç»„处理
            var groupDetails = outboundOrderDetails
                .GroupBy(x => new { x.MaterielCode, x.BatchNo })
                .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode })
                .Select(x => new
                {
                    MaterielCode = x.Key.MaterielCode,
                    BatchNo = x.Key.BatchNo,
                    SupplyCode = x.Key.SupplyCode,
                    Details = x.ToList(),
                    TotalNeedQuantity = x.Sum(v => v.OrderQuantity - v.OverOutQuantity - v.LockQuantity)
                    TotalNeedQuantity = x.Sum(v => v.OrderQuantity - v.OverOutQuantity - v.LockQuantity - v.MoveQty)
                })
                .Where(x => x.TotalNeedQuantity > 0)
                .ToList();
@@ -78,79 +89,106 @@
                var needQuantity = item.TotalNeedQuantity;
                // èŽ·å–å¯ç”¨åº“å­˜ï¼ˆæŒ‰å…ˆè¿›å…ˆå‡ºæŽ’åºï¼‰
                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo);
                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode);
                if (!stockInfos.Any())
                {
                    throw new Exception($"物料[{item.MaterielCode}]批次[{item.BatchNo}]未找到可分配库存");
                }
                // åˆ†é…åº“存(按先进先出)
                List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(
                    stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
                var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
                if (residueQuantity > 0)
                // æ£€æŸ¥åˆ†é…ç»“果:如果完全无法分配(分配数量为0),则报错
                decimal allocatedQuantity = needQuantity - residueQuantity;
                if (allocatedQuantity <= 0)
                {
                    throw new Exception($"物料[{item.MaterielCode}]库存不足,需要{needQuantity},可用{needQuantity - residueQuantity}");
                    throw new Exception($"物料[{item.MaterielCode}]批次[{item.BatchNo}]库存不足,需要{needQuantity},但无法分配任何库存");
                }
                outStocks.AddRange(autoAssignStocks);
                // æŒ‰å…ˆè¿›å…ˆå‡ºåŽŸåˆ™åˆ†é…é”å®šæ•°é‡åˆ°å„ä¸ªæ˜Žç»†
                DistributeLockQuantityByFIFO(item.Details, autoAssignStocks, outStockLockInfos, outboundOrder);
                var distributionResult = DistributeLockQuantityByFIFO(item.Details, autoAssignStocks, stockAllocations, outStockLockInfos, outboundOrder);
                if (!distributionResult.success)
                {
                    throw new Exception(distributionResult.message);
                }
                // æ›´æ–°å‡ºåº“单明细状态
                UpdateOrderDetailStatus(item.Details, allocatedQuantity, needQuantity);
            }
            locationInfos.AddRange(_locationInfoService.GetLocationInfos(outStocks.Select(x => x.LocationCode).Distinct().ToList()));
            if (outStocks.Any())
            {
                locationInfos.AddRange(_locationInfoService.GetLocationInfos(
                    outStocks.Select(x => x.LocationCode).Distinct().ToList()));
            }
            return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos);
        }
        /// <summary>
        /// æŒ‰å…ˆè¿›å…ˆå‡ºåŽŸåˆ™åˆ†é…é”å®šæ•°é‡åˆ°å„ä¸ªæ˜Žç»†
        /// </summary>
        private void DistributeLockQuantityByFIFO(
            List<Dt_OutboundOrderDetail> details,
            List<Dt_StockInfo> assignStocks,
            List<Dt_OutStockLockInfo> outStockLockInfos,
            Dt_OutboundOrder outboundOrder)
        private (bool success, string message) DistributeLockQuantityByFIFO(
           List<Dt_OutboundOrderDetail> details,
           List<Dt_StockInfo> assignStocks,
           Dictionary<int, decimal> stockAllocations,
           List<Dt_OutStockLockInfo> outStockLockInfos,
           Dt_OutboundOrder outboundOrder)
        {
            // æŒ‰å…ˆè¿›å…ˆå‡ºæŽ’序出库单明细(假设先创建的明细需要优先满足)
            // æŒ‰å…ˆè¿›å…ˆå‡ºæŽ’序出库单明细(Id小的优先)
            var sortedDetails = details
                .OrderBy(x => x.Id) // æŒ‰ID排序,假设先创建的ID小
                .Where(d => d.OrderQuantity - d.OverOutQuantity - d.LockQuantity - d.MoveQty > 0)
                .OrderBy(x => x.Id)
                .ToList();
            // æŒ‰å…ˆè¿›å…ˆå‡ºæŽ’序库存(生产日期最早的优先)
            var sortedStockDetails = assignStocks
            if (!sortedDetails.Any())
                return (true, "无需分配");
            // èŽ·å–æ‰€æœ‰åˆ†é…äº†åº“å­˜çš„æ˜Žç»†ï¼ŒæŒ‰å…ˆè¿›å…ˆå‡ºæŽ’åº
            var allocatedStockDetails = assignStocks
                .SelectMany(x => x.Details)
                .Where(x => details.Any(d => d.MaterielCode == x.MaterielCode))
                .OrderBy(x => x.ProductionDate)
                .Where(x => stockAllocations.ContainsKey(x.Id) && stockAllocations[x.Id] > 0)
                .OrderBy(x => x.CreateDate)
                .ThenBy(x => x.StockId)
                .ToList();
            if (!allocatedStockDetails.Any())
            {
                return (false, "没有可分配的库存明细");
            }
            decimal totalNeedQuantity = sortedDetails.Sum(d =>
                d.OrderQuantity - d.OverOutQuantity - d.LockQuantity - d.MoveQty);
            decimal allocatedQuantity = 0;
            // ä¸ºæ¯ä¸ªåº“存明细创建分配记录
            foreach (var stockDetail in sortedStockDetails)
            foreach (var stockDetail in allocatedStockDetails)
            {
                var stockInfo = assignStocks.First(x => x.Id == stockDetail.StockId);
                var allocatedQuantity = stockDetail.OutboundQuantity; // è¿™ä¸ªåº“存明细分配的数量
                if (!stockAllocations.TryGetValue(stockDetail.Id, out decimal allocatedQuantityForStock))
                    continue;
                if (allocatedQuantity <= 0) continue;
                if (allocatedQuantityForStock <= 0) continue;
                var stockInfo = assignStocks.First(x => x.Id == stockDetail.StockId);
                decimal remainingAllocate = allocatedQuantityForStock;
                // æŒ‰é¡ºåºåˆ†é…ç»™å„个出库单明细
                decimal remainingAllocate = allocatedQuantity;
                foreach (var detail in sortedDetails)
                {
                    if (remainingAllocate <= 0) break;
                    // è®¡ç®—这个明细还需要分配的数量
                    var alreadyAssigned = outStockLockInfos
                        .Where(x => x.OrderDetailId == detail.Id && x.StockId == stockInfo.Id)
                        .Sum(x => x.AssignQuantity);
                    var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity - alreadyAssigned;
                    var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity - detail.MoveQty;
                    if (detailNeed <= 0) continue;
                    // åˆ†é…æ•°é‡
                    var assignQuantity = Math.Min(remainingAllocate, detailNeed);
                    // éªŒè¯æ¡ç æ˜¯å¦å­˜åœ¨
                    if (string.IsNullOrEmpty(stockDetail.Barcode))
                    {
                        return (false, $"库存明细ID[{stockDetail.Id}]的条码为空");
                    }
                    // åˆ›å»ºå‡ºåº“锁定信息
                    var lockInfo = _outStockLockInfoService.GetOutStockLockInfo(
@@ -160,130 +198,56 @@
                    // æ›´æ–°æ˜Žç»†çš„锁定数量
                    detail.LockQuantity += assignQuantity;
                    remainingAllocate -= assignQuantity;
                    allocatedQuantity += assignQuantity;
                }
                // å¦‚果还有剩余分配数量,说明逻辑有误
                // å¦‚果还有剩余分配数量,记录警告
                if (remainingAllocate > 0)
                {
                    throw new Exception($"库存分配逻辑错误,剩余未分配数量:{remainingAllocate}");
                }
            }
        }
/// <summary>
    /// åˆ›å»ºå‡ºåº“锁定信息
    /// </summary>
    private void CreateOutStockLockInfos(Dt_OutboundOrder outboundOrder,List<Dt_OutboundOrderDetail> details,
        List<Dt_StockInfo> assignStocks,List<Dt_OutStockLockInfo> outStockLockInfos)
        {
            foreach (var stock in assignStocks)
            {
                // èŽ·å–è¯¥åº“å­˜ä¸­ç›¸å…³ç‰©æ–™çš„å¯ç”¨æ¡ç ä¿¡æ¯
                var stockDetails = stock.Details
                    .Where(x => details.Any(d => d.MaterielCode == x.MaterielCode) &&
                               x.StockQuantity > x.OutboundQuantity)
                    .OrderBy(x => x.ProductionDate) // å…ˆè¿›å…ˆå‡º
                    .ToList();
                if (!stockDetails.Any()) continue;
                var stockAssignQuantity = stockDetails.Sum(x => x.OutboundQuantity);
                // æŸ¥æ‰¾è¿™ä¸ªåº“存已经分配的数量
                var existingAssign = outStockLockInfos
                    .Where(x => x.StockId == stock.Id &&
                               details.Any(d => d.Id == x.OrderDetailId))
                    .Sum(x => x.AssignQuantity);
                var availableAssign = stockAssignQuantity - existingAssign;
                if (availableAssign <= 0) continue;
                // æŒ‰å…ˆè¿›å…ˆå‡ºåŽŸåˆ™åˆ†é…æ¡ç 
                var barcodeAllocation = AllocateBarcodes(stockDetails, availableAssign);
                // åˆ†é…ç»™å„个明细
                foreach (var detail in details.Where(d => d.LockQuantity > 0))
                {
                    var alreadyAssigned = outStockLockInfos
                        .Where(x => x.OrderDetailId == detail.Id && x.StockId == stock.Id)
                        .Sum(x => x.AssignQuantity);
                    var canAssign = Math.Min(detail.LockQuantity - alreadyAssigned, availableAssign);
                    if (canAssign > 0)
                    {
                        // ä¸ºè¿™ä¸ªåˆ†é…ç¡®å®šæ¡ç 
                        var (barcode, barcodeQuantity) = GetBarcodeForAllocation(barcodeAllocation, canAssign);
                        var lockInfo = _outStockLockInfoService.GetOutStockLockInfo(
                            outboundOrder, detail, stock, canAssign, barcode,null);
                        outStockLockInfos.Add(lockInfo);
                        availableAssign -= canAssign;
                        // æ›´æ–°æ¡ç åˆ†é…è®°å½•
                        UpdateBarcodeAllocation(barcodeAllocation, barcode, barcodeQuantity);
                    }
                    if (availableAssign <= 0) break;
                }
            }
        }
        /// <summary>
        /// æŒ‰å…ˆè¿›å…ˆå‡ºåŽŸåˆ™åˆ†é…æ¡ç 
        /// </summary>
        private Dictionary<string, decimal> AllocateBarcodes(List<Dt_StockInfoDetail> stockDetails, decimal totalQuantity)
        {
            var allocation = new Dictionary<string, decimal>();
            decimal remainingQuantity = totalQuantity;
            foreach (var detail in stockDetails.OrderBy(x => x.ProductionDate))
            {
                if (remainingQuantity <= 0) break;
                decimal available = detail.StockQuantity - detail.OutboundQuantity;
                decimal allocate = Math.Min(available, remainingQuantity);
                allocation[detail.Barcode] = allocate;
                remainingQuantity -= allocate;
            }
            return allocation;
        }
        /// <summary>
        /// ä¸ºåˆ†é…èŽ·å–åˆé€‚çš„æ¡ç 
        /// </summary>
        private (string barcode, decimal quantity) GetBarcodeForAllocation(Dictionary<string, decimal> barcodeAllocation, decimal requiredQuantity)
        {
            foreach (var (barcode, quantity) in barcodeAllocation)
            {
                if (quantity >= requiredQuantity)
                {
                    return (barcode, requiredQuantity);
                    _logger.LogWarning($"库存分配后仍有剩余数量未分配: {remainingAllocate}, æ¡ç : {stockDetail.Barcode}");
                }
            }
            // å¦‚果单个条码数量不足,使用第一个条码
            var first = barcodeAllocation.First();
            return (first.Key, Math.Min(first.Value, requiredQuantity));
            // éªŒè¯æ˜¯å¦è‡³å°‘分配了一部分
            if (allocatedQuantity <= 0)
            {
                return (false, "库存分配失败,无法分配任何数量");
            }
            // è®°å½•分配结果
            if (allocatedQuantity < totalNeedQuantity)
            {
                _logger.LogWarning($"库存部分分配,需要{totalNeedQuantity},实际分配{allocatedQuantity}");
            }
            else
            {
                _logger.LogInformation($"库存完全分配,分配数量{allocatedQuantity}");
            }
            return (true, "分配成功");
        }
        /// <summary>
        /// æ›´æ–°æ¡ç åˆ†é…è®°å½•
        /// </summary>
        private void UpdateBarcodeAllocation(Dictionary<string, decimal> barcodeAllocation, string barcode, decimal usedQuantity)
        private void UpdateOrderDetailStatus(List<Dt_OutboundOrderDetail> details,
    decimal allocatedQuantity, decimal needQuantity)
        {
            if (barcodeAllocation.ContainsKey(barcode))
            foreach (var detail in details)
            {
                barcodeAllocation[barcode] -= usedQuantity;
                if (barcodeAllocation[barcode] <= 0)
                var detailNeed = detail.OrderQuantity - detail.LockQuantity - detail.OverOutQuantity - detail.MoveQty;
                if (detailNeed <= 0)
                {
                    barcodeAllocation.Remove(barcode);
                    // è¯¥æ˜Žç»†å·²å®Œå…¨åˆ†é…
                    detail.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt();
                }
                else if (allocatedQuantity < needQuantity)
                {
                    // æ•´ä½“部分分配,该明细可能还有需求
                    detail.OrderDetailStatus = OrderDetailStatusEnum.AssignOverPartial.ObjToInt();
                }
                else
                {
                    // æ•´ä½“完全分配
                    detail.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt();
                }
            }
        }
@@ -297,8 +261,8 @@
        /// <param name="locationStatus"></param>
        /// <param name="tasks"></param>
        /// <returns></returns>
        public WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_OutboundOrderDetail> outboundOrderDetails,
            List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos,
        public WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_OutboundOrderDetail> outboundOrderDetails,
            List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos,
            LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null)
        {
            try
@@ -306,7 +270,7 @@
                // æ›´æ–°åº“存状态
                stockInfos.ForEach(x => x.StockStatus = (int)StockStatusEmun.出库锁定);
                _stockService.StockInfoService.Repository.UpdateData(stockInfos);
                // æ›´æ–°åº“存明细
                var stockDetails = stockInfos.SelectMany(x => x.Details).ToList();
                _stockService.StockInfoDetailService.Repository.UpdateData(stockDetails);
@@ -341,5 +305,102 @@
            }
        }
        public override PageGridData<Dt_OutboundOrderDetail> GetPageData(PageDataOptions options)
        {
            //var  pageGridData = base.GetPageData(options);
            ISugarQueryable<Dt_OutboundOrderDetail> sugarQueryable1 = BaseDal.Db.Queryable<Dt_OutboundOrderDetail>();
            if (!string.IsNullOrEmpty(options.Wheres))
            {
                List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
                int totalCount = 0;
                if (searchParametersList.Count > 0)
                {
                    {
                        SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_InboundOrderDetail.OrderId).FirstLetterToLower());
                        if (searchParameters != null)
                        {
                            sugarQueryable1 = sugarQueryable1.Where(x => x.OrderId == searchParameters.Value.ObjToInt());
                            var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount);
                            return new PageGridData<Dt_OutboundOrderDetail>(totalCount, dataList);
                        }
                    }
                }
            }
            return new PageGridData<Dt_OutboundOrderDetail>();
        }
        public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
        {
            (bool, string) checkResult = CheckSelectStockDeital(outboundOrderDetail, stockSelectViews);
            if (!checkResult.Item1) throw new Exception(checkResult.Item2);
            Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
            var originalNeedQuantity = outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity - outboundOrderDetail.MoveQty;
            var needQuantity = originalNeedQuantity;
            List<Dt_StockInfo> outStocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList());
            var assignQuantity = 0m;
            outStocks.ForEach(x =>
            {
                x.Details.ForEach(v =>
                {
                    assignQuantity += v.StockQuantity - v.OutboundQuantity;
                });
            });
            outboundOrderDetail.LockQuantity += assignQuantity;
            outStocks.ForEach(x =>
            {
                x.Details.ForEach(v =>
                {
                    v.OutboundQuantity = v.StockQuantity;
                });
            });
            needQuantity -= assignQuantity;
            if (outboundOrderDetail.OrderQuantity > outboundOrderDetail.LockQuantity)
            {
                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode, outboundOrderDetail.BatchNo, "");
                stockInfos = stockInfos.Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode)).ToList();
                var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(stockInfos, outboundOrderDetail.MaterielCode, needQuantity, out decimal residueQuantity);
                outboundOrderDetail.LockQuantity += needQuantity - residueQuantity;
                outStocks.AddRange(autoAssignStocks);
                outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt();
                if (residueQuantity > 0)
                {
                    outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.AssignOverPartial.ObjToInt();
                }
            }
            List<Dt_OutStockLockInfo> outStockLockInfos = _outStockLockInfoService.GetOutStockLockInfos(outboundOrder, outboundOrderDetail, outStocks);
            List<Dt_LocationInfo> locationInfos = _locationInfoService.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList());
            return (outStocks, outboundOrderDetail, outStockLockInfos, locationInfos);
        }
        private (bool, string) CheckSelectStockDeital(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
        {
            if (outboundOrderDetail == null)
            {
                return (false, "未找到出库单明细信息");
            }
            if (outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt() && outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt())
            {
                return (false, "该明细不可操作");
            }
            //if (stockSelectViews.Sum(x => x.UseableQuantity) > outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity - outboundOrderDetail.MoveQty)
            //{
            //    return (false, "选择数量超出单据数量");
            //}
            return (true, "成功");
        }
    }
}