From 96adc295cb04fd135d63d3a907f2732274f90965 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期二, 21 四月 2026 01:11:21 +0800
Subject: [PATCH] feat: 添加MES异步上传辅助服务并重构相关代码
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs
index cac934b..3f0f31d 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs
@@ -1,4 +1,3 @@
-using System.Diagnostics;
using WIDESEA_Common.Constants;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.StockEnum;
@@ -60,7 +59,6 @@
/// </summary>
public async Task<WebResponseContent> OutboundFinishTaskAsync(CreateTaskDto taskDto)
{
- var stopwatch = Stopwatch.StartNew();
try
{
var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode);
@@ -139,14 +137,25 @@
ContainerCode = taskDto.PalletCode
};
string palletCode = taskDto.PalletCode;
+ string requestJson = outboundRequest.ToJson();
// Fire-and-forget: 寮傛鎵цMES鍑虹珯锛屼笉闃诲涓讳笟鍔¢�昏緫
- _ = Task.Run(() => MesUploadAsync(palletCode, MesUploadStatusEnum.鍑虹珯涓婁紶鎴愬姛, async () =>
- {
- return await Task.FromResult(string.IsNullOrWhiteSpace(token)
- ? _mesService.OutboundInContainer(outboundRequest)
- : _mesService.OutboundInContainer(outboundRequest, token));
- }));
+ _mesUploadHelper.FireAndForget(
+ palletCode,
+ MesUploadStatusEnum.鍑虹珯涓婁紶鎴愬姛,
+ "OutboundInContainer",
+ requestJson,
+ () =>
+ {
+ var result = string.IsNullOrWhiteSpace(token)
+ ? _mesService.OutboundInContainer(outboundRequest)
+ : _mesService.OutboundInContainer(outboundRequest, token);
+ return (
+ result?.Data?.IsSuccess ?? false,
+ Newtonsoft.Json.JsonConvert.SerializeObject(result),
+ result?.Data?.Msg ?? result?.ErrorMessage ?? "鏈煡閿欒"
+ );
+ });
var completeResult = await CompleteTaskAsync(task, "鍑哄簱瀹屾垚");
if (!completeResult.Status)
--
Gitblit v1.9.3