Phase0_Day2_volpro_side

This commit is contained in:
2026-05-16 23:24:41 +08:00
parent 1b2792f2ed
commit 0f0d0c6a9b
21 changed files with 963 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
using Quartz;
using Microsoft.Extensions.DependencyInjection;
namespace VolPro.Warehouse.Services;
public class HeartbeatMonitorJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
var sp = (IServiceProvider)context.JobDetail.JobDataMap["ServiceProvider"];
var gwSvc = sp.GetService<Igateway_nodesService>();
var devSvc = sp.GetService<Ibase_deviceService>();
var timeout = DateTime.Now.AddSeconds(-30);
var offlineNodes = await gwSvc.FindAsIQueryable(x => x.IsOnline == "在线" && x.LastHeartbeat < timeout)
.ToListAsync();
foreach (var node in offlineNodes)
{
node.IsOnline = "离线";
await gwSvc.UpdateAsync(node);
await devSvc.UpdateAsync(x => x.GatewayNodeId == node.NodeId,
x => new base_device { IsOnline = "离线" });
}
}
}