|
|
|
@ -34,6 +34,10 @@ public class ConfigSubscribe : IJob
|
|
|
|
|
.SubscribeAsync($"thing/product/{gatewaySn}/services_reply",
|
|
|
|
|
async (args) => await HandleTopic(gatewaySn, args.ApplicationMessage.Topic,
|
|
|
|
|
Encoding.UTF8.GetString(args.ApplicationMessage.Payload)));
|
|
|
|
|
await mqttClientManager
|
|
|
|
|
.SubscribeAsync($"thing/product/{gatewaySn}/events",
|
|
|
|
|
async (args) => await HandleTopic(gatewaySn, args.ApplicationMessage.Topic,
|
|
|
|
|
Encoding.UTF8.GetString(args.ApplicationMessage.Payload)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task Execute(IJobExecutionContext context)
|
|
|
|
@ -69,15 +73,98 @@ public class ConfigSubscribe : IJob
|
|
|
|
|
sys/product/{gateway_sn}/status 设备上下线、更新拓扑
|
|
|
|
|
thing/product/{gateway_sn}/property/set_reply 设备属性设置的响应
|
|
|
|
|
thing/product/{gateway_sn}/drc/up DRC 协议上行*/
|
|
|
|
|
// thing/product/8UUXN5400A079H/requests
|
|
|
|
|
if (topic.Equals("thing/product/8UUXN5400A079H/requests"))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("收到的资源请求-未处理字符串");
|
|
|
|
|
}
|
|
|
|
|
var tempStr = topic.Replace(sn, "*");
|
|
|
|
|
if (tempStr.Equals("thing/product/*/requests"))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("收到的资源请求");
|
|
|
|
|
}
|
|
|
|
|
//Console.WriteLine($"成功调用主题 [{topic}] 的消息: {message}");
|
|
|
|
|
// 主题方法
|
|
|
|
|
var result = JsonConvert.DeserializeObject<TopicServicesRequest<dynamic>>(message);
|
|
|
|
|
var method = result.method;
|
|
|
|
|
var data = result.data;
|
|
|
|
|
long code = data.result;
|
|
|
|
|
var hasProperty = false;
|
|
|
|
|
foreach (var property in data.GetType().GetProperties())
|
|
|
|
|
{
|
|
|
|
|
if (property.Name != "result") continue;
|
|
|
|
|
hasProperty = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long code = 0;
|
|
|
|
|
if (hasProperty)
|
|
|
|
|
{
|
|
|
|
|
code = data.result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (tempStr)
|
|
|
|
|
{
|
|
|
|
|
case "thing/product/*/requests":
|
|
|
|
|
//{"bid":"f936a236-030c-4358-bee9-b5075e1e2ddf",
|
|
|
|
|
//"data":{"flight_id":"e5ce8433-c264-4357-84d9-b701faf90d9e"},
|
|
|
|
|
//"method":"flighttask_resource_get",
|
|
|
|
|
//"tid":"61b6389a-7b72-49ae-bb46-0729e85c95d2",
|
|
|
|
|
//"timestamp":1750554644321,
|
|
|
|
|
//"gateway":"8UUXN5400A079H"}
|
|
|
|
|
// todo 处理资源获取请求
|
|
|
|
|
switch (method)
|
|
|
|
|
{
|
|
|
|
|
case "flighttask_resource_get":
|
|
|
|
|
Console.WriteLine($"获取资源请求:{JsonConvert.SerializeObject(data)}");
|
|
|
|
|
var flightId = data.flight_id;
|
|
|
|
|
LasaTaskAssign taskAssign =
|
|
|
|
|
manageApp.GetTaskAssignByBidAndTidAndFlightId(result.bid, result.tid, flightId);
|
|
|
|
|
var flightTaskResourceGetTopic = $"thing/product/{sn}/requests_reply";
|
|
|
|
|
dynamic outData = new ExpandoObject();
|
|
|
|
|
var outRequest = new TopicServicesRequest<object>()
|
|
|
|
|
{
|
|
|
|
|
method = "flighttask_resource_get",
|
|
|
|
|
tid = result.tid,
|
|
|
|
|
bid = result.bid,
|
|
|
|
|
timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
|
|
|
|
|
data = outData
|
|
|
|
|
};
|
|
|
|
|
outData.result = 0;
|
|
|
|
|
outData.output = new
|
|
|
|
|
{
|
|
|
|
|
file = new
|
|
|
|
|
{
|
|
|
|
|
fingerprint = taskAssign.Md5,
|
|
|
|
|
url = taskAssign.Wpml
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
await mqttClientManager.PublishAsync(flightTaskResourceGetTopic,
|
|
|
|
|
JsonConvert.SerializeObject(outRequest));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Console.WriteLine($"未知请求:{message}");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
// thing/product/8UUXN5400A079H/events
|
|
|
|
|
// {"bid":"0ebc789e-7f06-4830-a58a-8c4753cd493c",
|
|
|
|
|
// "data":{"output":{"ext":{"current_waypoint_index":0,
|
|
|
|
|
// "flight_id":"d6c00cc5-ec59-4bab-8508-fcb259f00a60",
|
|
|
|
|
// "media_count":0,"track_id":"","wayline_id":65535,"wayline_mission_state":2},
|
|
|
|
|
// "progress":{"current_step":36,"percent":15},"status":"failed"},"result":314013},
|
|
|
|
|
// "method":"flighttask_progress","need_reply":1,"tid":"84b048f7-43db-41c5-86c5-8938dc446ea4","timestamp":1750411329943,"gateway":"8UUXN5400A079H"}
|
|
|
|
|
case "thing/product/*/events":
|
|
|
|
|
if (method.Equals("flighttask_progress"))
|
|
|
|
|
{
|
|
|
|
|
// todo 处理航线进度 ,也有可能是失败
|
|
|
|
|
if (code != 0)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"航线进度错误信息:{ErrorMap[code]}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
// todo
|
|
|
|
|
// 任务资源处理
|
|
|
|
|
// 航线进度处理
|
|
|
|
@ -87,7 +174,7 @@ public class ConfigSubscribe : IJob
|
|
|
|
|
{
|
|
|
|
|
case "flighttask_prepare": // 下发任务响应
|
|
|
|
|
// 报错处理
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("处理prepare消息");
|
|
|
|
|
var taskAssign = manageApp.GetTaskAssignByBidAndTid(result.bid, result.tid);
|
|
|
|
|
if (code == 0)
|
|
|
|
|
{
|
|
|
|
@ -95,11 +182,12 @@ public class ConfigSubscribe : IJob
|
|
|
|
|
var flightId = taskAssign.FlightId;
|
|
|
|
|
var request = new TopicServicesRequest<object>();
|
|
|
|
|
dynamic data1 = new ExpandoObject();
|
|
|
|
|
data.flight_id = flightId;
|
|
|
|
|
data1.flight_id = flightId;
|
|
|
|
|
request.SetMethod("flighttask_execute")
|
|
|
|
|
.SetTid(Guid.NewGuid().ToString())
|
|
|
|
|
.SetBid(Guid.NewGuid().ToString())
|
|
|
|
|
.SetData(data);
|
|
|
|
|
.SetTimestamp(DateTimeOffset.Now.ToUnixTimeMilliseconds())
|
|
|
|
|
.SetData(data1);
|
|
|
|
|
// 任务执行
|
|
|
|
|
await mqttClientManager.PublishAsync($"thing/product/{sn}/services",
|
|
|
|
|
JsonConvert.SerializeObject(request));
|
|
|
|
@ -127,7 +215,7 @@ public class ConfigSubscribe : IJob
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"任务成功");
|
|
|
|
|
Console.WriteLine($"flighttask_execute 任务成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|