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

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs
index e3b9076..cea1c65 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs
@@ -100,6 +100,32 @@
             }
         }
 
+        private readonly SemaphoreSlim _asyncLock = new SemaphoreSlim(1, 1);
+
+        public async Task<WebResponseContent> BeginTranAsync(Func<Task<WebResponseContent>> funcAsync)
+        {
+            await _asyncLock.WaitAsync();
+            try
+            {
+                BeginTran();   // 鍋囪杩欐槸鍚屾鏂规硶锛屽惎鍔ㄤ簨鍔�
+                WebResponseContent content = await funcAsync();
+                if (content.Status)
+                    CommitTran();   // 鍚屾鎻愪氦
+                else
+                    RollbackTran(); // 鍚屾鍥炴粴
+                return content;
+            }
+            catch (Exception ex)
+            {
+                RollbackTran();
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+            finally
+            {
+                _asyncLock.Release();
+            }
+        }
+
         public void CommitTran()
         {
             lock (this)

--
Gitblit v1.9.3