From 8e9f66a4ff34f64a3b9b2b9b8f813badca615111 Mon Sep 17 00:00:00 2001 From: lgd Date: Tue, 5 Aug 2025 09:00:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceApp/DroneDocking/DroneDockApp.cs | 65 +++++++++++++++++-- .../Request/AirPortStatusApply.cs | 23 +++++-- .../Request/AirPortUploadDbReq.cs | 20 ++++++ .../DroneDocking/Request/AirPortUploadReq.cs | 23 ++----- .../ServiceControllers/DroneDockController.cs | 18 ++++- 5 files changed, 118 insertions(+), 31 deletions(-) create mode 100644 OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadDbReq.cs diff --git a/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs b/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs index b9dabbf..b2b0bc1 100644 --- a/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs +++ b/OpenAuth.App/ServiceApp/DroneDocking/DroneDockApp.cs @@ -17,6 +17,8 @@ using DocumentFormat.OpenXml.Math; using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; using DocumentFormat.OpenXml.Drawing.Charts; using Org.BouncyCastle.Ocsp; +using System.Net.Http.Headers; +using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing; namespace OpenAuth.App.ServiceApp.DroneDocking @@ -828,13 +830,62 @@ namespace OpenAuth.App.ServiceApp.DroneDocking return Response; } - - /// - /// 无人机状态获取 - /// - /// - /// - public async Task getResult(string taskid) + public Response UploadFile(AirPortUploadDbReq req) + { + Response Response = new Response(); + var filePath = req.filePath; + var uploadUrl = req.fileUrl; + var fileName = Path.GetFileName(filePath); + byte[] fileBuffer = null; + HttpClient client = null; + MultipartFormDataContent formData = null; + try + { + //文件过大,建议使用 大文件上传接口,分段读取,进行上传 + fileBuffer = File.ReadAllBytes(filePath); + client = new HttpClient(); + client.Timeout = new TimeSpan(0, 0, 0, 5); + formData = new MultipartFormDataContent(); + var fileContent = new ByteArrayContent(fileBuffer); + fileContent.Headers.ContentDisposition = new + ContentDispositionHeaderValue("attachment"); + fileContent.Headers.ContentDisposition.FileName = fileName; + //注意:务必 根据 文件扩展名,这里指定 ContentType + fileContent.Headers.ContentType = new + MediaTypeHeaderValue(fileName); + formData.Add(fileContent); + var request = new HttpRequestMessage + { + //注意:这里是 PUT + Method = HttpMethod.Put, + RequestUri = new Uri(uploadUrl), + Content = formData + }; + var result = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result; + if (string.IsNullOrWhiteSpace(result)) + { + Response.Result = result; + + } + } + catch (Exception ex) + { + Response.Result = "上传失败"; + } + finally + { + fileBuffer = null; + formData?.Dispose(); + client?.Dispose(); + } + return Response; + } + /// + /// 无人机状态获取 + /// + /// + /// + public async Task getResult(string taskid) { ResData Response = new ResData(); using (var uow = base.UnitWork.CreateContext()) diff --git a/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortStatusApply.cs b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortStatusApply.cs index c80ce73..ebcd9c2 100644 --- a/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortStatusApply.cs +++ b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortStatusApply.cs @@ -6,15 +6,28 @@ using System.Threading.Tasks; namespace OpenAuth.App.ServiceApp.DroneDocking.Request { - public class AirPortUploadReq + public class AirPortStatusApply { - public string code { get; set; } + public string deviceid { get; set; } - public string regioncode { get; set; } + public string onlinestate { get; set; } - public List filenames { get; set; } + public double longitude { get; set; } + + public double latitude { get; set; } + + public double height { get; set; } + + public double elevation { get; set; } + + public double gimbal_pitch { get; set; } + + public double gimbal_ya { get; set; } + + public int battery_capacity_percent { get; set; } + + public int gps_state { get; set; } - } } diff --git a/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadDbReq.cs b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadDbReq.cs new file mode 100644 index 0000000..fc6c677 --- /dev/null +++ b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadDbReq.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenAuth.App.ServiceApp.DroneDocking.Request +{ + public class AirPortUploadDbReq + { + public string filePath { get; set; } + + public string fileUrl { get; set; } + + + + + + } +} diff --git a/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadReq.cs b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadReq.cs index ebcd9c2..c80ce73 100644 --- a/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadReq.cs +++ b/OpenAuth.App/ServiceApp/DroneDocking/Request/AirPortUploadReq.cs @@ -6,28 +6,15 @@ using System.Threading.Tasks; namespace OpenAuth.App.ServiceApp.DroneDocking.Request { - public class AirPortStatusApply + public class AirPortUploadReq { - public string deviceid { get; set; } + public string code { get; set; } - public string onlinestate { get; set; } + public string regioncode { get; set; } - public double longitude { get; set; } - - public double latitude { get; set; } - - public double height { get; set; } - - public double elevation { get; set; } - - public double gimbal_pitch { get; set; } - - public double gimbal_ya { get; set; } - - public int battery_capacity_percent { get; set; } - - public int gps_state { get; set; } + public List filenames { get; set; } + } } diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/DroneDockController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/DroneDockController.cs index b052f9f..5b7a187 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/DroneDockController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/DroneDockController.cs @@ -8,6 +8,7 @@ using OpenAuth.App.ServiceApp.DroneDocking.Request; using OpenAuth.App.ServiceApp.DroneDocking.Response; using OpenAuth.App.ServiceApp.Response; using OpenAuth.Repository.Domain; +using Org.BouncyCastle.Ocsp; using System.Text; namespace OpenAuth.WebApi.Controllers.ServiceControllers @@ -472,7 +473,6 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers /// 获取临时上传地址 /// /// - [Route("/zhcfzx/DataExchange/getUploadFilePath")] [HttpPost] [AllowAnonymous] public async Task> getUploadFilePath([FromBody] AirPortUploadReq req) @@ -490,6 +490,22 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers return result; } + [HttpPost] + [AllowAnonymous] + public Response UploadFile(AirPortUploadDbReq req) { + var result = new Response(); + try + { + result = _app.UploadFile(req); + } + catch (Exception ex) + { + result.Code = 500; + result.Message = ex.Message; + } + return result; + } + [HttpGet] [AllowAnonymous] [Route("/zhcfzx/droneAirport/getResult")] From 97ab02129c72629770ffbedb813965ab5e195cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Tue, 5 Aug 2025 10:12:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AA=92=E4=BD=93=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=B7=BB=E5=8A=A0=E8=BF=87=E6=BB=A4=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs | 4 +++- .../ServiceControllers/AirportMaintenanceController.cs | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs index 6a02ae5..64433f0 100644 --- a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs +++ b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs @@ -391,7 +391,7 @@ namespace OpenAuth.App.ServiceApp #endregion public async Task>>> GetMediaFile(string taskId, string device, - string picname, DateTime? startTime, DateTime? endTime, int page, int limit, string parentKey) + string picname, DateTime? startTime, DateTime? endTime, int page, int limit, string parentKey,int? objectKeyExist) { RefAsync totalCount = 0; using (var db = UnitWork.CreateContext()) @@ -401,6 +401,8 @@ namespace OpenAuth.App.ServiceApp .LeftJoin((x, b) => x.FlightId == b.FlightId) .WhereIF(!string.IsNullOrEmpty(device), x => x.DroneModelKey == device) .WhereIF(!string.IsNullOrEmpty(picname), x => x.Name.Contains(picname)) + .WhereIF(objectKeyExist is 0,x=> x.ObjectKey == null) + .WhereIF(objectKeyExist is 1,x=> x.ObjectKey != null) .WhereIF(!"0001/1/1 0:00:00".Equal(startTime.ToString()), x => x.CreateTime >= startTime) .WhereIF(!"0001/1/1 0:00:00".Equal(endTime.ToString()), x => x.CreateTime <= endTime) .WhereIF(!string.IsNullOrEmpty(parentKey), x => x.ParentKey == parentKey) diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs index 78da022..d574949 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs @@ -670,13 +670,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers [HttpGet] - [AllowAnonymous] - public async Task>>> GetMediaFile(string taskId,string device,string picname, DateTime startTime, DateTime endTime, int page, int limit,string parentKey) + public async Task>>> GetMediaFile(string taskId,string device,string picname, DateTime startTime, DateTime endTime, int page, int limit,string parentKey,int? objectKeyExist) { var result = new Response>>(); try { - result = await _app.GetMediaFile(taskId,device, picname,startTime, endTime, page, limit,parentKey); + result = await _app.GetMediaFile(taskId,device, picname,startTime, endTime, page, limit,parentKey,objectKeyExist); } catch (Exception ex) { From a14066442968947e52390cceaa6d28983e19a621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Tue, 5 Aug 2025 11:04:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AA=92=E4=BD=93=E5=BA=93=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs index a7f4f28..5e2ec85 100644 --- a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs +++ b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs @@ -58,7 +58,7 @@ public class ConfigSubscribe : IJob //"thing/product/+/osd", //"thing/product/+/status" }; - + _logger.LogInformation("开启监听"); await _mqttClientManager .SubscribeAsync(topicList, async (args) => @@ -242,7 +242,8 @@ public class ConfigSubscribe : IJob WorkspaceId = executeTask.WorkspaceId, }; parents.Add(parent1);*/ - var timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + var date = DateTime.Now; + var timeStr = date.ToString("yyyy-MM-dd HH:mm:ss"); var parent1 = new LasaMediaFile() { Id = folderKey[2], @@ -251,6 +252,7 @@ public class ConfigSubscribe : IJob ParentKey = "0", Name = string.IsNullOrEmpty(executeTask.TaskName) ? timeStr : $"{executeTask.TaskName} {timeStr}", WorkspaceId = executeTask.WorkspaceId, + CreateTime = date, }; await _sqlSugarClient.Insertable(parent1).ExecuteCommandAsync(); } @@ -299,9 +301,9 @@ public class ConfigSubscribe : IJob FlightId = flightId, // 计划id TaskId = taskAssign.TaskId, // 任务id DroneModelKey = data.file.ext.drone_model_key, // 无人机型号 + PayloadModelKey = data.file.ext.payload_model_key, //这应该可以标明是什么设置 IsOriginal = data.file.ext.is_original, MediaIndex = data.file.ext.media_index, - PayloadModelKey = data.file.ext.payload_model_key, //这应该可以标明是什么设置 AbsoluteAltitude = data.file.metadata.absolute_altitude, // 拍摄绝对高度 GimbalYawDegree = data.file.metadata.gimbal_yaw_degree, //云台偏航角度 RelativeAltitude = data.file.metadata.relative_altitude, // 拍摄相对高度