机场更新固件
commit
f425ae608c
|
|
@ -16,17 +16,18 @@ 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;
|
||||
private readonly ISqlSugarClient _client;
|
||||
private readonly MinioService _minioService;
|
||||
public AirportMaintenanceApp(ISugarUnitOfWork<SugarDbContext> unitWork, MinioService minioService, IConfiguration configuration, ISimpleClient<LasaDronePort> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||
public AirportMaintenanceApp(MinioService minioService,ISqlSugarClient client,ISugarUnitOfWork<SugarDbContext> unitWork, IConfiguration configuration, ISimpleClient<LasaDronePort> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_client = client;
|
||||
_minioService = minioService;
|
||||
}
|
||||
//获取设备绑定码
|
||||
|
|
@ -214,7 +215,6 @@ 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>
|
||||
|
|
@ -230,41 +230,6 @@ 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 健康报警
|
||||
|
|
@ -377,10 +342,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);
|
||||
|
|
@ -391,6 +356,30 @@ namespace OpenAuth.App.ServiceApp
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<Response<string>> UpdatePicStatus(string id, int showOnMap, int display)
|
||||
{
|
||||
string sql = "update lasa_mediafile set \"ShowOnMap\"=" + showOnMap + ",display=" + display + " where \"Id\"='" + id+"'";
|
||||
await _client.Ado.ExecuteCommandAsync(sql);
|
||||
return new Response<string> { Result = "修改成功!" };
|
||||
}
|
||||
|
||||
public async Task<Response<string>> deletepic(string ids)
|
||||
{
|
||||
string[] idarray = ids.Split(",");
|
||||
|
||||
for (int i = 0; i < idarray.Length; i++)
|
||||
{
|
||||
string sqlselect = "select \"ObjectKey\" from lasa_mediafile where \"Id\"='"+idarray[i]+"'";
|
||||
string objectkey = _client.Ado.SqlQuerySingle<string>(sqlselect);
|
||||
string sql = "delete from lasa_mediafile where \"Id\"='"+idarray[i]+"'";
|
||||
await _client.Ado.ExecuteCommandAsync(sql);
|
||||
await _minioService.DeleteFile(objectkey);
|
||||
|
||||
|
||||
}
|
||||
return new Response<string> { Result = "删除成功!" };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -675,5 +675,40 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<string>> UpdatePicStatus(string id, int showOnMap,int display)
|
||||
{
|
||||
var result = new Response<string>();
|
||||
try
|
||||
{
|
||||
result = await _app.UpdatePicStatus(id, showOnMap, display);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.Message;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<string>> deletepic(string ids)
|
||||
{
|
||||
var result = new Response<string>();
|
||||
try
|
||||
{
|
||||
result = await _app.deletepic(ids);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.Message;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue