skeleton only until Phase2 integration

This commit is contained in:
2026-05-17 01:09:47 +08:00
parent 21c9565146
commit 25be653e79
5 changed files with 24 additions and 562 deletions

View File

@@ -1,31 +1,13 @@
using Quartz;
using Microsoft.Extensions.DependencyInjection;
using Warehouse.IRepositories;
using VolPro.Entity.DomainModels;
namespace VolPro.Warehouse.Services;
public class SyncDevicesJob : IJob
{
public async Task Execute(IJobExecutionContext context)
public Task Execute(IJobExecutionContext context)
{
var sp = (IServiceProvider)context.JobDetail.JobDataMap["ServiceProvider"];
var gwRepo = sp.GetService<Igateway_nodesRepository>();
var httpFactory = sp.GetService<IHttpClientFactory>();
var db = gwRepo.DbContext;
var onlineNodes = db.Queryable<gateway_nodes>()
.Where(x => x.IsOnline == "在线" && x.Enable == "启用" && x.BaseUrl != null)
.ToList();
foreach (var node in onlineNodes)
{
try
{
var http = httpFactory.CreateClient();
await http.PostAsync($"{node.BaseUrl}/api/gateway/devices/sync?adapter={node.AdapterTypes}", null);
}
catch { }
}
// TODO: Phase 2 联调时实现 — 定时设备同步
return Task.CompletedTask;
}
}