ard-sample/src/main/java/com/ard/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -179,13 +179,14 @@
        }
        Optional<WaylineJobDTO> waylineJobOpt = this.createWaylineJob(param, loginUser.getUsername(),
                param.getExecuteTime(), param.getExecuteTime());
        if (waylineJobOpt.isEmpty()) {
            return ResponseResult.error("创建机场任务失败!");
        }
        // 循环任务
        if (param.getTaskType() == WaylineTaskTypeEnum.LOOP.getVal()) {
            // 循环任务,不立即执行,由定时任务发布
            return ResponseResult.success();
        }
        if (waylineJobOpt.isEmpty()) {
            return ResponseResult.error("创建机场任务失败!");
        }
        WaylineJobDTO waylineJob = waylineJobOpt.get();
@@ -230,11 +231,11 @@
//                        .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 +
@@ -248,6 +249,7 @@
                .build();
        ServiceReply serviceReply = messageSender.publishWithReply(topic, response);
        log.info("下发任务结果: {}", serviceReply.getResult());
        if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) {
            log.info("Prepare task ====> Error code: {}", serviceReply.getResult());
            this.updateJob(WaylineJobDTO.builder()
@@ -261,20 +263,20 @@
        // 飞行命令先注释掉
        // 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();
    }
@@ -301,7 +303,10 @@
        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());
        }
@@ -317,11 +322,11 @@
//                        .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 +
@@ -335,6 +340,9 @@
                .build();
        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()
@@ -348,20 +356,20 @@
        // 飞行命令先注释掉
        // 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();
    }
@@ -433,13 +441,14 @@
    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("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()
@@ -578,8 +587,8 @@
                new Page<WaylineJobEntity>(page, pageSize),
                new LambdaQueryWrapper<WaylineJobEntity>()
                        // 实际开始时间筛选,允许为空,为空则不进行筛选
                        .ge(startTime != null, WaylineJobEntity::getExecuteTime, startTime)
                        .le(endTime != null, WaylineJobEntity::getExecuteTime, endTime)
                        .ge(startTime != null, WaylineJobEntity::getBeginTime, startTime)
                        .le(endTime != null, WaylineJobEntity::getBeginTime, endTime)
                        // 任务类型筛选,允许为空,为空则不进行筛选
                        .eq(taskType != null, WaylineJobEntity::getTaskType, taskType)
                        // 任务名称筛选,允许为空,为空则不进行筛选;....模糊查询
@@ -628,6 +637,8 @@
        });
        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())
@@ -669,6 +680,7 @@
        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());
@@ -687,7 +699,6 @@
            messageSender.publish(topic, builder.build());
            return;
        }
        messageSender.publish(topic, builder.build());
    }
@@ -776,14 +787,27 @@
            return null;
        }
        // 修改航线文件名称,从ard_route_info航线表中取;
        String fileId = entity.getFileId();
        String fileName = "";
        try {
            if (fileId != null) {
                ArdRouteInfo ardRouteInfo = _ardRouteInfoService.selectArdRouteInfoById(fileId);
                if (ardRouteInfo != null) {
                    fileName = Optional.ofNullable(ardRouteInfo.getName()).orElse("");
                }
            }
        }
        catch (Exception e) {
            log.info("获取航线名称失败,fileId:{},异常原因:{}", fileId,e.getMessage());
            fileName = "";
        }
        WaylineJobDTO.WaylineJobDTOBuilder builder = WaylineJobDTO.builder()
                .jobId(entity.getJobId())
                .jobName(entity.getName())
                .fileId(entity.getFileId())
//                .fileName(waylineFileService.getWaylineByWaylineId(entity.getFileId())
//                        .orElse(WaylineFileDTO.builder().build()).getName())
                .fileName(_ardRouteInfoService.selectArdRouteInfoById(entity.getFileId())
                        .getName())
                .fileName(fileName)
                .dockSn(entity.getDockSn())
                .dockName(deviceService.getDeviceBySn(entity.getDockSn())
                        .orElse(DeviceDTO.builder().build()).getNickname())