任务下发任务执行能正常执行版本

feature-flyModify
陈伟 2025-06-25 08:46:21 +08:00
parent 8d0e5a4381
commit f1aac4ca20
3 changed files with 57 additions and 58 deletions

View File

@ -50,11 +50,13 @@ public class MqttClientManager
var inboundOptions = new MqttClientOptionsBuilder() var inboundOptions = new MqttClientOptionsBuilder()
.WithClientId(Guid.NewGuid() + "_inbound") .WithClientId(Guid.NewGuid() + "_inbound")
.WithTcpServer(server, port) .WithTcpServer(server, port)
.WithKeepAlivePeriod(TimeSpan.FromSeconds(20))
.WithCredentials(username, password) .WithCredentials(username, password)
.Build(); .Build();
var outboundOptions = new MqttClientOptionsBuilder() var outboundOptions = new MqttClientOptionsBuilder()
.WithClientId(Guid.NewGuid() + "_outbound") .WithClientId(Guid.NewGuid() + "_outbound")
.WithTcpServer(server, port) .WithTcpServer(server, port)
.WithKeepAlivePeriod(TimeSpan.FromSeconds(20))
.WithCredentials(username, password) .WithCredentials(username, password)
.Build(); .Build();
@ -91,7 +93,6 @@ public class MqttClientManager
/// <param name="message">json</param> /// <param name="message">json</param>
public async Task PublishAsync(string topic, string message) public async Task PublishAsync(string topic, string message)
{ {
Console.WriteLine($"Publish: {topic} - {message}");
// MqttChannelAdapter // MqttChannelAdapter
var mqttMsg = new MqttApplicationMessageBuilder() var mqttMsg = new MqttApplicationMessageBuilder()
.WithTopic(topic) .WithTopic(topic)

View File

@ -100,7 +100,7 @@ public class ConfigSubscribe : IJob
switch (method) switch (method)
{ {
case "storage_config_get": case "storage_config_get":
Console.WriteLine("进入临时凭证获取处理"); Console.WriteLine($"进入临时凭证获取处理 {message}");
// {"bid":"afc5c13e-da1c-4a15-aec1-a765aac34c57", // {"bid":"afc5c13e-da1c-4a15-aec1-a765aac34c57",
// "data":{"module":0}, // "data":{"module":0},
// "method":"storage_config_get", // "method":"storage_config_get",
@ -135,11 +135,8 @@ public class ConfigSubscribe : IJob
}; };
// thing/product/{gateway_sn}/requests_reply // thing/product/{gateway_sn}/requests_reply
var tempTopic = $"thing/product/{sn}/requests_reply"; var tempTopic = $"thing/product/{sn}/requests_reply";
//Console.WriteLine($"主题:{tempTopic} request:{JsonConvert.SerializeObject(storageConfigRequest)}");
// todo 临时注释
await mqttClientManager.PublishAsync(tempTopic, await mqttClientManager.PublishAsync(tempTopic,
JsonConvert.SerializeObject(storageConfigRequest)); JsonConvert.SerializeObject(storageConfigRequest));
//Console.WriteLine("临时凭证获取处理完成");
break; break;
case "flight_areas_get": case "flight_areas_get":
//Console.WriteLine("跳过自定义飞行区文件获取"); //Console.WriteLine("跳过自定义飞行区文件获取");
@ -158,13 +155,13 @@ public class ConfigSubscribe : IJob
// http://175.27.168.120:6013/test/2025062209390863860047.kmz // http://175.27.168.120:6013/test/2025062209390863860047.kmz
// md5 585c833012ddb794eaac1050ef71aa31 // md5 585c833012ddb794eaac1050ef71aa31
// todo 这一小段运行异常 // todo 这一小段运行异常
/*var taskAssign = await sqlSugarClient var taskAssign = await sqlSugarClient
.Queryable<LasaTaskAssign>() .Queryable<LasaTaskAssign>()
.Where(x => x.FlightId == flightId) .Where(x => x.FlightId == flightId)
.SingleAsync();*/ .SingleAsync();
//Console.WriteLine($"任务信息:{JsonConvert.SerializeObject(taskAssign)}"); Console.WriteLine($"任务信息:{JsonConvert.SerializeObject(taskAssign)}");
/*var taskAssign = /*var taskAssign =
manageApp.GetTaskAssignByBidAndTid1(result.bid, result.tid, flightId);*/ manageApp.GetTaskAssignByBidAndTid(result.bid, result.tid, flightId);*/
var flightTaskResourceGetTopic = $"thing/product/{sn}/requests_reply"; var flightTaskResourceGetTopic = $"thing/product/{sn}/requests_reply";
dynamic outData = new ExpandoObject(); dynamic outData = new ExpandoObject();
outData.result = 0; outData.result = 0;
@ -172,8 +169,9 @@ public class ConfigSubscribe : IJob
{ {
file = new file = new
{ {
fingerprint = "585c833012ddb794eaac1050ef71aa31", fingerprint = taskAssign.Md5,
url = "http://175.27.168.120:6013/test/2025062209390863860047.kmz" url = "http://175.27.168.120:6013/test/2025062415430484240112.kmz"
// url = "http://175.27.168.120:6013/test/2025062209390863860047.kmz"
} }
}; };
var outRequest = new TopicServicesRequest<object>() var outRequest = new TopicServicesRequest<object>()
@ -245,8 +243,8 @@ public class ConfigSubscribe : IJob
{ {
case "flighttask_prepare": // 下发任务响应 case "flighttask_prepare": // 下发任务响应
// todo 同一prepare消息只能处理一次 // todo 同一prepare消息只能处理一次
lock (locker) //lock (locker)
{ // {
// 报错处理 // 报错处理
Console.WriteLine("进入prepare订阅消息"); Console.WriteLine("进入prepare订阅消息");
code = data.result; code = data.result;
@ -294,7 +292,7 @@ public class ConfigSubscribe : IJob
}; };
sqlSugarClient.Updateable(taskAssignRecord).IgnoreNullColumns().ExecuteCommand(); sqlSugarClient.Updateable(taskAssignRecord).IgnoreNullColumns().ExecuteCommand();
} }
} // }
break; break;
case "flighttask_execute": // 执行任务响应 case "flighttask_execute": // 执行任务响应

View File

@ -646,7 +646,7 @@ namespace OpenAuth.App.ServiceApp
var md5 = await _minioService.GetMetaObject(wpml, ""); var md5 = await _minioService.GetMetaObject(wpml, "");
// todo 临时固定代码 // todo 临时固定代码
// http://175.27.168.120:6013/test/2025062209390863860047.kmz // http://175.27.168.120:6013/test/2025062209390863860047.kmz
//wpml = await _minioService.GetObjectUrl("test", "2025062209390863860047.kmz"); // wpml = await _minioService.GetObjectUrl("test", "2025062209390863860047.kmz");
data.file = new data.file = new
{ {
url = wpml, url = wpml,
@ -676,7 +676,7 @@ namespace OpenAuth.App.ServiceApp
} }
// 返航高度 {"max":1500,"min":20,"step":"","unit_name":"米 / m"} // 返航高度 {"max":1500,"min":20,"step":"","unit_name":"米 / m"}
data.rth_altitude = 50; // todo 取自任务 data.rth_altitude = 90; // todo 取自任务
// 返航高度模式 {"0":"智能高度","1":"设定高度"} // 返航高度模式 {"0":"智能高度","1":"设定高度"}
// 智能返航模式下,飞行器将自动规划最佳返航高度。大疆机场当前不支持设置返航高度模式,只能选择'设定高度'模式。当环境,光线不满足视觉系统要求时(譬如傍晚阳光直射、夜间弱光无光),飞行器将使用您设定的返航高度进行直线返航 // 智能返航模式下,飞行器将自动规划最佳返航高度。大疆机场当前不支持设置返航高度模式,只能选择'设定高度'模式。当环境,光线不满足视觉系统要求时(譬如傍晚阳光直射、夜间弱光无光),飞行器将使用您设定的返航高度进行直线返航
data.rth_mode = 0; data.rth_mode = 0;