|
|
@@ -196,7 +196,7 @@ public class FlightTaskServiceImpl extends AbstractWaylineService implements IFl
|
|
|
}
|
|
|
long now = System.currentTimeMillis() / 1000;
|
|
|
param.setTaskDays(List.of(now));
|
|
|
- param.setTaskPeriods(List.of(List.of(now)));
|
|
|
+ param.setTaskPeriods(List.of(now));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -227,18 +227,39 @@ public class FlightTaskServiceImpl extends AbstractWaylineService implements IFl
|
|
|
public HttpResultResponse publishFlightTask(CreateJobParam param, CustomClaim customClaim) throws SQLException {
|
|
|
fillImmediateTime(param);
|
|
|
|
|
|
- for (Long taskDay : param.getTaskDays()) {
|
|
|
- LocalDate date = LocalDate.ofInstant(Instant.ofEpochSecond(taskDay), ZoneId.systemDefault());
|
|
|
- for (List<Long> taskPeriod : param.getTaskPeriods()) {
|
|
|
+ if (TaskTypeEnum.TIMED == param.getTaskType() && null != param.getTaskTime()) {
|
|
|
+ boolean flg = waylineJobService.checkWaylineJobTime(param, customClaim.getWorkspaceId(), param.getTaskTime(),param.getTaskTime());
|
|
|
+ if(flg) {
|
|
|
+ throw new RuntimeException("该时间段不可用");
|
|
|
+ }
|
|
|
+ Optional<WaylineJobDTO> waylineJobOpt = waylineJobService.createWaylineJob(param, customClaim.getWorkspaceId(), customClaim.getUsername(), param.getTaskTime(), param.getTaskTime());
|
|
|
+ if (waylineJobOpt.isEmpty()) {
|
|
|
+ throw new SQLException("Failed to create wayline job.");
|
|
|
+ }
|
|
|
+ WaylineJobDTO waylineJob = waylineJobOpt.get();
|
|
|
+ // If it is a conditional task type, add conditions to the job parameters.
|
|
|
+ addConditions(waylineJob, param, param.getTaskTime(), param.getTaskTime());
|
|
|
+
|
|
|
+ HttpResultResponse response = this.publishOneFlightTask(waylineJob);
|
|
|
+ if (HttpResultResponse.CODE_SUCCESS != response.getCode()) {
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (Long taskDay : param.getTaskDays()) {
|
|
|
+ LocalDate date = LocalDate.ofInstant(Instant.ofEpochSecond(taskDay), ZoneId.systemDefault());
|
|
|
+ List<Long> taskPeriod = param.getTaskPeriods();
|
|
|
long beginTime = LocalDateTime.of(date, LocalTime.ofInstant(Instant.ofEpochSecond(taskPeriod.get(0)), ZoneId.systemDefault()))
|
|
|
- .atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
|
+ .atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
|
long endTime = taskPeriod.size() > 1 ?
|
|
|
- LocalDateTime.of(date, LocalTime.ofInstant(Instant.ofEpochSecond(taskPeriod.get(1)), ZoneId.systemDefault()))
|
|
|
- .atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() : beginTime;
|
|
|
+ LocalDateTime.of(date, LocalTime.ofInstant(Instant.ofEpochSecond(taskPeriod.get(1)), ZoneId.systemDefault()))
|
|
|
+ .atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() : beginTime;
|
|
|
if (TaskTypeEnum.IMMEDIATE != param.getTaskType() && endTime < System.currentTimeMillis()) {
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
+ boolean flg = waylineJobService.checkWaylineJobTime(param, customClaim.getWorkspaceId(), beginTime,endTime);
|
|
|
+ if(flg) {
|
|
|
+ throw new RuntimeException("该时间段不可用");
|
|
|
+ }
|
|
|
Optional<WaylineJobDTO> waylineJobOpt = waylineJobService.createWaylineJob(param, customClaim.getWorkspaceId(), customClaim.getUsername(), beginTime, endTime);
|
|
|
if (waylineJobOpt.isEmpty()) {
|
|
|
throw new SQLException("Failed to create wayline job.");
|
|
|
@@ -251,8 +272,10 @@ public class FlightTaskServiceImpl extends AbstractWaylineService implements IFl
|
|
|
if (HttpResultResponse.CODE_SUCCESS != response.getCode()) {
|
|
|
return response;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return HttpResultResponse.success();
|
|
|
}
|
|
|
|
|
|
@@ -513,6 +536,11 @@ public class FlightTaskServiceImpl extends AbstractWaylineService implements IFl
|
|
|
waylineRedisService.setConditionalWaylineJob(waylineJob);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void reStart(String workspaceId, String jobId) {
|
|
|
+ //to do
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public TopicEventsResponse<MqttReply> flighttaskReady(TopicEventsRequest<FlighttaskReady> response, MessageHeaders headers) {
|