洁 任 2 months ago
commit 19455f5f0c

@ -0,0 +1,24 @@
namespace Infrastructure.CloudSdk;
public class FileUploadCallbackEventReply<T>
{
public string tid { get; set; }
public string bid { get; set; }
public long? timestamp { get; set; }
public string gateway { get; set; }
public string method { get; set; }
public T data { get; set; }
public override string ToString()
{
return $"CommonTopicRequest{{tid='{tid}', bid='{bid}', timestamp={timestamp}, data={data}}}";
}
public FileUploadCallbackEventReply<T> SetTid(string tid)
{
this.tid = tid;
return this;
}
}

@ -209,7 +209,7 @@ public class MinioService
.WithContentType("application/octet-stream");
//.WithContentType(file.ContentType);
await _minioClient.PutObjectAsync(putArgs);
return UseSSL ? "https://" : "http://" + endPoint + "/" + bucketName + "/" + objectName;
return "http://" + endPoint + "/" + bucketName + "/" + objectName;
}
catch (Exception ex)
{

@ -1,13 +1,7 @@
using System;
using System.IO;
using System.Net.Security;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using MQTTnet;
using MQTTnet.Client;
using MQTTnet.Packets;
using MQTTnet.Protocol;
namespace OpenAuth.WebApi;

@ -32,6 +32,7 @@ public class TopicServicesRequest<T> : CommonTopicRequest<T>
return this;
}
public string method { get; set; }
public int need_reply { get; set; }
public TopicServicesRequest<T> SetMethod(string method)
{
this.method = method;

@ -1,11 +1,14 @@
using System.Dynamic;
using System.Text;
using Infrastructure.Cache;
using Infrastructure.CloudSdk;
using Infrastructure.CloudSdk.minio;
using Infrastructure.CloudSdk.wayline;
using MQTTnet;
using Infrastructure.Extensions;
using Microsoft.Extensions.Logging;
using MQTTnet.Client;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OpenAuth.App.ServiceApp;
using OpenAuth.Repository.Domain;
using OpenAuth.WebApi;
@ -22,15 +25,19 @@ public class ConfigSubscribe : IJob
private readonly ManageApp _manageApp;
private readonly MinioService _minioService;
private object _locker = new();
private object _dockUploadFileLocker = new();
private readonly ILogger<ConfigSubscribe> _logger;
public ConfigSubscribe(MqttClientManager mqttClientManager, ISqlSugarClient sqlSugarClient,
ICacheContext redisCacheContext, ManageApp manageApp, MinioService minioService)
ICacheContext redisCacheContext, ManageApp manageApp, MinioService minioService,
ILogger<ConfigSubscribe> logger)
{
_mqttClientManager = mqttClientManager;
_sqlSugarClient = sqlSugarClient;
_redisCacheContext = redisCacheContext as RedisCacheContext;
_manageApp = manageApp;
_minioService = minioService;
_logger = logger;
}
private async Task Subscribe()
@ -41,15 +48,17 @@ public class ConfigSubscribe : IJob
{
"thing/product/+/services_reply",
"thing/product/+/events",
"thing/product/+/requests"
"thing/product/+/requests",
//"thing/product/+/osd",
//"thing/product/+/status"
};
await _mqttClientManager
.SubscribeAsync(topicList,
async (args) =>
{
args.IsHandled = false; // todo 待实验确定
args.AutoAcknowledge = true; // todo 待实验确定
//args.IsHandled = false; // todo 待实验确定
//args.AutoAcknowledge = true; // todo 待实验确定
await HandleTopic(args, args.ApplicationMessage.Topic,
Encoding.UTF8.GetString(args.ApplicationMessage.Payload));
});
@ -84,8 +93,7 @@ public class ConfigSubscribe : IJob
var result = JsonConvert.DeserializeObject<TopicServicesRequest<dynamic>>(message);
var method = result.method;
var data = result.data;
_logger.LogInformation($"主题:{topic}\n消息{message}");
long code = 0;
switch (tempStr)
{
@ -99,8 +107,9 @@ public class ConfigSubscribe : IJob
// todo 处理资源获取请求
switch (method)
{
// 临时凭证上传
case "storage_config_get":
Console.WriteLine($"进入临时凭证获取处理 {message}");
_logger.LogInformation($"进入临时凭证获取处理");
// {"bid":"afc5c13e-da1c-4a15-aec1-a765aac34c57",
// "data":{"module":0},
// "method":"storage_config_get",
@ -114,23 +123,21 @@ public class ConfigSubscribe : IJob
tid = result.tid,
bid = result.bid,
timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
data = new
{
result = 0,
output = new
{
bucket = _minioService._bucketName,
// todo 这里待确定
endpoint = $"http://{_minioService.endPoint}",
object_key_prefix = Guid.NewGuid().ToString(), // todo 是否设计任务id
bucket = "test",
endpoint = "http://175.27.168.120:6013",
object_key_prefix = $"{Guid.NewGuid().ToString()}", // todo 是否设计任务id
provider = "minio",
region = "linyi",
credentials = new
{
access_key_id = _minioService.AccessKey,
access_key_secret = _minioService.SecretKey,
expire = 7200,
access_key_id = "minioadmin",
access_key_secret = "minioadmin",
expire = 480,
security_token = ""
}
}
@ -146,14 +153,8 @@ public class ConfigSubscribe : IJob
break;
// 获取航线
case "flighttask_resource_get":
Console.WriteLine("进入资源获取处理");
string flightId = data.flight_id + "";
Console.WriteLine($"任务ID{flightId}");
if (_sqlSugarClient != null)
{
Console.WriteLine("manageApp 注入没有问题");
}
_logger.LogInformation($"进入资源获取处理: 任务id {flightId}");
// eb87b257-5af1-4bf1-9aba-4267be9fdb12 flight
// http://175.27.168.120:6013/test/2025062209390863860047.kmz
// md5 585c833012ddb794eaac1050ef71aa31
@ -162,7 +163,7 @@ public class ConfigSubscribe : IJob
.Queryable<LasaTaskAssign>()
.Where(x => x.FlightId == flightId)
.SingleAsync();
Console.WriteLine($"任务信息:{JsonConvert.SerializeObject(taskAssign)}");
_logger.LogInformation($"任务信息:{JsonConvert.SerializeObject(taskAssign)}");
/*var taskAssign =
manageApp.GetTaskAssignByBidAndTid(result.bid, result.tid, flightId);*/
var flightTaskResourceGetTopic = $"thing/product/{sn}/requests_reply";
@ -193,7 +194,7 @@ public class ConfigSubscribe : IJob
case "config":
break;
default:
Console.WriteLine($"未知请求{message}");
_logger.LogInformation($"未处理消息{message}");
break;
}
@ -203,45 +204,76 @@ public class ConfigSubscribe : IJob
{
case "file_upload_callback":
// 文件上传
int flightType = int.Parse(data.flight_task.flight_type);
Console.WriteLine("进入文件上传处理");
Console.WriteLine($"文件上传处理:{message}");
int flightType = data.flight_task.flight_type;
if (flightType == 1) // 不处理一键起飞媒体信息
{
break;
}
string flightId = data.file.ext.flight_id;
string taskId = _manageApp.GetTaskAssignByFlightId(flightId).TaskId;
var fileUpload = new LasaMediaFile()
lock (_dockUploadFileLocker)
{
Id = Guid.NewGuid().ToString(),
FlightId = flightId, // 计划id
TaskId = taskId, // 任务id
DroneModelKey = data.file.ext.drone_model_key,
IsOriginal = data.file.ext.is_original,
MediaIndex = data.file.ext.media_index,
PayloadModelKey = data.file.ext.payload_model_key,
AbsoluteAltitude = data.file.metadata.absolute_altitude,
GimbalYawDegree = data.file.metadata.gimbal_yaw_degree, //云台偏航角度
RelativeAltitude = data.file.metadata.relative_altitude,
Lat = data.file.metadata.shoot_position.lat,
Lng = data.file.metadata.shoot_position.lng,
Name = data.file.name,
ObjectKey = data.file.object_key,
Path = data.file.path,
CreateTime = data.file.metadata.create_time.ToDateTime(),
};
await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync();
var expectFileCount = data.flight_task.expected_file_count;
var uploadedFileCount = data.flight_task.uploaded_file_count;
string flightId = data.file.ext.flight_id;
string taskId = _manageApp.GetTaskAssignByFlightId(flightId).TaskId;
var fileUpload = new LasaMediaFile()
{
Id = Guid.NewGuid().ToString(),
FlightId = flightId, // 计划id
TaskId = taskId, // 任务id
DroneModelKey = data.file.ext.drone_model_key, // 无人机型号
IsOriginal = data.file.ext.is_original,
MediaIndex = data.file.ext.media_index,
PayloadModelKey = data.file.ext.payload_model_key, //这应该可以标明是什么设置
AbsoluteAltitude = data.file.metadata.absolute_altitude, // 拍摄绝对高度
GimbalYawDegree = data.file.metadata.gimbal_yaw_degree, //云台偏航角度
RelativeAltitude = data.file.metadata.relative_altitude, // 拍摄相对高度
Lat = data.file.metadata.shoot_position.lat,
Lng = data.file.metadata.shoot_position.lng,
Name = data.file.name,
ObjectKey = data.file.object_key,
Path = data.file.path, // 目前这个好像没有值
CreateTime = ((string)data.file.metadata.created_time).ToDateTime(),
};
// todo 添加事务
_sqlSugarClient.Insertable(fileUpload).ExecuteCommand();
if (result.need_reply.Equals(1))
{
var fileUploadCallbackEventReply = new FileUploadCallbackEventReply<object>()
{
bid = result.bid,
tid = result.tid,
method = "file_upload_callback",
gateway = sn,
data = new
{
result = 0
},
timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
};
_ = _mqttClientManager.PublishAsync($"thing/product/{sn}/events_reply",
JsonConvert.SerializeObject(fileUploadCallbackEventReply));
}
var expectFileCount = data.flight_task.expected_file_count;
var uploadedFileCount = data.flight_task.uploaded_file_count;
var taskRecord = new LasaTask()
{
Id = taskId,
ExpectedFileCount = expectFileCount, // 期望文件数量
UploadedFileCount = uploadedFileCount // 已上传文件数量
};
// 当expectFileCount 等于uploadedFileCount时则表示航线执行完成
if (uploadedFileCount.Equals(expectFileCount))
{
taskRecord.Status = 5; // 成功状态
}
_sqlSugarClient.Updateable(taskRecord)
.IgnoreNullColumns().ExecuteCommand();
}
var taskRecord = new LasaTask()
{
Id = taskId,
ExpectedFileCount = expectFileCount, // 期望文件数量
UploadedFileCount = uploadedFileCount // 已上传文件数量
};
await _sqlSugarClient.Updateable(taskRecord)
.IgnoreNullColumns().ExecuteCommandAsync();
break;
case "release_terminal_control_area":
//暂不处理
@ -278,6 +310,24 @@ public class ConfigSubscribe : IJob
}
else
{
if (result.need_reply.Equals(1))
{
var fileUploadCallbackEventReply = new FileUploadCallbackEventReply<object>()
{
bid = result.bid,
tid = result.tid,
method = "flighttask_progress",
gateway = sn,
data = new
{
result = 0
},
timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
};
await _mqttClientManager.PublishAsync($"thing/product/{sn}/events_reply",
JsonConvert.SerializeObject(fileUploadCallbackEventReply));
}
Console.WriteLine($"航线进度:{message}");
}
@ -303,7 +353,7 @@ public class ConfigSubscribe : IJob
switch (method)
{
case "flighttask_prepare": // 下发任务响应
// todo 同一prepare消息只能处理一次
// 顺序处理,多余的不再处理
lock (_locker)
{
// 报错处理
@ -397,6 +447,9 @@ public class ConfigSubscribe : IJob
break;
}
break;
case "thing/product/*/osd":
Console.WriteLine($"osd消息: {message}");
break;
default:
Console.WriteLine($"未进入主题处理");

@ -14,6 +14,8 @@ using DocumentFormat.OpenXml.EMMA;
using NPOI.SS.Formula.Functions;
using Infrastructure.Extensions;
using DocumentFormat.OpenXml.Math;
using DocumentFormat.OpenXml.Spreadsheet;
using Org.BouncyCastle.Ocsp;
namespace OpenAuth.App.ServiceApp
{
@ -323,5 +325,28 @@ namespace OpenAuth.App.ServiceApp
}
}
#endregion
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string device, string picname, DateTime? startTime, DateTime? endTime, int page, int limit)
{
RefAsync<int> totalCount = 0;
using (var db = UnitWork.CreateContext())
{
Console.WriteLine(startTime.ToString());
var list = await db.LasaMediaFile.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(device),x => x.DroneModelKey == device)
.WhereIF(!string.IsNullOrEmpty(picname), x => x.Name.Contains(picname))
.WhereIF("0001/1/1 0:00:00".Equal(startTime.ToString() ), x => x.CreateTime >= startTime)
.WhereIF("0001/1/1 0:00:00".Equal(endTime.ToString()), x => x.CreateTime <= endTime)
.OrderBy(x => x.CreateTime, OrderByType.Asc)
.ToPageListAsync(page, limit, totalCount);
return new Response<PageInfo<List<LasaMediaFile>>>
{
Result = new PageInfo<List<LasaMediaFile>> { Items = list, Total = totalCount }
};
}
}
}
}

@ -11,6 +11,7 @@ using OpenAuth.App.ServiceApp.Response;
using Microsoft.Extensions.Configuration;
using OpenAuth.App.ServiceApp.DroneDocking.Request;
using DocumentFormat.OpenXml.Office.CustomUI;
using DocumentFormat.OpenXml.EMMA;
namespace OpenAuth.App.ServiceApp.DroneDocking
@ -614,6 +615,140 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
}
}
/// <summary>
/// 无人机状态获取
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<ResData> getDroneStatus(string deviceid)
{
ResData Response = new ResData();
string data = "{\r\n\"code\": 200,\r\n\"data\": {\r\n\"mode_code\":0,\r\n\"longitude\":122.45,\r\n\"latitude\":30.45,\r\n\"height\":80,\r\n\"elevation\":50,\r\n\"gimbal_pitch\":-45,\r\n\"gimbal_yaw\":23,\r\n\"battery_capacity_percent\":35,\r\n\"gps_state\":2,\r\n},\r\n\"message\": \"获取无人机机场状态成功!\",\r\n\"traceid\": \"xxx\"\r\n}";
//todo deviceid
if (true)
{
string x_lc_secret = _helper.getxseret();
// 转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(data);
var encryptedResData = _helper.Encrypt(bytes);
Response.Result = encryptedResData;
Response.Message = "获取无人机机场状态成功!";
Response.Code = 200;
Response.Secret = x_lc_secret;
return Response;
}
else
{
string x_lc_secret = _helper.getxseret();
// 转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(" ");
var encryptedResData = _helper.Encrypt(bytes);
Response.Result = encryptedResData;
Response.Message = "获取无人机机场状态失败!";
Response.Code = 500;
Response.Secret = x_lc_secret;
return Response;
}
}
/// <summary>
/// 无人机任务查询
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<ResData> queryTaskStatus(string req, string secret)
{
ResData Response = new ResData();
//解密数据
byte[] secretbyte = Convert.FromBase64String(secret); //x-lc-secret
byte[] reqbyte = Convert.FromBase64String(req); //返回数据
string data = _helper.Decrypt(secretbyte, reqbyte);
//序列化返回数据并处理
var task = JsonSerializer.Deserialize<AirPortTaskReq>(data);
string sql = "select * from drone_docktask where taskid=" + data;
string x_lc_secret = _helper.getxseret();
// 转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(sql);
var encryptedResData = _helper.Encrypt(bytes);
Response.Result = encryptedResData;
Response.Message = "查询无人机机场任务状态成功!";
Response.Code = 200;
Response.Secret = x_lc_secret;
return Response;
}
/// <summary>
/// 无人机机场设备注册/更新
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<Response<string>> reportDroneStatus(List<AirPortStatusApply> req)
{
Response<string> Response = new Response<string>();
var handler = new HttpClientHandler();
// 如果需要忽略服务器证书错误(仅测试环境)
handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
using (var client = new HttpClient())
{
try
{
string url = configuration.GetSection("DroneDocking:Url").Value + "/droneAirport/reportDroneStatus";
string x_lc_secret = _helper.getxseret();
string centercode = "UAV32_LJY2FPMYDE6UDES3P3ZD7V3IKQ";
string x_token = _helper.GetToken(centercode);
// 序列化为 JSON 字符串
string json = JsonSerializer.Serialize(req);
// 转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(json);
var encryptedData = _helper.Encrypt(bytes);
// 创建请求体
var httpContent = new StringContent(encryptedData, Encoding.UTF8, "application/json");
// 添加请求头
client.DefaultRequestHeaders.Add("x-lc-secret", x_lc_secret);
client.DefaultRequestHeaders.Add("x-lc-token", x_token);
//发送请求
HttpResponseMessage response = await client.PostAsync(url, httpContent);
response.EnsureSuccessStatusCode();
// 获取响应头中的 x_cl_screte 参数
string resx_cl_screte = GetHeaderValue(response, "x-lc-secret");
// 读取响应内容并反序列化
string responseBody = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ReciveData<string>>(responseBody);
//解密数据
byte[] resbytesx = Convert.FromBase64String(resx_cl_screte);
byte[] resdatabytes = Convert.FromBase64String(result?.data);
string data = _helper.Decrypt(resbytesx, resdatabytes);
Response.Result = data;
Response.Message = result.message;
Response.Code = result.code;
}
catch (HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ", e.Message);
Response.Result = "连接错误";
}
}
return Response;
}
// 安全获取响应头值的方法
private static string GetHeaderValue(HttpResponseMessage response, string headerName)
{

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.App.ServiceApp.DroneDocking.Request
{
public class AirPortStatusApply
{
public string deviceid { get; set; }
public string onlinestate { get; set; }
public double longitude { get; set; }
public double latitude { get; set; }
public double height { get; set; }
public double elevation { get; set; }
public double gimbal_pitch { get; set; }
public double gimbal_ya { get; set; }
public int battery_capacity_percent { get; set; }
public int gps_state { get; set; }
}
}

@ -275,8 +275,6 @@ namespace OpenAuth.App.ServiceApp
{
using (var db = UnitWork.CreateContext())
{
if (db.LasaUav.GetFirst(r => r.Sn == info.Sn) != null)
return false;
var flag = db.LasaUav.Insert(info);
if (db.Commit())
return true;
@ -1176,6 +1174,64 @@ namespace OpenAuth.App.ServiceApp
};
}
public async Task<Response<List<LasaMediaFile>>> GetTAskImageList(string taskId)
{
var list = await Repository
.ChangeRepository<SugarRepositiry<LasaMediaFile>>()
.AsQueryable()
.Where(r => r.TaskId == taskId)
.ToListAsync();
return new Response<List<LasaMediaFile>>()
{
Result = list
};
}
public async Task<Response<bool>> StartDronePortLive(string streamUrl)
{
var request = new
{
tid = Guid.NewGuid().ToString(),
bid = Guid.NewGuid().ToString(),
timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
method = "live_start_push",
data = new
{
url = streamUrl,
url_type = 1,
// 8UUXN5400A079H/165-0-7/normal-0
video_id = "8UUXN5400A079H/165-0-7/normal-0",
video_quality = 1,
}
};
//thing/product/{gateway_sn}/services
await _mqttClientManager.PublishAsync("thing/product/8UUXN5400A079H/services", JsonConvert.SerializeObject(request));
return new Response<bool>()
{
Result = true
};
}
public async Task<Response<bool>> StopDronePortLive(string streamUrl)
{
var request = new
{
tid = Guid.NewGuid().ToString(),
bid = Guid.NewGuid().ToString(),
timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
method = "live_stop_push",
data = new
{
video_id = "8UUXN5400A079H/165-0-7/normal-0"
}
};
await _mqttClientManager.PublishAsync("thing/product/8UUXN5400A079H/services", JsonConvert.SerializeObject(request));
return new Response<bool>()
{
Result = true
};
}
#region 基本信息统计
public async Task<Response<JObject>> GetBasicInfo()
{

@ -47,12 +47,12 @@ namespace OpenAuth.Repository.Domain
/// <summary>
/// 返航高度
/// </summary>
public int ReturnAltitude { get; set; }
public int? ReturnAltitude { get; set; }
/// <summary>
/// 返航失控动作
/// </summary>
public int LossOfControlAction { get; set; }
public int? LossOfControlAction { get; set; }
/// <summary>
/// 续飞模式
@ -65,9 +65,9 @@ namespace OpenAuth.Repository.Domain
public string AIInspection { get; set; }
/// <summary>
/// 状态 0-待执行任务 1-任务执行中 2-任务执行失败 3. 任务挂起(挂起的任务超时后,怎么处理?)
/// 状态 0-待执行任务 1-任务执行中 2-任务执行失败 3. 任务挂起(挂起的任务超时后,怎么处理?) 5. 成功
/// </summary>
public int Status { get; set; }
public int? Status { get; set; }
/// <summary>
/// 周期公式
@ -85,7 +85,7 @@ namespace OpenAuth.Repository.Domain
/// <summary>
/// 航线精度类型
/// </summary>
public int WaylinePrecisionType { get; set; }
public int? WaylinePrecisionType { get; set; }
public DateTime? ScheduledStartTime { get; set; }
@ -122,15 +122,15 @@ namespace OpenAuth.Repository.Domain
/// <summary>
/// 期望媒体数量
/// </summary>
public int ExpectedFileCount { get; set; }
public int? ExpectedFileCount { get; set; }
/// <summary>
/// 已上传媒体数量
/// </summary>
public int UploadedFileCount { get; set; }
public int? UploadedFileCount { get; set; }
public string FlightId { get; set; }
public string Reason { get; set; }
public string? Reason { get; set; }
}
}

@ -79,6 +79,8 @@ namespace OpenAuth.Repository
public SugarRepositiry<LasaDeviceDictionary> LasaDeviceDictionary { get; set; }
public SugarRepositiry<DroneDocktaskdetail> DroneDocktaskdetail { get; set; }
public SugarRepositiry<DroneDocktask> DroneDocktask { get; set; }
public SugarRepositiry<LasaMediaFile> LasaMediaFile { get; set; }
#endregion
}
}

@ -621,5 +621,23 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
return result;
}
#endregion
[HttpGet]
[AllowAnonymous]
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string device,string picname, DateTime startTime, DateTime endTime, int page, int limit)
{
var result = new Response<PageInfo<List<LasaMediaFile>>>();
try
{
result = await _app.GetMediaFile(device, picname,startTime, endTime, page, limit);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
}
}

@ -279,5 +279,129 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
}
}
[HttpGet]
[AllowAnonymous]
[Route("/zhcfzx/droneAirport/getDroneStatus")]
public async Task<ReciveData<string>> getDroneStatus( string deviceid)
{
var result = new ReciveData<string>();
if (Request.Headers.TryGetValue("x-lc-token", out var tokenValue))
{
var tokenflag = _helper.Verify(tokenValue);
if (tokenflag)
{
try
{
var data = await _app.getDroneStatus(deviceid);
result.data = data.Result;
result.code = data.Code;
result.message = data.Message;
Request.Headers.TryGetValue("traceid", out var traceid);
result.traceid = traceid;
Response.Headers.Add("x-lc-secret", data.Secret);
}
catch (Exception ex)
{
result.code = 200;
result.message = "error";
Request.Headers.TryGetValue("traceid", out var traceid);
result.traceid = traceid;
}
return result;
}
else
{
throw new Exception("unauthorized");
}
}
else
{
throw new Exception("Missing required header: x-lc-token");
}
}
/// <summary>
/// 无人机状态上报
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<Response<string>> reportDroneStatus([FromBody] List<AirPortStatusApply> req)
{
var result = new Response<string>();
try
{
result = await _app.reportDroneStatus(req);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
/// <summary>
/// 无人机任务进度查询
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[Route("/zhcfzx/droneAirport/queryTaskStatus")]
[HttpPost]
[AllowAnonymous]
public async Task<ReciveData<string>> queryTaskStatus(string taskid)
{
var result = new ReciveData<string>();
if (Request.Headers.TryGetValue("x-lc-token", out var tokenValue))
{
var tokenflag = _helper.Verify(tokenValue);
if (tokenflag)
{
// 获取请求头中的x-lc-secret
if (Request.Headers.TryGetValue("x-lc-secret", out var secretValue))
{
string secret = secretValue.ToString();
try
{
// 1. 从请求体中直接读取原始字符串(即 encryptedData
string req;
using (var reader = new StreamReader(Request.Body, Encoding.UTF8))
{
req = await reader.ReadToEndAsync();
}
var data = await _app.queryTaskStatus(req, secret);
result.data = data.Result;
result.code = data.Code;
result.message = data.Message;
Request.Headers.TryGetValue("traceid", out var traceid);
result.traceid = traceid;
Response.Headers.Add("x-lc-secret", data.Secret);
}
catch (Exception ex)
{
result.code = 200;
result.message = "error";
Request.Headers.TryGetValue("traceid", out var traceid);
result.traceid = traceid;
}
return result;
}
else
{
throw new Exception("Missing required header: x-lc-secret");
}
}
else
{
throw new Exception("unauthorized");
}
}
else
{
throw new Exception("Missing required header: x-lc-token");
}
}
}
}

@ -256,6 +256,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
return result;
}
/// <summary>
/// 航线详情
/// </summary>
@ -480,6 +481,40 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
await _app.PendingFlyTask(taskId);
}
/// <summary>
/// 任务图片列表查询
/// </summary>
/// <param name="taskId"></param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<Response<List<LasaMediaFile>>> GetTAskImageList(string taskId)
{
return await _app.GetTAskImageList(taskId);
}
/// <summary>
/// 开启机场直播(测试使用)
/// </summary>
/// <param name="streamUrl"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<Response<bool>> StartDronePortLive(string streamUrl)
{
return await _app.StartDronePortLive(streamUrl);
}
/// <summary>
/// 测试使用
/// </summary>
/// <param name="streamUrl"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<Response<bool>> StopDronePortLive(string streamUrl)
{
return await _app.StopDronePortLive(streamUrl);
}
[HttpPost]
[AllowAnonymous]
public async Task<string> TestExecuteFlyTask(string flightid)

@ -85,10 +85,10 @@ namespace OpenAuth.WebApi.Model.mqtt
// 生成 bind_status 对象列表
var bindStatusList = snList?.Select(sn => new
{
device_callsign = "山东慧创",
device_callsign = "sdhc",
is_device_bind_organization = true,
organization_id = "371300",
organization_name = "山东慧创",
organization_name = "sdhc",
sn = sn
}).ToArray();
@ -124,7 +124,7 @@ namespace OpenAuth.WebApi.Model.mqtt
{
output = new
{
organization_name = "山东慧创"
organization_name = "sdhc"
},
result = 0
},

Loading…
Cancel
Save