zhangbin 2025-09-09 17:24:09 +08:00
commit 7f985d89de
8 changed files with 48 additions and 63 deletions

View File

@ -797,7 +797,7 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
Response.Code = 202; Response.Code = 202;
}else if(taskinfo.state == 2) }else if(taskinfo.state == 2)
{ {
Response.Code = 202; Response.Code = 200;
}else if( taskinfo.state == 3) }else if( taskinfo.state == 3)
{ {
Response.Code = 204; Response.Code = 204;
@ -822,7 +822,7 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
public async Task<Response<bool>> ReportDroneStatus() public async Task<Response<bool>> ReportDroneStatus()
{ {
var droneList = await Repository var droneList = await Repository
.ChangeRepository<SugarRepositiry<LasaUav>>() .ChangeRepository<SugarRepositiry<LasaDronePort>>()
.AsQueryable() .AsQueryable()
.Where(it => it.IsDelete == false) .Where(it => it.IsDelete == false)
.ToListAsync(); .ToListAsync();
@ -876,6 +876,7 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
// 读取响应内容并反序列化 // 读取响应内容并反序列化
var responseBody = await response.Content.ReadAsStringAsync(); var responseBody = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ReciveData<string>>(responseBody); var result = JsonSerializer.Deserialize<ReciveData<string>>(responseBody);
Console.WriteLine($"无人机状态上报结果:{responseBody}");
//解密数据 //解密数据
byte[] resbytesx = Convert.FromBase64String(resxClScrete); byte[] resbytesx = Convert.FromBase64String(resxClScrete);
byte[] resdatabytes = Convert.FromBase64String(result?.data); byte[] resdatabytes = Convert.FromBase64String(result?.data);
@ -1387,11 +1388,11 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
DbfineInfo dbfine = new DbfineInfo(); DbfineInfo dbfine = new DbfineInfo();
dbfine.id = Guid.NewGuid().ToString(); dbfine.id = Guid.NewGuid().ToString();
dbfine.taskid = taskidsheng; dbfine.taskid = taskidsheng;
dbfine.regioncode = filigtlist[0].xzqdm; dbfine.regioncode = signData.RegionCode;
dbfine.extension = ".db"; dbfine.extension = signData.Extension;
dbfine.attachment_count = Convert.ToInt32(signData.Count); dbfine.attachment_count = Convert.ToInt32(signData.AttachmentCount);
dbfine.size = Convert.ToInt32(signData.Size); dbfine.size = Convert.ToInt32(signData.Size);
dbfine.count = totalcount; dbfine.count = Convert.ToInt32(signData.Count);
dbfine.url = read; dbfine.url = read;
dbfine.hash = signData.Hash; dbfine.hash = signData.Hash;
dbfine.key = "hopetry"; dbfine.key = "hopetry";

View File

@ -392,7 +392,7 @@ namespace OpenAuth.App.ServiceApp
/// <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) int? status,string airLineId)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
using (var db = UnitWork.CreateContext()) using (var db = UnitWork.CreateContext())
@ -400,6 +400,7 @@ namespace OpenAuth.App.ServiceApp
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)) .WhereIF(status != null, a => a.Status.Equals(status))
.WhereIF(!string.IsNullOrEmpty(airLineId), a => a.AirLineId == airLineId)
.OrderByDescending(a => a.CreateTime) .OrderByDescending(a => a.CreateTime)
.ToPageListAsync(page, limit, totalCount); .ToPageListAsync(page, limit, totalCount);
return new Response<PageInfo<List<LasaTask>>> return new Response<PageInfo<List<LasaTask>>>
@ -2437,6 +2438,7 @@ namespace OpenAuth.App.ServiceApp
} }
else else
{ {
// 计划任务
var aiInspection = await Repository var aiInspection = await Repository
.ChangeRepository<SugarRepositiry<LasaAiInspection>>() .ChangeRepository<SugarRepositiry<LasaAiInspection>>()
.AsQueryable().Where(x => x.TaskId == req.TaskId).FirstAsync(); .AsQueryable().Where(x => x.TaskId == req.TaskId).FirstAsync();
@ -2499,7 +2501,7 @@ namespace OpenAuth.App.ServiceApp
} }
json.tag = jsonTag; json.tag = jsonTag;
Console.WriteLine(JsonConvert.SerializeObject(json)); _logger.LogDebug($"发送的json:{JsonConvert.SerializeObject(json)}");
var content = new StringContent(JsonConvert.SerializeObject(json), Encoding.UTF8, "application/json"); var content = new StringContent(JsonConvert.SerializeObject(json), Encoding.UTF8, "application/json");
var url = config["AIModelApi:Url"]; var url = config["AIModelApi:Url"];
using var httpClient = new HttpClient(); using var httpClient = new HttpClient();

View File

@ -35,6 +35,7 @@ public class ConfigSubscribe : IJob
private object _dockUploadFileLocker = new(); private object _dockUploadFileLocker = new();
private readonly ILogger<ConfigSubscribe> _logger; private readonly ILogger<ConfigSubscribe> _logger;
private readonly ConcurrentDictionary<string, DateTime> _processedMessages = new(); private readonly ConcurrentDictionary<string, DateTime> _processedMessages = new();
private readonly ConcurrentDictionary<string, string> liveInfo = new();
private readonly TimeSpan _deduplicationWindow = TimeSpan.FromMinutes(1); private readonly TimeSpan _deduplicationWindow = TimeSpan.FromMinutes(1);
public ConfigSubscribe(MqttClientManager mqttClientManager, ISqlSugarClient sqlSugarClient, public ConfigSubscribe(MqttClientManager mqttClientManager, ISqlSugarClient sqlSugarClient,
@ -104,6 +105,9 @@ public class ConfigSubscribe : IJob
var data = result.data; var data = result.data;
//_logger.LogInformation($"主题:{topic}\n消息{message}"); //_logger.LogInformation($"主题:{topic}\n消息{message}");
long code = 0; long code = 0;
// rtmp://175.27.168.120:6019/live/
var rtmp = "rtmp://box.wisestcity.com:1935/live/7";
//var rtmp = "rtmp://175.27.168.120:6019/live/7";
switch (tempStr) switch (tempStr)
{ {
case "thing/product/*/requests": case "thing/product/*/requests":
@ -544,51 +548,22 @@ public class ConfigSubscribe : IJob
break; break;
case "flighttask_progress": case "flighttask_progress":
{ {
string flightId1 = (string)data.output.ext.flight_id;
var waylineMissionState = (int)data.output.ext.wayline_mission_state;
// current_step // current_step
// "0":"初始状态" var isHandle = IsDuplicate(Md5.Encrypt($"{result.bid}{flightId1}"));
// "1":"启动前检查,飞行器是否在执行航线中" _logger.LogDebug($"md5: {isHandle} 重复否:{IsDuplicate(Md5.Encrypt(message))}" +
// "2":"启动前检查,机场是否退出工作模式" $"主题:{topic} 信息:{message} ");
// "3":"启动前检查,航线执行中"
// "4":"启动前检查,返航中"
// "5":"航线执行进入准备状态,开始等待任务下发"
// "6":"机场进入工作状态"
// "7":"进入开机检查准备工作和开盖准备工作"
// "8":"图传远程对频"
// "9":"等待飞行系统准备就绪,推送连接建立"
// "10":"等待 RTK 源监听有值上报"
// "11":"检查 RTK 源是否是机场源,如果不是要重新设置"
// "12":"等待飞行控制权通知"
// "13":"机场无控制权,抢夺飞行器控制权"
// "14":"自定义飞行区一致性检查"
// "15":"离线地图一致性检查"
// "16":"获取最新 KMZ URL"
// "17":"下载 KMZ"
// "18":"KMZ 上传中"
// "19":"染色配置"
// "20":"飞行器起飞参数设置,备降点设置,起飞高度设置,染色设置"
// "21":"飞行器 flyto 起飞参数设置"
// "22":"起飞机场检查降落机场准备状态"
// "23":"Home 点设置"
// "24":"触发执行航线"
// "25":"航线执行中"
// "26":"进入返航的检查准备工作"
// "27":"飞行器降落机场"
// "28":"降落以后的关盖"
// "29":"机场退出工作模式"
// "30":"机场异常恢复","31":"机场上传飞行系统日志","32":"相机录像状态检查","33":"获取媒体文件数量","34":"机场起飞开盖的异常恢复","35":"通知任务结果","36":"日志列表拉取 - 飞行器列表","37":"日志列表拉取 - 拉取机场列表","38":"日志列表拉取 - 上传日志列表结果","39":"日志拉取-拉取飞行器日志","40":"日志拉取-拉取机场日志","41":"日志拉取-压缩飞行器日志","42":"日志拉取-压缩机场日志","43":"日志拉取-上传飞行器日志","44":"日志拉取-上传机场日志","45":"日志拉取-通知结果","46":"自定义飞行区文件更新准备中","47":"自定义飞行区更新中","48":"离线地图更新准备中","49":"离线地图更新中","65533":"结束后等待服务回包","65534":"无具体状态","65535":"UNKNOWN"}
var isHandle = IsDuplicate(Md5.Encrypt(message));
_logger.LogDebug($"md5: {isHandle} 重复否:{IsDuplicate(Md5.Encrypt(message))} 信息:{message} ");
if (isHandle) if (isHandle)
{ {
_logger.LogInformation("跳过处理"); _logger.LogInformation("跳过处理");
break; break;
} }
_logger.LogDebug("航线进度未跳过处理"); _logger.LogDebug("航线进度未跳过处理");
code = data.result; // result code = data.result; // result
var waylineMissionState = (int)data.output.ext.wayline_mission_state;
string flightId1 = (string)data.output.ext.flight_id;
var taskAssign1 = _manageApp.GetTaskAssignByFlightId(flightId1); var taskAssign1 = _manageApp.GetTaskAssignByFlightId(flightId1);
// 处理航线进度 ,也有可能是失败 // 处理航线进度 ,也有可能是失败
if (code != 0) if (code != 0)
@ -630,7 +605,7 @@ public class ConfigSubscribe : IJob
{ {
var step = (int)data.output.progress.current_step; var step = (int)data.output.progress.current_step;
_logger.LogDebug($"航线进度:{waylineMissionState} {step} {message}"); _logger.LogDebug($"航线进度:{waylineMissionState} {step} {message}");
if (step.Equals(25)) // 航线执行 if (step.Equals(25)) // todo 关于会接收到不同消息问题,如何处理
{ {
var task = await _sqlSugarClient.Queryable<LasaTask>() var task = await _sqlSugarClient.Queryable<LasaTask>()
.FirstAsync(y => y.Id == taskAssign1.TaskId); .FirstAsync(y => y.Id == taskAssign1.TaskId);
@ -638,11 +613,13 @@ public class ConfigSubscribe : IJob
task.AIInspection.Equals("true") && string.IsNullOrEmpty(task.PushUrl)) task.AIInspection.Equals("true") && string.IsNullOrEmpty(task.PushUrl))
{ {
_logger.LogDebug("执行AI 智能巡检。。。。。"); _logger.LogDebug("执行AI 智能巡检。。。。。");
var rtmp = "rtmp://box.wisestcity.com:1935/live/7"; //var rtmp = "rtmp://box.wisestcity.com:1935/live/7";
var bid = Guid.NewGuid().ToString();
var tid = Guid.NewGuid().ToString();
var param = @$"{{ var param = @$"{{
""bid"": ""{Guid.NewGuid().ToString()}"", ""bid"": ""{bid}"",
""method"": ""live_start_push"", ""method"": ""live_start_push"",
""tid"": ""{Guid.NewGuid().ToString()}"", ""tid"": ""{tid}"",
""timestamp"": {DateTimeOffset.Now.ToUnixTimeMilliseconds()}, ""timestamp"": {DateTimeOffset.Now.ToUnixTimeMilliseconds()},
""data"": {{ ""data"": {{
""url_type"": 1, ""url_type"": 1,
@ -655,9 +632,7 @@ public class ConfigSubscribe : IJob
var topicRequest = $"thing/product/{sn}/services"; var topicRequest = $"thing/product/{sn}/services";
// 开启直播 // 开启直播
await _mqttClientManager.PublishAsync(topicRequest, param); await _mqttClientManager.PublishAsync(topicRequest, param);
// todo 关于直播是否开启成功 liveInfo[$"{tid}{bid}"] = taskAssign1.TaskId;
var req = new CallAiModel { TaskId = taskAssign1.TaskId, RtmpUrl = rtmp };
await _manageApp.CallAiModel(req);
} }
} }
@ -666,7 +641,7 @@ public class ConfigSubscribe : IJob
{ {
var task = await _sqlSugarClient.Queryable<LasaTask>() var task = await _sqlSugarClient.Queryable<LasaTask>()
.FirstAsync(y => y.Id == taskAssign1.TaskId); .FirstAsync(y => y.Id == taskAssign1.TaskId);
if (!string.IsNullOrEmpty(task.AIInspection) && task.AIInspection.Equals(true) && if (!string.IsNullOrEmpty(task.AIInspection) && task.AIInspection.Equals("true") &&
!string.IsNullOrEmpty(task.PushUrl)) !string.IsNullOrEmpty(task.PushUrl))
{ {
// todo video_id 需要根据不同设备改变 // todo video_id 需要根据不同设备改变
@ -740,9 +715,15 @@ public class ConfigSubscribe : IJob
{ {
break; break;
} }
// todo 已验证tid bid 是相同的 // 已验证tid bid 是相同的
// todo 开启直播成功调用ai model // 开启直播成功调用ai model
_logger.LogDebug($"开启直播成功 {message}"); _logger.LogDebug($"开启直播成功 {message}");
// 关于直播是否开启成功
// 取得taskid 然后从liveInfo中移除
var tempTaskId = liveInfo[$"{result.tid}{result.bid}"];
liveInfo.TryRemove($"{result.tid}{result.bid}", out _);
var req = new CallAiModel { TaskId = tempTaskId, RtmpUrl = rtmp };
await _manageApp.CallAiModel(req);
break; break;
case "live_stop_push": case "live_stop_push":
_logger.LogDebug($"停止直播成功 {message}"); _logger.LogDebug($"停止直播成功 {message}");

View File

@ -231,12 +231,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// <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) int? status,string airLineId)
{ {
var result = new Response<PageInfo<List<LasaTask>>>(); var result = new Response<PageInfo<List<LasaTask>>>();
try try
{ {
result = await _app.GetTaskPageList(page, limit, key, status); result = await _app.GetTaskPageList(page, limit, key, status,airLineId);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -49,10 +49,11 @@ namespace OpenAuth.WebApi.Model
return; return;
} }
if (File.Exists("license.lic")) var licensePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "license.lic");
if (File.Exists(licensePath))
{ {
var licenseManager = new LicenseManager(); var licenseManager = new LicenseManager();
if (!licenseManager.ValidateLicense(System.IO.File.ReadAllText("license.lic"), out var error)) if (!licenseManager.ValidateLicense(System.IO.File.ReadAllText(licensePath), out var error))
{ {
context.HttpContext.Response.StatusCode = 401; context.HttpContext.Response.StatusCode = 401;
context.Result = new JsonResult(new Response context.Result = new JsonResult(new Response

View File

@ -187,8 +187,8 @@ namespace OpenAuth.WebApi
services.AddHostedService<DelayedExecutionService>(); services.AddHostedService<DelayedExecutionService>();
#region rabbitmq #region rabbitmq
//services.AddSingleton<RabbitMqListenerService>(); services.AddSingleton<RabbitMqListenerService>();
//services.AddHostedService(sp => sp.GetRequiredService<RabbitMqListenerService>()); services.AddHostedService(sp => sp.GetRequiredService<RabbitMqListenerService>());
#endregion #endregion
#region AppSetting #region AppSetting

View File

@ -23,7 +23,7 @@ public class DelayedExecutionService : BackgroundService
{ {
await PerformDelayedTask(); await PerformDelayedTask();
// 等待5秒 // 等待5秒
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken); await Task.Delay(TimeSpan.FromMinutes(5), stoppingToken);
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {

View File

@ -22,7 +22,7 @@
"UploadPath": "", "UploadPath": "",
// //
"RedisConf": { "RedisConf": {
"Conn": "123.132.248.154:9253,password=HopetryRedis1406", "Conn": "192.168.10.163:6379,password=123456",
//"Conn": "127.0.0.1:6379,password=123456", //"Conn": "127.0.0.1:6379,password=123456",
"Database": 7 "Database": 7
}, },