pan
2025-12-03 1b80ac5c10cd02ac0fac487b4ab9a2c6b935f8ad
提交
已修改5个文件
110 ■■■■■ 文件已修改
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/PickingReturnController.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs
@@ -50,6 +50,6 @@
        Task<WebResponseContent> GenerateOutboundBatchTasksAsync(int orderDetailId, decimal batchQuantity, string outStation);
        Task<WebResponseContent> GenerateAllocatOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews);
        Task<WebResponseContent> GenerateAllocatOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews, string station);
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs
@@ -558,8 +558,7 @@
        }
        public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>)
       AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
        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);
@@ -575,12 +574,9 @@
            decimal totalAssignedFromUserSelection = 0;
            // æŒ‰å…ˆè¿›å…ˆå‡ºæŽ’序用户选择的库存
            var userSelectedStocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(
                stockSelectViews.Select(x => x.PalletCode).ToList());
            var userSelectedStocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList());
            var sortedUserSelectedStocks = userSelectedStocks
                .OrderBy(x => x.CreateDate)
                .ToList();
            var sortedUserSelectedStocks = userSelectedStocks.OrderBy(x => x.CreateDate).ToList();
            // åˆ†é…ç”¨æˆ·é€‰æ‹©çš„库存
            foreach (var stock in sortedUserSelectedStocks)
@@ -596,9 +592,7 @@
                    outboundOrderDetail.BatchNo, outboundOrderDetail.SupplyCode);
                // ç¡®å®šåˆ†é…æ•°é‡ï¼šå–用户选择数量、可用数量和剩余需求的最小值
                var assignQuantity = Math.Min(
                    Math.Min(userSelection.UseableQuantity, availableQuantity),
                    remainingNeedQuantity);
                var assignQuantity = Math.Min(Math.Min(userSelection.UseableQuantity, availableQuantity),remainingNeedQuantity);
                if (assignQuantity <= 0) continue;
@@ -623,42 +617,57 @@
            }
            // å¦‚果用户选择的库存不够,自动分配剩余部分
            decimal autoAssignedQuantity = 0;
            if (remainingNeedQuantity > 0)
            {
                List<Dt_StockInfo> autoStocks = _stockService.StockInfoService.GetUseableStocks(
                    outboundOrderDetail.MaterielCode, outboundOrderDetail.BatchNo, "");
                //// å¯é€‰ï¼šè¿™é‡Œå¯ä»¥æ ¹æ®ä¸šåŠ¡éœ€æ±‚å†³å®šæ˜¯å¦å…è®¸è‡ªåŠ¨åˆ†é…
                //// å¦‚果要求严格按用户选择出库,可以抛出异常
                //// throw new Exception($"用户选择的库存数量不足,还需{remainingNeedQuantity},请重新选择");
                // æŽ’除用户已选择的托盘
                autoStocks = autoStocks
                    .Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode))
                    .ToList();
                //// å¦‚果需要自动分配,记录日志
                //_logger.LogInformation($"用户选择的库存数量不足,还需{remainingNeedQuantity},系统将自动分配");
                var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks(
                    autoStocks, outboundOrderDetail.MaterielCode, remainingNeedQuantity, out decimal residueQuantity);
                //List<Dt_StockInfo> autoStocks = _stockService.StockInfoService.GetUseableStocks(
                //    outboundOrderDetail.MaterielCode,
                //    outboundOrderDetail.BatchNo,
                //    "");
                // æ£€æŸ¥è‡ªåŠ¨åˆ†é…ç»“æžœ
                autoAssignedQuantity = remainingNeedQuantity - residueQuantity;
                if (autoAssignedQuantity <= 0 && remainingNeedQuantity > 0)
                {
                    // éƒ¨åˆ†åˆ†é…æ˜¯å¯ä»¥æŽ¥å—的,记录警告但不报错
                    _logger.LogWarning($"自动分配失败,剩余需求{remainingNeedQuantity}无法满足");
                }
                else if (autoAssignedQuantity > 0)
                {
                    outStocks.AddRange(autoAssignStocks);
                //// æŽ’除用户已选择且已分配的托盘
                //var assignedPalletCodes = outStocks.Select(x => x.PalletCode).ToList();
                //autoStocks = autoStocks
                //    .Where(x => !assignedPalletCodes.Contains(x.PalletCode))
                //    .ToList();
                    // ä¸ºè‡ªåŠ¨åˆ†é…çš„åº“å­˜åˆ›å»ºé”å®šè®°å½•
                    var autoLockInfos = CreateLockInfosForAutoAssign(outboundOrder, outboundOrderDetail, autoAssignStocks, stockAllocations);
                    outStockLockInfos.AddRange(autoLockInfos);
                }
                //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}无法满足");
                //}
            }
            // æ›´æ–°é”å®šæ•°é‡
            outboundOrderDetail.LockQuantity += totalAssignedFromUserSelection + autoAssignedQuantity;
            outboundOrderDetail.LockQuantity += totalAssignedFromUserSelection + totalAssignedFromUserSelection;
            // æ›´æ–°çŠ¶æ€
            UpdateOrderDetailStatus(outboundOrderDetail, remainingNeedQuantity - autoAssignedQuantity);
            UpdateOrderDetailStatus(outboundOrderDetail, remainingNeedQuantity);
            List<Dt_LocationInfo> locationInfos = _locationInfoService.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList());
@@ -682,17 +691,21 @@
            decimal remainingAssign = assignQuantity;
            // æŒ‰å…ˆè¿›å…ˆå‡ºåˆ†é…åº“存明细
            var sorteds = stock.Details
            var query = stock.Details.AsQueryable()
                .Where(d => d.MaterielCode == detail.MaterielCode &&
                           (d.StockQuantity - d.OutboundQuantity) > 0);
               // .OrderBy(d => d.CreateDate);             
            if (!string.IsNullOrEmpty(detail.BatchNo))
            {
                sorteds= stock.Details.Where(x => x.BatchNo == detail.BatchNo);
                query = query.Where(x => x.BatchNo == detail.BatchNo);
            }
            var sortedDetails= sorteds.ToList().OrderBy(d => d.CreateDate);
            // å¦‚果出库单有供应商要求,按供应商过滤
            if (!string.IsNullOrEmpty(detail.SupplyCode))
            {
                query = query.Where(d => d.SupplyCode == detail.SupplyCode);
            }
            var sortedDetails= query.ToList().OrderBy(d => d.CreateDate);
            foreach (var stockDetail in sortedDetails)
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -475,7 +475,14 @@
            }
        }
        public async Task<WebResponseContent> GenerateAllocatOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews)
        /// <summary>
        /// æ™ºä»“调智仓
        /// </summary>
        /// <param name="orderDetailId"></param>
        /// <param name="stockSelectViews"></param>
        /// <param name="station"></param>
        /// <returns></returns>
        public async Task<WebResponseContent> GenerateAllocatOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews, string station = null)
        {
            try
            {
@@ -502,7 +509,7 @@
                    return WebResponseContent.Instance.Error("找不到出库明细单据");
                }
                (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(outboundOrder.Details.First().Id, stockSelectViews);
                (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(outboundOrder.Details.First().Id, stockSelectViews,station);
                WebResponseContent content =await GenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5);
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/PickingReturnController.cs
@@ -26,7 +26,7 @@
        }
        /// <summary>
        /// é‡æ£€ç»„盘入库
        /// é‡æ£€  æ™ºä»“调智仓   ç»„盘入库
        /// </summary>
        /// <param name="materielGroupDTO"></param>
        /// <returns></returns>
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs
@@ -92,9 +92,9 @@
        /// <param name="stockSelectViews"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("GenerateAllocatOutboundTask"), AllowAnonymous]
        public async Task<WebResponseContent> GenerateAllocatOutboundTask(int orderDetailId, [FromBody] List<StockSelectViewDTO> stockSelectViews)
        public async Task<WebResponseContent> GenerateAllocatOutboundTask(int orderDetailId, string station, [FromBody] List<StockSelectViewDTO> stockSelectViews)
        {
            return await Service.GenerateAllocatOutboundTask(orderDetailId, stockSelectViews);
            return await Service.GenerateAllocatOutboundTask(orderDetailId, stockSelectViews,station);
        }
        /// <summary>