From 4506a1ed31e5d3c009ea5049f385ada6527bb595 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期二, 21 四月 2026 00:18:08 +0800
Subject: [PATCH] refactor(StockService): MES调用改为Task.Run异步执行

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 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 7d39b67..cac934b 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs
@@ -138,25 +138,15 @@
                         LocalTime = DateTime.Now,
                         ContainerCode = taskDto.PalletCode
                     };
-                    string requestJson = outboundRequest.ToJson();
-                    var outboundResult = string.IsNullOrWhiteSpace(token)
-                        ? _mesService.OutboundInContainer(outboundRequest)
-                        : _mesService.OutboundInContainer(outboundRequest, token);
-                    stopwatch.Stop();
-                    await _mesLogService.LogAsync(new MesApiLogDto
+                    string palletCode = taskDto.PalletCode;
+
+                    // Fire-and-forget: 寮傛鎵цMES鍑虹珯锛屼笉闃诲涓讳笟鍔¢�昏緫
+                    _ = Task.Run(() => MesUploadAsync(palletCode, MesUploadStatusEnum.鍑虹珯涓婁紶鎴愬姛, async () =>
                     {
-                        ApiType = "UnbindContainer",
-                        RequestJson = requestJson,
-                        ResponseJson = System.Text.Json.JsonSerializer.Serialize(outboundResult),
-                        IsSuccess = outboundResult.IsSuccess,
-                        ErrorMessage = outboundResult.ErrorMessage,
-                        ElapsedMs = (int)stopwatch.ElapsedMilliseconds,
-                        Creator = "systeam"
-                    });
-                    if (outboundResult == null || outboundResult.Data == null || !outboundResult.Data.IsSuccess)
-                    {
-                        return content.Error($"鍑哄簱瀹屾垚澶辫触锛歁ES鍑虹珯澶辫触: {outboundResult?.Data?.Msg ?? outboundResult?.ErrorMessage ?? "鏈煡閿欒"}");
-                    }
+                        return await Task.FromResult(string.IsNullOrWhiteSpace(token)
+                            ? _mesService.OutboundInContainer(outboundRequest)
+                            : _mesService.OutboundInContainer(outboundRequest, token));
+                    }));
 
                     var completeResult = await CompleteTaskAsync(task, "鍑哄簱瀹屾垚");
                     if (!completeResult.Status)

--
Gitblit v1.9.3