机场更新固件
parent
5db0cf7aa4
commit
85459e39c6
|
|
@ -15,15 +15,19 @@ using NPOI.SS.Formula.Functions;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
using DocumentFormat.OpenXml.Math;
|
using DocumentFormat.OpenXml.Math;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Infrastructure.CloudSdk.minio;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace OpenAuth.App.ServiceApp
|
namespace OpenAuth.App.ServiceApp
|
||||||
{
|
{
|
||||||
public class AirportMaintenanceApp : SqlSugarBaseApp<LasaDronePort, SugarDbContext>
|
public class AirportMaintenanceApp : SqlSugarBaseApp<LasaDronePort, SugarDbContext>
|
||||||
{
|
{
|
||||||
private readonly IConfiguration _configuration;
|
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;
|
_configuration = configuration;
|
||||||
|
_minioService = minioService;
|
||||||
}
|
}
|
||||||
//获取设备绑定码
|
//获取设备绑定码
|
||||||
public async Task<Response<LasaDeviceBindingCode>> GetDeviceBindingCode()
|
public async Task<Response<LasaDeviceBindingCode>> GetDeviceBindingCode()
|
||||||
|
|
@ -210,6 +214,7 @@ namespace OpenAuth.App.ServiceApp
|
||||||
{
|
{
|
||||||
using (var db = UnitWork.CreateContext())
|
using (var db = UnitWork.CreateContext())
|
||||||
{
|
{
|
||||||
|
info.Id = Guid.NewGuid().ToString();
|
||||||
var flag = await db.LasaFirmware.InsertAsync(info);
|
var flag = await db.LasaFirmware.InsertAsync(info);
|
||||||
if (db.Commit())
|
if (db.Commit())
|
||||||
return new Response<bool>
|
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
|
#endregion
|
||||||
|
|
||||||
#region 健康报警
|
#region 健康报警
|
||||||
|
|
@ -338,9 +378,9 @@ namespace OpenAuth.App.ServiceApp
|
||||||
Console.WriteLine(startTime.ToString());
|
Console.WriteLine(startTime.ToString());
|
||||||
var list = await db.LasaMediaFile.AsQueryable()
|
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(!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)
|
.WhereIF("0001/1/1 0:00:00".Equal(endTime.ToString()), x => x.CreateTime <= endTime)
|
||||||
.OrderBy(x => x.CreateTime, OrderByType.Asc)
|
.OrderBy(x => x.CreateTime, OrderByType.Asc)
|
||||||
.ToPageListAsync(page, limit, totalCount);
|
.ToPageListAsync(page, limit, totalCount);
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
||||||
/// <param name="info"></param>
|
/// <param name="info"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
[AllowAnonymous]
|
||||||
public async Task<Response<bool>> AddFirmware(LasaFirmware info)
|
public async Task<Response<bool>> AddFirmware(LasaFirmware info)
|
||||||
{
|
{
|
||||||
var result = new Response<bool>();
|
var result = new Response<bool>();
|
||||||
|
|
@ -137,6 +138,41 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
||||||
}
|
}
|
||||||
return result;
|
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
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -625,12 +661,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[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>>>();
|
var result = new Response<PageInfo<List<LasaMediaFile>>>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = await _app.GetMediaFile(device, picname,startTime, endTime, page, limit);
|
result = await _app.GetMediaFile(device, picname, startTime, endTime, page, limit);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue