feat(manage): 优化无人机设备类型解析与智能巡检任务状态管理

- 改进设备类型ID解析逻辑,增强代码可读性
- 根据设备字典查询结果动态设置设备名称
- 新增智能巡检任务标识及状态更新机制
- 实现人工飞行任务结束前的智能巡检状态检查
- 整理Redis数据获取相关代码结构
- 添加必要的注释说明待办事项
main
陈伟 2025-11-29 15:29:11 +08:00
parent d3d732bcce
commit b094961e2c
1 changed files with 22 additions and 4 deletions

View File

@ -367,15 +367,18 @@ namespace OpenAuth.App.ServiceApp
{
using (var db = UnitWork.CreateContext())
{
int[] uavtype = info.TypeId.Split('-', StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
int[] uavtype = info.TypeId.Split('-', StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x))
.ToArray();
if (uavtype.Length == 3)
{
var devicename = db.LasaDeviceDictionary.AsQueryable().Where(r => r.Domain == uavtype[0] && r.DeviceType == uavtype[1] && r.SubType == uavtype[2]).First();
var devicename = db.LasaDeviceDictionary.AsQueryable().Where(r =>
r.Domain == uavtype[0] && r.DeviceType == uavtype[1] && r.SubType == uavtype[2]).First();
if (devicename != null)
{
info.TypeId = devicename.DeviceName;
}
}
var flag = db.LasaUav.Insert(info);
if (db.Commit())
return true;
@ -2538,11 +2541,14 @@ namespace OpenAuth.App.ServiceApp
aiInspection.WarningContent = req.WarningContent;
}
// 更新
// todo 关于多次调用问题
// 关于多次调用问题
var count = await db.Queryable<LasaAiInspection>().Where(x => x.TaskId == req.TaskId).CountAsync();
if (count == 0)
{
// 设置任务智能巡检标识
task.AIInspection = "true";
task.Status = 3; // 表示智能巡检中
await db.Updateable(task).ExecuteCommandAsync();
await db.Insertable(aiInspection).ExecuteCommandAsync();
}
}
@ -2655,6 +2661,15 @@ namespace OpenAuth.App.ServiceApp
public async Task<Response<bool>> EndHandFlyTask(string taskid)
{
// todo
var savedTask = await Repository.ChangeRepository<SugarRepositiry<LasaTask>>().AsQueryable()
.Where(x => x.Id == taskid)
.FirstAsync();
if (savedTask.Status == 3)
{
throw new Exception("智能巡检未关闭");
}
var task = new LasaTask()
{
Id = taskid,
@ -3018,6 +3033,7 @@ WHERE
#region redis获取数据
public async Task<Response<string>> GetDronePortInfoFromRedis(string key)
{
var info = _redisCacheContext.Get<string>(key);
@ -3028,12 +3044,14 @@ WHERE
Result = info
};
}
return new Response<string>
{
Message = "暂无数据",
Code = 500
};
}
#endregion
}
}