private String requestId; | private String requestId; | ||||
/** | /** | ||||
* 机场飞行类型 0默认 1机场巡逻 2指点飞行 | |||||
* 任务类型:0:巡检任务 1:应急任务 | |||||
*/ | */ | ||||
private Integer airportFlyType; | |||||
private Integer accidentTask; | |||||
/** | |||||
* 应急任务关联数据任务ID | |||||
*/ | |||||
private Integer emergencyDataMissionId; | |||||
} | } |
@ApiModelProperty(value = "租户Id",hidden = true) | @ApiModelProperty(value = "租户Id",hidden = true) | ||||
private Integer tenantId; | private Integer tenantId; | ||||
@ApiModelProperty(value = "机场飞行类型 0默认 1机场巡逻 2指点飞行") | |||||
private Integer airportFlyType; | |||||
@ApiModelProperty(value = "任务类型:0:巡检任务 1:应急任务") | |||||
private Integer accidentTask; | |||||
@ApiModelProperty(value = "任务状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | @ApiModelProperty(value = "任务状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | ||||
private List<String> statusList; | private List<String> statusList; |
* @date 2023-02-13 | * @date 2023-02-13 | ||||
*/ | */ | ||||
public enum AirportFlyTypeEnum { | |||||
public enum AccidentTaskEnum { | |||||
NULL(0, "无"), | |||||
AIRPORT_PATROL(1,"机场巡逻"), | |||||
POINTING_FLIGHT(2,"指点飞行"); | |||||
INSPECTION_TASK(0,"巡检任务"), | |||||
ACCIDENT_TASK(1,"应急任务"); | |||||
AirportFlyTypeEnum(int code, String description){ | |||||
AccidentTaskEnum(int code, String description){ | |||||
this.code = code; | this.code = code; | ||||
this.description = description; | this.description = description; | ||||
} | } |
import com.tuoheng.admin.entity.vo.AirPortVO; | import com.tuoheng.admin.entity.vo.AirPortVO; | ||||
import com.tuoheng.admin.entity.vo.AirWeatherVO; | import com.tuoheng.admin.entity.vo.AirWeatherVO; | ||||
import com.tuoheng.admin.entity.vo.InspectionVO; | import com.tuoheng.admin.entity.vo.InspectionVO; | ||||
import com.tuoheng.admin.enums.AirportFlyTypeEnum; | |||||
import com.tuoheng.admin.enums.AccidentTaskEnum; | |||||
import com.tuoheng.admin.enums.MarkTypeEnum; | import com.tuoheng.admin.enums.MarkTypeEnum; | ||||
import com.tuoheng.admin.enums.TaskStatusEnum; | import com.tuoheng.admin.enums.TaskStatusEnum; | ||||
import com.tuoheng.admin.enums.UpdateOrCreateEnum; | import com.tuoheng.admin.enums.UpdateOrCreateEnum; | ||||
if (ObjectUtil.isNull(mission)) { | if (ObjectUtil.isNull(mission)) { | ||||
throw new ServiceException("没有该任务记录"); | throw new ServiceException("没有该任务记录"); | ||||
} | } | ||||
if (ObjectUtil.isNotNull(mission.getAirportFlyType()) && AirportFlyTypeEnum.POINTING_FLIGHT.getCode() == mission.getAirportFlyType()) { | |||||
// 定点飞行 | |||||
WarningRecord warningRecord = warningRecordMapper.selectOne(new LambdaQueryWrapper<WarningRecord>() | |||||
.eq(WarningRecord::getEmergencyMissionId, id) | |||||
.eq(WarningRecord::getMark, MarkTypeEnum.VALID.getCode()) | |||||
.orderByDesc(WarningRecord::getCreateTime) | |||||
.last(" limit 1")); | |||||
if (ObjectUtil.isNull(warningRecord)) { | |||||
throw new ServiceException("该应急任务没有对应的预警记录"); | |||||
} | |||||
ThMission oldMission = missionMapper.selectOne(new LambdaQueryWrapper<ThMission>() | |||||
.eq(ThMission::getId, warningRecord.getMissionId()) | |||||
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode())); | |||||
if (ObjectUtil.isNull(oldMission)) { | |||||
throw new ServiceException("该应急任务没有对应的巡检任务记录"); | |||||
} | |||||
if (mission.getAirportId().equals(oldMission.getAirportId())) { | |||||
// 原机场执行的应急任务,在查看应急任务轨迹时,查询的是原巡检任务的轨迹 | |||||
id = oldMission.getId(); | |||||
log.info("该任务是应急任务,执行的是原机场,id={}", id); | |||||
} else { | |||||
log.info("该任务是应急任务,执行的是新机场,id={}", id); | |||||
} | |||||
if (ObjectUtil.isNotNull(mission.getAccidentTask()) | |||||
&& AccidentTaskEnum.ACCIDENT_TASK.getCode() == mission.getAccidentTask() | |||||
&& mission.getEmergencyDataMissionId() != 0) { | |||||
id = mission.getEmergencyDataMissionId(); | |||||
} | } | ||||
LambdaQueryWrapper<ThInspection> lambdaQueryWrapper = new LambdaQueryWrapper<>(); | LambdaQueryWrapper<ThInspection> lambdaQueryWrapper = new LambdaQueryWrapper<>(); | ||||
lambdaQueryWrapper.eq(ThInspection::getMissionId, id) | lambdaQueryWrapper.eq(ThInspection::getMissionId, id) |
import com.tuoheng.admin.entity.domain.ThMission; | import com.tuoheng.admin.entity.domain.ThMission; | ||||
import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest; | import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest; | ||||
import com.tuoheng.admin.entity.request.emergency.QueryEmergencyListRequest; | import com.tuoheng.admin.entity.request.emergency.QueryEmergencyListRequest; | ||||
import com.tuoheng.admin.enums.AccidentTaskEnum; | |||||
import com.tuoheng.admin.enums.MarkEnum; | import com.tuoheng.admin.enums.MarkEnum; | ||||
import com.tuoheng.admin.enums.MissionEnum; | import com.tuoheng.admin.enums.MissionEnum; | ||||
import com.tuoheng.admin.enums.TaskStatusEnum; | import com.tuoheng.admin.enums.TaskStatusEnum; | ||||
List<ThMission> missionList = thMissionMapper.selectList(new LambdaQueryWrapper<ThMission>() | List<ThMission> missionList = thMissionMapper.selectList(new LambdaQueryWrapper<ThMission>() | ||||
.eq(ThMission::getMark, MarkEnum.VALID.getCode()) | .eq(ThMission::getMark, MarkEnum.VALID.getCode()) | ||||
.eq(ThMission::getTenantId, tenantId) | .eq(ThMission::getTenantId, tenantId) | ||||
.eq(ObjectUtil.isNotEmpty(request.getAirportFlyType()), ThMission::getAirportFlyType, request.getAirportFlyType()) | |||||
.eq(ThMission::getAccidentTask, AccidentTaskEnum.ACCIDENT_TASK.getCode()) | |||||
.in(CollectionUtil.isNotEmpty(request.getStatusList()), ThMission::getStatus, request.getStatusList())); | .in(CollectionUtil.isNotEmpty(request.getStatusList()), ThMission::getStatus, request.getStatusList())); | ||||
if (CollectionUtil.isEmpty(missionList)) { | if (CollectionUtil.isEmpty(missionList)) { |
ThMission mission = this.createMission(user, request); | ThMission mission = this.createMission(user, request); | ||||
// 调用机场平台 | // 调用机场平台 | ||||
if (oldMission.getAirportId().equals(request.getAirportId())) { | |||||
log.info("原机场执行定点飞行"); | |||||
this.callOldAirpor(request); | |||||
} else { | |||||
log.info("新机场执行定点飞行"); | |||||
// 修改原巡检任务状态为已完成 | |||||
if (TaskStatusEnum.COMPLETE.getCode() == mission.getStatus()) { | |||||
log.info("执行定点飞行, 原巡检任务已完成"); | |||||
// 巡检任务已经结束 | |||||
// 再次选择原来机场进行定点飞行, | |||||
if (mission.getAirportId() == request.getAirportId()) { | |||||
log.info("新机场执行定点飞行"); | |||||
} else { | |||||
log.info("新机场执行定点飞行"); | |||||
} | |||||
this.callNewAirpor(tenant, request, mission.getId()); | this.callNewAirpor(tenant, request, mission.getId()); | ||||
} else { | |||||
log.info("执行定点飞行, 原巡检任务在执行"); | |||||
if (oldMission.getAirportId().equals(request.getAirportId())) { | |||||
log.info("原机场执行定点飞行"); | |||||
oldMission.setEmergencyDataMissionId(mission.getId()); | |||||
this.callOldAirpor(request); | |||||
} else { | |||||
log.info("新机场执行定点飞行"); | |||||
this.callNewAirpor(tenant, request, mission.getId()); | |||||
} | |||||
} | } | ||||
// 修改原巡检任务状态为已完成 | |||||
oldMission.setStatus(TaskStatusEnum.COMPLETE.getCode()); | oldMission.setStatus(TaskStatusEnum.COMPLETE.getCode()); | ||||
missionMapper.updateById(oldMission); | missionMapper.updateById(oldMission); | ||||
if (ObjectUtil.isNotNull(warningRecord)) { | if (ObjectUtil.isNotNull(warningRecord)) { | ||||
ThMission missionTmp = missionMapper.selectOne(new LambdaQueryWrapper<ThMission>() | ThMission missionTmp = missionMapper.selectOne(new LambdaQueryWrapper<ThMission>() | ||||
.eq(ThMission::getId, warningRecord.getEmergencyMissionId()) | .eq(ThMission::getId, warningRecord.getEmergencyMissionId()) | ||||
.eq(ThMission::getStatus, TaskStatusEnum.FLIGHT.getCode()) | |||||
.eq(ThMission::getMark, MarkEnum.VALID.getCode())); | .eq(ThMission::getMark, MarkEnum.VALID.getCode())); | ||||
if (ObjectUtil.isNotNull(missionTmp)) { | |||||
if (TaskStatusEnum.FLIGHT.getCode() == missionTmp.getStatus()) { | |||||
log.info("原机场正在执行任务"); | |||||
throw new ServiceException("原机场正在执行任务"); | |||||
} | |||||
if (TaskStatusEnum.COMPLETE.getCode() == missionTmp.getStatus()) { | |||||
log.info("原机场正在执行任务"); | log.info("原机场正在执行任务"); | ||||
throw new ServiceException("原机场正在执行任务"); | throw new ServiceException("原机场正在执行任务"); | ||||
} | } | ||||
mission.setInspectionLineName(""); | mission.setInspectionLineName(""); | ||||
mission.setExecutionStartTime(DateUtils.now()); | mission.setExecutionStartTime(DateUtils.now()); | ||||
mission.setStatus(TaskStatusEnum.FLIGHT.getCode()); // 设置应急任务状态为飞行中 | mission.setStatus(TaskStatusEnum.FLIGHT.getCode()); // 设置应急任务状态为飞行中 | ||||
mission.setAirportFlyType(AirportFlyTypeEnum.POINTING_FLIGHT.getCode()); | |||||
mission.setAccidentTask(AccidentTaskEnum.ACCIDENT_TASK.getCode()); | |||||
mission.setCreateUser(user.getId()); | mission.setCreateUser(user.getId()); | ||||
mission.setCreateTime(DateUtils.now()); | mission.setCreateTime(DateUtils.now()); | ||||
Integer count = missionMapper.insert(mission); | Integer count = missionMapper.insert(mission); |