feature-flyModify
洁 任 2025-07-16 09:49:39 +08:00
commit 94ed43e1dc
15 changed files with 510 additions and 109 deletions

View File

@ -158,7 +158,6 @@ public class MinioService
{ {
objectName = objectName.Replace($"http://{endPoint}/{_bucketName}/", ""); objectName = objectName.Replace($"http://{endPoint}/{_bucketName}/", "");
} }
var deleteargs = new RemoveObjectArgs().WithBucket(_bucketName).WithObject(objectName); var deleteargs = new RemoveObjectArgs().WithBucket(_bucketName).WithObject(objectName);
await _minioClient.RemoveObjectAsync(deleteargs); await _minioClient.RemoveObjectAsync(deleteargs);
Console.WriteLine($"File {objectName} deleted."); Console.WriteLine($"File {objectName} deleted.");

View File

@ -57,21 +57,21 @@ public class MqttClientManager
/// <param name="password"></param> /// <param name="password"></param>
public async Task ConnectAsync(string server, int port, string username = null, string password = null) public async Task ConnectAsync(string server, int port, string username = null, string password = null)
{ {
var inboundOptions = new MqttClientOptionsBuilder() _inboundOptions = new MqttClientOptionsBuilder()
.WithClientId(Guid.NewGuid() + "_inbound") .WithClientId(Guid.NewGuid() + "_inbound")
.WithTcpServer(server, port) .WithTcpServer(server, port)
.WithKeepAlivePeriod(TimeSpan.FromSeconds(20)) .WithKeepAlivePeriod(TimeSpan.FromSeconds(20))
.WithCredentials(username, password) .WithCredentials(username, password)
.Build(); .Build();
var outboundOptions = new MqttClientOptionsBuilder() _outboundOptions = new MqttClientOptionsBuilder()
.WithClientId(Guid.NewGuid() + "_outbound") .WithClientId(Guid.NewGuid() + "_outbound")
.WithTcpServer(server, port) .WithTcpServer(server, port)
.WithKeepAlivePeriod(TimeSpan.FromSeconds(20)) .WithKeepAlivePeriod(TimeSpan.FromSeconds(20))
.WithCredentials(username, password) .WithCredentials(username, password)
.Build(); .Build();
await _outBoundClient.ConnectAsync(inboundOptions, _cancellationTokenSource.Token); await _outBoundClient.ConnectAsync(_inboundOptions, _cancellationTokenSource.Token);
await _inBoundClient.ConnectAsync(outboundOptions, _cancellationTokenSource.Token); await _inBoundClient.ConnectAsync(_outboundOptions, _cancellationTokenSource.Token);
_outBoundClient.ConnectedAsync += OnConnectedAsync; _outBoundClient.ConnectedAsync += OnConnectedAsync;
_inBoundClient.ConnectedAsync += OnConnectedAsync; _inBoundClient.ConnectedAsync += OnConnectedAsync;
_outBoundClient.DisconnectedAsync += OnOutboundDisconnectedAsync; _outBoundClient.DisconnectedAsync += OnOutboundDisconnectedAsync;

View File

@ -0,0 +1,23 @@
using OpenAuth.App.Request;
namespace OpenAuth.App.ServiceApp.AirLine.Request;
public class AirLineListRequestPage : PageReq
{
public bool Ascending { get; set; }
/// <summary>
///无人机型号
/// </summary>
public string UavTypeId { get; set; }
/// <summary>
/// 航线类型
/// </summary>
public string AirLineType { get; set; }
/// <summary>
/// 航线名称
/// </summary>
public string AirLineName { get; set; }
}

View File

@ -14,15 +14,22 @@ using DocumentFormat.OpenXml.EMMA;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using DocumentFormat.OpenXml.Math; using DocumentFormat.OpenXml.Math;
using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.Extensions.Configuration;
using Org.BouncyCastle.Ocsp; 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>
{ {
public AirportMaintenanceApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<LasaDronePort> repository, IAuth auth) : base(unitWork, repository, auth) private readonly IConfiguration _configuration;
private readonly ISqlSugarClient _client;
private readonly MinioService _minioService;
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;
} }
//获取设备绑定码 //获取设备绑定码
public async Task<Response<LasaDeviceBindingCode>> GetDeviceBindingCode() public async Task<Response<LasaDeviceBindingCode>> GetDeviceBindingCode()
@ -115,15 +122,19 @@ namespace OpenAuth.App.ServiceApp
} }
else else
{ {
var serverIp = _configuration.GetSection("MQTT:Server").Value;
var port = _configuration.GetSection("MQTT:Port").Value;
var username = _configuration.GetSection("MQTT:UserName").Value;
var password = _configuration.GetSection("MQTT:Password").Value;
//如果网关不存在,则创建一个新的 //如果网关不存在,则创建一个新的
var newGateway = new LasaGateway var newGateway = new LasaGateway
{ {
Id = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(),
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
GatewayAccount = "sdhc", GatewayAccount = username,
GatewaySn = Guid.NewGuid().ToString("N").Substring(0, 8).ToUpper(), // 生成一个新的 GatewaySn = Guid.NewGuid().ToString("N").Substring(0, 8).ToUpper(), // 生成一个新的
MqttGateway = "175.27.168.120:6011", MqttGateway = serverIp + ":" + port,
MqttPassword = "", MqttPassword = password,
OrgId = "371300", // 默认组织ID OrgId = "371300", // 默认组织ID
BindStatus = 0 // 未绑定状态 BindStatus = 0 // 未绑定状态
}; };
@ -205,6 +216,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>
@ -220,6 +232,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 健康报警
@ -325,7 +372,7 @@ namespace OpenAuth.App.ServiceApp
} }
} }
#endregion #endregion
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, int level, string parentKey)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
@ -333,10 +380,12 @@ 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)
.WhereIF(level >= 0, x => x.Level == level)
.WhereIF(!string.IsNullOrEmpty(parentKey), x => x.ParentKey == parentKey)
.OrderBy(x => x.CreateTime, OrderByType.Asc) .OrderBy(x => x.CreateTime, OrderByType.Asc)
.ToPageListAsync(page, limit, totalCount); .ToPageListAsync(page, limit, totalCount);
return new Response<PageInfo<List<LasaMediaFile>>> return new Response<PageInfo<List<LasaMediaFile>>>
@ -346,6 +395,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 = "删除成功!" };
}
} }

View File

@ -19,6 +19,9 @@ using OpenAuth.WebApi.CloudSdk;
using SqlSugar; using SqlSugar;
using System.Dynamic; using System.Dynamic;
using System.Text; using System.Text;
using NPOI.HSSF.Record;
using OpenAuth.App.Request;
using OpenAuth.App.ServiceApp.AirLine.Request;
namespace OpenAuth.App.ServiceApp namespace OpenAuth.App.ServiceApp
{ {
@ -26,15 +29,18 @@ namespace OpenAuth.App.ServiceApp
{ {
private readonly MqttClientManager _mqttClientManager; private readonly MqttClientManager _mqttClientManager;
private readonly MinioService _minioService; private readonly MinioService _minioService;
private readonly OpenJobApp _openJobApp;
CommonDataManager _commonDataManager; CommonDataManager _commonDataManager;
public ManageApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<LasaDronePort> repository, IAuth auth, public ManageApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<LasaDronePort> repository, IAuth auth,
MqttClientManager mqttClientManager, CommonDataManager commonDataManager, MinioService minioService) MqttClientManager mqttClientManager, CommonDataManager commonDataManager, MinioService minioService,
OpenJobApp openJobApp)
: base(unitWork, repository, auth) : base(unitWork, repository, auth)
{ {
_mqttClientManager = mqttClientManager; _mqttClientManager = mqttClientManager;
_minioService = minioService; _minioService = minioService;
_commonDataManager = commonDataManager; _commonDataManager = commonDataManager;
_openJobApp = openJobApp;
} }
#region 机场管理 #region 机场管理
@ -46,14 +52,32 @@ namespace OpenAuth.App.ServiceApp
/// <param name="pageSize"></param> /// <param name="pageSize"></param>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
public async Task<Response<PageInfo<List<LasaDronePort>>>> GetPageList(int page, int limit, string key) public async Task<Response<PageInfo<List<LasaDronePort>>>> GetPageList(int page, int limit, string sn,
string type, string workspaceid)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
{ {
var list = await db.LasaDronePort.AsQueryable().Includes(a => a.UavList) var list = await db.LasaDronePort.AsQueryable().Includes(a => a.UavList)
.LeftJoin<LasaSpaceDevice>((a,b)=>a.Id==b.DeviceId)
.Where(a => a.IsDelete == false) .Where(a => a.IsDelete == false)
.WhereIF(!string.IsNullOrEmpty(key), a => a.Name.Contains(key)) .WhereIF(!string.IsNullOrEmpty(sn), (a, b) => a.Sn == sn)
.WhereIF(!string.IsNullOrEmpty(type), (a, b) => a.TypeId == type)
.WhereIF(!string.IsNullOrEmpty(workspaceid), (a, b) => b.WorkSpaceId == workspaceid)
.Select((a,b)=>new LasaDronePort
{
Id = a.Id,
Name = a.Name,
TypeId = a.TypeId,
FirmwareVersion = a.FirmwareVersion,
CreateTime = a.CreateTime,
UpdateTime = a.UpdateTime,
OrgId = a.OrgId,
Sn = a.Sn,
UavList = a.UavList,
GateWay = a.GateWay,
WorkSpaceId = b.WorkSpaceId
})
.ToPageListAsync(page, limit, totalCount); .ToPageListAsync(page, limit, totalCount);
return new Response<PageInfo<List<LasaDronePort>>> return new Response<PageInfo<List<LasaDronePort>>>
{ {
@ -71,6 +95,13 @@ namespace OpenAuth.App.ServiceApp
{ {
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
{ {
//删除项目中的机场数据
await db.LasaSpaceDevice.DeleteAsync(r => r.DeviceId == info.Id);
await db.LasaSpaceDevice.InsertAsync(new LasaSpaceDevice
{
DeviceId = info.Id,
WorkSpaceId = info.WorkSpaceId
});
var flag = await db.LasaDronePort.UpdateAsync(it => new LasaDronePort() var flag = await db.LasaDronePort.UpdateAsync(it => new LasaDronePort()
{ {
Name = info.Name, Name = info.Name,
@ -143,16 +174,20 @@ namespace OpenAuth.App.ServiceApp
/// <param name="limit"></param> /// <param name="limit"></param>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
public async Task<Response<PageInfo<List<dynamic>>>> GetUavPageList(int page, int limit, string key) public async Task<Response<PageInfo<List<dynamic>>>> GetUavPageList(int page, int limit, string sn, string type,
string workspaceid)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
{ {
var list = await db.LasaUav.AsQueryable() var list = await db.LasaUav.AsQueryable()
.LeftJoin<LasaDronePort>((a, b) => a.PId == b.Id) .LeftJoin<LasaDronePort>((a, b) => a.PId == b.Id)
.Where((a, b) => a.IsDelete == false) .LeftJoin<LasaSpaceDevice>((a, b,c) => b.Id == c.DeviceId)
.WhereIF(!string.IsNullOrEmpty(key), (a, b) => a.Name.Contains(key)) .Where((a, b, c) => a.IsDelete == false)
.Select<dynamic>((a, b) => new .WhereIF(!string.IsNullOrEmpty(sn), (a, b, c) => a.Sn == sn)
.WhereIF(!string.IsNullOrEmpty(type), (a, b, c) => a.TypeId == type)
.WhereIF(!string.IsNullOrEmpty(workspaceid), (a, b, c) => c.WorkSpaceId == workspaceid)
.Select<dynamic>((a, b,c) => new
{ {
id = a.Id, id = a.Id,
name = a.Name, name = a.Name,
@ -163,7 +198,7 @@ namespace OpenAuth.App.ServiceApp
updateTime = a.UpdateTime, updateTime = a.UpdateTime,
isDelete = a.IsDelete, isDelete = a.IsDelete,
pName = b.Name, // 机场名称 pName = b.Name, // 机场名称
workSpaceId = a.WorkSpaceId, workSpaceId = c.WorkSpaceId,
firmwareVersion = a.FirmwareVersion, firmwareVersion = a.FirmwareVersion,
}) })
.ToPageListAsync(page, limit, totalCount); .ToPageListAsync(page, limit, totalCount);
@ -173,6 +208,7 @@ namespace OpenAuth.App.ServiceApp
}; };
} }
} }
/// <summary> /// <summary>
/// 获取机场sn获取无人机列表 /// 获取机场sn获取无人机列表
/// </summary> /// </summary>
@ -283,6 +319,19 @@ namespace OpenAuth.App.ServiceApp
} }
} }
//导出无人机信息
public async Task<string> GetUavSn()
{
using (var db = UnitWork.CreateContext())
{
var snList = await db.LasaUav.AsQueryable().Where(r => r.IsDelete == false).Select(r => r.Sn)
.ToListAsync();
var result = string.Join(Environment.NewLine, snList);
return result;
}
}
/// <summary> /// <summary>
/// 获取任务列表 /// 获取任务列表
/// </summary> /// </summary>
@ -290,13 +339,15 @@ namespace OpenAuth.App.ServiceApp
/// <param name="limit"></param> /// <param name="limit"></param>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
public async Task<Response<PageInfo<List<LasaTask>>>> GetTaskPageList(int page, int limit, string key) public async Task<Response<PageInfo<List<LasaTask>>>> GetTaskPageList(int page, int limit, string key,
int? status)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
{ {
var list = await db.LasaTask.AsQueryable() var list = await db.LasaTask.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(key), a => a.TaskName.Contains(key)) .WhereIF(!string.IsNullOrEmpty(key), a => a.TaskName.Contains(key))
.WhereIF(status != null, a => a.Status.Equals(status))
.ToPageListAsync(page, limit, totalCount); .ToPageListAsync(page, limit, totalCount);
return new Response<PageInfo<List<LasaTask>>> return new Response<PageInfo<List<LasaTask>>>
{ {
@ -310,10 +361,35 @@ namespace OpenAuth.App.ServiceApp
{ {
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
{ {
var user = _auth.GetCurrentUser().User;
task.Id = Guid.NewGuid().ToString(); task.Id = Guid.NewGuid().ToString();
task.CreateId = _auth.GetCurrentUser().User.Id; task.CreateId = user.Id;
task.CreateUserName = user.Name;
task.CreateTime = DateTime.Now; task.CreateTime = DateTime.Now;
var flag = await db.LasaTask.InsertAsync(task); var flag = await db.LasaTask.InsertAsync(task);
// todo 判断任务类型添加openjob记录 (openjob 增删改)
// //{"0":"立即任务","1":"定时任务",
var type = task.TaskType;
if (type.Equals(1)) // 定时任务
{
AddOrUpdateOpenJobReq record = new AddOrUpdateOpenJobReq()
{
JobName = $"{task.Id}",
JobType = 0, // 本地任务
JobCall = "OpenAuth.App.BaseApp.Jobs.TaskJob",
JobCallParams = "{\"taskId\":\"" + task.Id + "\"}",
Cron = task.PeriodicFormula,
Status = 1, // 开启运行 todo 关于修改后关闭问题
Remark = "定时任务",
};
_openJobApp.Add(record);
}
else if (type.Equals(0))
{
// 调用飞行任务
await ExecuteFlyTask(task.Id);
}
if (db.Commit()) if (db.Commit())
return new Response<bool> { Result = true, Message = "添加成功" }; return new Response<bool> { Result = true, Message = "添加成功" };
else else
@ -337,13 +413,43 @@ namespace OpenAuth.App.ServiceApp
//删除任务 //删除任务
public async Task<Response<bool>> DeleteTask(string id) public async Task<Response<bool>> DeleteTask(string id)
{ {
var task = await Repository
.ChangeRepository<SugarRepositiry<LasaTask>>()
.AsQueryable()
.Where(it => it.Id == id).SingleAsync();
if (task == null)
{
return new Response<bool> { Result = false, Message = "任务不存在" };
}
if (task.CompletedTime != null) // 定时任务
{
return new Response<bool> { Result = false, Message = "已完成任务禁止删除" };
}
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
{ {
var flag = await db.LasaTask.DeleteAsync(it => it.Id == id); var flag = await db.LasaTask.DeleteAsync(it => it.Id == id);
var taskId = task.Id;
var mediaFileList = await db.LasaMediaFile.AsQueryable()
.Where(it => it.TaskId == taskId)
.ToListAsync();
foreach (var item in mediaFileList)
{
await _minioService.DeleteFile(item.ObjectKey);
}
// 定时任务,
if (task.TaskType.Equals(1))
{
await db.SysOpenJob.AsDeleteable()
.Where(it => it.JobCallParams.Contains(taskId))
.ExecuteCommandAsync();
}
if (db.Commit()) if (db.Commit())
return new Response<bool> { Result = true, Message = "删除成功" }; return new Response<bool> { Result = true, Message = "删除成功" };
else return new Response<bool> { Result = false, Message = "删除失败" };
return new Response<bool> { Result = false, Message = "删除失败" };
} }
} }
@ -356,14 +462,18 @@ namespace OpenAuth.App.ServiceApp
/// <param name="limit"></param> /// <param name="limit"></param>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
public async Task<Response<PageInfo<List<LasaAirLine>>>> GetAirLinePageList(int page, int limit, string key) public async Task<Response<PageInfo<List<LasaAirLine>>>> GetAirLinePageList(AirLineListRequestPage req)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
{ {
var list = await db.LasaAirLine.AsQueryable() var list = await db.LasaAirLine.AsQueryable().LeftJoin<LasaUav>((a, b) => a.UavId == b.Id)
.WhereIF(!string.IsNullOrEmpty(key), a => a.AirLineName.Contains(key)) .WhereIF(!string.IsNullOrEmpty(req.UavTypeId),(a,b) => b.TypeId == req.UavTypeId)
.ToPageListAsync(page, limit, totalCount); .WhereIF(!string.IsNullOrEmpty(req.key), a => a.AirLineName.Contains(req.key))
.WhereIF(!string.IsNullOrEmpty(req.AirLineName), a => a.AirLineName.Contains(req.AirLineName))
.WhereIF(!string.IsNullOrEmpty(req.AirLineType), a => a.AirLineType.Equals(req.AirLineType))
.OrderByIF(true, a => a.CreateTime, req.Ascending ? OrderByType.Asc : OrderByType.Desc)
.ToPageListAsync(req.page, req.limit, totalCount);
return new Response<PageInfo<List<LasaAirLine>>> return new Response<PageInfo<List<LasaAirLine>>>
{ {
Result = new PageInfo<List<LasaAirLine>> { Items = list, Total = totalCount } Result = new PageInfo<List<LasaAirLine>> { Items = list, Total = totalCount }
@ -445,7 +555,7 @@ namespace OpenAuth.App.ServiceApp
} }
var list = await db.LasaWorkspace.AsQueryable() var list = await db.LasaWorkspace.AsQueryable()
.Where(a=>a.IsDelete==false) .Where(a => a.IsDelete == false)
.WhereIF(!string.IsNullOrEmpty(key), a => a.WorkspaceName.Contains(key)) .WhereIF(!string.IsNullOrEmpty(key), a => a.WorkspaceName.Contains(key))
.WhereIF(state != 0, a => a.Sate == state) .WhereIF(state != 0, a => a.Sate == state)
.WhereIF(isjoin == 1, a => ids.Contains(a.Id)) .WhereIF(isjoin == 1, a => ids.Contains(a.Id))
@ -656,6 +766,8 @@ namespace OpenAuth.App.ServiceApp
#endregion #endregion
// todo 保存任务时,执行任务
public async Task ExecuteFlyTask(string taskId) public async Task ExecuteFlyTask(string taskId)
{ {
// 任务信息 // 任务信息
@ -1063,7 +1175,6 @@ namespace OpenAuth.App.ServiceApp
//修改图斑数据 //修改图斑数据
var flagGeom = await db.Ado.ExecuteCommandAsync(geomSql.ToString()); var flagGeom = await db.Ado.ExecuteCommandAsync(geomSql.ToString());
}); });
if (transFlag.IsSuccess) if (transFlag.IsSuccess)
return new Response<string> return new Response<string>
@ -1204,7 +1315,8 @@ namespace OpenAuth.App.ServiceApp
} }
}; };
//thing/product/{gateway_sn}/services //thing/product/{gateway_sn}/services
await _mqttClientManager.PublishAsync("thing/product/8UUXN5400A079H/services", JsonConvert.SerializeObject(request)); await _mqttClientManager.PublishAsync("thing/product/8UUXN5400A079H/services",
JsonConvert.SerializeObject(request));
return new Response<bool>() return new Response<bool>()
{ {
Result = true Result = true
@ -1224,7 +1336,8 @@ namespace OpenAuth.App.ServiceApp
video_id = "8UUXN5400A079H/165-0-7/normal-0" video_id = "8UUXN5400A079H/165-0-7/normal-0"
} }
}; };
await _mqttClientManager.PublishAsync("thing/product/8UUXN5400A079H/services", JsonConvert.SerializeObject(request)); await _mqttClientManager.PublishAsync("thing/product/8UUXN5400A079H/services",
JsonConvert.SerializeObject(request));
return new Response<bool>() return new Response<bool>()
{ {
Result = true Result = true
@ -1232,12 +1345,15 @@ namespace OpenAuth.App.ServiceApp
} }
#region 基本信息统计 #region 基本信息统计
public async Task<Response<JObject>> GetBasicInfo() public async Task<Response<JObject>> GetBasicInfo()
{ {
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
{ {
var dronInfo = await db.LasaDronePort.AsQueryable().Where(r => r.IsDelete == false && r.TypeId.Contains("Dock")).CountAsync(); var dronInfo = await db.LasaDronePort.AsQueryable()
var otherInfo = await db.LasaDronePort.AsQueryable().Where(r => r.IsDelete == false && !r.TypeId.Contains("Dock")).CountAsync(); .Where(r => r.IsDelete == false && r.TypeId.Contains("Dock")).CountAsync();
var otherInfo = await db.LasaDronePort.AsQueryable()
.Where(r => r.IsDelete == false && !r.TypeId.Contains("Dock")).CountAsync();
var pilotInfo = await db.SysUserRole.AsQueryable().Where(r => r.RoleId == 555252989157446).CountAsync(); var pilotInfo = await db.SysUserRole.AsQueryable().Where(r => r.RoleId == 555252989157446).CountAsync();
var taskInfo = await db.LasaTask.AsQueryable().CountAsync(); var taskInfo = await db.LasaTask.AsQueryable().CountAsync();
JObject obj = new JObject JObject obj = new JObject
@ -1249,8 +1365,8 @@ namespace OpenAuth.App.ServiceApp
}; };
return new Response<JObject> { Result = obj, Message = "获取数据成功" }; return new Response<JObject> { Result = obj, Message = "获取数据成功" };
} }
} }
#endregion #endregion
} }
} }

View File

@ -98,13 +98,6 @@ public class ConfigSubscribe : IJob
switch (tempStr) switch (tempStr)
{ {
case "thing/product/*/requests": case "thing/product/*/requests":
//{"bid":"f936a236-030c-4358-bee9-b5075e1e2ddf",
//"data":{"flight_id":"e5ce8433-c264-4357-84d9-b701faf90d9e"},
//"method":"flighttask_resource_get",
//"tid":"61b6389a-7b72-49ae-bb46-0729e85c95d2",
//"timestamp":1750554644321,
//"gateway":"8UUXN5400A079H"}
// todo 处理资源获取请求
switch (method) switch (method)
{ {
// 临时凭证上传 // 临时凭证上传
@ -130,14 +123,14 @@ public class ConfigSubscribe : IJob
{ {
bucket = "test", bucket = "test",
endpoint = "http://175.27.168.120:6013", endpoint = "http://175.27.168.120:6013",
object_key_prefix = $"{Guid.NewGuid().ToString()}", // todo 是否设计任务id object_key_prefix = Guid.NewGuid().ToString(), // todo 是否设计任务id
provider = "minio", provider = "minio",
region = "linyi", region = "linyi",
credentials = new credentials = new
{ {
access_key_id = "minioadmin", access_key_id = "minioadmin",
access_key_secret = "minioadmin", access_key_secret = "minioadmin",
expire = 480, expire = 3600,
security_token = "" security_token = ""
} }
} }
@ -151,6 +144,12 @@ public class ConfigSubscribe : IJob
case "flight_areas_get": case "flight_areas_get":
//Console.WriteLine("跳过自定义飞行区文件获取"); //Console.WriteLine("跳过自定义飞行区文件获取");
break; break;
//{"bid":"f936a236-030c-4358-bee9-b5075e1e2ddf",
//"data":{"flight_id":"e5ce8433-c264-4357-84d9-b701faf90d9e"},
//"method":"flighttask_resource_get",
//"tid":"61b6389a-7b72-49ae-bb46-0729e85c95d2",
//"timestamp":1750554644321,
//"gateway":"8UUXN5400A079H"}
// 获取航线 // 获取航线
case "flighttask_resource_get": case "flighttask_resource_get":
string flightId = data.flight_id + ""; string flightId = data.flight_id + "";
@ -212,15 +211,66 @@ public class ConfigSubscribe : IJob
break; break;
} }
lock (_dockUploadFileLocker) string flightId = data.file.ext.flight_id;
var taskAssgin = _manageApp.GetTaskAssignByFlightId(flightId);
var taskId = taskAssgin.TaskId;
string objectKey = data.file.object_key;
var folderKey = ((string)data.file.object_key).Split("/");
var parentKey = folderKey[^2];
var isExist = await _sqlSugarClient
.Queryable<LasaMediaFile>()
.Where(x => x.ObjectKey.Equals(parentKey)).CountAsync();
if (isExist == 0)
{
var parents = new List<LasaMediaFile>(3);
var parent1 = new LasaMediaFile()
{
Id = Guid.NewGuid().ToString(),
FlightId = flightId,
TaskId = taskId,
ParentKey = "",
ObjectKey = folderKey[0],
WorkspaceId = "", // todo 从任务中取来
Level = 1,
};
parents.Add(parent1);
parent1 = new LasaMediaFile()
{
Id = Guid.NewGuid().ToString(),
FlightId = flightId,
TaskId = taskId,
ParentKey = folderKey[0],
ObjectKey = folderKey[1],
WorkspaceId = "",
Level = 2,
};
parents.Add(parent1);
parent1 = new LasaMediaFile()
{
Id = Guid.NewGuid().ToString(),
FlightId = flightId,
TaskId = taskId,
ParentKey = folderKey[1],
ObjectKey = folderKey[2],
WorkspaceId = "",
Level = 3,
};
parents.Add(parent1);
await _sqlSugarClient.Insertable(parents).ExecuteCommandAsync();
}
// 重复检测
var mediaFile = await _sqlSugarClient
.Queryable<LasaMediaFile>()
.Where(a => a.FlightId.Equals(flightId))
.Where(a => a.ObjectKey.Equals(objectKey)).SingleAsync();
if (mediaFile == null)
{ {
string flightId = data.file.ext.flight_id;
string taskId = _manageApp.GetTaskAssignByFlightId(flightId).TaskId;
var fileUpload = new LasaMediaFile() var fileUpload = new LasaMediaFile()
{ {
Id = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(),
FlightId = flightId, // 计划id FlightId = flightId, // 计划id
TaskId = taskId, // 任务id TaskId = taskAssgin.TaskId, // 任务id
DroneModelKey = data.file.ext.drone_model_key, // 无人机型号 DroneModelKey = data.file.ext.drone_model_key, // 无人机型号
IsOriginal = data.file.ext.is_original, IsOriginal = data.file.ext.is_original,
MediaIndex = data.file.ext.media_index, MediaIndex = data.file.ext.media_index,
@ -234,46 +284,49 @@ public class ConfigSubscribe : IJob
ObjectKey = data.file.object_key, ObjectKey = data.file.object_key,
Path = data.file.path, // 目前这个好像没有值 Path = data.file.path, // 目前这个好像没有值
CreateTime = ((string)data.file.metadata.created_time).ToDateTime(), CreateTime = ((string)data.file.metadata.created_time).ToDateTime(),
ParentKey = folderKey[2],
Level = 4
}; };
// todo 添加事务 // todo 添加事务
_sqlSugarClient.Insertable(fileUpload).ExecuteCommand(); await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync();
if (result.need_reply.Equals(1))
{
var fileUploadCallbackEventReply = new FileUploadCallbackEventReply<object>()
{
bid = result.bid,
tid = result.tid,
method = "file_upload_callback",
gateway = sn,
data = new
{
result = 0
},
timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
};
_ = _mqttClientManager.PublishAsync($"thing/product/{sn}/events_reply",
JsonConvert.SerializeObject(fileUploadCallbackEventReply));
}
var expectFileCount = data.flight_task.expected_file_count;
var uploadedFileCount = data.flight_task.uploaded_file_count;
var taskRecord = new LasaTask()
{
Id = taskId,
ExpectedFileCount = expectFileCount, // 期望文件数量
UploadedFileCount = uploadedFileCount // 已上传文件数量
};
// 当expectFileCount 等于uploadedFileCount时则表示航线执行完成
if (uploadedFileCount.Equals(expectFileCount))
{
taskRecord.Status = 5; // 成功状态
}
_sqlSugarClient.Updateable(taskRecord)
.IgnoreNullColumns().ExecuteCommand();
} }
if (result.need_reply.Equals(1))
{
var fileUploadCallbackEventReply = new FileUploadCallbackEventReply<object>()
{
bid = result.bid,
tid = result.tid,
method = "file_upload_callback",
gateway = sn,
data = new
{
result = 0
},
timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
};
_ = _mqttClientManager.PublishAsync($"thing/product/{sn}/events_reply",
JsonConvert.SerializeObject(fileUploadCallbackEventReply));
}
var expectFileCount = data.flight_task.expected_file_count;
var uploadedFileCount = data.flight_task.uploaded_file_count;
var taskRecord = new LasaTask()
{
Id = taskId,
ExpectedFileCount = expectFileCount, // 期望文件数量
UploadedFileCount = uploadedFileCount // 已上传文件数量
};
// 当expectFileCount 等于uploadedFileCount时则表示航线执行完成
if (uploadedFileCount.Equals(expectFileCount))
{
taskRecord.Status = 5; // 成功状态
}
await _sqlSugarClient.Updateable(taskRecord)
.IgnoreNullColumns().ExecuteCommandAsync();
break; break;
case "release_terminal_control_area": case "release_terminal_control_area":
//暂不处理 //暂不处理

View File

@ -87,4 +87,20 @@ public class LasaMediaFile
public DateTime? CreateTime { get; set; } public DateTime? CreateTime { get; set; }
public string TaskId { get; set; } public string TaskId { get; set; }
/// <summary>
/// 文件夹所属层级
/// </summary>
public int Level { get; set; }
/// <summary>
/// 父文件key
/// </summary>
public string ParentKey { get; set; }
public string WorkspaceId { get; set; }
public int? ShowOnMap { get; set; }
public int? display { get; set; }
} }

View File

@ -24,8 +24,10 @@ namespace OpenAuth.Repository.Domain
/// </summary> /// </summary>
public string TaskName { get; set; } public string TaskName { get; set; }
public string CreateUserName { get; set; }
/// <summary> /// <summary>
/// 任务类型 /// 任务类型 "0":"立即任务","1":"定时任务"
/// </summary> /// </summary>
public int TaskType { get; set; } public int TaskType { get; set; }

View File

@ -22,6 +22,7 @@ namespace OpenAuth.Repository.Domain
public string DevicePicUrl { get; set; } public string DevicePicUrl { get; set; }
public string Did { get; set; } public string Did { get; set; }
public string PId { get; set; } public string PId { get; set; }
public DateTime? CreateTime { get; set; }
/// <summary> /// <summary>
/// Desc:是否删除 /// Desc:是否删除
/// Default:false /// Default:false

View File

@ -81,6 +81,8 @@ namespace OpenAuth.Repository
public SugarRepositiry<DroneDocktask> DroneDocktask { get; set; } public SugarRepositiry<DroneDocktask> DroneDocktask { get; set; }
public SugarRepositiry<LasaMediaFile> LasaMediaFile { get; set; } public SugarRepositiry<LasaMediaFile> LasaMediaFile { get; set; }
public SugarRepositiry<SysOpenJob> SysOpenJob { get; set; }
#endregion #endregion
} }
} }

View File

@ -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,47 @@ 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,int level,string parentKey)
{ {
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, level,parentKey);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
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) catch (Exception ex)
{ {

View File

@ -1,4 +1,5 @@
using System.Text; using System.Text;
using DocumentFormat.OpenXml.Math;
using Infrastructure; using Infrastructure;
using Infrastructure.CloudSdk.wayline; using Infrastructure.CloudSdk.wayline;
using Infrastructure.Extensions; using Infrastructure.Extensions;
@ -8,6 +9,7 @@ using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using OpenAuth.App.ServiceApp; using OpenAuth.App.ServiceApp;
using OpenAuth.App.ServiceApp.AirLine.Request;
using OpenAuth.App.ServiceApp.Request; using OpenAuth.App.ServiceApp.Request;
using OpenAuth.App.ServiceApp.Response; using OpenAuth.App.ServiceApp.Response;
using OpenAuth.Repository.Domain; using OpenAuth.Repository.Domain;
@ -37,15 +39,18 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// </summary> /// </summary>
/// <param name="page"></param> /// <param name="page"></param>
/// <param name="limit"></param> /// <param name="limit"></param>
/// <param name="key"></param> /// <param name="sn">sn</param>
/// <param name="type">类型</param>
/// <param name="workspaceid">项目</param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public async Task<Response<PageInfo<List<LasaDronePort>>>> GetDataList(int page, int limit, string key) public async Task<Response<PageInfo<List<LasaDronePort>>>> GetDataList(int page, int limit, string sn,
string type, string workspaceid)
{ {
var result = new Response<PageInfo<List<LasaDronePort>>>(); var result = new Response<PageInfo<List<LasaDronePort>>>();
try try
{ {
result = await _app.GetPageList(page, limit, key); result = await _app.GetPageList(page, limit, sn, type, workspaceid);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -95,17 +100,20 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// <summary> /// <summary>
/// 获取无人机列表 /// 获取无人机列表
/// </summary> /// </summary>
/// <param name="pageIndex"></param> /// <param name="page"></param>
/// <param name="pageSize"></param> /// <param name="limit"></param>
/// <param name="key"></param> /// <param name="sn">sn</param>
/// <param name="type">类型</param>
/// <param name="workspaceid">项目</param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public async Task<Response<PageInfo<List<dynamic>>>> GetUavPageList(int page, int limit, string key) public async Task<Response<PageInfo<List<dynamic>>>> GetUavPageList(int page, int limit, string sn, string type,
string workspaceid)
{ {
var result = new Response<PageInfo<List<dynamic>>>(); var result = new Response<PageInfo<List<dynamic>>>();
try try
{ {
result = await _app.GetUavPageList(page, limit, key); result = await _app.GetUavPageList(page, limit, sn, type, workspaceid);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -147,6 +155,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
{ {
return await _app.DeleteUav(id); return await _app.DeleteUav(id);
} }
/// <summary> /// <summary>
/// 根据机场sn获取无人机列表 /// 根据机场sn获取无人机列表
/// </summary> /// </summary>
@ -171,6 +180,19 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
return result; return result;
} }
/// <summary>
/// 导出无人机信息
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IActionResult> ExportDevice()
{
var content = await _app.GetUavSn();
byte[] fileBytes = Encoding.UTF8.GetBytes(content);
string fileName = "DeviceSNList_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
return File(fileBytes, "text/plain", fileName);
}
#endregion #endregion
#region 任务管理 #region 任务管理
@ -183,12 +205,13 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public async Task<Response<PageInfo<List<LasaTask>>>> GetTaskPageList(int page, int limit, string key) public async Task<Response<PageInfo<List<LasaTask>>>> GetTaskPageList(int page, int limit, string key,
int? status)
{ {
var result = new Response<PageInfo<List<LasaTask>>>(); var result = new Response<PageInfo<List<LasaTask>>>();
try try
{ {
result = await _app.GetTaskPageList(page, limit, key); result = await _app.GetTaskPageList(page, limit, key, status);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -210,10 +233,11 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
} }
/// <summary> /// <summary>
/// 编辑任务 /// 编辑任务,不再允许编辑任务
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Obsolete]
public async Task<Response<bool>> EditTask(LasaTask info) public async Task<Response<bool>> EditTask(LasaTask info)
{ {
return await _app.EditTask(info); return await _app.EditTask(info);
@ -241,12 +265,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public async Task<Response<PageInfo<List<LasaAirLine>>>> GetAirLineList(int page, int limit, string key) public async Task<Response<PageInfo<List<LasaAirLine>>>> GetAirLineList([FromQuery] AirLineListRequestPage req)
{ {
var result = new Response<PageInfo<List<LasaAirLine>>>(); var result = new Response<PageInfo<List<LasaAirLine>>>();
try try
{ {
result = await _app.GetAirLinePageList(page, limit, key); result = await _app.GetAirLinePageList(req);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -492,6 +516,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
{ {
return await _app.GetTAskImageList(taskId); return await _app.GetTAskImageList(taskId);
} }
/// <summary> /// <summary>
/// 开启机场直播(测试使用) /// 开启机场直播(测试使用)
/// </summary> /// </summary>
@ -503,6 +528,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
{ {
return await _app.StartDronePortLive(streamUrl); return await _app.StartDronePortLive(streamUrl);
} }
/// <summary> /// <summary>
/// 测试使用 /// 测试使用
/// </summary> /// </summary>
@ -739,6 +765,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
#endregion #endregion
#region 基本信息 #region 基本信息
/// <summary> /// <summary>
/// 获取基本信息 /// 获取基本信息
/// </summary> /// </summary>
@ -749,6 +776,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
{ {
return await _app.GetBasicInfo(); return await _app.GetBasicInfo();
} }
#endregion #endregion
} }
} }

View File

@ -12,6 +12,7 @@ namespace OpenAuth.WebApi.Model.mqtt
private readonly MqttMessageCenter _mqttCenter; private readonly MqttMessageCenter _mqttCenter;
private readonly AirportMaintenanceApp _app; private readonly AirportMaintenanceApp _app;
public MqttHostedService(IServiceProvider serviceProvider, MqttMessageCenter mqttCenter, AirportMaintenanceApp app) public MqttHostedService(IServiceProvider serviceProvider, MqttMessageCenter mqttCenter, AirportMaintenanceApp app)
{ {
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
@ -23,14 +24,29 @@ namespace OpenAuth.WebApi.Model.mqtt
{ {
using var scope = _serviceProvider.CreateScope(); using var scope = _serviceProvider.CreateScope();
var handlers = scope.ServiceProvider.GetServices<IMqttMessageHandler>(); var handlers = scope.ServiceProvider.GetServices<IMqttMessageHandler>();
// 创建配置构建器
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile(
$"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"}.json",
optional: true)
.AddEnvironmentVariables();
// 构建配置
var configuration = builder.Build();
// 读取连接字符串
var serverIp = configuration["MQTT:Server"];
var port = configuration["MQTT:Port"];
var username = configuration["MQTT:UserName"];
var password = configuration["MQTT:Password"];
await _mqttCenter.InitializeAsync( await _mqttCenter.InitializeAsync(
handlers, handlers,
server: "175.27.168.120", server: serverIp,
port: 6011, port: int.Parse(port),
clientId: Guid.NewGuid().ToString(), clientId: Guid.NewGuid().ToString(),
username: "sdhc", username: username,
password: "" password: password
); );
//查询网关,订阅主题 //查询网关,订阅主题
var topics = new List<string>(); var topics = new List<string>();

View File

@ -171,6 +171,7 @@ namespace OpenAuth.WebApi.Model.mqtt
lasaUav.IsDelete = false; lasaUav.IsDelete = false;
//lasaUav.TypeId = obj["device_model_key"].ToString(); //lasaUav.TypeId = obj["device_model_key"].ToString();
lasaUav.TypeId = "M4TD"; lasaUav.TypeId = "M4TD";
lasaUav.CreateTime = DateTime.Now;
lasaUav.Sn = obj["sn"].ToString(); lasaUav.Sn = obj["sn"].ToString();
lasaUav.PId = lasaDronePort.Id; lasaUav.PId = lasaDronePort.Id;
lasaUav.Name = obj["device_callsign"]?.ToString(); lasaUav.Name = obj["device_callsign"]?.ToString();