diff --git a/OpenAuth.App/ServiceApp/FlyTask/Response/CommandPictureResponse.cs b/OpenAuth.App/ServiceApp/FlyTask/Response/CommandPictureResponse.cs new file mode 100644 index 0000000..60758e3 --- /dev/null +++ b/OpenAuth.App/ServiceApp/FlyTask/Response/CommandPictureResponse.cs @@ -0,0 +1,24 @@ +namespace OpenAuth.App.ServiceApp.FlyTask.Response; + +public class CommandPictureResponse +{ + public bool Issuccess { get; set; } + public byte[] imgBlob { get; set; } + public ExtData zpkzxx { get; set; } +} + +public class ExtData +{ + public float? lon { get; set; } + public float? lat { get; set; } + public float? yaw { get; set; } + public int pitch { get; set; } + public int roll { get; set; } + public DateTime? time { get; set; } + public double height { get; set; } + public long imgWidth { get; set; } + public long imgHeight { get; set; } + public long imgOriginWidth { get; set; } + public long imgOriginHeight { get; set; } + public double psjj { get; set; } +} \ No newline at end of file diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index f4b7a12..b5b414b 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -1,3 +1,4 @@ +using System.Drawing; using DocumentFormat.OpenXml.Office2010.Excel; using DocumentFormat.OpenXml.Wordprocessing; using Infrastructure; @@ -19,9 +20,12 @@ using OpenAuth.WebApi.CloudSdk; using SqlSugar; using System.Dynamic; using System.Text; +using Hopetry.App.Common; using NPOI.HSSF.Record; using OpenAuth.App.Request; using OpenAuth.App.ServiceApp.AirLine.Request; +using OpenAuth.App.ServiceApp.FlyTask.Response; +using Image = NetModular.DocX.Core.Image; namespace OpenAuth.App.ServiceApp { @@ -1519,7 +1523,7 @@ namespace OpenAuth.App.ServiceApp return rootNodes; } - public async Task> GetTaskPicList(string flightId, long timestamp) + public async Task> GetTaskPicList(string flightId, long timestamp) { var lasaMediaFile = await Repository.ChangeRepository>() .AsQueryable() @@ -1529,18 +1533,54 @@ namespace OpenAuth.App.ServiceApp .SingleAsync(); if (lasaMediaFile == null) { - return new Response() + return new Response() { - Result = new LasaMediaFile() + Result = new CommandPictureResponse() }; } - lasaMediaFile.PicLink = "http://" + _minioService.endPoint + "/" + _minioService._bucketName + "/" + - lasaMediaFile.ObjectKey; - return new Response() + /*lasaMediaFile.PicLink = "http://" + _minioService.endPoint + "/" + _minioService._bucketName + "/" + + lasaMediaFile.ObjectKey;*/ + var tempPath = Path.Combine(Path.GetTempPath(),"lasa"); + if (!Directory.Exists(tempPath)) { - Result = lasaMediaFile + Directory.CreateDirectory(tempPath); + } + await _minioService + .DownLoadObject(_minioService._bucketName, lasaMediaFile.ObjectKey, tempPath, ""); + var picPath = Path.Combine(tempPath, lasaMediaFile.ObjectKey); + var dimensions = GetImageDimensions(picPath); + return new Response() + { + Result = new CommandPictureResponse() + { + Issuccess = true, + // minio 下载图片,并取得图片二进制数据 + imgBlob = await File.ReadAllBytesAsync(picPath), + zpkzxx = new ExtData() + { + imgHeight = dimensions.height, + imgWidth = dimensions.width, + imgOriginHeight = dimensions.height, + imgOriginWidth = dimensions.width, + psjj = 0, // 等效焦距 + time = lasaMediaFile.CreateTime, + height = lasaMediaFile.Height, + lon = lasaMediaFile.Lng, + lat = lasaMediaFile.Lat, + pitch = 0, + roll = 0, + yaw = lasaMediaFile.GimbalYawDegree + } + } }; } + public (int width, int height) GetImageDimensions(string imagePath) + { + using (var bmp = new Bitmap(imagePath)) + { + return (bmp.Width, bmp.Height); + } + } } } \ No newline at end of file diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs index e793638..2371800 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OpenAuth.App.ServiceApp; using OpenAuth.App.ServiceApp.AirLine.Request; +using OpenAuth.App.ServiceApp.FlyTask.Response; using OpenAuth.App.ServiceApp.Request; using OpenAuth.App.ServiceApp.Response; using OpenAuth.Repository.Domain; @@ -259,7 +260,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers /// [HttpGet] [AllowAnonymous] - public async Task> GetTaskPicList(string flightId, long timestamp) + public async Task> GetTaskPicList(string flightId, long timestamp) { return await _app.GetTaskPicList(flightId, timestamp); }