| | |
| | | // .fingerprint(waylineFile.get().getSign()) |
| | | .fingerprint(md5) |
| | | .build()) |
| | | .simulateMission(WaylineSimulateMissionDTO.builder() |
| | | .isEnable(1) |
| | | .latitude(46.558831038) |
| | | .longitude(125.148072319) |
| | | .build()) |
| | | // .simulateMission(WaylineSimulateMissionDTO.builder() |
| | | // .isEnable(1) |
| | | // .latitude(46.558831038) |
| | | // .longitude(125.148072319) |
| | | // .build()) |
| | | .build(); |
| | | |
| | | String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + |
| | |
| | | |
| | | // 飞行命令先注释掉 |
| | | // Issue an immediate task execution command. |
| | | // if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) { |
| | | // if (!executeFlightTask(waylineJob.getJobId())) { |
| | | // return ResponseResult.error("Failed to execute job."); |
| | | // } |
| | | // } |
| | | // |
| | | // if (WaylineTaskTypeEnum.TIMED.getVal() == waylineJob.getTaskType()) { |
| | | // boolean isAdd = RedisOpsUtils.zAdd(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, |
| | | // waylineJob.getDockSn() + RedisConst.DELIMITER + waylineJob.getJobId(), |
| | | // waylineJob.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | // if (!isAdd) { |
| | | // return ResponseResult.error("Failed to create scheduled job."); |
| | | // } |
| | | // } |
| | | if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) { |
| | | if (!executeFlightTask(waylineJob.getJobId())) { |
| | | return ResponseResult.error("Failed to execute job."); |
| | | } |
| | | } |
| | | |
| | | if (WaylineTaskTypeEnum.TIMED.getVal() == waylineJob.getTaskType()) { |
| | | boolean isAdd = RedisOpsUtils.zAdd(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, |
| | | waylineJob.getDockSn() + RedisConst.DELIMITER + waylineJob.getJobId(), |
| | | waylineJob.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | if (!isAdd) { |
| | | return ResponseResult.error("Failed to create scheduled job."); |
| | | } |
| | | } |
| | | |
| | | return ResponseResult.success(); |
| | | } |
| | |
| | | try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) { |
| | | md5 = DigestUtils.md5Hex(inputStream); |
| | | url = new URL(ardRouteOpt.getPath()); |
| | | log.info("机场任务航线文件url地址:{}", url); |
| | | log.info("机场任务航线文件md5值:{}", md5); |
| | | } catch (Exception e) { |
| | | log.error("机场任务航线文件地址错误!{}", e.getMessage()); |
| | | return ResponseResult.error("机场任务航线文件地址错误!" + e.getMessage()); |
| | | } |
| | | |
| | |
| | | // .fingerprint(waylineFile.get().getSign()) |
| | | .fingerprint(md5) |
| | | .build()) |
| | | .simulateMission(WaylineSimulateMissionDTO.builder() |
| | | .isEnable(1) |
| | | .latitude(46.558831038) |
| | | .longitude(125.148072319) |
| | | .build()) |
| | | // .simulateMission(WaylineSimulateMissionDTO.builder() |
| | | // .isEnable(1) |
| | | // .latitude(46.558831038) |
| | | // .longitude(125.148072319) |
| | | // .build()) |
| | | .build(); |
| | | |
| | | String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + |
| | |
| | | |
| | | ServiceReply serviceReply = messageSender.publishWithReply(topic, response); |
| | | log.info("下发任务结果: {}", serviceReply.getResult()); |
| | | log.info("机场任务航线文件url地址:{}", url); |
| | | log.info("机场任务航线文件md5值:{}", md5); |
| | | if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) { |
| | | log.info("Prepare task ====> Error code: {}", serviceReply.getResult()); |
| | | this.updateJob(WaylineJobDTO.builder() |
| | |
| | | |
| | | // 飞行命令先注释掉 |
| | | // Issue an immediate task execution command. |
| | | // if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) { |
| | | // if (!executeFlightTask(waylineJob.getJobId())) { |
| | | // return ResponseResult.error("Failed to execute job."); |
| | | // } |
| | | // } |
| | | // |
| | | // if (WaylineTaskTypeEnum.TIMED.getVal() == waylineJob.getTaskType()) { |
| | | // boolean isAdd = RedisOpsUtils.zAdd(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, |
| | | // waylineJob.getDockSn() + RedisConst.DELIMITER + waylineJob.getJobId(), |
| | | // waylineJob.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | // if (!isAdd) { |
| | | // return ResponseResult.error("Failed to create scheduled job."); |
| | | // } |
| | | // } |
| | | if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) { |
| | | if (!executeFlightTask(waylineJob.getJobId())) { |
| | | return ResponseResult.error("Failed to execute job."); |
| | | } |
| | | } |
| | | |
| | | if (WaylineTaskTypeEnum.TIMED.getVal() == waylineJob.getTaskType()) { |
| | | boolean isAdd = RedisOpsUtils.zAdd(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, |
| | | waylineJob.getDockSn() + RedisConst.DELIMITER + waylineJob.getJobId(), |
| | | waylineJob.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | if (!isAdd) { |
| | | return ResponseResult.error("Failed to create scheduled job."); |
| | | } |
| | | } |
| | | |
| | | return ResponseResult.success(); |
| | | } |
| | |
| | | public void cancelFlightTask(Collection<String> jobIds) { |
| | | List<WaylineJobDTO> waylineJobs = getJobsByConditions(jobIds, WaylineJobStatusEnum.PENDING); |
| | | |
| | | Set<String> waylineJobIds = waylineJobs.stream().map(WaylineJobDTO::getJobId).collect(Collectors.toSet()); |
| | | // Check if the task status is correct. |
| | | boolean isErr = !jobIds.removeAll(waylineJobIds) || !jobIds.isEmpty(); |
| | | if (isErr) { |
| | | throw new IllegalArgumentException("任务开始后,无法取消。" + Arrays.toString(jobIds.toArray())); |
| | | // throw new IllegalArgumentException("These tasks have an incorrect status and cannot be canceled. " |
| | | // + Arrays.toString(jobIds.toArray())); |
| | | } |
| | | // Set<String> waylineJobIds = waylineJobs.stream().map(WaylineJobDTO::getJobId).collect(Collectors.toSet()); |
| | | // // Check if the task status is correct. |
| | | // boolean isErr = !jobIds.removeAll(waylineJobIds) || !jobIds.isEmpty(); |
| | | // if (isErr) { |
| | | // throw new IllegalArgumentException("任务开始后,无法取消。" + Arrays.toString(jobIds.toArray())); |
| | | //// throw new IllegalArgumentException("These tasks have an incorrect status and cannot be canceled. " |
| | | //// + Arrays.toString(jobIds.toArray())); |
| | | // } |
| | | |
| | | // Group job id by dock sn. |
| | | Map<String, List<String>> dockJobs = waylineJobs.stream() |
| | |
| | | }); |
| | | String jobId = jobIdMap.get(MapKeyConst.FLIGHT_ID); |
| | | |
| | | log.info("机场通过flightTaskResourceGet获取航线文件地址,jobId: " + jobId); |
| | | |
| | | CommonTopicResponse.CommonTopicResponseBuilder<RequestsReply> builder = CommonTopicResponse.<RequestsReply>builder() |
| | | .tid(receiver.getTid()) |
| | | .bid(receiver.getBid()) |
| | |
| | | try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) { |
| | | md5 = DigestUtils.md5Hex(inputStream); |
| | | url = new URL(ardRouteOpt.getPath()); |
| | | log.info("机场通过flightTaskResourceGet获取航线文件地址,jobId: " + jobId + " 返回信息为url:" + url.toString() + " md5:" + md5); |
| | | // } |
| | | // try { |
| | | // url = waylineFileService.getObjectUrl(waylineFile.get().getWaylineId()); |
| | |
| | | messageSender.publish(topic, builder.build()); |
| | | return; |
| | | } |
| | | |
| | | messageSender.publish(topic, builder.build()); |
| | | |
| | | } |