parent
947a781e1b
commit
aeb12f6ad1
|
|
@ -11,6 +11,7 @@ using Infrastructure.Extensions;
|
|||
using Infrastructure.Helpers;
|
||||
using MetadataExtractor;
|
||||
using MetadataExtractor.Formats.Exif;
|
||||
using MetadataExtractor.Formats.Xmp;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
|
@ -1889,7 +1890,7 @@ namespace OpenAuth.App.ServiceApp
|
|||
imgOriginWidth = dimensions.width,
|
||||
psjj = (double)lasaMediaFile.FocalLength,
|
||||
time = lasaMediaFile.CreateTime,
|
||||
height = (double) lasaMediaFile.Height,
|
||||
height = (double)lasaMediaFile.Height,
|
||||
lon = lasaMediaFile.Lng,
|
||||
lat = lasaMediaFile.Lat,
|
||||
pitch = 0,
|
||||
|
|
@ -2016,11 +2017,32 @@ namespace OpenAuth.App.ServiceApp
|
|||
var data = result.data;
|
||||
int flightType = data.flight_task.flight_type;
|
||||
string flightId = data.file.ext.flight_id;
|
||||
// 关于flightId 没有值的问题怎么办???
|
||||
var taskAssign = GetTaskAssignByFlightId(flightId);
|
||||
var taskId = taskAssign.TaskId;
|
||||
var executeTask = await Repository.AsSugarClient()
|
||||
.Queryable<LasaTask>()
|
||||
.SingleAsync(a => a.Id == taskId);
|
||||
var taskId = "";
|
||||
var taskName = "";
|
||||
var workspaceId = "";
|
||||
if (taskAssign != null)
|
||||
{
|
||||
taskId = taskAssign.TaskId;
|
||||
var executeTask = await Repository.AsSugarClient()
|
||||
.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];
|
||||
|
|
@ -2037,10 +2059,8 @@ namespace OpenAuth.App.ServiceApp
|
|||
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 Repository.AsSugarClient().Insertable(parent1).ExecuteCommandAsync();
|
||||
|
|
@ -2054,8 +2074,8 @@ namespace OpenAuth.App.ServiceApp
|
|||
if (mediaFile == null)
|
||||
{
|
||||
var type = 0;
|
||||
var preSize = 5;
|
||||
// todo 判断是不是图片
|
||||
var preSize = 1;
|
||||
// 判断是不是图片
|
||||
if (objectKey.EndsWith(".jpeg")) // todo 是否有其它类型的图片,待确定
|
||||
{
|
||||
preSize = 65535;
|
||||
|
|
@ -2082,7 +2102,8 @@ namespace OpenAuth.App.ServiceApp
|
|||
int width = 0, height = 0, focalLength = 0;
|
||||
int offset = 0, length = 0;
|
||||
string model = "";
|
||||
|
||||
float? gimbalRoll = 0, gimbalPitch = 0;
|
||||
float? digitalZoomRatio = 1;
|
||||
var fileUrl = "http://" + _minioService.endPoint + "/" + _minioService._bucketName +
|
||||
"/" + objectKey;
|
||||
using (var httpClient = new HttpClient())
|
||||
|
|
@ -2098,24 +2119,42 @@ namespace OpenAuth.App.ServiceApp
|
|||
.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;
|
||||
Console.WriteLine(
|
||||
$"获取范围:{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)
|
||||
{
|
||||
// // drone-dji:GimbalPitchDegree: -90.00
|
||||
//drone-dji:GimbalReverse: 0
|
||||
//drone-dji:GimbalRollDegree: +180.00
|
||||
//drone-dji:GimbalYawDegree: -96.40
|
||||
case "drone-dji:GimbalPitchDegree":
|
||||
gimbalPitch = float.Parse(keyValuePair.Value);
|
||||
break;
|
||||
case "drone-dji:GimbalRollDegree":
|
||||
gimbalRoll = float.Parse(keyValuePair.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var directory in directories)
|
||||
{
|
||||
if (directory is ExifDirectoryBase)
|
||||
|
|
@ -2133,8 +2172,14 @@ namespace OpenAuth.App.ServiceApp
|
|||
|
||||
if (directory.Name.Equals("Exif SubIFD"))
|
||||
{
|
||||
// Digital Zoom Ratio: 1 Exif SubIFD
|
||||
foreach (var tag in directory.Tags)
|
||||
{
|
||||
if (tag.Name.Equals("Digital Zoom Ratio"))
|
||||
{
|
||||
digitalZoomRatio = float.Parse(tag.Description);
|
||||
}
|
||||
|
||||
if (tag.Name.Equals("Exif Image Width"))
|
||||
{
|
||||
width = int.Parse(tag.Description.Replace("pixels", "")
|
||||
|
|
@ -2205,6 +2250,7 @@ namespace OpenAuth.App.ServiceApp
|
|||
var createTime = string.IsNullOrEmpty(createdTimeStr)
|
||||
? DateTime.Now
|
||||
: createdTimeStr.ToDateTime();
|
||||
// _logger.LogDebug("执行到保存媒体文件之前");
|
||||
var fileUpload = new LasaMediaFile()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
|
|
@ -2223,7 +2269,7 @@ namespace OpenAuth.App.ServiceApp
|
|||
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,
|
||||
|
|
@ -2236,9 +2282,12 @@ namespace OpenAuth.App.ServiceApp
|
|||
display = 1,
|
||||
FocalLength = focalLength,
|
||||
PayloadModelName = model,
|
||||
Type = type
|
||||
Type = type,
|
||||
GimbalPitchDegree = gimbalPitch,
|
||||
GimbalRollDegree = gimbalRoll,
|
||||
DigitalZoomRatio = digitalZoomRatio
|
||||
};
|
||||
// todo 添加事务
|
||||
// 添加事务
|
||||
await Repository.AsSugarClient().Insertable(fileUpload).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
|
@ -2269,14 +2318,6 @@ namespace OpenAuth.App.ServiceApp
|
|||
ExpectedFileCount = expectFileCount, // 期望文件数量
|
||||
UploadedFileCount = uploadedFileCount // 已上传文件数量
|
||||
};
|
||||
// 当expectFileCount 等于uploadedFileCount时,则表示航线执行完成
|
||||
/*
|
||||
if (uploadedFileCount.Equals(expectFileCount))
|
||||
{
|
||||
taskRecord.Status = 5; // 成功状态
|
||||
}
|
||||
*/
|
||||
|
||||
await Repository.AsSugarClient().Updateable(taskRecord)
|
||||
.IgnoreNullColumns().ExecuteCommandAsync();
|
||||
|
||||
|
|
|
|||
|
|
@ -210,6 +210,7 @@ public class ConfigSubscribe : IJob
|
|||
// 文件上传
|
||||
_logger.LogDebug("进入文件上传处理");
|
||||
_logger.LogDebug($"文件上传处理:{message}");
|
||||
//飞行任务 0 指令飞行 1
|
||||
int flightType = data.flight_task.flight_type;
|
||||
string flightId = data.file.ext.flight_id;
|
||||
// 关于flightId 没有值的问题怎么办???
|
||||
|
|
@ -270,7 +271,7 @@ public class ConfigSubscribe : IJob
|
|||
{
|
||||
var type = 0;
|
||||
var preSize = 1;
|
||||
// todo 判断是不是图片
|
||||
// 判断是不是图片
|
||||
if (objectKey.EndsWith(".jpeg")) // todo 是否有其它类型的图片,待确定
|
||||
{
|
||||
preSize = 65535;
|
||||
|
|
@ -450,7 +451,7 @@ public class ConfigSubscribe : IJob
|
|||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
FlightId = flightId, // 计划id
|
||||
TaskId = taskAssign.TaskId, // 任务id
|
||||
TaskId = taskId, // 任务id
|
||||
DroneModelKey = data.file.ext.drone_model_key, // 无人机型号
|
||||
PayloadModelKey = data.file.ext.payload_model_key, //这应该可以标明是什么设置
|
||||
IsOriginal = data.file.ext.is_original,
|
||||
|
|
|
|||
Loading…
Reference in New Issue