Ver código fonte

重构定点飞行代码

tags/v1.2.0^2
wanjing 1 ano atrás
pai
commit
1d6b05726a
1 arquivos alterados com 25 adições e 11 exclusões
  1. +25
    -11
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java

+ 25
- 11
tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java Ver arquivo

@@ -60,32 +60,46 @@ public class PointFlightService {
// 获取租户信息
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()) {
log.info("执行定点飞行, 原巡检任务已完成");
// 巡检任务已经结束
// 再次选择原来机场进行定点飞行,
if (emergencyMission.getAirportId() == request.getAirportId()) {
if (oldMission.getAirportId() == request.getAirportId()) {
log.info("原机场,重新执行定点飞行");
} else {
log.info("新机场执行定点飞行");
}
this.callNewAirpor(tenant, request, emergencyMission.getId());
callNewAirpor = true;
} else {
log.info("执行定点飞行, 原巡检任务在执行");
if (oldMission.getAirportId().equals(request.getAirportId())) {
log.info("原机场,直接执行定点飞行");
this.callOldAirpor(request);
callOldAirpor = true;
emergencyDataMissionId = oldMission.getId();
} else {
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());
missionMapper.updateById(oldMission);

@@ -254,7 +268,7 @@ public class PointFlightService {
* @param request
* @return
*/
private ThMission createMission(User user, PointFlightRequest request) {
private ThMission createMission(User user, PointFlightRequest request, Integer emergencyDataMissionId) {
ThMission mission = new ThMission(UpdateOrCreateEnum.CREATE.getCode());
String code = "XJRW" + CodeUtil.createCodeNo();
mission.setCode(code);
@@ -270,7 +284,7 @@ public class PointFlightService {
mission.setExecutionStartTime(DateUtils.now());
mission.setCreateUser(user.getId());
mission.setCreateTime(DateUtils.now());
mission.setEmergencyDataMissionId(request.getMissionId());
mission.setEmergencyDataMissionId(emergencyDataMissionId);
Integer count = missionMapper.insert(mission);
if (count <= 0) {
log.info("创建应急任务失败");

Carregando…
Cancelar
Salvar