编辑 | blame | 历史 | 原始文档

MES 电芯绑定解绑集成实现计划

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: 在 StockService 的组盘、换盘、拆盘操作中正确调用 MES 电芯绑定/解绑接口,并将 MES 调用纳入 WMS 事务内。

Architecture: 修改 StockService 三个方法,将 _mesService.BindContainer() / _mesService.UnBindContainer() 正确地用 await 调用并检查返回结果,MES 失败则事务回滚。

Tech Stack: ASP.NET Core 6.0, SqlSugar, IMesService


任务总览

任务 方法 操作
Task 1 GroupPalletAsync 修复 _mesService.BindContainer() 缺少 await 和结果检查
Task 2 ChangePalletAsync 添加解绑源托盘 + 绑定目标托盘
Task 3 SplitPalletAsync 添加解绑电芯

Task 1: 修复 GroupPalletAsync 中的 MES 调用

Files:
- Modify: WIDESEA_StockService/StockSerivce.cs:132-176

  • [ ] Step 1: 查看当前代码确认上下文

读取 StockSerivce.cs 第 132-176 行,确认 bindRequest 对象的构建和 _mesService.BindContainer() 调用的位置。

  • [ ] Step 2: 修改 BindContainer 调用为 await 并检查结果

将第 166 行:
csharp _mesService.BindContainer()

修改为:
csharp var mesResult = await _mesService.BindContainer(bindRequest); if (mesResult == null || !mesResult.Success) { return content.Error($"组盘成功,但MES绑定失败: {mesResult?.Message ?? "未知错误"}"); }

  • [ ] Step 3: 构建验证
cd WIDESEA_WMSServer && dotnet build WIDESEA_StockService/WIDESEA_StockService.csproj

确认无编译错误。

  • [ ] Step 4: 提交
git add WIDESEA_StockService/StockSerivce.cs
git commit -m "fix(StockService): GroupPalletAsync正确await MES BindContainer调用并检查结果"

Task 2: 修改 ChangePalletAsync 添加 MES 解绑和绑定调用

Files:
- Modify: WIDESEA_StockService/StockSerivce.cs:181-240

  • [ ] Step 1: 查看当前代码确认上下文

读取 StockSerivce.cs 第 181-240 行,确认:
- detailEntities 变量定义位置(包含要换盘的电芯明细)
- targetStock.Id 赋值位置
- return content.OK("换盘成功") 之前的逻辑

  • [ ] Step 2: 在更新库存明细前添加 UnBindContainer 调用

在第 231 行 var result = await StockInfoDetailService.Repository.UpdateDataAsync(detailEntities); 之前添加:

// 调用MES解绑源托盘电芯
var unbindRequest = new UnBindContainerRequest
{
    EquipmentCode = "STK-GROUP-001",
    ResourceCode = "STK-GROUP-001",
    LocalTime = DateTime.Now,
    ContainCode = stock.SourcePalletNo,
    SfcList = detailEntities.Select(d => d.SerialNumber).ToList()
};
var unbindResult = await _mesService.UnBindContainer(unbindRequest);
if (unbindResult == null || !unbindResult.Success)
{
    return content.Error($"换盘成功,但MES解绑失败: {unbindResult?.Message ?? "未知错误"}");
}
  • [ ] Step 3: 在更新库存明细后添加 BindContainer 调用

在第 231 行之后、return content.OK("换盘成功"); 之前添加:

// 调用MES绑定目标托盘电芯
var bindRequest = new BindContainerRequest
{
    ContainerCode = stock.TargetPalletNo,
    EquipmentCode = "STK-GROUP-001",
    ResourceCode = "STK-GROUP-001",
    LocalTime = DateTime.Now,
    OperationType = 0,
    ContainerSfcList = detailEntities.Select(d => new ContainerSfcItem
    {
        Sfc = d.SerialNumber,
        Location = d.InboundOrderRowNo.ToString()
    }).ToList()
};
var bindResult = await _mesService.BindContainer(bindRequest);
if (bindResult == null || !bindResult.Success)
{
    return content.Error($"换盘成功,但MES绑定失败: {bindResult?.Message ?? "未知错误"}");
}
  • [ ] Step 4: 构建验证
cd WIDESEA_WMSServer && dotnet build WIDESEA_StockService/WIDESEA_StockService.csproj

确认无编译错误。

  • [ ] Step 5: 提交
git add WIDESEA_StockService/StockSerivce.cs
git commit -m "feat(StockService): ChangePalletAsync添加MES解绑和绑定调用"

Task 3: 修改 SplitPalletAsync 添加 MES 解绑调用

Files:
- Modify: WIDESEA_StockService/StockSerivce.cs:245-286

  • [ ] Step 1: 查看当前代码确认上下文

读取 StockSerivce.cs 第 245-286 行,确认:
- detailEntities 变量定义和包含的电芯列表
- return content.OK("拆盘成功"); 之前的逻辑

  • [ ] Step 2: 在删除库存明细前添加 UnBindContainer 调用

在第 277 行 var result = await StockInfoDetailService.Repository.DeleteDataAsync(detailEntities); 之前添加:

// 调用MES解绑电芯
var unbindRequest = new UnBindContainerRequest
{
    EquipmentCode = "STK-GROUP-001",
    ResourceCode = "STK-GROUP-001",
    LocalTime = DateTime.Now,
    ContainCode = stock.SourcePalletNo,
    SfcList = detailEntities.Select(d => d.SerialNumber).ToList()
};
var unbindResult = await _mesService.UnBindContainer(unbindRequest);
if (unbindResult == null || !unbindResult.Success)
{
    return content.Error($"拆盘成功,但MES解绑失败: {unbindResult?.Message ?? "未知错误"}");
}
  • [ ] Step 3: 构建验证
cd WIDESEA_WMSServer && dotnet build WIDESEA_StockService/WIDESEA_StockService.csproj

确认无编译错误。

  • [ ] Step 4: 提交
git add WIDESEA_StockService/StockSerivce.cs
git commit -m "feat(StockService): SplitPalletAsync添加MES解绑调用"

Task 4: 整体构建验证

  • [ ] Step 1: 构建整个解决方案
cd WIDESEA_WMSServer && dotnet build WIDESEA_WMSServer.sln

确认无编译错误、无警告。

  • [ ] Step 2: 提交所有更改

如果之前没有合并提交,在此执行最终提交。


验证检查清单

  • [ ] GroupPalletAsyncawait _mesService.BindContainer() 正确 await
  • [ ] ChangePalletAsync 中先 UnBind 再 Bind,顺序正确
  • [ ] SplitPalletAsync 中 UnBind 在 Delete 之前
  • [ ] 所有 MES 调用检查 Success 属性
  • [ ] 错误信息格式统一:"{操作}成功,但MES{操作}失败: {错误信息}"
  • [ ] 解决方案构建无错误