Merge branch 'main' of http://123.132.248.154:10000/HC_YFZX/LASAPlatform
commit
fc8a9233cc
|
|
@ -1,17 +1,23 @@
|
|||
using System.Dynamic;
|
||||
using Infrastructure;
|
||||
using Newtonsoft.Json;
|
||||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.Repository;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.WebApi;
|
||||
using SqlSugar;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp;
|
||||
|
||||
public class LasaAircraftServiceApp : SqlSugarBaseApp<LasaAircraft, SugarDbContext>
|
||||
{
|
||||
public LasaAircraftServiceApp(ISugarUnitOfWork<SugarDbContext> unitWork,
|
||||
private readonly MqttClientManager _mqttClientManager;
|
||||
|
||||
public LasaAircraftServiceApp(MqttClientManager mqttClientManager, ISugarUnitOfWork<SugarDbContext> unitWork,
|
||||
ISimpleClient<LasaAircraft> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||
{
|
||||
_mqttClientManager = mqttClientManager;
|
||||
}
|
||||
|
||||
public async Task<Response<bool>> AddLasaAircraft(LasaAircraft info)
|
||||
|
|
@ -102,4 +108,39 @@ public class LasaAircraftServiceApp : SqlSugarBaseApp<LasaAircraft, SugarDbConte
|
|||
Result = await Repository.GetByIdAsync(id)
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<Response<bool>> StartLiveStreaming(string id)
|
||||
{
|
||||
var lasaAircraft = await Repository.GetByIdAsync(id);
|
||||
// 主题参考thing/product/1581F8HGX254V00A0BUY/osd
|
||||
dynamic data = new ExpandoObject();
|
||||
data.method = "live_start_push";
|
||||
data.data.url = ""; // todo
|
||||
data.video_quality = 3; // "0":"自适应","1":"流畅","2":"标清","3":"高清","4":"超清"
|
||||
// todo 发送消息
|
||||
// todo 关于监听反馈消息
|
||||
String sn = lasaAircraft.Sn;
|
||||
await _mqttClientManager.PublishAsync("thing/aircraft/{sn}/service",
|
||||
JsonConvert.SerializeObject(data));
|
||||
return new Response<bool>
|
||||
{
|
||||
Result = true,
|
||||
Message = "推流命令已发送"
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<Response<bool>> StopLiveStreaming(string id)
|
||||
{
|
||||
var lasaAircraft = await Repository.GetByIdAsync(id);
|
||||
dynamic data = new ExpandoObject();
|
||||
data.method = "live_start_push";
|
||||
String sn = lasaAircraft.Sn;
|
||||
await _mqttClientManager.PublishAsync("thing/aircraft/{sn}/service",
|
||||
JsonConvert.SerializeObject(data));
|
||||
return new Response<bool>
|
||||
{
|
||||
Result = true,
|
||||
Message = "停止推流命令已发送"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1220,10 +1220,11 @@ namespace OpenAuth.App.ServiceApp
|
|||
FlightId = data.flight_id,
|
||||
ExternalTaskId = task.ExternalTaskId
|
||||
});
|
||||
|
||||
|
||||
var taskUpdate1 = new LasaTask
|
||||
{
|
||||
Id = taskId,
|
||||
PushUrl = "",
|
||||
//任务因挂起失败
|
||||
Status = 0,
|
||||
};
|
||||
|
|
@ -1232,7 +1233,7 @@ namespace OpenAuth.App.ServiceApp
|
|||
.AsUpdateable(taskUpdate1)
|
||||
.IgnoreNullColumns()
|
||||
.ExecuteCommandAsync();
|
||||
return new Response<bool>(){Result = true};
|
||||
return new Response<bool>() { Result = true };
|
||||
}
|
||||
|
||||
public async Task PendingFlyTask(string taskId)
|
||||
|
|
@ -2884,12 +2885,13 @@ namespace OpenAuth.App.ServiceApp
|
|||
int year = int.Parse(array[0]);
|
||||
int month = int.Parse(array[1]);
|
||||
start = new DateTime(year, month, 1);
|
||||
end = start.AddMonths(1).AddMilliseconds(-1);;
|
||||
end = start.AddMonths(1).AddMilliseconds(-1);
|
||||
;
|
||||
}
|
||||
|
||||
var taskHistoryList = await Repository.ChangeRepository<SugarRepositiry<LasaTaskHistory>>()
|
||||
.AsQueryable()
|
||||
.WhereIF(!string.IsNullOrEmpty(date),
|
||||
.WhereIF(!string.IsNullOrEmpty(date),
|
||||
r => r.ExecuteTime >= start && r.ExecuteTime <= end)
|
||||
.Where(r => r.TaskId == taskId)
|
||||
.OrderByDescending(r => r.ExecuteTime)
|
||||
|
|
@ -2899,5 +2901,32 @@ namespace OpenAuth.App.ServiceApp
|
|||
Result = taskHistoryList
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<Response<dynamic>> ListDronePort(string lng, string lat)
|
||||
{
|
||||
var sql =
|
||||
@$"WITH target_point AS ( SELECT ST_SetSRID ( ST_MakePoint ( '{lng}', '{lat}' ), 4326 ) AS geom )
|
||||
SELECT
|
||||
b.""Id"" AS DronePortId,
|
||||
b.""Name"" AS DronePortName,
|
||||
u.""Sn"",
|
||||
b.""Sn"" as DronePortSn,
|
||||
b.""GateWay"",
|
||||
ST_AsText ( b.""WorkArea"" ) AS coverage_wkt,
|
||||
ST_AsText ( tp.geom ) AS point_location
|
||||
FROM
|
||||
lasa_droneport b left join lasa_uav u on u.""PId"" = b.""Id"",
|
||||
target_point tp
|
||||
WHERE
|
||||
ST_Covers ( b.""WorkArea"", tp.geom )
|
||||
AND b.""IsDelete"" = 'false' and u.""IsDelete"" = 'false'
|
||||
|
||||
";
|
||||
var x = await Repository.AsSugarClient().SqlQueryable<dynamic>(sql).ToListAsync();
|
||||
return new Response<dynamic>
|
||||
{
|
||||
Result = x
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ using System.Dynamic;
|
|||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Cache;
|
||||
using Infrastructure.CloudSdk;
|
||||
using Infrastructure.CloudSdk.minio;
|
||||
|
|
@ -64,6 +65,7 @@ public class ConfigSubscribe : IJob
|
|||
"thing/product/+/services_reply",
|
||||
"thing/product/+/events",
|
||||
"thing/product/+/requests",
|
||||
"thing/aircraft/+/service_reply" //大飞机推流消息
|
||||
//"thing/product/+/osd",
|
||||
//"thing/product/+/status"
|
||||
};
|
||||
|
|
@ -597,6 +599,7 @@ public class ConfigSubscribe : IJob
|
|||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var task = await _sqlSugarClient.Queryable<LasaTask>()
|
||||
.FirstAsync(y => y.Id == taskAssign1.TaskId);
|
||||
// 如果开启了智能巡检
|
||||
|
|
@ -739,9 +742,11 @@ public class ConfigSubscribe : IJob
|
|||
// 关于直播是否开启成功
|
||||
// 取得taskid 然后从liveInfo中移除
|
||||
var tempTaskId = _liveInfo[$"{result.tid}{result.bid}"];
|
||||
_logger.LogDebug($"智能巡检TaskId:{tempTaskId}");
|
||||
_liveInfo.TryRemove($"{result.tid}{result.bid}", out _);
|
||||
var req = new CallAiModel { TaskId = tempTaskId, RtmpUrl = rtmp };
|
||||
await _manageApp.CallAiModel(req);
|
||||
_logger.LogDebug($"智能巡检调用参数:{JsonConvert.SerializeObject(req)}");
|
||||
_ = _manageApp.CallAiModel(req);
|
||||
break;
|
||||
case "live_stop_push":
|
||||
_logger.LogDebug($"停止直播成功 {message}");
|
||||
|
|
|
|||
|
|
@ -5,19 +5,19 @@ namespace OpenAuth.Repository.Domain
|
|||
[SugarTable("lasa_droneport")]
|
||||
public class LasaDronePort
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string TypeId { get; set; }
|
||||
public string SerialNumber { get; set; }
|
||||
public string FirmwareVersion { get; set; }
|
||||
public int BindStatus { get; set; }
|
||||
[SugarColumn(IsPrimaryKey = true)] public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string TypeId { get; set; }
|
||||
public string SerialNumber { get; set; }
|
||||
public string FirmwareVersion { get; set; }
|
||||
public int BindStatus { get; set; }
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public string OrgId { get; set; }
|
||||
public string Sn { get; set; }
|
||||
public string DevicePicUrl { get; set; }
|
||||
public string OrgId { get; set; }
|
||||
public string Sn { get; set; }
|
||||
public string DevicePicUrl { get; set; }
|
||||
public string Did { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:是否删除
|
||||
/// Default:false
|
||||
|
|
@ -25,9 +25,14 @@ namespace OpenAuth.Repository.Domain
|
|||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "false")]
|
||||
public bool IsDelete { get; set; }
|
||||
|
||||
public string WorkSpaceId { get; set; }
|
||||
public string GateWay { get; set; }
|
||||
//
|
||||
public string WorkArea { get; set; }
|
||||
public int? Status { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToMany, nameof(LasaUav.PId))]
|
||||
public List<LasaUav> UavList { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,4 +76,14 @@ public class LasaAircraftController : ControllerBase
|
|||
{
|
||||
return await _app.GetLasaAircraft(id);
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<Response<bool>> StartLiveStreaming(string id)
|
||||
{
|
||||
return await _app.StartLiveStreaming(id);
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<Response<bool>> StopLiveStreaming(string id)
|
||||
{
|
||||
return await _app.StopLiveStreaming(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -966,7 +966,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetTaskHistoryList(string taskId,string date)
|
||||
public async Task<Response<dynamic>> GetTaskHistoryList(string taskId, string date)
|
||||
{
|
||||
if (string.IsNullOrEmpty(taskId))
|
||||
{
|
||||
|
|
@ -976,7 +976,15 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
Message = "参数缺失"
|
||||
};
|
||||
}
|
||||
return await _app.GetTaskHistoryList(taskId,date);
|
||||
|
||||
return await _app.GetTaskHistoryList(taskId, date);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<dynamic>> ListDronePort(string lng, string lat)
|
||||
{
|
||||
return await _app.ListDronePort(lng, lat);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue