diff --git a/Infrastructure/Infrastructure.csproj b/Infrastructure/Infrastructure.csproj
index 0e81524..9240894 100644
--- a/Infrastructure/Infrastructure.csproj
+++ b/Infrastructure/Infrastructure.csproj
@@ -34,6 +34,7 @@
+
diff --git a/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs b/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs
index b2b0bc1..92fc982 100644
--- a/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs
+++ b/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs
@@ -19,6 +19,12 @@ using DocumentFormat.OpenXml.Drawing.Charts;
using Org.BouncyCastle.Ocsp;
using System.Net.Http.Headers;
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
+using System.Data.SQLite;
+using Infrastructure.CloudSdk.minio;
+using Infrastructure.Extensions;
+using System.Security.Cryptography;
+using System.Text.Json.Nodes;
+using Newtonsoft.Json.Linq;
namespace OpenAuth.App.ServiceApp.DroneDocking
@@ -27,10 +33,14 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
{
private EncryptionHelper _helper;
private IConfiguration configuration;
- public DroneDockApp(EncryptionHelper helper, IConfiguration configuration, ISugarUnitOfWork unitWork, ISimpleClient repository, IAuth auth) : base(unitWork, repository, auth)
+ private readonly ISqlSugarClient _client;
+ private readonly MinioService _minioService;
+ public DroneDockApp(EncryptionHelper helper, IConfiguration configuration, ISqlSugarClient client, MinioService minioService, ISugarUnitOfWork unitWork, ISimpleClient repository, IAuth auth) : base(unitWork, repository, auth)
{
_helper = helper;
this.configuration = configuration;
+ _client = client;
+ _minioService = minioService;
}
///
@@ -830,12 +840,12 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
return Response;
}
- public Response UploadFile(AirPortUploadDbReq req)
+ public async Task> UploadFile(AirPortUploadDbReq req)
{
Response Response = new Response();
var filePath = req.filePath;
var uploadUrl = req.fileUrl;
- var fileName = Path.GetFileName(filePath);
+ var fileName = req.filename;
byte[] fileBuffer = null;
HttpClient client = null;
MultipartFormDataContent formData = null;
@@ -852,7 +862,7 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
fileContent.Headers.ContentDisposition.FileName = fileName;
//注意:务必 根据 文件扩展名,这里指定 ContentType
fileContent.Headers.ContentType = new
- MediaTypeHeaderValue(fileName);
+ MediaTypeHeaderValue("application/octet-stream");
formData.Add(fileContent);
var request = new HttpRequestMessage
{
@@ -893,33 +903,176 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
//查询数据 检查是否有重复数据
var info = uow.DbfineInfo.AsQueryable().Where(r => r.taskid == taskid).First();
- if (true)
- {
string json = JsonSerializer.Serialize(info);
string x_lc_secret = _helper.getxseret();
// 转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(json);
var encryptedResData = _helper.Encrypt(bytes);
Response.Result = encryptedResData;
- Response.Message = "获取无人机机场状态成功!";
+ Response.Message = "获取无人机成果成功!";
Response.Code = 200;
Response.Secret = x_lc_secret;
return Response;
+
+
+ }
+ }
+
+ public async void InsertDb(string taskid) {
+ var sqliteconnect = configuration.GetSection("DroneDocking:DbFile").Value;
+ string _sqliteConnection = "DataSource = "+ sqliteconnect + "; Version = 3; ";
+ string sql = "select * from drone_docktaskdetail where taskid='" + taskid + "'";
+ var filigtlist = _client.Ado.SqlQuery(sql);
+ using (var sqliteConn = new SQLiteConnection(_sqliteConnection))
+ {
+ sqliteConn.Open();
+
+
+
+ string deleteDbinfo1 = "delete from JMXX";
+ using (var cmd2 = new SQLiteCommand(deleteDbinfo1, sqliteConn))
+ {
+
+ cmd2.ExecuteNonQuery();
+ }
+ string sqlInsert = "INSERT INTO JMXX (ZSDM, SZZS,ZSBFJGDM,ZSBFJGGY) VALUES (@ZSDM, @SZZS,@ZSBFJGDM,@ZSBFJGGY)";
+ using (var cmd1 = new SQLiteCommand(sqlInsert, sqliteConn))
+ {
+ cmd1.Parameters.AddWithValue("@ZSDM", "UAV32_LJY2FPMYDE6UDES3P3ZD7V3IKQ");
+ cmd1.Parameters.AddWithValue("@SZZS", "eyJvcmdjb2RlIjoiOTEzNzEzMDAzMjgzOTg1NzdRIiwib3JnbmFtZSI6IuWxseS4nOaFp+WIm+S/oeaBr+enkeaKgOaciemZkOWFrOWPuCIsImNlcnRjb2RlIjoiVUFWMzJfTEpZMkZQTVlERTZVREVTM1AzWkQ3VjNJS1EiLCJjZXJ0b3JnY29kZSI6IjEyMTAwMDAwNDAwMDEwMzk4UCIsImNlcnRvcmduYW1lIjoi5Lit5Zu95Zu95Zyf5YuY5rWL6KeE5YiS6Zmi5omn5rOV5qih5Z2XIiwiZXhwaXJhdGlvbiI6IjIwMjYtMDctMDEgMTU6NDY6MjAiLCJwdWJsaWNrZXkiOiIwNEYxQkYxQkVGRDYzRjE2RTVEQjNCQ0QzMkNBNUQ5QThFOERGN0FERDY3RDZDNEYyOTNGQjIzRjdCREE3NEY1MkQzMUI4RERBRDAzRDk1NUQ1NjY1MDVBMTVEOEI3REJFODNCNDIzNzhCOEU4NzQ5QzBFQjZFMkZCQzg2Nz" +
+ "U4MzhCIiwic2lnbiI6IjJBQTIyNDkwQzYxNkI0NjEzNUY2MDRBNDczNjFCQjJGRDcxMEJGOTdBQjcyNDdCMzYxQzc2N0NGQTNGNzcyMTQ0MkExQzhDMUVBRTIxRkEwQUZEMzJGRDg1NjdDMDg1MThGRUY4NTg2RUVCNkE4OTE1MDVBQjUxRjZDNDUyRUM2IiwiY2VydHR5cGUiOiLml6DkurrmnLrkuL7or4Hor4HkuaYiLCJyZWdpb25jb2RlIjoiMzcxMzAwIn0=");
+ cmd1.Parameters.AddWithValue("@ZSBFJGDM", "91371300328398577Q");
+ cmd1.Parameters.AddWithValue("@ZSBFJGGY", "04F1BF1BEFD63F16E5DB3BCD32CA5D9A8E8DF7ADD67D6C4F293FB23F7BDA74F52D31B8DDAD03D955D566505A15D8B7DBE83B42378B8E8749C0EB6E2FBC8675838B");
+ cmd1.ExecuteNonQuery();
+ }
+
+
+
+ string deleteDbinfo = "delete from DB_INFO";
+ using (var cmd = new SQLiteCommand(deleteDbinfo, sqliteConn))
+ {
+
+ cmd.ExecuteNonQuery();
}
- else
+
+ DateTime dt = DateTime.Now;
+ string dt24 = dt.ToString("yyyy-MM-dd HH:mm:ss");
+ string sqlInsertDbinfo = "INSERT INTO DB_INFO (VERSION, CREATETIME,UPDATETIME,CREATEUSER,DESCRIPTION) VALUES (@VERSION, @CREATETIME,@UPDATETIME,@CREATEUSER,@DESCRIPTION)";
+ using (var cmd = new SQLiteCommand(sqlInsertDbinfo, sqliteConn))
+ {
+ cmd.Parameters.AddWithValue("@VERSION", 2.0);
+ cmd.Parameters.AddWithValue("@CREATETIME", dt24);
+ cmd.Parameters.AddWithValue("@UPDATETIME", dt24);
+ cmd.Parameters.AddWithValue("@CREATEUSER", "system");
+ cmd.Parameters.AddWithValue("@DESCRIPTION", "DESCRIPTION");
+ cmd.ExecuteNonQuery();
+ }
+ string deleteFj = "delete from FJ";
+ using (var cmd = new SQLiteCommand(deleteFj, sqliteConn))
{
- 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;
+ cmd.ExecuteNonQuery();
}
+ for (int i = 0; i < filigtlist.Count; i++)
+ {
+ var flightid = filigtlist[i];
+ string fligthpicsql = "select * from lasa_mediafile where \"FlightId\"='"+ flightid.flighttaskid+"'";
+
+ var pics = _client.Ado.SqlQuery(fligthpicsql);
+ for (int j = 0; j < pics.Count; j++)
+ {
+
+ var pic = pics[j];
+ var imageStream = _minioService.GetObjectAsStream("", pic.ObjectKey+"");
+ if (imageStream.Result==null)
+ {
+ continue;
+ }
+ byte[] bytes;
+ using (MemoryStream memoryStream = new MemoryStream())
+ {
+ imageStream.Result.CopyTo(memoryStream); // 将原始流复制到MemoryStream中
+ bytes = memoryStream.ToArray(); // 获取MemoryStream的字节数组表示
+ }
+
+ string fileHash;
+ using (var sha256 = SHA256.Create()) {
+ var hashBytes = sha256.ComputeHash(bytes);
+ fileHash = BitConverter.ToString(hashBytes).Replace("-",
+ "").ToLower();
+ }
+ string sqlintoFj = "INSERT INTO FJ (BSM, DKLX,DKBSM,ZDKBH,XZQDM,FJMC,FJLX,PSTZ,FJ,FJHXZ,PSSJ,XDGD,JDGD,Longitude,Latitude,PSFYJ,PSJD,PSHGJ,PSJJ,FJYSKD,FJYSGD,PSDXZXX,PSRY,SPKZXX,ZSDM,JYM) " +
+ "VALUES (@BSM, @DKLX,@DKBSM,@ZDKBH,@XZQDM,@FJMC,@FJLX,@PSTZ,@FJ,@FJHXZ,@PSSJ,@XDGD,@JDGD,@Longitude,@Latitude,@PSFYJ,@PSJD,@PSHGJ,@PSJJ,@FJYSKD,@FJYSGD,@PSDXZXX,@PSRY,@SPKZXX,@ZSDM,@JYM)";
+ using (var cmd = new SQLiteCommand(sqlintoFj, sqliteConn))
+ {
+ cmd.Parameters.AddWithValue("@BSM", pic.Id);
+ cmd.Parameters.AddWithValue("@DKLX", flightid.dklx);
+ cmd.Parameters.AddWithValue("@DKBSM", flightid.dkbh);
+ cmd.Parameters.AddWithValue("@ZDKBH", flightid.zdkbh);
+ cmd.Parameters.AddWithValue("@XZQDM", flightid.xzqdm);
+ cmd.Parameters.AddWithValue("@FJMC", pic.Name);
+ cmd.Parameters.AddWithValue("@FJLX", 1);
+ cmd.Parameters.AddWithValue("@PSTZ", "Y");
+ cmd.Parameters.AddWithValue("@FJ", bytes);
+ cmd.Parameters.AddWithValue("@FJHXZ", fileHash);
+ cmd.Parameters.AddWithValue("@PSSJ",pic.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
+ cmd.Parameters.AddWithValue("@XDGD", pic.RelativeAltitude);
+ cmd.Parameters.AddWithValue("@JDGD", pic.AbsoluteAltitude);
+ cmd.Parameters.AddWithValue("@Longitude", pic.Lat);
+ cmd.Parameters.AddWithValue("@Latitude", pic.Lng);
+ cmd.Parameters.AddWithValue("@PSFYJ", pic.GimbalYawDegree);
+ cmd.Parameters.AddWithValue("@PSJD", pic.GimbalYawDegree);
+ cmd.Parameters.AddWithValue("@PSHGJ", pic.GimbalYawDegree);
+ cmd.Parameters.AddWithValue("@PSJJ", pic.FocalLength);
+ cmd.Parameters.AddWithValue("@FJYSKD", pic.Width);
+ cmd.Parameters.AddWithValue("@FJYSGD", pic.Height);
+ cmd.Parameters.AddWithValue("@PSDXZXX", "");
+ cmd.Parameters.AddWithValue("@PSRY", "system");
+ cmd.Parameters.AddWithValue("@SPKZXX", "wu");
+ cmd.Parameters.AddWithValue("@ZSDM", "UAV32_LJY2FPMYDE6UDES3P3ZD7V3IKQ");
+ cmd.Parameters.AddWithValue("@JYM", "DESCRIPTION");
+ cmd.ExecuteNonQuery();
+ }
+ }
+ }
+ sqliteConn.Close();
+
+ }
+ AirPortUploadReq airPortUploadReq = new AirPortUploadReq();
+ airPortUploadReq.code = "AirportData";
+ airPortUploadReq.regioncode = filigtlist[0].xzqdm;
+ List strings = new List();
+ strings.Add(filigtlist[0].xzqdm + ".db");
+ airPortUploadReq.filenames = strings;
+ var result = await getUploadFilePath(airPortUploadReq);
+ var jsonstr = result.Result;
+ JArray jObject = JArray.Parse(jsonstr);
+ var liststr = jObject[0].Value();
+ var write = liststr["writeurl"].ToString();
+ var read = liststr["readurl"].ToString();
+ AirPortUploadDbReq req = new AirPortUploadDbReq();
+ req.fileUrl = write;
+ req.filePath = configuration.GetSection("DroneDocking:DbFile").Value;
+ req.filename = filigtlist[0].xzqdm + ".db";
+ using (var uow = base.UnitWork.CreateContext())
+ {
+ DbfineInfo dbfine = new DbfineInfo();
+ dbfine.id = Guid.NewGuid().ToString();
+ dbfine.taskid = taskid;
+ dbfine.regioncode = filigtlist[0].xzqdm;
+ dbfine.extension = ".db";
+ dbfine.attachment_count = 1;
+ dbfine.size = 1000;
+ dbfine.count = 50;
+ dbfine.url = read;
+ dbfine.hashcode = "adewfdafdaf";
+ var info = await uow.DbfineInfo.InsertAsync(dbfine);
+
+ uow.Commit();
+ Console.WriteLine(info);
}
+ await UploadFile(req);
+
}
// 安全获取响应头值的方法
private static string GetHeaderValue(HttpResponseMessage response, string headerName)
diff --git a/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortDbFj.cs b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortDbFj.cs
new file mode 100644
index 0000000..f4bf87a
--- /dev/null
+++ b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortDbFj.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenAuth.App.ServiceApp.DroneDocking.Request
+{
+ public class AirPortDbFj
+ {
+ public string BSM { get; set; }
+ public string DKIX { get; set; }
+ public string DRBSM { get; set; }
+ public string ZDKBH { get; set; }
+ public string XZQDM { get; set; }
+ public string FJMC { get; set; }
+ public string FJLX { get; set; }
+ public byte[] FJ { get; set; }
+ public string FJHXZ { get; set; }
+ public string PSSJ { get; set; }
+ public double XDGD { get; set; }
+ public double JDGD { get; set; }
+ public float Longitude { get; set; }
+ public float Latitude { get; set; }
+ public int PSF01 { get; set; }
+ public int PSJD { get; set; }
+ public int FJYSKD { get; set; }
+ public int FJYSGD { get; set; }
+ public string PSRY { get; set; }
+ public string ZSDM { get; set; }
+ public string JYM { get; set; }
+
+
+
+
+
+
+ }
+}
diff --git a/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadDbReq.cs b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadDbReq.cs
index fc6c677..aa44d6c 100644
--- a/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadDbReq.cs
+++ b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadDbReq.cs
@@ -12,9 +12,9 @@ namespace OpenAuth.App.ServiceApp.DroneDocking.Request
public string fileUrl { get; set; }
-
+ public string filename { get; set; }
+
+
-
-
}
}
diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs
index bd5062c..fcb270b 100644
--- a/OpenAuth.App/ServiceApp/ManageApp.cs
+++ b/OpenAuth.App/ServiceApp/ManageApp.cs
@@ -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;
@@ -897,7 +898,7 @@ namespace OpenAuth.App.ServiceApp
var rainThreshold = 3; // 大雨
var windSpeedThreshold = 12;
double weatherWindSpeed = 0; // 天气预报风速
- double weatherWindSpeedThreshold = 0;
+ double weatherWindSpeedThreshold = 12;
switch (dockTypeId)
{
case "Dock":
@@ -914,6 +915,12 @@ namespace OpenAuth.App.ServiceApp
break;
}
+ // 如果未开始云端阻飞,或者未开启天气阻飞,改变天气阻飞默认阀值
+ if (!workspace.IsWeatherBlockFlight || !workspace.IsCloudBlockFlight)
+ {
+ weatherWindSpeedThreshold = windSpeedThreshold;
+ }
+
// 1. 云端阻飞开启天气阻飞未开启 2. 云端阻飞未开启 3. 云端阻飞开启,天气阻飞开启
if (workspace.IsCloudBlockFlight)
{
@@ -1887,9 +1894,9 @@ namespace OpenAuth.App.ServiceApp
imgWidth = dimensions.width,
imgOriginHeight = dimensions.height,
imgOriginWidth = dimensions.width,
- psjj = lasaMediaFile.FocalLength,
+ psjj = (double)lasaMediaFile.FocalLength,
time = lasaMediaFile.CreateTime,
- height = lasaMediaFile.Height,
+ height = (double)lasaMediaFile.Height,
lon = lasaMediaFile.Lng,
lat = lasaMediaFile.Lat,
pitch = 0,
@@ -2016,11 +2023,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()
- .SingleAsync(a => a.Id == taskId);
+ var taskId = "";
+ var taskName = "";
+ var workspaceId = "";
+ if (taskAssign != null)
+ {
+ taskId = taskAssign.TaskId;
+ var executeTask = await Repository.AsSugarClient()
+ .Queryable()
+ .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 +2065,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 +2080,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 +2108,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 +2125,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().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 +2178,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 +2256,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 +2275,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 +2288,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 +2324,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();
diff --git a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs
index 127753b..8a9f7f8 100644
--- a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs
+++ b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs
@@ -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;
@@ -208,16 +210,43 @@ 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 没有值的问题怎么办???
var taskAssign = _manageApp.GetTaskAssignByFlightId(flightId);
- var taskId = taskAssign.TaskId;
- var executeTask = await _sqlSugarClient
- .Queryable()
- .SingleAsync(a => a.Id == taskId);
+ var taskId = "";
+ var taskName = "";
+ var workspaceId = "";
+ if (taskAssign != null)
+ {
+ taskId = taskAssign.TaskId;
+ var executeTask = await _sqlSugarClient
+ .Queryable()
+ .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];
+ if (flightType.Equals(1))
+ {
+ parentKey = flightId;
+ }
+
var isExist = await _sqlSugarClient
.Queryable()
.Where(x => x.Id.Equals(parentKey)).CountAsync();
@@ -227,14 +256,12 @@ public class ConfigSubscribe : IJob
var timeStr = date.ToString("yyyy-MM-dd HH:mm:ss");
var parent1 = new LasaMediaFile()
{
- Id = folderKey[2],
+ Id = parentKey,
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();
@@ -249,7 +276,7 @@ public class ConfigSubscribe : IJob
{
var type = 0;
var preSize = 1;
- // todo 判断是不是图片
+ // 判断是不是图片
if (objectKey.EndsWith(".jpeg")) // todo 是否有其它类型的图片,待确定
{
preSize = 65535;
@@ -276,7 +303,8 @@ public class ConfigSubscribe : IJob
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())
@@ -292,24 +320,42 @@ 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().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)
@@ -327,8 +373,14 @@ public class ConfigSubscribe : IJob
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", "")
@@ -404,7 +456,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,
@@ -418,8 +470,8 @@ public class ConfigSubscribe : IJob
ObjectKey = data.file.object_key,
Path = data.file.path, // 目前这个好像没有值
CreateTime = createTime,
- WorkspaceId = executeTask.WorkspaceId,
- ParentKey = folderKey[2],
+ WorkspaceId = workspaceId,
+ ParentKey = parentKey,
Tid = result.tid,
Bid = result.bid,
FlightType = flightType,
@@ -431,9 +483,12 @@ public class ConfigSubscribe : IJob
display = 1,
FocalLength = focalLength,
PayloadModelName = model,
- Type = type
+ Type = type,
+ GimbalPitchDegree = gimbalPitch,
+ GimbalRollDegree = gimbalRoll,
+ DigitalZoomRatio = digitalZoomRatio
};
- // todo 添加事务
+ // 添加事务
await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync();
}
@@ -538,6 +593,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 +603,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 +658,6 @@ public class ConfigSubscribe : IJob
}
break;
- // todo
// 任务资源处理
// 航线进度处理
// 任务取消 thing/product/*/services_reply
diff --git a/OpenAuth.Repository/Domain/DbfileInfo.cs b/OpenAuth.Repository/Domain/DbfileInfo.cs
index 96ea76a..f8e3b87 100644
--- a/OpenAuth.Repository/Domain/DbfileInfo.cs
+++ b/OpenAuth.Repository/Domain/DbfileInfo.cs
@@ -49,6 +49,7 @@ public class DbfineInfo
///
/// 云台偏航角
///
+
public string hashcode { get; set; }
///
diff --git a/OpenAuth.Repository/Domain/LasaMediaFile.cs b/OpenAuth.Repository/Domain/LasaMediaFile.cs
index 11a6009..32f67b9 100644
--- a/OpenAuth.Repository/Domain/LasaMediaFile.cs
+++ b/OpenAuth.Repository/Domain/LasaMediaFile.cs
@@ -51,6 +51,21 @@ public class LasaMediaFile
///
public float? GimbalYawDegree { get; set; }
+ ///
+ /// 云台横滚角
+ ///
+ public float? GimbalRollDegree { get; set; }
+
+ ///
+ /// 云台俯仰角
+ ///
+ public float? GimbalPitchDegree { get; set; }
+
+ ///
+ /// 数字变焦比例
+ ///
+ public float? DigitalZoomRatio { get; set; }
+
///
/// 拍摄相对高度
///
@@ -116,16 +131,16 @@ public class LasaMediaFile
public int? FlightType { get; set; }
- [SugarColumn(IsIgnore = true)]
- public string PicLink { get; set; }
+ [SugarColumn(IsIgnore = true)] public string PicLink { get; set; }
public string minipic { get; set; }
-
+
public double? FocalLength { get; set; }
-
+
public string PayloadModelName { get; set; }
public int? Type { get; set; }
+
[SugarColumn(IsIgnore = true)] public List Children { get; set; }
[SugarColumn(IsIgnore = true)] public string CreateUserName { get; set; }
diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/DroneDockController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/DroneDockController.cs
index 5b7a187..b915ca3 100644
--- a/OpenAuth.WebApi/Controllers/ServiceControllers/DroneDockController.cs
+++ b/OpenAuth.WebApi/Controllers/ServiceControllers/DroneDockController.cs
@@ -492,11 +492,11 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
[HttpPost]
[AllowAnonymous]
- public Response UploadFile(AirPortUploadDbReq req) {
+ public async Task> UploadFile(AirPortUploadDbReq req) {
var result = new Response();
try
{
- result = _app.UploadFile(req);
+ result = await _app.UploadFile(req);
}
catch (Exception ex)
{
@@ -547,5 +547,21 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
}
}
+
+
+ [HttpGet]
+ [AllowAnonymous]
+
+ public async Task> dbupload (string taskid)
+ {
+ var result = new ReciveData();
+
+ _app.InsertDb(taskid);
+ result.code = 200;
+ result.message = "success";
+
+ return result;
+
+ }
}
}
diff --git a/OpenAuth.WebApi/Startup.cs b/OpenAuth.WebApi/Startup.cs
index 01e67e0..4b64f46 100644
--- a/OpenAuth.WebApi/Startup.cs
+++ b/OpenAuth.WebApi/Startup.cs
@@ -399,7 +399,9 @@ namespace OpenAuth.WebApi
{ ".txt", "application/octet-stream" },
{ ".xlsx", "application/octet-stream" },
{ ".xls", "application/vnd.ms-excel" },
- { ".pdf", "application/pdf" }
+ { ".pdf", "application/pdf" },
+ { ".js","application/javascript" },
+ { ".cjs","application/javascript" }
})
};
app.UseStaticFiles(staticfile);
diff --git a/OpenAuth.WebApi/appsettings.json b/OpenAuth.WebApi/appsettings.json
index 7287275..d628cfb 100644
--- a/OpenAuth.WebApi/appsettings.json
+++ b/OpenAuth.WebApi/appsettings.json
@@ -83,6 +83,7 @@
"limitspeed": 1048576
},
"DroneDocking": {
- "Url": "https://wp.tianmu.cloud:5443/zhcfzx"
+ "Url": "https://wp.tianmu.cloud:5443/zhcfzx",
+ "DbFile": "E:\\Program Files (x86)\\DingDing\\DTalkFIle\\(371325)费县_20250628155400093.db"
}
}