机场更新固件

feature-flyModify
zhangbin 2025-07-15 09:47:03 +08:00
parent 5db0cf7aa4
commit 85459e39c6
2 changed files with 82 additions and 6 deletions

View File

@ -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<LasaDronePort, SugarDbContext>
{
private readonly IConfiguration _configuration;
public AirportMaintenanceApp(ISugarUnitOfWork<SugarDbContext> unitWork, IConfiguration configuration, ISimpleClient<LasaDronePort> repository, IAuth auth) : base(unitWork, repository, auth)
private readonly MinioService _minioService;
public AirportMaintenanceApp(ISugarUnitOfWork<SugarDbContext> unitWork, MinioService minioService, IConfiguration configuration, ISimpleClient<LasaDronePort> repository, IAuth auth) : base(unitWork, repository, auth)
{
_configuration = configuration;
_minioService = minioService;
}
//获取设备绑定码
public async Task<Response<LasaDeviceBindingCode>> 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<bool>
@ -225,6 +230,41 @@ namespace OpenAuth.App.ServiceApp
};
}
}
//修改无人机或机场版本
public async Task<Response<bool>> 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<bool> { Result = true, Message = "编辑成功" };
else
return new Response<bool> { 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<bool> { Result = true, Message = "编辑成功" };
else
return new Response<bool> { Result = false, Message = "编辑失败" };
}
}
}
public Task<string> 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);

View File

@ -123,6 +123,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// <param name="info"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<Response<bool>> AddFirmware(LasaFirmware info)
{
var result = new Response<bool>();
@ -137,6 +138,41 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
}
return result;
}
/// <summary>
/// 修改无人机或机场版本
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<Response<bool>> UpdateFirmware(string id, string version, int type)
{
var result = new Response<bool>();
try
{
result = await _app.UpdateFirmware(id, version, type);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
/// <summary>
/// 上传固件文件
/// </summary>
/// <param name="xmlFile"></param>
/// <returns></returns>
[HttpPost("upload")]
[AllowAnonymous]
public async Task<IActionResult> UploadFirmwareFile(IFormFile xmlFile)
{
if (xmlFile == null || xmlFile.Length == 0)
return BadRequest("文件为空");
var path = await _app.UploadFile(xmlFile);
return Ok(new { message = "上传成功", path });
}
#endregion
/// <summary>
@ -625,12 +661,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
[HttpGet]
[AllowAnonymous]
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string device,string picname, DateTime startTime, DateTime endTime, int page, int limit)
public async Task<Response<PageInfo<List<LasaMediaFile>>>> GetMediaFile(string device, string picname, DateTime startTime, DateTime endTime, int page, int limit)
{
var result = new Response<PageInfo<List<LasaMediaFile>>>();
try
{
result = await _app.GetMediaFile(device, picname,startTime, endTime, page, limit);
result = await _app.GetMediaFile(device, picname, startTime, endTime, page, limit);
}
catch (Exception ex)
{