添加横滚角,俯仰角

main
陈伟 3 weeks ago
parent 70bf5de0d5
commit d8dc1bbd5f

@ -9,9 +9,11 @@ using Infrastructure.CloudSdk.wayline;
using Infrastructure.Extensions;
using MetadataExtractor;
using MetadataExtractor.Formats.Exif;
using MetadataExtractor.Formats.Xmp;
using Microsoft.Extensions.Logging;
using MQTTnet.Client;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using OpenAuth.App.ServiceApp;
using OpenAuth.Repository.Domain;
using OpenAuth.WebApi;
@ -210,11 +212,32 @@ public class ConfigSubscribe : IJob
_logger.LogDebug($"文件上传处理:{message}");
int flightType = data.flight_task.flight_type;
string flightId = data.file.ext.flight_id;
// 关于flightId 没有值的问题怎么办???
var taskAssign = _manageApp.GetTaskAssignByFlightId(flightId);
var taskId = taskAssign.TaskId;
var executeTask = await _sqlSugarClient
.Queryable<LasaTask>()
.SingleAsync(a => a.Id == taskId);
var taskId = "";
var taskName = "";
var workspaceId = "";
if (taskAssign != null)
{
taskId = taskAssign.TaskId;
var executeTask = await _sqlSugarClient
.Queryable<LasaTask>()
.SingleAsync(a => a.Id == taskId);
if (!string.IsNullOrEmpty(executeTask.TaskName))
{
taskName = executeTask.TaskName;
}
if (!string.IsNullOrEmpty(executeTask.WorkspaceId))
{
workspaceId = executeTask.WorkspaceId;
}
}
else
{
taskName = "指令";
}
string objectKey = data.file.object_key;
var folderKey = ((string)data.file.object_key).Split("/");
var parentKey = folderKey[2];
@ -231,10 +254,8 @@ public class ConfigSubscribe : IJob
FlightId = flightId,
TaskId = taskId,
ParentKey = "0",
Name = string.IsNullOrEmpty(executeTask.TaskName)
? timeStr
: $"{executeTask.TaskName} {timeStr}",
WorkspaceId = executeTask.WorkspaceId,
Name = $"{taskName} {timeStr}",
WorkspaceId = workspaceId,
CreateTime = date,
};
await _sqlSugarClient.Insertable(parent1).ExecuteCommandAsync();
@ -276,7 +297,7 @@ public class ConfigSubscribe : IJob
int width = 0, height = 0, focalLength = 0;
int offset = 0, length = 0;
string model = "";
float? gimbalRoll= 0, gimbalPitch=0;
var fileUrl = "http://" + _minioService.endPoint + "/" + _minioService._bucketName +
"/" + objectKey;
using (var httpClient = new HttpClient())
@ -292,24 +313,38 @@ public class ConfigSubscribe : IJob
.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead).Result;
if (response.StatusCode == HttpStatusCode.PartialContent)
{
//Focal Length 35: 24 mm
//Exif Image Width: 4032 pixels : Exif SubIFD
//Exif Image Height: 3024 pixels : Exif SubIFD
// 3.1 解析Content-Range头格式bytes start-end/total
var contentRange = response.Content.Headers.ContentRange;
if (contentRange != null)
{
fileSize = contentRange.Length.Value;
_logger.LogDebug(
$"获取范围:{contentRange.From}-{contentRange.To}/{contentRange.Length}");
}
if (objectKey.ToLower().EndsWith("jpeg"))
{
// 成功获取部分内容
var y = response.Content.ReadAsByteArrayAsync().Result;
MemoryStream ms = new MemoryStream(y);
var ms = new MemoryStream(y);
var directories = ImageMetadataReader.ReadMetadata(ms);
// 获取 XMP 目录(包含 XMP 原始 XML 数据)
var xmpDirectory = directories.OfType<XmpDirectory>().FirstOrDefault();
if (xmpDirectory != null)
{
// 获取 XMP 的 XML 字符串(原始数据)
var xmpXml = xmpDirectory.GetXmpProperties();
foreach (var keyValuePair in xmpXml)
{
switch (keyValuePair.Key)
{
case "GimbalPitchDegree":
gimbalPitch = float.Parse(keyValuePair.Value);
break;
case "GimbalRollDegree":
gimbalRoll = float.Parse(keyValuePair.Value);
break;
}
}
}
foreach (var directory in directories)
{
if (directory is ExifDirectoryBase)
@ -418,7 +453,7 @@ public class ConfigSubscribe : IJob
ObjectKey = data.file.object_key,
Path = data.file.path, // 目前这个好像没有值
CreateTime = createTime,
WorkspaceId = executeTask.WorkspaceId,
WorkspaceId = workspaceId,
ParentKey = folderKey[2],
Tid = result.tid,
Bid = result.bid,
@ -431,9 +466,11 @@ public class ConfigSubscribe : IJob
display = 1,
FocalLength = focalLength,
PayloadModelName = model,
Type = type
Type = type,
GimbalPitchDegree = gimbalPitch,
GimbalRollDegree = gimbalRoll
};
// todo 添加事务
// 添加事务
await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync();
}
@ -538,6 +575,8 @@ public class ConfigSubscribe : IJob
//更新任务状态及失败原因?
string flightId1 = data.output.ext.flight_id;
var taskId1 = _manageApp.GetTaskAssignByFlightId(flightId1).TaskId;
// "773":"低电量返航导致航线中断"
int reasonCode = data.output.ext.break_point.break_reason;
// 添加断点信息
var taskRecord1 = new LasaTask()
{
@ -546,8 +585,10 @@ public class ConfigSubscribe : IJob
Reason = ErrorMap[code],
BreakPoint = JsonConvert.SerializeObject(data.output.ext.break_point)
};
// 创建一个条件任务怎么样?
await _sqlSugarClient.Updateable(taskRecord1)
.IgnoreNullColumns().ExecuteCommandAsync();
// todo 关于断点原因为773(电量低),处置
}
else
{
@ -599,7 +640,6 @@ public class ConfigSubscribe : IJob
}
break;
// todo
// 任务资源处理
// 航线进度处理
// 任务取消 thing/product/*/services_reply

@ -50,6 +50,14 @@ public class LasaMediaFile
/// 云台偏航角
/// </summary>
public float? GimbalYawDegree { get; set; }
/// <summary>
/// 云台横滚角
/// </summary>
public float? GimbalRollDegree { get; set; }
/// <summary>
/// 云台俯仰角
/// </summary>
public float? GimbalPitchDegree { get; set; }
/// <summary>
/// 拍摄相对高度

Loading…
Cancel
Save