cloudsdk挪动位置

main
陈伟 3 months ago
parent 40ed1bd3a1
commit 322dfd1304

@ -9,13 +9,13 @@ public class GatewayManager
/// <summary>
/// 机场任务准备异常通知 flight_setup_exception_notify
/// </summary>
public string FlightSetupExceptionNotify =
public static string FlightSetupExceptionNotify =
TopicConst.ThingModelPre + TopicConst.Product + "%s" + TopicConst.EventsSuffix;
/// <summary>
/// 下发任务 down(向设备端发布消息) flighttask_prepare(method) thing/product/{gateway_sn}/services(topic)
/// </summary>
public string FlightTaskPrepare = TopicConst.ThingModelPre + TopicConst.Product + "%s" + TopicConst.ServicesSuffix;
public static string FlightTaskPrepare = TopicConst.ThingModelPre + TopicConst.Product + "%s" + TopicConst.ServicesSuffix;
public GatewayManager(string gatewaySn, string droneSn, GatewayType gatewayType)
{

@ -1,5 +1,5 @@
using MQTTnet;
using MQTTnet.Adapter;
using Microsoft.Extensions.Configuration;
using MQTTnet;
using MQTTnet.Client;
using MQTTnet.Protocol;
@ -68,7 +68,7 @@ public class MqttClientManager
/// <param name="message">json</param>
public async Task PublishAsync(string topic, string message)
{
// MqttChannelAdapter
// MqttChannelAdapter
var mqttMsg = new MqttApplicationMessageBuilder()
.WithTopic(topic)
.WithPayload(message)

@ -17,6 +17,7 @@
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="MQTTnet" Version="4.1.4.563" />
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
<PackageReference Include="NetTopologySuite.IO.Esri.Shapefile" Version="1.0.0" />
<PackageReference Include="NetTopologySuite.IO.ShapeFile" Version="2.1.0" />

@ -4,13 +4,15 @@ using OpenAuth.App.Interface;
using OpenAuth.App.ServiceApp.Request;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using OpenAuth.WebApi.CloudSdk;
using SqlSugar;
namespace OpenAuth.App.ServiceApp
{
public class ManageApp : SqlSugarBaseApp<LasaDronePort, SugarDbContext>
{
public ManageApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<LasaDronePort> repository, IAuth auth) : base(unitWork, repository, auth)
public ManageApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<LasaDronePort> repository, IAuth auth)
: base(unitWork, repository, auth)
{
}
@ -30,12 +32,14 @@ namespace OpenAuth.App.ServiceApp
PageSize = pageSize,
TotalCount = totalCount
};
var list = await Repository.GetPageListAsync(it => it.Name.Contains(key), pageModel, it => it.UpdateTime, OrderByType.Desc);
var list = await Repository.GetPageListAsync(it => it.Name.Contains(key), pageModel, it => it.UpdateTime,
OrderByType.Desc);
return new Response<PageInfo<List<LasaDronePort>>>
{
Result = new PageInfo<List<LasaDronePort>> { Items = list, Total = totalCount }
};
}
/// <summary>
/// 获取无人机列表
/// </summary>
@ -57,6 +61,7 @@ namespace OpenAuth.App.ServiceApp
};
}
}
/// <summary>
/// 获取任务列表
/// </summary>
@ -78,6 +83,7 @@ namespace OpenAuth.App.ServiceApp
};
}
}
//添加任务
public async Task<Response<bool>> AddTask(LasaTask task)
{
@ -87,17 +93,18 @@ namespace OpenAuth.App.ServiceApp
task.CreateId = _auth.GetCurrentUser().User.Id;
task.CreateTime = DateTime.Now;
var flag = await db.LasaTask.InsertAsync(task);
if(db.Commit())
if (db.Commit())
return new Response<bool> { Result = true, Message = "添加成功" };
else
return new Response<bool> { Result = false, Message = "添加失败" };
return new Response<bool> { Result = false, Message = "添加失败" };
}
}
//编辑任务
public async Task<Response<bool>> EditTask(LasaTask task)
{
using (var db = UnitWork.CreateContext())
{
{
var flag = await db.LasaTask.UpdateAsync(task);
if (db.Commit())
return new Response<bool> { Result = true, Message = "编辑成功" };
@ -105,6 +112,7 @@ namespace OpenAuth.App.ServiceApp
return new Response<bool> { Result = false, Message = "编辑失败" };
}
}
//删除任务
public async Task<Response<bool>> DeleteTask(string id)
{
@ -117,7 +125,9 @@ namespace OpenAuth.App.ServiceApp
return new Response<bool> { Result = false, Message = "删除失败" };
}
}
#region 航线管理
/// <summary>
/// 获取航线列表
/// </summary>
@ -139,6 +149,7 @@ namespace OpenAuth.App.ServiceApp
};
}
}
//添加航线
public async Task<Response<bool>> AddAirLine(LasaAirLine lasaAirLine)
{
@ -154,6 +165,7 @@ namespace OpenAuth.App.ServiceApp
return new Response<bool> { Result = false, Message = "添加失败" };
}
}
//编辑航线
public async Task<Response<bool>> EditAirLine(LasaAirLine lasaAirLine)
{
@ -166,6 +178,7 @@ namespace OpenAuth.App.ServiceApp
return new Response<bool> { Result = false, Message = "编辑失败" };
}
}
//删除航线
public async Task<Response<bool>> DeleteAirLine(string id)
{
@ -181,7 +194,9 @@ namespace OpenAuth.App.ServiceApp
//生成航线文件
#endregion
#region 项目管理
#region 项目管理
/// <summary>
/// 获取项目列表
/// </summary>
@ -197,25 +212,26 @@ namespace OpenAuth.App.ServiceApp
.ToListAsync();
return new Response<List<LasaWorkspace>>
{
Result = list
Result = list
};
}
}
//添加项目
public async Task<Response<bool>> AddWorkspace(WorkSpace info)
{
using (var db = UnitWork.CreateContext())
{
LasaWorkspace lasaWorkspace= info.LasaWorkspace;
LasaWorkspace lasaWorkspace = info.LasaWorkspace;
lasaWorkspace.Id = Guid.NewGuid().ToString();
lasaWorkspace.CreateId = _auth.GetCurrentUser().User.Id;
lasaWorkspace.CreateTime = DateTime.Now;
List<LasaSpaceDevice> devices= new List<LasaSpaceDevice>();
foreach(var item in info.DeviceIds)
List<LasaSpaceDevice> devices = new List<LasaSpaceDevice>();
foreach (var item in info.DeviceIds)
{
LasaSpaceDevice sd = new LasaSpaceDevice();
sd.WorkSpaceId=lasaWorkspace.Id;
sd.WorkSpaceId = lasaWorkspace.Id;
sd.DeviceId = item;
devices.Add(sd);
}
@ -228,6 +244,7 @@ namespace OpenAuth.App.ServiceApp
sd.UserId = item;
users.Add(sd);
}
await db.LasaWorkspace.InsertAsync(lasaWorkspace);
await db.LasaSpaceDevice.InsertRangeAsync(devices);
await db.LasaSpaceUser.InsertRangeAsync(users);
@ -237,6 +254,7 @@ namespace OpenAuth.App.ServiceApp
return new Response<bool> { Result = false, Message = "添加失败" };
}
}
//编辑项目
public async Task<Response<bool>> EditWorkspace(WorkSpace info)
{
@ -261,9 +279,10 @@ namespace OpenAuth.App.ServiceApp
sd.UserId = item;
users.Add(sd);
}
await db.LasaSpaceDevice.DeleteAsync(r=>r.WorkSpaceId == lasaWorkspace.Id);
await db.LasaSpaceDevice.DeleteAsync(r => r.WorkSpaceId == lasaWorkspace.Id);
await db.LasaSpaceDevice.InsertRangeAsync(devices);
await db.LasaSpaceUser.DeleteAsync(r=>r.WorkSpaceId==lasaWorkspace.Id);
await db.LasaSpaceUser.DeleteAsync(r => r.WorkSpaceId == lasaWorkspace.Id);
await db.LasaSpaceUser.InsertRangeAsync(users);
if (db.Commit())
return new Response<bool> { Result = true, Message = "编辑成功" };
@ -271,6 +290,7 @@ namespace OpenAuth.App.ServiceApp
return new Response<bool> { Result = false, Message = "编辑失败" };
}
}
//删除项目
public async Task<Response<bool>> DeleteWorkspace(string id)
{
@ -286,6 +306,22 @@ namespace OpenAuth.App.ServiceApp
return new Response<bool> { Result = false, Message = "删除失败" };
}
}
#endregion
public async Task ExecuteFlyTask(string taskId)
{
var airLine = await Repository.ChangeRepository<SugarRepositiry<LasaAirLine>>().GetByIdAsync(taskId);
var wpml = airLine.WPML;
// todo 查询sn
var device = await Repository.ChangeRepository<SugarRepositiry<LasaUav>>().GetByIdAsync(airLine.UavId);
var topic = string.Format(GatewayManager.FlightTaskPrepare, airLine.UavId) ;
// todo 1. 下发任务2. 执行任务 3. 改变任务库任务状态
// todo 创建飞行任务
// todo 改变任务状态
// todo
}
}
}
}

@ -313,12 +313,10 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// </summary>
/// <param name="taskId"></param>
[HttpPost]
public async Task ExecuteTask(string taskId)
public async Task ExecuteFlyTask(string taskId)
{
// todo 取得任务信息
// todo 创建飞行任务
// todo 改变任务状态
// todo
await _app.ExecuteFlyTask(taskId);
}
/// <summary>

@ -42,7 +42,6 @@
<PackageReference Include="MiniProfiler.AspNetCore" Version="4.2.22" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.2.22" />
<PackageReference Include="MiniProfiler.Shared" Version="4.2.22" />
<PackageReference Include="MQTTnet" Version="4.1.4.563" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NPOI" Version="2.5.6" />
<PackageReference Include="NUnit" Version="3.13.1" />
@ -80,12 +79,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="CloudSdk\common\" />
<Folder Include="CloudSdk\config\" />
<Folder Include="CloudSdk\control\" />
<Folder Include="CloudSdk\device\" />
<Folder Include="CloudSdk\meida\" />
<Folder Include="CloudSdk\wayline\" />
<Folder Include="Controllers\BaseControllers\Permission\" />
</ItemGroup>

Loading…
Cancel
Save