From 23fa14a272ee9e054828e6a214a632f9ab004141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Fri, 29 Aug 2025 15:17:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?1.=20CallAiModel=E5=85=BC=E5=AE=B9=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E4=BB=BB=E5=8A=A1=E6=94=B9=E9=80=A0=202.=20=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E4=BB=BB=E5=8A=A1=E6=99=BA=E8=83=BD=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/ManageApp.cs | 31 ++++---- .../ServiceApp/Subscribe/ConfigSubscribe.cs | 73 +++++++++++++++---- 2 files changed, 77 insertions(+), 27 deletions(-) diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index 8ee1b86..6666b42 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -2381,24 +2381,27 @@ namespace OpenAuth.App.ServiceApp public async Task> CallAiModel(CallAiModel req) { - var aiInspection = new LasaAiInspection - { - Id = Guid.NewGuid().ToString(), - TaskId = req.TaskId, - AlgoInstanceId = req.AlgoInstanceId, - WarningTitle = req.WarningTitle, - WarningContent = req.WarningContent - }; + var task = await Repository + .ChangeRepository>() + .GetByIdAsync(req.TaskId); + ; using var db = Repository.AsSugarClient(); try { db.Ado.BeginTran(); - // 更新 - await db.Updateable(aiInspection).IgnoreNullColumns().ExecuteCommandAsync(); - - var task = await db.Queryable() - .Where(x => x.Id == req.TaskId) - .FirstAsync(); + if (task.FlightTaskType.Equals(1)) + { + var aiInspection = new LasaAiInspection + { + Id = Guid.NewGuid().ToString(), + TaskId = req.TaskId, + AlgoInstanceId = req.AlgoInstanceId, + WarningTitle = req.WarningTitle, + WarningContent = req.WarningContent + }; + // 更新 + await db.Updateable(aiInspection).IgnoreNullColumns().ExecuteCommandAsync(); + } var algoInstances = await db .Queryable() .Where(x => x.Id == req.AlgoInstanceId) diff --git a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs index 2a972fd..276734e 100644 --- a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs +++ b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs @@ -15,6 +15,7 @@ using MQTTnet.Client; using Newtonsoft.Json; using NPOI.SS.Formula.Functions; using OpenAuth.App.ServiceApp; +using OpenAuth.App.ServiceApp.FlyTask.Request; using OpenAuth.Repository.Domain; using OpenAuth.WebApi; using Quartz; @@ -570,8 +571,9 @@ public class ConfigSubscribe : IJob // "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"} code = data.result; // result - var x = (int)data.output.ext.wayline_mission_state; - var flightId2 = (string)data.output.ext.flight_id; + var waylineMissionState = (int)data.output.ext.wayline_mission_state; + string flightId1 = (string)data.output.ext.flight_id; + var taskAssign1 = _manageApp.GetTaskAssignByFlightId(flightId1); // 处理航线进度 ,也有可能是失败 if (code != 0) { @@ -592,14 +594,13 @@ public class ConfigSubscribe : IJob await _mqttClientManager.PublishAsync(cancelTaskTopic, JsonConvert.SerializeObject(cancelTaskRequest)); //更新任务状态及失败原因? - string flightId1 = data.output.ext.flight_id; - var taskId1 = _manageApp.GetTaskAssignByFlightId(flightId1).TaskId; + // "773":"低电量返航导致航线中断" int reasonCode = data.output.ext.break_point.break_reason; // 添加断点信息 var taskRecord1 = new LasaTask() { - Id = taskId1, + Id = taskAssign1.TaskId, Status = 2, Reason = ErrorMap[code], BreakPoint = JsonConvert.SerializeObject(data.output.ext.break_point) @@ -611,22 +612,68 @@ public class ConfigSubscribe : IJob } else { - // 航线成功 - if (x.Equals(9)) // 航结结束,更新任务状态 + var step = (int)data.output.progress.current_step; + if (step.Equals(25)) // 航线执行 { - var task1 = await _sqlSugarClient - .Queryable() - .SingleAsync(a => a.FlightId == flightId2); + var task = await _sqlSugarClient.Queryable() + .FirstAsync(y => y.Id == taskAssign1.TaskId); + if (task != null && !string.IsNullOrEmpty(task.AIInspection) && + task.AIInspection.Equals("true") && string.IsNullOrEmpty(task.PushUrl)) + { + var param = @$"{{ + ""bid"": {Guid.NewGuid().ToString()}, + ""method"": ""live_start_push"", + ""tid"": {Guid.NewGuid().ToString()}, + ""timestamp"": {DateTimeOffset.Now.ToUnixTimeMilliseconds()}, + ""data"": {{ + ""url_type"": 1, + ""url"": ""rtmp://box.wisestcity.com:1935/live/7"", + ""video_id"": ""1581F8HGX254V00A0BUY/99-0-0/normal-0"", + ""video_quality"": 3 + }} +}}"; + var topicRequest = $"thing/product/{sn}/services"; + await _mqttClientManager.PublishAsync(topicRequest, param); + var req = new CallAiModel { TaskId = taskAssign1.TaskId }; + await _manageApp.CallAiModel(req); + } + } + + // 航线成功 + if (waylineMissionState.Equals(9)) // 航结结束,更新任务状态 + { + var task = await _sqlSugarClient.Queryable() + .FirstAsync(y => y.Id == taskAssign1.TaskId); + if (!string.IsNullOrEmpty(task.AIInspection) && task.AIInspection.Equals(true) && + !string.IsNullOrEmpty(task.PushUrl)) + { + // todo 停止直播 + // todo 停止 aimodel 运行 + var para = @$"{{ + ""bid"": {Guid.NewGuid().ToString()}, + ""data"": {{ + ""video_id"": ""1581F8HGX254V00A0BUY/99-0-0/normal-0"" + }}, + ""tid"":{Guid.NewGuid().ToString()}, + ""timestamp:"": {DateTimeOffset.Now.ToUnixTimeMilliseconds()}, + ""method"": ""live_stop_push"" + }}"; + var topicRequest = $"thing/product/{sn}/services"; + await _mqttClientManager.PublishAsync(topicRequest, para); + using var httpClient = new HttpClient(); + await httpClient.PostAsync("http://192.168.10.131:9025/stop_detection", null); + } + var record = new LasaTask() { - Id = task1.Id, + Id = taskAssign1.TaskId, Status = 5 }; await _sqlSugarClient.Updateable(record).IgnoreNullColumns().ExecuteCommandAsync(); } } - if (result.need_reply.Equals(1)) + /*if (result.need_reply.Equals(1)) { var fileUploadCallbackEventReply = new FileUploadCallbackEventReply() { @@ -642,7 +689,7 @@ public class ConfigSubscribe : IJob }; await _mqttClientManager.PublishAsync($"thing/product/{sn}/events_reply", JsonConvert.SerializeObject(fileUploadCallbackEventReply)); - } + }*/ //Console.WriteLine($"航线进度:{message}"); break; From 89441d000313407022339c1e56a0a2f58212c9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Fri, 29 Aug 2025 15:55:05 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=89=8B=E9=A3=9E=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/ManageApp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index 6666b42..ab0d438 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -2358,7 +2358,7 @@ namespace OpenAuth.App.ServiceApp var lasaTask = new LasaTask { Id = Guid.NewGuid().ToString(), - TaskName = $"手飞任务 {date:yyyy-MM-dd HH:mm:ss}", + TaskName = $"手飞任务 {date:yyyyMMddHHmmss}", TaskType = 0, //0 计划任务 1 手飞任务 FlightTaskType = 1, From 8983632b71b82da15724fa6658a0448bf879a48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Fri, 29 Aug 2025 15:56:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=89=8B=E9=A3=9E?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/ManageApp.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index ab0d438..6cb632b 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -2461,6 +2461,8 @@ namespace OpenAuth.App.ServiceApp var task = new LasaTask() { Id = taskid, + // ScheduledEndTime = DateTime.Now, + CompletedTime = DateTime.Now, Status = 5 // 成功 }; using var db = Repository.AsSugarClient();