| | |
| | | |
| | | boolean isOnline = deviceService.checkDeviceOnline(waylineJob.getDockSn()); |
| | | if (!isOnline) { |
| | | return ResponseResult.error("机场不在线!"); |
| | | return ResponseResult.error(CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg()); |
| | | } |
| | | |
| | | // get wayline file |
| | |
| | | log.info("下发任务结果: {}", serviceReply.getResult()); |
| | | |
| | | if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) { |
| | | log.info("Prepare task ====> Error code: {}", serviceReply.getResult()); |
| | | String errorMsg = CommonErrorEnum.getMsgByCode(serviceReply.getResult()); |
| | | log.info("Prepare task ====> Error code: {},Error Msg:{}", serviceReply.getResult(), errorMsg); |
| | | this.updateJob(WaylineJobDTO.builder() |
| | | .jobId(waylineJob.getJobId()) |
| | | .executeTime(LocalDateTime.now()) |
| | | .status(WaylineJobStatusEnum.FAILED.getVal()) |
| | | .completedTime(LocalDateTime.now()) |
| | | .code(serviceReply.getResult()).build()); |
| | | return ResponseResult.error("Prepare task ====> Error code: " + serviceReply.getResult()); |
| | | //return ResponseResult.error("Prepare task ====> Error code: " + serviceReply.getResult()); |
| | | return ResponseResult.error(serviceReply.getResult(), errorMsg); |
| | | } |
| | | |
| | | // 飞行命令先注释掉 |
| | |
| | | log.info("机场任务航线文件md5值:{}", md5); |
| | | |
| | | if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) { |
| | | log.info("Prepare task ====> Error code: {}", serviceReply.getResult()); |
| | | String errorMsg = CommonErrorEnum.getMsgByCode(serviceReply.getResult()); |
| | | log.info("Prepare task ====> Error code: {},Error Msg: {}", serviceReply.getResult(), errorMsg); |
| | | this.updateJob(WaylineJobDTO.builder() |
| | | .jobId(waylineJob.getJobId()) |
| | | .executeTime(LocalDateTime.now()) |
| | | .status(WaylineJobStatusEnum.FAILED.getVal()) |
| | | .completedTime(LocalDateTime.now()) |
| | | .code(serviceReply.getResult()).build()); |
| | | return ResponseResult.error("Prepare task ====> Error code: " + serviceReply.getResult()); |
| | | // return ResponseResult.error("Prepare task ====> Error code: " + serviceReply.getResult()); |
| | | return ResponseResult.error(serviceReply.getResult(), errorMsg); |
| | | } |
| | | |
| | | // 飞行命令先注释掉 |
| | |
| | | // get job |
| | | Optional<WaylineJobDTO> waylineJob = this.getJobByJobId(jobId); |
| | | if (waylineJob.isEmpty()) { |
| | | throw new IllegalArgumentException("Job doesn't exist."); |
| | | throw new IllegalArgumentException("计划任务不存在。"); |
| | | } |
| | | |
| | | boolean isOnline = deviceService.checkDeviceOnline(waylineJob.get().getDockSn()); |
| | | if (!isOnline) { |
| | | throw new RuntimeException("Dock is offline."); |
| | | // throw new RuntimeException("Dock is offline."); |
| | | throw new RuntimeException(CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg()); |
| | | } |
| | | |
| | | WaylineJobDTO job = waylineJob.get(); |
| | |
| | | log.info("下发-执行飞行任务-结果: {}", serviceReply.getResult()); |
| | | |
| | | if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) { |
| | | log.info("Execute job ====> Error code: {}", serviceReply.getResult()); |
| | | String errorMsg = CommonErrorEnum.getMsgByCode(serviceReply.getResult()); |
| | | log.info("Execute job ====> Error code: {},Error Msg:{}", serviceReply.getResult(), errorMsg); |
| | | this.updateJob(WaylineJobDTO.builder() |
| | | .jobId(jobId) |
| | | .executeTime(LocalDateTime.now()) |
| | |
| | | public void publishCancelTask(String dockSn, List<String> jobIds) { |
| | | boolean isOnline = deviceService.checkDeviceOnline(dockSn); |
| | | if (!isOnline) { |
| | | throw new RuntimeException("Dock is offline."); |
| | | throw new RuntimeException(CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg()); |
| | | } |
| | | String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + dockSn + TopicConst.SERVICES_SUF; |
| | | |
| | |
| | | |
| | | ServiceReply serviceReply = messageSender.publishWithReply(topic, response); |
| | | if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) { |
| | | log.info("Cancel job ====> Error code: {}", serviceReply.getResult()); |
| | | throw new RuntimeException("Failed to cancel the wayline job of " + dockSn); |
| | | String errorMsg = CommonErrorEnum.getMsgByCode(serviceReply.getResult()); |
| | | log.info("取消飞行任务失败 ====> 设备sn: {}, 错误码: {}, {}", dockSn, serviceReply.getResult(), errorMsg); |
| | | //throw new RuntimeException("Failed to cancel the wayline job of " + dockSn); |
| | | throw new RuntimeException("设备:" + dockSn + "取消飞行任务失败,错误码:" + serviceReply.getResult() + "," + errorMsg); |
| | | } |
| | | |
| | | for (String jobId : jobIds) { |
| | |
| | | .stream() |
| | | .map(this::entity2Dto) |
| | | .peek(job -> { |
| | | List<WaylineJobDTO> parentOpt = this.getJobByJobParentId(job.getJobId()); |
| | | job.setParentJobs(parentOpt); |
| | | List<WaylineJobDTO> childOpt = this.getJobByJobParentId(job.getJobId()); |
| | | job.setChildren(childOpt); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | |
| | | .data(Map.of(MapKeyConst.FLIGHT_ID, jobId)) |
| | | .build()); |
| | | if (ResponseResult.CODE_SUCCESS != reply.getResult()) { |
| | | throw new RuntimeException("Failed to set media job upload priority. Error Code: " + reply.getResult()); |
| | | String errorMsg = CommonErrorEnum.getMsgByCode(reply.getResult()); |
| | | throw new RuntimeException("未能设置媒体作业上传优先级. Error Code: " + reply.getResult() +", Error Msg: " + errorMsg); |
| | | } |
| | | } |
| | | |