浏览代码

重构定点飞行代码

tags/v1.2.0^2
wanjing 1年前
父节点
当前提交
3e5a0bc403
共有 3 个文件被更改,包括 27 次插入11 次删除
  1. +23
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/UpdateEmergencyMissionStatusService.java
  2. +2
    -10
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportCallBackUpdateStatusService.java
  3. +2
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java

+ 23
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/UpdateEmergencyMissionStatusService.java 查看文件

@@ -3,8 +3,11 @@ package com.tuoheng.admin.service.third;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.domain.WarningRecord;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.MarkTypeEnum;
import com.tuoheng.admin.mapper.ThMissionMapper;
import com.tuoheng.admin.mapper.WarningRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -13,6 +16,9 @@ import org.springframework.stereotype.Service;
@Service
public class UpdateEmergencyMissionStatusService {

@Autowired
private WarningRecordMapper warningRecordMapper;

@Autowired
private ThMissionMapper thMissionMapper;

@@ -23,13 +29,29 @@ public class UpdateEmergencyMissionStatusService {
*/
public void updateStatus(ThMission oldMission, Integer status) {
log.info("修改应急任务数据, type:{}, emergencyDataMissionId:{}, status={}", oldMission.getType(), oldMission.getEmergencyDataMissionId(), status);
WarningRecord warningRecord = warningRecordMapper.selectOne(new LambdaQueryWrapper<WarningRecord>()
.eq(WarningRecord::getMissionId, oldMission.getId())
.eq(WarningRecord::getMark, MarkTypeEnum.VALID.getCode())
.orderByDesc(WarningRecord::getCreateTime)
.last(" limit 1"));
if (ObjectUtil.isNull(warningRecord)) {
log.info("修改应急任务数据,该巡检任务没有产生预警记录");
return;
}

ThMission emergencyMission = thMissionMapper.selectOne(new LambdaQueryWrapper<ThMission>()
.eq(ThMission::getId, oldMission.getEmergencyDataMissionId())
.eq(ThMission::getId, warningRecord.getEmergencyMissionId())
.eq(ThMission::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNull(emergencyMission)) {
log.info("修改应急任务数据,应急任务不存在");
return;
}

if (0 == emergencyMission.getEmergencyDataMissionId()) {
log.info("修改应急任务数据,该应急任务,作为独立的任务");
return;
}

// 在查询一次,保证数据是最新的
ThMission mission = thMissionMapper.selectOne(new LambdaQueryWrapper<ThMission>()
.eq(ThMission::getId, oldMission.getId())

+ 2
- 10
tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportCallBackUpdateStatusService.java 查看文件

@@ -91,11 +91,7 @@ public class AirportCallBackUpdateStatusService {
// throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "任务分析失败!");
}

if (2 == thMission.getType() && 0 != thMission.getEmergencyDataMissionId()) {
log.info("机场平台回调,执行中,开始修改应急任务数据, status={}", status);
updateEmergencyMissionStatusService.updateStatus(thMission, status);
log.info("机场平台回调,执行中,修改应急任务数据结束");
}
updateEmergencyMissionStatusService.updateStatus(thMission, status);
} else if (AirPortTaskStatusEnum.WAIT.getCode() == missionStatusRequest.getStatus()) {
log.info("被硬件调用,存任务状态:已完成");
// 机场飞行完成,立即修改任务状态为已完成
@@ -117,11 +113,7 @@ public class AirportCallBackUpdateStatusService {

status = TaskStatusEnum.COMPLETE.getCode();

if (2 == thMission.getType() && 0 != thMission.getEmergencyDataMissionId()) {
log.info("机场平台回调,已完成,开始修改应急任务数据, status={}", status);
updateEmergencyMissionStatusService.updateStatus(thMission, status);
log.info("机场平台回调,已完成,修改应急任务数据结束");
}
updateEmergencyMissionStatusService.updateStatus(thMission, status);

//硬件停止后,停止AI分析
this.stopAI(missionStatusRequest, thMission);

+ 2
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java 查看文件

@@ -253,6 +253,8 @@ public class PointFlightService {
if (count <= 0) {
log.info("创建应急任务失败");
throw new ServiceException("创建应急任务失败");
} else {
log.info("创建应急任务成功, mission={}", mission);
}
return mission;
}

正在加载...
取消
保存