From 3ba2ea4de914835bc316826f2c7f93a648760e9c Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 26 Sep 2023 16:24:56 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/main'
---
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java b/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
index 1ee81ad..796a705 100644
--- a/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
+++ b/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -142,24 +142,26 @@
}
/**
- * For immediate tasks, the server time shall prevail.
+ * 对于即时任务,以服务器时间为准。
* @param param
*/
private void fillImmediateTime(CreateJobParam param) {
if (WaylineTaskTypeEnum.IMMEDIATE != param.getTaskType()) {
return;
}
- long now = System.currentTimeMillis() / 1000;
- param.setTaskDays(Collections.singletonList(now));
- param.setTaskPeriods(Collections.singletonList(Collections.singletonList(now)));
+ long now = System.currentTimeMillis() / 1000 - 10;
+// 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
--
Gitblit v1.9.3