xieb
2023-09-26 6ec922e73cc857085e2a5313983c936514d389fa
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -142,7 +142,7 @@
    }
    /**
     * For immediate tasks, the server time shall prevail.
     * 对于即时任务,以服务器时间为准。
     * @param param
     */
    private void fillImmediateTime(CreateJobParam param) {
@@ -150,16 +150,18 @@
            return;
        }
        long now = System.currentTimeMillis() / 1000;
        param.setTaskDays(Collections.singletonList(now));
        param.setTaskPeriods(Collections.singletonList(Collections.singletonList(now)));
//        param.setTaskDays(Collections.singletonList(now));
//        param.setTaskPeriods(Collections.singletonList(Collections.singletonList(now)));
        param.setTaskDays(List.of(now));
        param.setTaskPeriods(List.of(List.of(now)));
    }
    @Override
    public ResponseResult publishFlightTask(CreateJobParam param, CustomClaim customClaim) throws SQLException {
        fillImmediateTime(param);
        param.getTaskDays().sort((a, b) -> (int) (a - b));
        param.getTaskPeriods().sort((a, b) -> (int) (a.get(0) - b.get(0)));
//        param.getTaskDays().sort((a, b) -> (int) (a - b));
//        param.getTaskPeriods().sort((a, b) -> (int) (a.get(0) - b.get(0)));
        for (Long taskDay : param.getTaskDays()) {
            LocalDate date = LocalDate.ofInstant(Instant.ofEpochSecond(taskDay), ZoneId.systemDefault());
            for (List<Long> taskPeriod : param.getTaskPeriods()) {
@@ -173,16 +175,16 @@
                }
                Optional<WaylineJobDTO> waylineJobOpt = this.createWaylineJob(param, customClaim.getWorkspaceId(), customClaim.getUsername(), beginTime, endTime);
                if (waylineJobOpt.isEmpty()) {
                    return ResponseResult.error("Failed to create wayline job.");
                    throw new SQLException("Failed to create wayline job.");
                }
                WaylineJobDTO waylineJob = waylineJobOpt.get();
                if (WaylineTaskTypeEnum.IMMEDIATE == param.getTaskType()) {
                    return this.publishOneFlightTask(waylineJob);
                }
                // If it is a conditional task type, add conditions to the job parameters.
                addPreparedJob(waylineJob, param, beginTime, endTime);
                ResponseResult response = this.publishOneFlightTask(waylineJob);
                if (ResponseResult.CODE_SUCCESS != response.getCode()) {
                    return response;
                }
            }
        }
        return ResponseResult.success();
@@ -232,13 +234,13 @@
        boolean isOnline = deviceRedisService.checkDeviceOnline(waylineJob.getDockSn());
        if (!isOnline) {
            throw new RuntimeException("Dock is offline.");
            throw new RuntimeException("设备离线。");
        }
        // get wayline file
        Optional<WaylineFileDTO> waylineFile = waylineFileService.getWaylineByWaylineId(waylineJob.getWorkspaceId(), waylineJob.getFileId());
        if (waylineFile.isEmpty()) {
            throw new SQLException("Wayline file doesn't exist.");
            throw new SQLException("航线文件不存在。");
        }
        // get file url