2026-03-02 10:47:02 +08:00
|
|
|
|
using Infrastructure.Cache;
|
|
|
|
|
|
using Infrastructure.CloudSdk.mqttmessagecenter;
|
|
|
|
|
|
using OpenAuth.App.ServiceApp;
|
|
|
|
|
|
using OpenAuth.Repository.Domain;
|
|
|
|
|
|
using System.Text.Json.Nodes;
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.WebApi.Model.mqtt
|
|
|
|
|
|
{
|
|
|
|
|
|
//机载盒子
|
|
|
|
|
|
public class ThingOnboardCaseHandler : IMqttMessageHandler
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ICacheContext _cache;
|
|
|
|
|
|
public ThingOnboardCaseHandler(AirportMaintenanceApp app, ICacheContext cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_cache = cache;
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool CanHandle(string topic)
|
|
|
|
|
|
{
|
|
|
|
|
|
return topic.Contains("/onboardcase");
|
|
|
|
|
|
}
|
|
|
|
|
|
public async Task HandleAsync(string topic, string payload)
|
|
|
|
|
|
{
|
|
|
|
|
|
var root = JsonNode.Parse(payload)?.AsObject();
|
2026-03-05 13:52:07 +08:00
|
|
|
|
if (root != null && root["type"]?.ToString() == "status_update")
|
2026-03-02 10:47:02 +08:00
|
|
|
|
{
|
2026-03-02 17:31:23 +08:00
|
|
|
|
var onboardcase = _cache.Set(root["device_id"]?.ToString(), payload, DateTime.Now.AddSeconds(20));
|
2026-03-02 10:47:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|