pan
2025-11-17 f5df33d51a8555d709a4e8369fa98ce70759ddfc
提交
已修改11个文件
590 ■■■■■ 文件已修改
项目代码/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_DTO/Task/WMSTaskDTO.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundPickingService.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs 467 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundPickingController.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue
@@ -30,7 +30,7 @@
          <el-button type="info" @click="openRevertSplitDialog">撤销拆包</el-button>
      
          <el-button type="primary" @click="openBatchReturnDialog">回库</el-button>
          <el-button type="danger" @click="handleDirectOutbound">直接出库</el-button>
          <!-- <el-button type="danger" @click="handleDirectOutbound">直接出库</el-button>  -->
        </div>
      </el-card>
@@ -42,7 +42,7 @@
        <div class="summary-info">
          <el-tag type="warning">未拣选条数: {{summary.unpickedCount}}</el-tag>
          <el-tag type="danger">未拣选数量: {{summary.unpickedQuantity}}</el-tag>
          <el-tag type="success">已拣选条数: {{summary.pickedCount}}</el-tag>
    <!--       <el-tag type="success">已拣选条数: {{summary.pickedCount}}</el-tag> -->
          <el-tag type="info">托盘状态: {{palletStatus}}</el-tag>
        </div>
      </el-card>
@@ -552,7 +552,7 @@
      }
    },
    // æ‰¹é‡å›žåº“托盘码扫码
    // å›žåº“托盘码扫码
    onBatchReturnPalletScan() {
      if (!this.batchReturnForm.palletCode) return;
      
@@ -564,7 +564,7 @@
      }
    },
    // æ‰¹é‡å›žåº“确认
    // å›žåº“确认
    async handleBatchReturnConfirm() {
      // è¡¨å•验证
      if (this.$refs.batchReturnFormRef) {
@@ -587,25 +587,25 @@
      }
    },
    
    // æäº¤æ‰¹é‡å›žåº“请求
    // æäº¤å›žåº“请求
    async submitBatchReturn() {
      this.batchReturnLoading = true;
      
      try {
        const res = await this.http.post('/api/OutboundPicking/batch-return-to-stock', {
        const res = await this.http.post('/api/OutboundPicking/return-to-stock', {
          orderNo: this.batchReturnForm.orderNo,
          palletCode: this.batchReturnForm.palletCode
        });
        
        if (res.status) {
          this.$message.success('批量回库成功');
          this.$message.success('回库成功');
          this.showBatchReturnDialog = false;
          this.loadData();
        } else {
          this.$message.error(res.message || '批量回库失败');
          this.$message.error(res.message || '回库失败');
        }
      } catch (error) {
        this.$message.error('批量回库失败');
        this.$message.error('回库失败');
      } finally {
        this.batchReturnLoading = false;
      }
@@ -979,7 +979,7 @@
          barcode: this.returnForm.barcode
        });
        
        if (res.success) {
        if (res.status) {
          this.$message.success('回库成功');
          this.showReturnDialog = false;
          this.resetReturnForm();
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs
@@ -35,6 +35,11 @@
                var result = await PostAsync<MoveContainerRequest, ApiResponse<string>>(url, request);
                if (result != null && result.Code == 0)
                {
                    //{"code":0,"msg":"success","data":{"107":"TASK_ALREADY_EXIST"}}
                    if (result.Data.Contains("TASK_ALREADY_EXIST"))
                    {
                        return false;
                    }
                    return true;
                }
                return false;
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_DTO/Task/WMSTaskDTO.cs
@@ -72,4 +72,13 @@
        public int PalletType { get; set; }
    }
    public class GenerateOutboundTasksDto
    {
        public string outboundPlatform { get; set; }
        public int[] taskIds { get; set; }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundPickingService.cs
@@ -30,5 +30,7 @@
   
        Task<List<Dt_OutStockLockInfo>> GetUnpickedList(string orderNo, string palletCode);
        Task<WebResponseContent> ValidateBarcode(string barcode);
        Task<WebResponseContent> ReturnRemaining(string orderNo, string palletCode, string reason);
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs
@@ -44,7 +44,7 @@
        Task<WebResponseContent> TaskCompleted(string taskNum);
        Task<WebResponseContent> GenerateOutboundTasksAsync(int[] keys);
        Task<WebResponseContent> GenerateOutboundTasksAsync(int[] keys, string outStation);
 
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs
@@ -1,6 +1,7 @@
using Dm.filter;
using MailKit.Search;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -10,10 +11,12 @@
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Outbound;
using WIDESEA_IBasicService;
using WIDESEA_IOutboundService;
@@ -39,9 +42,26 @@
        private readonly IOutboundOrderService _outboundOrderService;
        private readonly ISplitPackageService _splitPackageService;
        private readonly IRepository<Dt_Task> _taskRepository;
        private readonly IESSApiService _eSSApiService;
        public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService, IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService, IRepository<Dt_Task> taskRepository) : base(BaseDal)
        private readonly ILogger<OutboundPickingService> _logger;
        private Dictionary<string, string> stations = new Dictionary<string, string>
        {
            {"2-1","2-9" },
            {"3-1","3-9" },
        };
        private Dictionary<string, string> movestations = new Dictionary<string, string>
        {
            {"2-1","2-5" },
            {"3-1","3-5" },
        };
        public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService, IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService, IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger) : base(BaseDal)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _stockInfoService = stockInfoService;
@@ -53,6 +73,8 @@
            _splitPackageService = splitPackageService;
            _outboundOrderService = outboundOrderService;
            _taskRepository = taskRepository;
            _eSSApiService = eSSApiService;
            _logger = logger;
        }
@@ -224,9 +246,29 @@
                  .FirstAsync();
                if (lockInfo == null)
                {
                    var splitBarcode = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
                   .Where(it => it.NewBarcode == barcode && it.Status == 1)
                   .FirstAsync();
                    if (splitBarcode != null)
                    {
                        // é€šè¿‡æ‹†åŒ…条码记录找到对应的出库锁定记录
                        lockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
                            .Where(it => it.ParentLockId == splitBarcode.OutStockLockInfoId)
                            .FirstAsync();
                        if (lockInfo == null)
                            throw new Exception($"未找到拆包条码{barcode}对应的出库锁定记录");
                    }
                    else
                    {
                    throw new Exception($"条码{barcode}不属于托盘{palletCode}或不存在待分拣记录");
                    }
                }
                if (lockInfo.PalletCode != palletCode)
                    throw new Exception($"条码{barcode}不属于托盘{palletCode}");
                var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
                        .Where(x => x.Barcode == barcode && x.StockId == lockInfo.StockId)
@@ -247,6 +289,15 @@
                lockInfo.Status = (int)OutLockStockStatusEnum.拣选完成;
                await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
                var splitBarcodeRecord = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
               .Where(it => it.NewBarcode == barcode)
               .FirstAsync();
                if (splitBarcodeRecord != null)
                {
                    splitBarcodeRecord.Status = 2;
                    await _splitPackageService.Db.Updateable(splitBarcodeRecord).ExecuteCommandAsync();
                }
                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
               .SetColumns(it => it.PickedQty == it.PickedQty + actualQty)
@@ -313,6 +364,395 @@
                    .ExecuteCommandAsync();
            }
        }
        /// <summary>
        /// å›žåº“操作
        /// </summary>
        //public async Task<WebResponseContent> ReturnRemaining(string orderNo, string palletCode, string reason)
        //{
        //    try
        //    {
        //        // 1. èŽ·å–æ‰€æœ‰æœªåˆ†æ‹£çš„å‡ºåº“é”å®šè®°å½•ï¼ŒåŒ…æ‹¬æ‹†åŒ…äº§ç”Ÿçš„è®°å½•
        //        var remainingLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
        //            .Where(it => it.OrderNo == orderNo && it.Status == 1)
        //            .ToListAsync();
        //        if (!remainingLocks.Any())
        //        {
        //            return WebResponseContent.Instance.Error("没有需要回库的剩余货物");
        //        }
        //        var tasks = new List<Dt_Task>();
        //        // æŒ‰æ‰˜ç›˜åˆ†ç»„
        //        var palletGroups = remainingLocks.GroupBy(x => x.PalletCode);
        //        //查询任务表
        //        var task = _taskRepository.QueryData(x => x.TaskNum == remainingLocks.First().TaskNum).FirstOrDefault();
        //        foreach (var group in palletGroups)
        //        {
        //            if (group.Key == palletCode)
        //            {
        //                var totalReturnQty = group.Sum(x => x.AssignQuantity - x.PickedQty);
        //                if (totalReturnQty <= 0) continue;
        //                // åˆ†é…æ–°è´§ä½
        //                var newLocation = _locationInfoService.AssignLocation();
        //                // æ›´æ–°å‡ºåº“锁定记录状态
        //                var lockIds = group.Where(x => x.PalletCode == palletCode).Select(x => x.Id).ToList();
        //                await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>()
        //                    .SetColumns(it => new Dt_OutStockLockInfo { Status = OutLockStockStatusEnum.回库中.ObjToInt() })
        //                    .Where(it => lockIds.Contains(it.Id))
        //                    .ExecuteCommandAsync();
        //                // æ›´æ–°æ‹†åŒ…条码记录状态
        //                var splitBarcodes = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
        //                    .Where(it => lockIds.Contains(it.OutStockLockInfoId))
        //                    .ToListAsync();
        //                foreach (var splitBarcode in splitBarcodes)
        //                {
        //                    splitBarcode.Status = 3;
        //                    await _splitPackageService.Db.Updateable(splitBarcode).ExecuteCommandAsync();
        //                }
        //                foreach (var lockInfo in group)
        //                {
        //                    if (lockInfo.PalletCode == palletCode)
        //                    {
        //                        decimal returnQty = lockInfo.AssignQuantity - lockInfo.PickedQty;
        //                        // æ£€æŸ¥åº“存记录是否存在
        //                        var existingStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
        //                            .Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
        //                            .FirstAsync();
        //                        if (existingStock != null)
        //                        {
        //                            // åº“存记录存在,恢复锁定数量
        //                            await _stockInfoDetailService.Db.Updateable<Dt_StockInfoDetail>()
        //                                .SetColumns(it => new Dt_StockInfoDetail
        //                                {
        //                                    OutboundQuantity = it.OutboundQuantity - returnQty
        //                                })
        //                                .Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
        //                                .ExecuteCommandAsync();
        //                        }
        //                        else
        //                        {
        //                            // åº“存记录不存在(可能是拆包产生的新条码),创建新的库存记录
        //                            var newStockDetail = new Dt_StockInfoDetail
        //                            {
        //                                StockId = lockInfo.StockId,
        //                                MaterielCode = lockInfo.MaterielCode,
        //                                OrderNo = lockInfo.OrderNo,
        //                                BatchNo = lockInfo.BatchNo,
        //                                StockQuantity = returnQty, // å®žé™…库存数量
        //                                OutboundQuantity = 0, // å›žåº“后不再锁定
        //                                Barcode = lockInfo.CurrentBarcode,
        //                                InboundOrderRowNo = "0",
        //                                Status = StockStatusEmun.入库确认.ObjToInt(),
        //                            };
        //                            await _stockInfoDetailService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
        //                        }
        //                    }
        //                }
        //                Dt_Task newtask = new()
        //                {
        //                    CurrentAddress = stations[task.TargetAddress],
        //                    Grade = 0,
        //                    PalletCode = palletCode,
        //                    NextAddress = "",
        //                    OrderNo= task.OrderNo,
        //                    Roadway = newLocation.RoadwayNo,
        //                    SourceAddress = stations[task.TargetAddress],
        //                    TargetAddress = newLocation.LocationCode,
        //                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
        //                    TaskType = TaskTypeEnum.InPick.ObjToInt(),
        //                    // TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
        //                    PalletType = task.PalletType,
        //                    WarehouseId = task.WarehouseId,
        //                };
        //                tasks.Add(newtask);
        //            }
        //        }
        //        try
        //        {
        //            await _taskRepository.Db.Insertable(tasks).ExecuteCommandAsync();
        //            //删除 å‡ºåº“çš„  task
        //            //给 ess  æµåŠ¨ä¿¡å·  å’Œåˆ›å»ºä»»åŠ¡
        //        }
        //        catch (Exception ex)
        //        {
        //        }
        //        return WebResponseContent.Instance.OK();
        //    }
        //    catch (Exception ex)
        //    {
        //        return WebResponseContent.Instance.Error($"回库操作失败: {ex.Message}");
        //    }
        //}
        public async Task<WebResponseContent> ReturnRemaining(string orderNo, string palletCode, string reason)
        {
            try
            {
                // 1. èŽ·å–æ‰€æœ‰æœªåˆ†æ‹£çš„å‡ºåº“é”å®šè®°å½•ï¼ŒåŒ…æ‹¬æ‹†åŒ…äº§ç”Ÿçš„è®°å½•
                var remainingLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
                    .Where(it => it.OrderNo == orderNo && it.Status == 1)
                    .ToListAsync();
                var stockinfo = _stockInfoService.Db.Queryable<Dt_StockInfo>().First(x => x.PalletCode == palletCode);
                // 2. æ£€æŸ¥æ‰˜ç›˜ä¸Šæ˜¯å¦æœ‰å…¶ä»–非出库货物(库存货物)
                var palletStockGoods = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
                    .Where(it => it.StockId == stockinfo.Id && it.Status == StockStatusEmun.入库确认.ObjToInt())
                    .Where(it => it.OutboundQuantity == 0 || it.OutboundQuantity < it.StockQuantity) // æœªå®Œå…¨å‡ºåº“çš„
                    .ToListAsync();
                // 3. å¦‚果没有需要回库的货物(既无未分拣出库货物,也无其他库存货物)
                if (!remainingLocks.Any() && !palletStockGoods.Any())
                {
                    return WebResponseContent.Instance.Error("没有需要回库的剩余货物");
                }
                var tasks = new List<Dt_Task>();
                // æŸ¥è¯¢ä»»åŠ¡è¡¨
                var task = remainingLocks.Any()
                    ? _taskRepository.QueryData(x => x.TaskNum == remainingLocks.First().TaskNum).FirstOrDefault()
                    : _taskRepository.QueryData(x => x.PalletCode == palletCode).FirstOrDefault();
                if (task == null)
                {
                    return WebResponseContent.Instance.Error("未找到对应的任务信息");
                }
                var firstlocation = _locationInfoService.Db.Queryable<Dt_LocationInfo>().First(x => x.LocationCode == task.SourceAddress);
                decimal totalReturnQty = 0;
                var hasRemainingLocks = remainingLocks.Any(x => x.PalletCode == palletCode);
                // æƒ…况1:处理未分拣的出库锁定记录
                if (hasRemainingLocks)
                {
                    var palletLocks = remainingLocks.Where(x => x.PalletCode == palletCode).ToList();
                    totalReturnQty = palletLocks.Sum(x => x.AssignQuantity - x.PickedQty);
                    if (totalReturnQty > 0)
                    {
                        // åˆ†é…æ–°è´§ä½
                        var newLocation = _locationInfoService.AssignLocation(firstlocation.LocationType);
                        // æ›´æ–°å‡ºåº“锁定记录状态
                        var lockIds = palletLocks.Select(x => x.Id).ToList();
                        await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>()
                            .SetColumns(it => new Dt_OutStockLockInfo { Status = OutLockStockStatusEnum.回库中.ObjToInt() })
                            .Where(it => lockIds.Contains(it.Id))
                            .ExecuteCommandAsync();
                        // æ›´æ–°æ‹†åŒ…条码记录状态
                        var splitBarcodes = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
                            .Where(it => lockIds.Contains(it.OutStockLockInfoId))
                            .ToListAsync();
                        foreach (var splitBarcode in splitBarcodes)
                        {
                            splitBarcode.Status = 3;
                            await _splitPackageService.Db.Updateable(splitBarcode).ExecuteCommandAsync();
                        }
                        // å¤„理库存记录
                        foreach (var lockInfo in palletLocks)
                        {
                            decimal returnQty = lockInfo.AssignQuantity - lockInfo.PickedQty;
                            // æ£€æŸ¥åº“存记录是否存在
                            var existingStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
                                .Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
                                .FirstAsync();
                            if (existingStock != null)
                            {
                                // åº“存记录存在,恢复锁定数量
                                await _stockInfoDetailService.Db.Updateable<Dt_StockInfoDetail>()
                                    .SetColumns(it => new Dt_StockInfoDetail
                                    {
                                        OutboundQuantity = it.OutboundQuantity - returnQty
                                    })
                                    .Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
                                    .ExecuteCommandAsync();
                            }
                            else
                            {
                                // åº“存记录不存在(可能是拆包产生的新条码),创建新的库存记录
                                var newStockDetail = new Dt_StockInfoDetail
                                {
                                    StockId = lockInfo.StockId,
                                    MaterielCode = lockInfo.MaterielCode,
                                    OrderNo = lockInfo.OrderNo,
                                    BatchNo = lockInfo.BatchNo,
                                    StockQuantity = returnQty,
                                    OutboundQuantity = 0,
                                    Barcode = lockInfo.CurrentBarcode,
                                    InboundOrderRowNo = "0",
                                    Status = StockStatusEmun.入库确认.ObjToInt(),
                                };
                                await _stockInfoDetailService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
                            }
                        }
                        // åˆ›å»ºå›žåº“任务
                        CreateReturnTask(tasks, task, palletCode, newLocation);
                    }
                }
                // æƒ…况2:出库货物已分拣完,但托盘上还有其他库存货物需要回库
                if (!hasRemainingLocks && palletStockGoods.Any())
                {
                    // åˆ†é…æ–°è´§ä½
                    var newLocation = _locationInfoService.AssignLocation(firstlocation.LocationType);
                    // åˆ›å»ºå›žåº“任务
                    CreateReturnTask(tasks, task, palletCode, newLocation);
                    totalReturnQty = palletStockGoods.Sum(x => x.StockQuantity - x.OutboundQuantity);
                }
                // ä¿å­˜ä»»åŠ¡
                if (tasks.Any())
                {
                    try
                    {
                        await _taskRepository.Db.Insertable(tasks).ExecuteCommandAsync();
                        // ç»™ ESS æµåŠ¨ä¿¡å·å’Œåˆ›å»ºä»»åŠ¡
                        try
                        {
                            var result = await _eSSApiService.MoveContainerAsync(new WIDESEA_DTO.Basic.MoveContainerRequest
                            {
                                slotCode = movestations[task.TargetAddress],
                                containerCode = palletCode
                            });
                            if (result)
                            {
                                TaskModel esstask = new TaskModel()
                                {
                                    taskType = "putaway",
                                    taskGroupCode = "",
                                    groupPriority = 0,
                                    tasks = new List<TasksType>
                                    {
                                        new()
                                        {
                                            taskCode = tasks.First().TaskNum.ToString(),
                                            taskPriority = 0,
                                            taskDescribe = new TaskDescribeType {
                                                containerCode = palletCode,
                                                containerType = "CT_KUBOT_STANDARD",
                                                fromLocationCode = stations.GetValueOrDefault(task.TargetAddress) ?? "",
                                                toStationCode = "",
                                                toLocationCode = tasks.First().TargetAddress,
                                                deadline = 0, storageTag = ""
                                            }
                                        }
                                    }
                                };
                                var resulttask = await _eSSApiService.CreateTaskAsync(esstask);
                                _logger.LogInformation("ReturnRemaining åˆ›å»ºä»»åŠ¡è¿”å›ž:  " + resulttask);
                            }
                        }
                        catch (Exception ex)
                        {
                            _logger.LogInformation("ReturnRemaining åˆ›å»ºä»»åŠ¡è¿”å›ž catch err:  " + ex.Message);
                        }
                        return WebResponseContent.Instance.OK($"回库操作成功,共回库数量:{totalReturnQty}");
                    }
                    catch (Exception ex)
                    {
                        return WebResponseContent.Instance.Error($"创建回库任务失败: {ex.Message}");
                    }
                }
                return WebResponseContent.Instance.Error("未创建任何回库任务");
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error($"回库操作失败: {ex.Message}");
            }
        }
        /// <summary>
        /// åˆ›å»ºå›žåº“任务
        /// </summary>
        private void CreateReturnTask(List<Dt_Task> tasks, Dt_Task originalTask, string palletCode, Dt_LocationInfo newLocation)
        {
            Dt_Task newTask = new()
            {
                CurrentAddress = stations[originalTask.TargetAddress],
                Grade = 0,
                PalletCode = palletCode,
                NextAddress = "",
                OrderNo = originalTask.OrderNo,
                Roadway = newLocation.RoadwayNo,
                SourceAddress = stations[originalTask.TargetAddress],
                TargetAddress = newLocation.LocationCode,
                TaskStatus = TaskStatusEnum.New.ObjToInt(),
                TaskType = TaskTypeEnum.InPick.ObjToInt(),
                PalletType = originalTask.PalletType,
                WarehouseId = originalTask.WarehouseId,
            };
            tasks.Add(newTask);
        }
        /// <summary>
        /// æ£€æŸ¥æ‰˜ç›˜æ˜¯å¦éœ€è¦å›žåº“的辅助方法
        /// </summary>
        public async Task<bool> CheckPalletNeedReturn(string orderNo, string palletCode)
        {
            // 1. æ£€æŸ¥æ˜¯å¦æœ‰æœªåˆ†æ‹£çš„出库记录
            var hasUnpickedLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
                .Where(it => it.OrderNo == orderNo && it.PalletCode == palletCode && it.Status == 1)
                .AnyAsync();
            if (hasUnpickedLocks)
                return true;
            // 2. æ£€æŸ¥å‡ºåº“是否已完成但托盘还有库存货物
            var outboundFinished = !await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
                .Where(it => it.PalletCode == palletCode && it.Status == 1)
                .AnyAsync();
            var stockinfo = _stockInfoService.Db.Queryable<Dt_StockInfo>().First(x => x.PalletCode == palletCode);
            var hasRemainingGoods = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
                .Where(it => it.StockId == stockinfo.Id && it.Status == StockStatusEmun.入库确认.ObjToInt())
                .Where(it => it.OutboundQuantity == 0 || it.OutboundQuantity < it.StockQuantity)
                .AnyAsync();
            return outboundFinished && hasRemainingGoods;
        }
        // å–消拣选功能
        public async Task<WebResponseContent> CancelPicking(string orderNo, string palletCode, string barcode)
        {
@@ -394,36 +834,17 @@
            var list = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
                .Where(x => x.OrderNo == orderNo &&
                           x.PalletCode == palletCode &&
                           x.Status == 2)
                           x.Status == 6)
                .ToListAsync();
            return list;
        }
        public async Task<object> GetPickingSummary(string orderNo, string palletCode)
        {
            var summary = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
                .Where(x => x.OrderNo == orderNo &&
                           x.PalletCode == palletCode && x.Status == 1)
                .GroupBy(x => new { x.PalletCode, x.MaterielCode })
                .Select(x => new
                {
                    PalletCode = x.PalletCode,
                    MaterielCode = x.MaterielCode,
                    UnpickedCount = SqlFunc.AggregateCount(x.Id),
                    UnpickedQuantity = SqlFunc.AggregateSum(x.AssignQuantity) - SqlFunc.AggregateSum(x.PickedQty)
                })
                .FirstAsync();
            return summary;
        }
        // èŽ·å–æ‹£é€‰æ±‡æ€»
        public async Task<object> GetPickingSummary(ConfirmPickingDto dto)
        {
            var picked = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
             .WhereIF(!string.IsNullOrEmpty(dto.OrderNo), x => x.OrderNo == dto.OrderNo)
             .WhereIF(!string.IsNullOrEmpty(dto.PalletCode), x => x.PalletCode == dto.PalletCode)
             .Where(x => x.Status == 2)
             .Where(x => x.Status == 6)
             .GroupBy(x => new { x.PalletCode, x.MaterielCode })
             .Select(x => new SummaryPickingDto
             {
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs
@@ -62,14 +62,32 @@
                    return WebResponseContent.Instance.Error($"拆包数量不能大于剩余锁定数量,剩余:{remainingLockQuantity}");
                var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
               .Where(x => x.Barcode == request.OriginalBarcode)
               .Where(x => x.Barcode == request.OriginalBarcode && x.StockId == lockInfo.StockId)
               .FirstAsync();
                if (stockDetail == null)
                    throw new Exception($"未找到条码{request.OriginalBarcode}对应的库存记录");
                var seq = await _dailySequenceService.GetNextSequenceAsync();
                // 3. ç”Ÿæˆæ–°æ¡ç 
                string newBarcode = "WSLOT" + DateTime.Now.ToString("yyyyMMdd") + seq.ToString()?.PadLeft(5, '0');
                decimal remainingQty = remainingLockQuantity - request.SplitQuantity;
                // ä¸ºæ‹†åŒ…产生的新条码创建库存记录
                var newStockDetail = new Dt_StockInfoDetail
                {
                    StockId = lockInfo.StockId,
                    MaterielCode = lockInfo.MaterielCode,
                    OrderNo = lockInfo.OrderNo,
                    BatchNo = lockInfo.BatchNo,
                    StockQuantity = remainingQty,
                    OutboundQuantity = remainingQty, // é”å®šå…¨éƒ¨æ•°é‡
                    Barcode = newBarcode,
                    InboundOrderRowNo = stockDetail.InboundOrderRowNo,
                };
                await _outStockLockInfoService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
                // 4. åˆ›å»ºæ–°çš„出库锁定信息(新条码)
                var newLockInfo = new Dt_OutStockLockInfo
                {
@@ -99,7 +117,7 @@
                await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteCommandAsync();
                // 5. æ›´æ–°åŽŸé”å®šä¿¡æ¯çš„åˆ†é…æ•°é‡ï¼ˆå‡å°‘æ‹†åŒ…æ•°é‡ï¼‰
                lockInfo.AssignQuantity -= request.SplitQuantity;
                lockInfo.AssignQuantity = request.SplitQuantity;
                await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
                // 6. è®°å½•拆包历史(用于追踪)
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -283,14 +283,45 @@
                }
            }
            catch (Exception ex) {
            catch (Exception ex)
            {
                _logger.LogInformation("InboundTaskCompleted å›žå†™MES失败:  " + ex.Message);
            }
            return WebResponseContent.Instance.OK();
        }
        public WebResponseContent OutboundTaskCompleted(Dt_Task task)
        {
            _logger.LogInformation($"TaskService  OutboundTaskCompleted: {task.TaskNum}");
            //查货位
            Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
            if (locationInfo == null)
            {
                return WebResponseContent.Instance.Error($"未找到对应的终点货位信息");
            }
            locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
            _locationInfoService.Repository.UpdateData(locationInfo);
            var outloks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>().Where(x => x.TaskNum == task.TaskNum).ToList();
            outloks.ForEach(o =>
            {
                o.Status = OutLockStockStatusEnum.已出库.ObjToInt();
            });
            _outStockLockInfoService.Db.Updateable(outloks).ExecuteCommand();
            var locationCodes = outloks.Select(it => it.LocationCode).Distinct().ToList();
            //_stockRepository.Db.Updateable<Dt_StockInfo>()
            //  .SetColumns(it => new Dt_StockInfo { StockStatus = StockStatusEmun.})
            //  .Where(it => locationCodes.Contains(it.LocationCode))
            //  .ExecuteCommand();
            return WebResponseContent.Instance.OK();
        }
        public async Task<WebResponseContent> InEmptyTaskCompleted(Dt_Task task)
        {
@@ -344,8 +375,14 @@
            }
        }
        public  WebResponseContent InPickTaskCompleted(Dt_Task task)
        {
            _logger.LogInformation($"TaskService  InPickTaskCompleted: {task.TaskNum}");
            return WebResponseContent.Instance.OK();
        }
        public async Task<WebResponseContent> OutEmptyTaskCompleted(Dt_Task task)
        {
            WebResponseContent content = new WebResponseContent();
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -131,7 +131,7 @@
        /// <param name="stockSelectViews"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int[] keys)
        public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int[] keys, string outStation)
        {
            List<Dt_Task> tasks = new List<Dt_Task>();
            List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id));
@@ -161,7 +161,7 @@
                        (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality,
                        _ => new TaskTypeEnum()
                    };
                    tasks = GetTasks(result.Item1, typeEnum);
                    tasks = GetTasks(result.Item1, typeEnum, outStation);
                    tasks.ForEach(x =>
                    {
                        x.OrderNo = outboundOrder.OrderNo;
@@ -304,7 +304,7 @@
        /// </summary>
        /// <param name="stockInfos"></param>
        /// <returns></returns>
        public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType)
        public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType, string outStation)
        {
            List<Dt_Task> tasks = new List<Dt_Task>();
            List<Dt_LocationInfo> locationInfos = _locationInfoService.Repository.QueryData(x => stockInfos.Select(x => x.LocationCode).Contains(x.LocationCode));
@@ -325,7 +325,7 @@
                            NextAddress = "",
                            Roadway = locationInfo.RoadwayNo,
                            SourceAddress = stockInfo.LocationCode,
                            TargetAddress = "",
                            TargetAddress = outStation,
                            TaskStatus = TaskStatusEnum.New.ObjToInt(),
                            TaskType = taskType.ObjToInt(),
                            // TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
@@ -353,7 +353,7 @@
        /// </summary>
        /// <param name="keys">出库单明细主键</param>
        /// <returns></returns>
        public async Task<WebResponseContent> GenerateOutboundTasksAsync(int[] keys)
        public async Task<WebResponseContent> GenerateOutboundTasksAsync(int[] keys,string outStation)
        {
            try
            {
@@ -364,7 +364,7 @@
                List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
                List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
                (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys);
                (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys,outStation);
                if (result.Item2 != null && result.Item2.Count > 0)
                {
                    stockInfos.AddRange(result.Item2);
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/OutboundPickingController.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Autofac.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WIDESEA_Core;
using WIDESEA_Core.BaseController;
@@ -92,10 +93,9 @@
        [HttpPost("return-to-stock")]
        public async Task<WebResponseContent> ReturnToStock( )
        public async Task<WebResponseContent> ReturnToStock([FromBody] ConfirmPickingDto dto)
        {
            var data= "";
            return WebResponseContent.Instance.OK("", data);
            return await Service.ReturnRemaining(dto.OrderNo, dto.PalletCode, "");
        }
        [HttpPost("direct-outbound")]
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs
@@ -42,9 +42,9 @@
        /// <param name="keys"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("GenerateOutboundTasks"), AllowAnonymous]
        public async Task<WebResponseContent> GenerateOutboundTasks([FromBody] int[] keys)
        public async Task<WebResponseContent> GenerateOutboundTasks([FromBody] GenerateOutboundTasksDto data)
        {
            return await Service.GenerateOutboundTasksAsync(keys);
            return await Service.GenerateOutboundTasksAsync(data.taskIds,data.outboundPlatform);
        }
    }