From fac6be89f3a02270b7b4a1bbe1f0dc05788c368e Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期二, 21 四月 2026 13:19:53 +0800
Subject: [PATCH] Merge branch 'dev' of http://115.159.85.185:8098/r/SuZhouGuanHong/ShanMeiXinNengYuan into dev
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs | 73 ++++++++++++++++++++++--------------
1 files changed, 44 insertions(+), 29 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
index 0d17367..1e37368 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
@@ -1,6 +1,5 @@
锘縰sing Newtonsoft.Json;
using SqlSugar;
-using System.Diagnostics;
using WIDESEA_Common.Constants;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
@@ -54,6 +53,7 @@
public IMesService _mesService { get; }
private readonly IMesLogService _mesLogService;
+ private readonly IMesUploadHelper _mesUploadHelper;
/// <summary>
/// 鏋勯�犲嚱鏁�
@@ -62,6 +62,7 @@
/// <param name="stockInfoService">搴撳瓨淇℃伅鏈嶅姟</param>
/// <param name="stockInfoDetail_HtyService">搴撳瓨鏄庣粏鍘嗗彶鏈嶅姟</param>
/// <param name="stockInfo_HtyService">搴撳瓨鍘嗗彶鏈嶅姟</param>
+ /// <param name="mesUploadHelper">MES寮傛涓婁紶杈呭姪鏈嶅姟</param>
public StockService(
IStockInfoDetailService stockInfoDetailService,
IStockInfoService stockInfoService,
@@ -70,7 +71,8 @@
IMesService mesService,
IWarehouseService warehouseService,
ISqlSugarClient sqlSugarClient,
- IMesLogService mesLogService)
+ IMesLogService mesLogService,
+ IMesUploadHelper mesUploadHelper)
{
StockInfoDetailService = stockInfoDetailService;
StockInfoService = stockInfoService;
@@ -80,6 +82,7 @@
_warehouseService = warehouseService;
SqlSugarClient = sqlSugarClient;
_mesLogService = mesLogService;
+ _mesUploadHelper = mesUploadHelper;
}
/// <summary>
@@ -435,7 +438,7 @@
}
}
- // 3. 璋冪敤MES瑙g粦
+ // 3. Fire-and-forget寮傛璋冪敤MES瑙g粦
var unbindRequest = new UnBindContainerRequest
{
EquipmentCode = equipmentCode,
@@ -444,13 +447,25 @@
ContainCode = palletCode,
SfcList = sfcList
};
- var unbindResult = string.IsNullOrWhiteSpace(token)
- ? _mesService.UnBindContainer(unbindRequest)
- : _mesService.UnBindContainer(unbindRequest, token);
- if (unbindResult == null || unbindResult.Data == null || !unbindResult.Data.IsSuccess)
- {
- return content.Error($"MES瑙g粦澶辫触: {unbindResult?.Data?.Msg ?? unbindResult?.ErrorMessage ?? "鏈煡閿欒"}");
- }
+ string requestJson = unbindRequest.ToJson();
+ var localToken = token;
+
+ _mesUploadHelper.FireAndForget(
+ palletCode,
+ MesUploadStatusEnum.鎷嗙洏涓婁紶鎴愬姛,
+ "UnBindContainer",
+ requestJson,
+ () =>
+ {
+ var result = string.IsNullOrWhiteSpace(localToken)
+ ? _mesService.UnBindContainer(unbindRequest)
+ : _mesService.UnBindContainer(unbindRequest, localToken);
+ return (
+ result?.Data?.IsSuccess ?? false,
+ System.Text.Json.JsonSerializer.Serialize(result),
+ result?.Data?.Msg ?? result?.ErrorMessage ?? "鏈煡閿欒"
+ );
+ });
// 4. 鍒犻櫎涓存椂琛ㄨ褰�
await SqlSugarClient.Deleteable<Dt_SplitTemp>().Where(t => t.PalletCode == palletCode).ExecuteCommandAsync();
@@ -472,7 +487,6 @@
public async Task<WebResponseContent> GroupPalletConfirmAsync(string palletCode, string deviceName)
{
WebResponseContent content = new WebResponseContent();
- var stopwatch = Stopwatch.StartNew();
try
{
if (string.IsNullOrWhiteSpace(palletCode))
@@ -518,24 +532,25 @@
}).ToList()
};
string requestJson = bindRequest.ToJson();
- var bindResult = string.IsNullOrWhiteSpace(token)
- ? _mesService.BindContainer(bindRequest)
- : _mesService.BindContainer(bindRequest, token);
- stopwatch.Stop();
- await _mesLogService.LogAsync(new MesApiLogDto
- {
- ApiType = "BindContainer",
- RequestJson = requestJson,
- ResponseJson = System.Text.Json.JsonSerializer.Serialize(bindResult),
- IsSuccess = bindResult.IsSuccess,
- ErrorMessage = bindResult.ErrorMessage,
- ElapsedMs = (int)stopwatch.ElapsedMilliseconds,
- Creator = "systeam"
- });
- if (bindResult == null || bindResult.Data == null || !bindResult.Data.IsSuccess)
- {
- return content.Error($"MES缁戝畾澶辫触: {bindResult?.Data?.Msg ?? bindResult?.ErrorMessage ?? "鏈煡閿欒"}");
- }
+ var localToken = token;
+
+ // 3. Fire-and-forget寮傛璋冪敤MES缁戝畾
+ _mesUploadHelper.FireAndForget(
+ palletCode,
+ MesUploadStatusEnum.缁勭洏涓婁紶鎴愬姛,
+ "BindContainer",
+ requestJson,
+ () =>
+ {
+ var result = string.IsNullOrWhiteSpace(localToken)
+ ? _mesService.BindContainer(bindRequest)
+ : _mesService.BindContainer(bindRequest, localToken);
+ return (
+ result?.Data?.IsSuccess ?? false,
+ System.Text.Json.JsonSerializer.Serialize(result),
+ result?.Data?.Msg ?? result?.ErrorMessage ?? "鏈煡閿欒"
+ );
+ });
return content.OK("鎵归噺缁勭洏纭鎴愬姛");
}
--
Gitblit v1.9.3