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: 在 TaskService 的入库完成/出库完成方法中集成 MES 进站/出站调用,新增空托盘入库/出库完成方法。
Architecture: 在 ExecuteWithinTransactionAsync 事务内添加 MES 调用,MES 失败则事务回滚。
Tech Stack: ASP.NET Core 6.0, IMesService, ExecuteWithinTransactionAsync
| 任务 | 方法 | 操作 |
|---|---|---|
| Task 1 | InboundFinishTaskAsync |
添加 InboundInContainer 调用 |
| Task 2 | OutboundFinishTaskAsync |
添加 OutboundInContainer 调用 |
| Task 3 | InboundFinishTaskTrayAsync(新增) |
空托盘入库完成,无需 MES |
| Task 4 | OutboundFinishTaskTrayAsync(新增) |
空托盘出库完成,无需 MES |
TaskService 需注入 IMesService。检查现有构造函数是否已有:csharp private readonly IMesService _mesService;
如果不存在,需添加。
Files:
- Modify: WIDESEA_TaskInfoService/TaskService.cs(InboundFinishTaskAsync 方法,约第 215 行)
读取 TaskService.cs 第 199-240 行,确认 CompleteTaskAsync 调用的位置。
在 return await CompleteTaskAsync(task); 之前添加:
// 调用MES托盘进站
var inboundRequest = new InboundInContainerRequest
{
EquipmentCode = "STK-GROUP-001",
ResourceCode = "STK-GROUP-001",
LocalTime = DateTime.Now,
ContainerCode = taskDto.PalletCode
};
var inboundResult = _mesService.InboundInContainer(inboundRequest);
if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess)
{
return content.Error($"任务完成失败:MES进站失败: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "未知错误"}");
}
确认文件顶部已有 using WIDESEA_IBasicService; 和 using WIDESEA_DTO.MES;。如果没有,添加。
cd WIDESEA_WMSServer && dotnet build WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj
确认无编译错误。
git add WIDESEA_TaskInfoService/TaskService.cs
git commit -m "feat(TaskService): InboundFinishTaskAsync添加MES进站调用"
Files:
- Modify: WIDESEA_TaskInfoService/TaskService.cs(OutboundFinishTaskAsync 方法,约第 258 行)
读取 TaskService.cs 第 258-280 行,确认 CompleteTaskAsync 调用的位置。
在 return await CompleteTaskAsync(task); 之前添加:
// 调用MES托盘出站
var outboundRequest = new OutboundInContainerRequest
{
EquipmentCode = "STK-GROUP-001",
ResourceCode = "STK-GROUP-001",
LocalTime = DateTime.Now,
ContainerCode = taskDto.PalletCode,
ParamList = new List<ParamItem>()
};
var outboundResult = _mesService.OutboundInContainer(outboundRequest);
if (outboundResult == null || outboundResult.Data == null || !outboundResult.Data.IsSuccess)
{
return content.Error($"任务完成失败:MES出站失败: {outboundResult?.Data?.Msg ?? outboundResult?.ErrorMessage ?? "未知错误"}");
}
cd WIDESEA_WMSServer && dotnet build WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj
确认无编译错误。
git add WIDESEA_TaskInfoService/TaskService.cs
git commit -m "feat(TaskService): OutboundFinishTaskAsync添加MES出站调用"
Files:
- Modify: WIDESEA_TaskInfoService/TaskService.cs(在 InboundFinishTaskTrayAsync 方法之后添加新方法)
读取 TaskService.cs 第 330-350 行,确认 CreateTaskInboundTrayAsync 之后的位置。
在 CreateTaskInboundTrayAsync 方法之后添加:
/// <summary>
/// 空托盘入库完成
/// </summary>
public async Task<WebResponseContent> InboundFinishTaskTrayAsync(CreateTaskDto taskDto)
{
try
{
var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode);
if (task == null) return WebResponseContent.Instance.Error("未找到对应的任务");
var location = await _locationInfoService.GetLocationInfo(task.Roadway, task.TargetAddress);
if (location == null) return WebResponseContent.Instance.Error("未找到对应的货位");
var stockInfo = await _stockInfoService.GetStockInfoAsync(taskDto.PalletCode);
if (stockInfo == null) return WebResponseContent.Instance.Error("未找到对应库存信息");
return await ExecuteWithinTransactionAsync(async () =>
{
stockInfo.LocationCode = location.LocationCode;
stockInfo.LocationId = location.Id;
stockInfo.StockStatus = StockStatusEmun.空托盘库存.GetHashCode();
location.LocationStatus = LocationStatusEnum.InStock.GetHashCode();
var updateLocationResult = await _locationInfoService.UpdateLocationInfoAsync(location);
var updateStockResult = await _stockInfoService.UpdateStockAsync(stockInfo);
if (!updateLocationResult || !updateStockResult)
return WebResponseContent.Instance.Error("任务完成失败");
var deleteResult = await BaseDal.DeleteDataAsync(task);
if (!deleteResult) return WebResponseContent.Instance.Error("任务完成失败");
return WebResponseContent.Instance.OK("任务完成");
});
}
catch (Exception ex)
{
return WebResponseContent.Instance.Error($"完成任务失败: {ex.Message}");
}
}
cd WIDESEA_WMSServer && dotnet build WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj
确认无编译错误。
git add WIDESEA_TaskInfoService/TaskService.cs
git commit -m "feat(TaskService): 新增InboundFinishTaskTrayAsync空托盘入库完成方法"
Files:
- Modify: WIDESEA_TaskInfoService/TaskService.cs(在 OutboundFinishTaskTrayAsync 方法之后添加新方法)
读取 TaskService.cs 第 357-393 行,确认 GetOutBoundTrayTaskAsync 之后的位置。
在 GetOutBoundTrayTaskAsync 方法之后添加:
/// <summary>
/// 空托盘出库完成
/// </summary>
public async Task<WebResponseContent> OutboundFinishTaskTrayAsync(CreateTaskDto taskDto)
{
try
{
var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode);
if (task == null) return WebResponseContent.Instance.Error("未找到对应的任务");
var location = await _locationInfoService.GetLocationInfo(task.Roadway, task.SourceAddress);
if (location == null) return WebResponseContent.Instance.Error("未找到对应的货位");
var stockInfo = await _stockInfoService.GetStockInfoAsync(taskDto.PalletCode);
if (stockInfo == null) return WebResponseContent.Instance.Error("未找到对应库存信息");
return await ExecuteWithinTransactionAsync(async () =>
{
stockInfo.LocationId = 0;
stockInfo.LocationCode = null;
stockInfo.StockStatus = StockStatusEmun.出库完成.GetHashCode();
location.LocationStatus = LocationStatusEnum.Free.GetHashCode();
var updateLocationResult = await _locationInfoService.UpdateLocationInfoAsync(location);
var updateStockResult = await _stockInfoService.UpdateStockAsync(stockInfo);
if (!updateLocationResult || !updateStockResult)
return WebResponseContent.Instance.Error("任务完成失败");
var deleteResult = await BaseDal.DeleteDataAsync(task);
if (!deleteResult) return WebResponseContent.Instance.Error("任务完成失败");
return WebResponseContent.Instance.OK("任务完成");
});
}
catch (Exception ex)
{
return WebResponseContent.Instance.Error($"完成任务失败: {ex.Message}");
}
}
cd WIDESEA_WMSServer && dotnet build WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj
确认无编译错误。
git add WIDESEA_TaskInfoService/TaskService.cs
git commit -m "feat(TaskService): 新增OutboundFinishTaskTrayAsync空托盘出库完成方法"
cd WIDESEA_WMSServer && dotnet build WIDESEA_WMSServer.sln
确认无编译错误、无警告。
InboundFinishTaskAsync 中 InboundInContainer 在 CompleteTaskAsync 之前OutboundFinishTaskAsync 中 OutboundInContainer 在 CompleteTaskAsync 之前mesResult.Data?.IsSuccess"任务完成失败:MES{操作}失败: {错误信息}"InboundFinishTaskTrayAsync 和 OutboundFinishTaskTrayAsync 新增方法签名正确