提交 8e6d5436 authored 作者: junjie's avatar junjie

feat(cron):cron time fix

上级 83a243e1
...@@ -2,7 +2,6 @@ package io.dataease.controller.dataset; ...@@ -2,7 +2,6 @@ package io.dataease.controller.dataset;
import io.dataease.base.domain.DatasetTableTask; import io.dataease.base.domain.DatasetTableTask;
import io.dataease.controller.request.dataset.DataSetTaskRequest; import io.dataease.controller.request.dataset.DataSetTaskRequest;
import io.dataease.service.dataset.DataSetTableService;
import io.dataease.service.dataset.DataSetTableTaskService; import io.dataease.service.dataset.DataSetTableTaskService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -18,13 +17,10 @@ import java.util.List; ...@@ -18,13 +17,10 @@ import java.util.List;
public class DataSetTableTaskController { public class DataSetTableTaskController {
@Resource @Resource
private DataSetTableTaskService dataSetTableTaskService; private DataSetTableTaskService dataSetTableTaskService;
@Resource
private DataSetTableService dataSetTableService;
@PostMapping("save") @PostMapping("save")
public DatasetTableTask save(@RequestBody DataSetTaskRequest dataSetTaskRequest) throws Exception { public DatasetTableTask save(@RequestBody DataSetTaskRequest dataSetTaskRequest) throws Exception {
dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig()); return dataSetTableTaskService.save(dataSetTaskRequest);
return dataSetTableTaskService.save(dataSetTaskRequest.getDatasetTableTask());
} }
@PostMapping("delete/{id}") @PostMapping("delete/{id}")
......
...@@ -3,10 +3,13 @@ package io.dataease.service.dataset; ...@@ -3,10 +3,13 @@ package io.dataease.service.dataset;
import io.dataease.base.domain.DatasetTableTask; import io.dataease.base.domain.DatasetTableTask;
import io.dataease.base.domain.DatasetTableTaskExample; import io.dataease.base.domain.DatasetTableTaskExample;
import io.dataease.base.mapper.DatasetTableTaskMapper; import io.dataease.base.mapper.DatasetTableTaskMapper;
import io.dataease.controller.request.dataset.DataSetTaskRequest;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import io.dataease.service.ScheduleService; import io.dataease.service.ScheduleService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.quartz.CronExpression; import org.quartz.CronExpression;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -27,14 +30,25 @@ public class DataSetTableTaskService { ...@@ -27,14 +30,25 @@ public class DataSetTableTaskService {
private DataSetTableTaskLogService dataSetTableTaskLogService; private DataSetTableTaskLogService dataSetTableTaskLogService;
@Resource @Resource
private ScheduleService scheduleService; private ScheduleService scheduleService;
@Resource
@Lazy
private DataSetTableService dataSetTableService;
public DatasetTableTask save(DatasetTableTask datasetTableTask) throws Exception { public DatasetTableTask save(DataSetTaskRequest dataSetTaskRequest) throws Exception {
dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig());
DatasetTableTask datasetTableTask = dataSetTaskRequest.getDatasetTableTask();
// check // check
if (StringUtils.isNotEmpty(datasetTableTask.getCron())) { if (StringUtils.isNotEmpty(datasetTableTask.getCron())) {
if (!CronExpression.isValidExpression(datasetTableTask.getCron())) { if (!CronExpression.isValidExpression(datasetTableTask.getCron())) {
throw new RuntimeException(Translator.get("i18n_cron_expression_error")); throw new RuntimeException(Translator.get("i18n_cron_expression_error"));
} }
} }
// check start time and end time
if (ObjectUtils.isNotEmpty(datasetTableTask.getStartTime())
&& ObjectUtils.isNotEmpty(datasetTableTask.getEndTime())
&& datasetTableTask.getStartTime() > datasetTableTask.getEndTime()) {
throw new RuntimeException(Translator.get("i18n_cron_time_error"));
}
if (StringUtils.isEmpty(datasetTableTask.getId())) { if (StringUtils.isEmpty(datasetTableTask.getId())) {
datasetTableTask.setId(UUID.randomUUID().toString()); datasetTableTask.setId(UUID.randomUUID().toString());
datasetTableTask.setCreateTime(System.currentTimeMillis()); datasetTableTask.setCreateTime(System.currentTimeMillis());
......
...@@ -184,7 +184,6 @@ automation_exec_info=There are no test steps to execute ...@@ -184,7 +184,6 @@ automation_exec_info=There are no test steps to execute
authsource_name_already_exists=Authentication source name already exists authsource_name_already_exists=Authentication source name already exists
authsource_name_is_null=Authentication source name cannot be empty authsource_name_is_null=Authentication source name cannot be empty
authsource_configuration_is_null=Authentication source configuration cannot be empty authsource_configuration_is_null=Authentication source configuration cannot be empty
个人信息=Personal Information 个人信息=Personal Information
仪表盘=Panel 仪表盘=Panel
修改密码=Change Password 修改密码=Change Password
...@@ -238,3 +237,4 @@ i18n_panel_list=Panel ...@@ -238,3 +237,4 @@ i18n_panel_list=Panel
i18n_processing_data=Processing data now, Refresh later i18n_processing_data=Processing data now, Refresh later
i18n_union_already_exists=Union relation already exists i18n_union_already_exists=Union relation already exists
i18n_union_field_exists=The same field can't in two dataset i18n_union_field_exists=The same field can't in two dataset
i18n_cron_time_error=Start time can't greater then end time
...@@ -239,3 +239,4 @@ i18n_panel_list=仪表盘 ...@@ -239,3 +239,4 @@ i18n_panel_list=仪表盘
i18n_processing_data=正在处理数据,稍后刷新 i18n_processing_data=正在处理数据,稍后刷新
i18n_union_already_exists=关联关系已存在 i18n_union_already_exists=关联关系已存在
i18n_union_field_exists=两个数据集之间关联不能出现多次相同字段 i18n_union_field_exists=两个数据集之间关联不能出现多次相同字段
i18n_cron_time_error=开始时间不能大于结束时间
...@@ -239,3 +239,4 @@ i18n_panel_list=仪表盘 ...@@ -239,3 +239,4 @@ i18n_panel_list=仪表盘
i18n_processing_data=正在處理數據,稍後刷新 i18n_processing_data=正在處理數據,稍後刷新
i18n_union_already_exists=關聯關系已存在 i18n_union_already_exists=關聯關系已存在
i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字段 i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字段
i18n_cron_time_error=開始時間不能大於結束時間
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论