pan
4 天以前 e4e304318532574e418bc01b5a45b8836dac3e1a
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs
@@ -78,13 +78,14 @@
            // æŒ‰ç‰©æ–™å’Œæ‰¹æ¬¡åˆ†ç»„处理
            var groupDetails = outboundOrderDetails
                .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode })
                .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode,x.WarehouseCode })
                .Select(x => new
                {
                    MaterielCode = x.Key.MaterielCode,
                    BatchNo = x.Key.BatchNo,
                    SupplyCode = x.Key.SupplyCode,
                    Details = x.ToList(),
                    WarehouseCode=x.Key.WarehouseCode,
                    TotalNeedQuantity = CalculateReassignNeedQuantity(x.ToList())
                })
                .Where(x => x.TotalNeedQuantity > 0)
@@ -95,7 +96,7 @@
                var needQuantity = item.TotalNeedQuantity;
                // èŽ·å–å¯ç”¨åº“å­˜ï¼ˆæŒ‰å…ˆè¿›å…ˆå‡ºæŽ’åºï¼‰
                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode);
                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode,item.WarehouseCode, outboundOrder.FactoryArea);
                if (!stockInfos.Any())
                {
@@ -311,12 +312,13 @@
            // æŒ‰ç‰©æ–™å’Œæ‰¹æ¬¡åˆ†ç»„处理(这里只有一个明细)
            var groupDetails = new List<Dt_OutboundOrderDetail> { orderDetail }
                .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode })
                .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode ,x.WarehouseCode})
                .Select(x => new
                {
                    MaterielCode = x.Key.MaterielCode,
                    BatchNo = x.Key.BatchNo,
                    SupplyCode = x.Key.SupplyCode,
                    WarehouseCode=x.Key.WarehouseCode,
                    Details = x.ToList(),
                    TotalNeedQuantity = batchQuantity  // ä½¿ç”¨åˆ†æ‰¹æ•°é‡
                })
@@ -328,7 +330,7 @@
                var needQuantity = item.TotalNeedQuantity;
                // èŽ·å–å¯ç”¨åº“å­˜ï¼ˆæŒ‰å…ˆè¿›å…ˆå‡ºæŽ’åºï¼‰
                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode);
                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode,item.WarehouseCode,outboundOrder.FactoryArea);
                if (!stockInfos.Any())
                {
                    throw new Exception($"物料[{item.MaterielCode}]批次[{item.BatchNo}]未找到可分配库存");
@@ -669,47 +671,7 @@
          
            if (remainingNeedQuantity > 0)
            {
                //// å¯é€‰ï¼šè¿™é‡Œå¯ä»¥æ ¹æ®ä¸šåŠ¡éœ€æ±‚å†³å®šæ˜¯å¦å…è®¸è‡ªåŠ¨åˆ†é…
                //// å¦‚果要求严格按用户选择出库,可以抛出异常
                //// throw new Exception($"用户选择的库存数量不足,还需{remainingNeedQuantity},请重新选择");
                //// å¦‚果需要自动分配,记录日志
                //_logger.LogInformation($"用户选择的库存数量不足,还需{remainingNeedQuantity},系统将自动分配");
                //List<Dt_StockInfo> autoStocks = _stockService.StockInfoService.GetUseableStocks(
                //    outboundOrderDetail.MaterielCode,
                //    outboundOrderDetail.BatchNo,
                //    "");
                //// æŽ’除用户已选择且已分配的托盘
                //var assignedPalletCodes = outStocks.Select(x => x.PalletCode).ToList();
                //autoStocks = autoStocks
                //    .Where(x => !assignedPalletCodes.Contains(x.PalletCode))
                //    .ToList();
                //var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(
                //    autoStocks,
                //    outboundOrderDetail.MaterielCode,
                //    remainingNeedQuantity,
                //    out decimal residueQuantity);
                //if (autoAssignStocks != null && autoAssignStocks.Any())
                //{
                //    outStocks.AddRange(autoAssignStocks);
                //    // ä¸ºè‡ªåŠ¨åˆ†é…çš„åº“å­˜åˆ›å»ºé”å®šè®°å½•
                //    var autoLockInfos = CreateLockInfosForAutoAssign(outboundOrder, outboundOrderDetail, autoAssignStocks, stockAllocations);
                //    outStockLockInfos.AddRange(autoLockInfos);
                //    // æ›´æ–°å·²åˆ†é…æ•°é‡
                //    decimal autoAssignedQuantity = remainingNeedQuantity - residueQuantity;
                //    totalAssignedFromUserSelection += autoAssignedQuantity;
                //    remainingNeedQuantity = residueQuantity; // æ›´æ–°å‰©ä½™éœ€æ±‚
                //}
                //else if (remainingNeedQuantity > 0)
                //{
                //    _logger.LogWarning($"自动分配失败,剩余需求{remainingNeedQuantity}无法满足");
                //}
            }
            // æ›´æ–°é”å®šæ•°é‡
@@ -763,6 +725,8 @@
                           (d.StockQuantity - d.OutboundQuantity) > 0 &&
                           d.Barcode == barcode); // åªåˆ†é…æŒ‡å®šæ¡ç 
            query = query.Where(x => x.WarehouseCode == detail.WarehouseCode);
            if (!string.IsNullOrEmpty(detail.BatchNo))
            {
                query = query.Where(x => x.BatchNo == detail.BatchNo);