|
|
|
|
|
|
|
|
// 获取租户信息 |
|
|
// 获取租户信息 |
|
|
Tenant tenant = this.getTenant(tenantId); |
|
|
Tenant tenant = this.getTenant(tenantId); |
|
|
|
|
|
|
|
|
// 创建应急任务 |
|
|
|
|
|
ThMission emergencyMission = this.createMission(user, request); |
|
|
|
|
|
|
|
|
|
|
|
// 调用机场平台 |
|
|
|
|
|
// 修改原巡检任务状态为已完成 |
|
|
|
|
|
|
|
|
Integer emergencyDataMissionId = 0; |
|
|
|
|
|
boolean callOldAirpor = false; |
|
|
|
|
|
boolean callNewAirpor = false; |
|
|
if (TaskStatusEnum.COMPLETE.getCode() == oldMission.getStatus()) { |
|
|
if (TaskStatusEnum.COMPLETE.getCode() == oldMission.getStatus()) { |
|
|
log.info("执行定点飞行, 原巡检任务已完成"); |
|
|
log.info("执行定点飞行, 原巡检任务已完成"); |
|
|
// 巡检任务已经结束 |
|
|
// 巡检任务已经结束 |
|
|
// 再次选择原来机场进行定点飞行, |
|
|
// 再次选择原来机场进行定点飞行, |
|
|
if (emergencyMission.getAirportId() == request.getAirportId()) { |
|
|
|
|
|
|
|
|
if (oldMission.getAirportId() == request.getAirportId()) { |
|
|
log.info("原机场,重新执行定点飞行"); |
|
|
log.info("原机场,重新执行定点飞行"); |
|
|
} else { |
|
|
} else { |
|
|
log.info("新机场执行定点飞行"); |
|
|
log.info("新机场执行定点飞行"); |
|
|
} |
|
|
} |
|
|
this.callNewAirpor(tenant, request, emergencyMission.getId()); |
|
|
|
|
|
|
|
|
callNewAirpor = true; |
|
|
} else { |
|
|
} else { |
|
|
log.info("执行定点飞行, 原巡检任务在执行"); |
|
|
log.info("执行定点飞行, 原巡检任务在执行"); |
|
|
if (oldMission.getAirportId().equals(request.getAirportId())) { |
|
|
if (oldMission.getAirportId().equals(request.getAirportId())) { |
|
|
log.info("原机场,直接执行定点飞行"); |
|
|
log.info("原机场,直接执行定点飞行"); |
|
|
this.callOldAirpor(request); |
|
|
|
|
|
|
|
|
callOldAirpor = true; |
|
|
|
|
|
emergencyDataMissionId = oldMission.getId(); |
|
|
} else { |
|
|
} else { |
|
|
log.info("新机场执行定点飞行"); |
|
|
log.info("新机场执行定点飞行"); |
|
|
this.callNewAirpor(tenant, request, emergencyMission.getId()); |
|
|
|
|
|
|
|
|
callNewAirpor = true; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 创建应急任务 |
|
|
|
|
|
ThMission emergencyMission = this.createMission(user, request, emergencyDataMissionId); |
|
|
|
|
|
|
|
|
|
|
|
// 调用机场平台 |
|
|
|
|
|
log.info("调用机场平台, callOldAirpor={}, callNewAirpor={}", callOldAirpor, callNewAirpor); |
|
|
|
|
|
if (callOldAirpor) { |
|
|
|
|
|
this.callOldAirpor(request); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (callNewAirpor) { |
|
|
|
|
|
this.callNewAirpor(tenant, request, emergencyMission.getId()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 修改原巡检任务状态为已完成 |
|
|
oldMission.setStatus(TaskStatusEnum.COMPLETE.getCode()); |
|
|
oldMission.setStatus(TaskStatusEnum.COMPLETE.getCode()); |
|
|
missionMapper.updateById(oldMission); |
|
|
missionMapper.updateById(oldMission); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* @param request |
|
|
* @param request |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
private ThMission createMission(User user, PointFlightRequest request) { |
|
|
|
|
|
|
|
|
private ThMission createMission(User user, PointFlightRequest request, Integer emergencyDataMissionId) { |
|
|
ThMission mission = new ThMission(UpdateOrCreateEnum.CREATE.getCode()); |
|
|
ThMission mission = new ThMission(UpdateOrCreateEnum.CREATE.getCode()); |
|
|
String code = "XJRW" + CodeUtil.createCodeNo(); |
|
|
String code = "XJRW" + CodeUtil.createCodeNo(); |
|
|
mission.setCode(code); |
|
|
mission.setCode(code); |
|
|
|
|
|
|
|
|
mission.setExecutionStartTime(DateUtils.now()); |
|
|
mission.setExecutionStartTime(DateUtils.now()); |
|
|
mission.setCreateUser(user.getId()); |
|
|
mission.setCreateUser(user.getId()); |
|
|
mission.setCreateTime(DateUtils.now()); |
|
|
mission.setCreateTime(DateUtils.now()); |
|
|
mission.setEmergencyDataMissionId(request.getMissionId()); |
|
|
|
|
|
|
|
|
mission.setEmergencyDataMissionId(emergencyDataMissionId); |
|
|
Integer count = missionMapper.insert(mission); |
|
|
Integer count = missionMapper.insert(mission); |
|
|
if (count <= 0) { |
|
|
if (count <= 0) { |
|
|
log.info("创建应急任务失败"); |
|
|
log.info("创建应急任务失败"); |