skeleton only until Phase2 integration
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user