wanshenmean
2026-03-30 894f6a1d5204ee40ef41c61da32820bd1178021e
fix(StockService): GroupPalletAsync正确调用MES BindContainer并检查结果

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
已修改1个文件
30 ■■■■■ 文件已修改
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
@@ -1,7 +1,9 @@
using SqlSugar;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_DTO.MES;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
@@ -33,6 +35,11 @@
        public IStockInfo_HtyService StockInfo_HtyService { get; }
        /// <summary>
        /// Mes接口服务
        /// </summary>
        public IMesService _mesService { get; }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="stockInfoDetailService">库存明细服务</param>
@@ -43,12 +50,14 @@
            IStockInfoDetailService stockInfoDetailService,
            IStockInfoService stockInfoService,
            IStockInfoDetail_HtyService stockInfoDetail_HtyService,
            IStockInfo_HtyService stockInfo_HtyService)
            IStockInfo_HtyService stockInfo_HtyService,
            IMesService mesService)
        {
            StockInfoDetailService = stockInfoDetailService;
            StockInfoService = stockInfoService;
            StockInfoDetail_HtyService = stockInfoDetail_HtyService;
            StockInfo_HtyService = stockInfo_HtyService;
            _mesService = mesService;
        }
        /// <summary>
@@ -120,6 +129,20 @@
                    Status = StockStatusEmun.组盘暂存.GetHashCode(),
                }).ToList();
                var bindRequest = new BindContainerRequest
                {
                    ContainerCode = stock?.TargetPalletNo,
                    EquipmentCode = "STK-GROUP-001",
                    ResourceCode = "STK-GROUP-001",
                    LocalTime = now,
                    OperationType = 0, // 0代表组盘
                    ContainerSfcList = details.Select(d => new ContainerSfcItem
                    {
                        Sfc = d.SerialNumber,
                        Location = d.InboundOrderRowNo.ToString(),
                    }).ToList()
                };
                return await ExecuteWithinTransactionAsync(async () =>
                {
                    var existingStock = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.TargetPalletNo);
@@ -140,6 +163,11 @@
                        Creater = "system",
                        Details = details
                    };
                    var mesResult = _mesService.BindContainer(bindRequest);
                    if (mesResult == null || !mesResult.IsSuccess)
                    {
                        return content.Error($"组盘成功,但MES绑定失败: {mesResult?.ErrorMessage ?? "未知错误"}");
                    }
                    result = StockInfoService.Repository.AddData(entity, x => x.Details);
                    return result ? content.OK("组盘成功") : content.Error("组盘失败");