From 85459e39c659b6dae5d15ceda7e48182f3c4648d Mon Sep 17 00:00:00 2001 From: zhangbin <460190368@qq.com> Date: Tue, 15 Jul 2025 09:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=BA=E5=9C=BA=E6=9B=B4=E6=96=B0=E5=9B=BA?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceApp/AirportMaintenanceApp.cs | 48 +++++++++++++++++-- .../AirportMaintenanceController.cs | 40 +++++++++++++++- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs index 6dcc53c..74df2e7 100644 --- a/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs +++ b/OpenAuth.App/ServiceApp/AirportMaintenanceApp.cs @@ -15,15 +15,19 @@ using NPOI.SS.Formula.Functions; using Infrastructure.Extensions; using DocumentFormat.OpenXml.Math; using Microsoft.Extensions.Configuration; +using Infrastructure.CloudSdk.minio; +using Microsoft.AspNetCore.Http; namespace OpenAuth.App.ServiceApp { public class AirportMaintenanceApp : SqlSugarBaseApp { private readonly IConfiguration _configuration; - public AirportMaintenanceApp(ISugarUnitOfWork unitWork, IConfiguration configuration, ISimpleClient repository, IAuth auth) : base(unitWork, repository, auth) + private readonly MinioService _minioService; + public AirportMaintenanceApp(ISugarUnitOfWork unitWork, MinioService minioService, IConfiguration configuration, ISimpleClient repository, IAuth auth) : base(unitWork, repository, auth) { _configuration = configuration; + _minioService = minioService; } //获取设备绑定码 public async Task> GetDeviceBindingCode() @@ -210,6 +214,7 @@ namespace OpenAuth.App.ServiceApp { using (var db = UnitWork.CreateContext()) { + info.Id = Guid.NewGuid().ToString(); var flag = await db.LasaFirmware.InsertAsync(info); if (db.Commit()) return new Response @@ -225,6 +230,41 @@ namespace OpenAuth.App.ServiceApp }; } } + //修改无人机或机场版本 + public async Task> UpdateFirmware(string id, string version, int type) + { + using (var db = UnitWork.CreateContext()) + { + if (type == 1) + { + var flag = await db.LasaDronePort.UpdateAsync(it => new LasaDronePort() + { + FirmwareVersion = version, + }, it => it.Id == id); + if (db.Commit()) + return new Response { Result = true, Message = "编辑成功" }; + else + return new Response { Result = false, Message = "编辑失败" }; + } + else + { + var flag = await db.LasaUav.UpdateAsync(it => new LasaUav() + { + FirmwareVersion = version, + }, it => it.Id == id); + if (db.Commit()) + return new Response { Result = true, Message = "编辑成功" }; + else + return new Response { Result = false, Message = "编辑失败" }; + } + + + } + } + public Task UploadFile(IFormFile xmlFile) + { + return _minioService.UploadFile(xmlFile, "firmware"); + } #endregion #region 健康报警 @@ -337,10 +377,10 @@ namespace OpenAuth.App.ServiceApp { Console.WriteLine(startTime.ToString()); var list = await db.LasaMediaFile.AsQueryable() - - .WhereIF(!string.IsNullOrEmpty(device),x => x.DroneModelKey == device) + + .WhereIF(!string.IsNullOrEmpty(device), x => x.DroneModelKey == device) .WhereIF(!string.IsNullOrEmpty(picname), x => x.Name.Contains(picname)) - .WhereIF("0001/1/1 0:00:00".Equal(startTime.ToString() ), x => x.CreateTime >= startTime) + .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) .OrderBy(x => x.CreateTime, OrderByType.Asc) .ToPageListAsync(page, limit, totalCount); diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs index dcee7f3..efcaa69 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs @@ -123,6 +123,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers /// /// [HttpPost] + [AllowAnonymous] public async Task> AddFirmware(LasaFirmware info) { var result = new Response(); @@ -137,6 +138,41 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers } return result; } + /// + /// 修改无人机或机场版本 + /// + /// + /// + [HttpPost] + [AllowAnonymous] + public async Task> UpdateFirmware(string id, string version, int type) + { + var result = new Response(); + try + { + result = await _app.UpdateFirmware(id, version, type); + } + catch (Exception ex) + { + result.Code = 500; + result.Message = ex.Message; + } + return result; + } + /// + /// 上传固件文件 + /// + /// + /// + [HttpPost("upload")] + [AllowAnonymous] + public async Task UploadFirmwareFile(IFormFile xmlFile) + { + if (xmlFile == null || xmlFile.Length == 0) + return BadRequest("文件为空"); + var path = await _app.UploadFile(xmlFile); + return Ok(new { message = "上传成功", path }); + } #endregion /// @@ -625,12 +661,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers [HttpGet] [AllowAnonymous] - public async Task>>> GetMediaFile(string device,string picname, DateTime startTime, DateTime endTime, int page, int limit) + public async Task>>> GetMediaFile(string device, string picname, DateTime startTime, DateTime endTime, int page, int limit) { var result = new Response>>(); try { - result = await _app.GetMediaFile(device, picname,startTime, endTime, page, limit); + result = await _app.GetMediaFile(device, picname, startTime, endTime, page, limit); } catch (Exception ex) {