From 20529bc6bc67d63c5f248fbe923558efb57a435b Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 13:43:37 +0800
Subject: [PATCH] feat(SignalR): 创建 StockHub 实现库存实时更新
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs | 4 ++++
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Hubs/StockHub.cs | 24 ++++++++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Hubs/StockHub.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Hubs/StockHub.cs
new file mode 100644
index 0000000..d5208b1
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Hubs/StockHub.cs
@@ -0,0 +1,24 @@
+using Microsoft.AspNetCore.SignalR;
+using System.Threading.Tasks;
+
+namespace WIDESEA_WMSServer.Hubs
+{
+ public class StockHub : Hub
+ {
+ /// <summary>
+ /// 鍙戦�佸簱瀛樻洿鏂�
+ /// </summary>
+ public async Task SendStockUpdate(StockUpdateDTO update)
+ {
+ await Clients.All.SendAsync("StockUpdated", update);
+ }
+ }
+
+ public class StockUpdateDTO
+ {
+ public int LocationId { get; set; }
+ public int WarehouseId { get; set; }
+ public float StockQuantity { get; set; }
+ public int StockStatus { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
index e5332e1..59cbd0a 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
@@ -99,6 +99,8 @@
options.Filters.Add(typeof(ActionExecuteFilter));
});
+builder.Services.AddSignalR();
+
builder.Services.AddScoped<HttpClientHelper>();
builder.Services.AddAuthorizationSetup();
@@ -174,4 +176,6 @@
app.MapControllers();
+app.MapHub<WIDESEA_WMSServer.Hubs.StockHub>("/stockHub");
+
app.Run();
--
Gitblit v1.9.3