|
|
|
@ -6,7 +6,6 @@ using OpenAuth.App.Interface;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using Infrastructure;
|
|
|
|
|
using Infrastructure.Helpers;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using OpenAuth.App.ServiceApp.Response;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using OpenAuth.App.ServiceApp.DroneDocking.Request;
|
|
|
|
@ -20,12 +19,16 @@ using Org.BouncyCastle.Ocsp;
|
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
|
|
|
|
using System.Data.SQLite;
|
|
|
|
|
using System.Dynamic;
|
|
|
|
|
using Infrastructure.CloudSdk.minio;
|
|
|
|
|
using Infrastructure.Extensions;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
|
using System.Text.Json.Nodes;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using OpenAuth.WebApi;
|
|
|
|
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
@ -651,51 +654,121 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<ResData> getDroneStatus(string deviceid)
|
|
|
|
|
public async Task<ResData> GetDroneStatus(string deviceid)
|
|
|
|
|
{
|
|
|
|
|
// 取得无人机类型
|
|
|
|
|
// 取得机场信息
|
|
|
|
|
// 监听无人机信息
|
|
|
|
|
// mode_code 0:在线;1:不在线;2:任务执行中
|
|
|
|
|
// todo drone_in_dock 0":"舱外","1":"舱内"
|
|
|
|
|
// 舱外 任务执行中 关机是在线还是不在线?应该是不在线吧?
|
|
|
|
|
// todo 1. 先取机场信息,是否在
|
|
|
|
|
var now = DateTime.Now;
|
|
|
|
|
var time = now.AddSeconds(-5);
|
|
|
|
|
var log = await Repository
|
|
|
|
|
.ChangeRepository<SugarRepositiry<LasaLog>>()
|
|
|
|
|
.AsQueryable()
|
|
|
|
|
.Where(r => r.Topic == "")
|
|
|
|
|
.Where(r => r.CreateTime > time) // 查询5秒以内数据
|
|
|
|
|
.Where(r => SqlFunc.JsonLike(r.Data, "drone_in_dock"))
|
|
|
|
|
.OrderByDescending(r => r.CreateTime)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
// 当前时间
|
|
|
|
|
|
|
|
|
|
ResData response = new ResData();
|
|
|
|
|
string data = @"
|
|
|
|
|
/*string data = @"
|
|
|
|
|
{
|
|
|
|
|
""code"": 200,
|
|
|
|
|
""data"": {
|
|
|
|
|
""mode_code"": 0,
|
|
|
|
|
""longitude"": 122.45,
|
|
|
|
|
""latitude"": 30.45,
|
|
|
|
|
""height"": 80,
|
|
|
|
|
""elevation"": 50,
|
|
|
|
|
""gimbal_pitch"": -45,
|
|
|
|
|
""gimbal_yaw"": 23,
|
|
|
|
|
""battery_capacity_percent"": 35,
|
|
|
|
|
""gps_state"": 2
|
|
|
|
|
},
|
|
|
|
|
""message"": ""获取无人机机场状态成功!"",
|
|
|
|
|
""traceid"": ""xxx""
|
|
|
|
|
""code"": 200,
|
|
|
|
|
""data"": {
|
|
|
|
|
""mode_code"": 0,
|
|
|
|
|
""longitude"": 122.45,
|
|
|
|
|
""latitude"": 30.45,
|
|
|
|
|
""height"": 80,
|
|
|
|
|
""elevation"": 50,
|
|
|
|
|
""gimbal_pitch"": -45,
|
|
|
|
|
""gimbal_yaw"": 23,
|
|
|
|
|
""battery_capacity_percent"": 35,
|
|
|
|
|
""gps_state"": 2
|
|
|
|
|
},
|
|
|
|
|
""message"": ""获取无人机机场状态成功!"",
|
|
|
|
|
""traceid"": ""xxx""
|
|
|
|
|
}
|
|
|
|
|
";
|
|
|
|
|
if (true)
|
|
|
|
|
";*/
|
|
|
|
|
dynamic data = new ExpandoObject();
|
|
|
|
|
var dock = await Repository
|
|
|
|
|
.ChangeRepository<SugarRepositiry<LasaDronePort>>()
|
|
|
|
|
.AsQueryable()
|
|
|
|
|
.LeftJoin<LasaUav>((a, b) => a.Id == b.PId)
|
|
|
|
|
.Where((a, b) => b.Sn == deviceid).FirstAsync();
|
|
|
|
|
if (dock == null)
|
|
|
|
|
{
|
|
|
|
|
data.code = 500;
|
|
|
|
|
data.message = "获取无人机机场状态失败";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.code = 200;
|
|
|
|
|
var dockOsdTopic = $"thing/product/{dock.Sn}/osd";
|
|
|
|
|
var now = DateTime.Now;
|
|
|
|
|
var time = now.AddSeconds(-5);
|
|
|
|
|
var log = await Repository
|
|
|
|
|
.ChangeRepository<SugarRepositiry<LasaLog>>()
|
|
|
|
|
.AsQueryable()
|
|
|
|
|
.Where(r => r.Topic == dockOsdTopic)
|
|
|
|
|
.Where(r => r.CreateTime > time) // 查询5秒以内数据
|
|
|
|
|
.Where(r => SqlFunc.JsonLike(r.Data, "drone_in_dock"))
|
|
|
|
|
.OrderByDescending(r => r.CreateTime)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (log != null)
|
|
|
|
|
{
|
|
|
|
|
// 当前时间
|
|
|
|
|
var dockOsdData =
|
|
|
|
|
JsonConvert.DeserializeObject<JObject>(JsonConvert.DeserializeObject<string>(log.Data));
|
|
|
|
|
//drone_in_dock 0":"舱外","1":"舱内"
|
|
|
|
|
var droneInDock = dockOsdData["data"]?["drone_in_dock"]?.Value<int>();
|
|
|
|
|
if (droneInDock == 0) // 飞行任务状态
|
|
|
|
|
{
|
|
|
|
|
var droneOsdTopic = $"thing/product/{deviceid}/osd";
|
|
|
|
|
log = await Repository
|
|
|
|
|
.ChangeRepository<SugarRepositiry<LasaLog>>()
|
|
|
|
|
.AsQueryable()
|
|
|
|
|
.Where(r => r.Topic == droneOsdTopic)
|
|
|
|
|
.Where(r => r.CreateTime > time) // 查询5秒以内数据
|
|
|
|
|
.OrderByDescending(r => r.CreateTime)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (log != null)
|
|
|
|
|
{
|
|
|
|
|
var droneOsdData =
|
|
|
|
|
JsonConvert.DeserializeObject<JObject>(JsonConvert.DeserializeObject<string>(log.Data));
|
|
|
|
|
|
|
|
|
|
var longitude = Math.Round(droneOsdData["data"]?["longitude"]?.Value<decimal>() ?? 0m, 7);
|
|
|
|
|
var latitude = Math.Round(droneOsdData["data"]?["latitude"]?.Value<decimal>() ?? 0m, 7);
|
|
|
|
|
var height = Math.Round(droneOsdData["data"]?["height"]?.Value<decimal>() ?? 0m, 2);
|
|
|
|
|
var elevation = Math.Round(droneOsdData["data"]?["elevation"]?.Value<decimal>() ?? 0m, 2);
|
|
|
|
|
// 云台信息
|
|
|
|
|
var payload99 = droneOsdData["data"]?["99-0-0"];
|
|
|
|
|
var gimbalPitch = payload99?["gimbal_pitch"]?.Value<double>();
|
|
|
|
|
var gimbalYaw = payload99?["gimbal_yaw"]?.Value<double>();
|
|
|
|
|
//var gimbalRoll = payload99?["gimbal_roll"]?.Value<double>();
|
|
|
|
|
var batteryCapacityPercent =
|
|
|
|
|
droneOsdData["data"]?["battery"]?["capacity_percent"]?.Value<int>();
|
|
|
|
|
|
|
|
|
|
dynamic inData = new ExpandoObject();
|
|
|
|
|
// mode_code 0:在线;1:不在线;2:任务执行中
|
|
|
|
|
inData.mode_code = 2;
|
|
|
|
|
inData.longitude = longitude;
|
|
|
|
|
inData.latitude = latitude;
|
|
|
|
|
inData.height = height;
|
|
|
|
|
inData.elevation = elevation;
|
|
|
|
|
inData.gimbal_pitch = gimbalPitch;
|
|
|
|
|
inData.gimbal_yaw = gimbalYaw;
|
|
|
|
|
//data.gimbal_roll = gimbalRoll;
|
|
|
|
|
inData.battery_capacity_percent = batteryCapacityPercent;
|
|
|
|
|
inData.gps_state = 2;
|
|
|
|
|
data.data = inData;
|
|
|
|
|
data.message = "获取无人机机场状态成功!";
|
|
|
|
|
data.traceid = Guid.NewGuid().ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.code = 500;
|
|
|
|
|
data.message = "获取无人机机场状态失败";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.code = 500;
|
|
|
|
|
data.message = "获取无人机机场状态失败";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var response = new ResData();
|
|
|
|
|
if (data.code == 200)
|
|
|
|
|
{
|
|
|
|
|
string x_lc_secret = _helper.getxseret();
|
|
|
|
|
// 转换为字节数组
|
|
|
|
|
byte[] bytes = Encoding.UTF8.GetBytes(data);
|
|
|
|
|
byte[] bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(data));
|
|
|
|
|
var encryptedResData = _helper.Encrypt(bytes);
|
|
|
|
|
response.Result = encryptedResData;
|
|
|
|
|
response.Message = "获取无人机机场状态成功!";
|
|
|
|
@ -705,15 +778,14 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string x_lc_secret = _helper.getxseret();
|
|
|
|
|
string xLcSecret = _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;
|
|
|
|
|
response.Secret = xLcSecret;
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|