提交 d1174fed authored 作者: taojinlong's avatar taojinlong

feat(數據集): 数据集任务,增加简单重复执行的功能

上级 38487c5b
...@@ -31,5 +31,7 @@ public class DatasetTableTask implements Serializable { ...@@ -31,5 +31,7 @@ public class DatasetTableTask implements Serializable {
private String lastExecStatus; private String lastExecStatus;
private String extraData;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -973,6 +973,76 @@ public class DatasetTableTaskExample { ...@@ -973,6 +973,76 @@ public class DatasetTableTaskExample {
addCriterion("last_exec_status not between", value1, value2, "lastExecStatus"); addCriterion("last_exec_status not between", value1, value2, "lastExecStatus");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andExtraDataIsNull() {
addCriterion("extra_data is null");
return (Criteria) this;
}
public Criteria andExtraDataIsNotNull() {
addCriterion("extra_data is not null");
return (Criteria) this;
}
public Criteria andExtraDataEqualTo(String value) {
addCriterion("extra_data =", value, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataNotEqualTo(String value) {
addCriterion("extra_data <>", value, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataGreaterThan(String value) {
addCriterion("extra_data >", value, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataGreaterThanOrEqualTo(String value) {
addCriterion("extra_data >=", value, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataLessThan(String value) {
addCriterion("extra_data <", value, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataLessThanOrEqualTo(String value) {
addCriterion("extra_data <=", value, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataLike(String value) {
addCriterion("extra_data like", value, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataNotLike(String value) {
addCriterion("extra_data not like", value, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataIn(List<String> values) {
addCriterion("extra_data in", values, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataNotIn(List<String> values) {
addCriterion("extra_data not in", values, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataBetween(String value1, String value2) {
addCriterion("extra_data between", value1, value2, "extraData");
return (Criteria) this;
}
public Criteria andExtraDataNotBetween(String value1, String value2) {
addCriterion("extra_data not between", value1, value2, "extraData");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<result column="last_exec_time" jdbcType="BIGINT" property="lastExecTime" /> <result column="last_exec_time" jdbcType="BIGINT" property="lastExecTime" />
<result column="status" jdbcType="VARCHAR" property="status" /> <result column="status" jdbcType="VARCHAR" property="status" />
<result column="last_exec_status" jdbcType="VARCHAR" property="lastExecStatus" /> <result column="last_exec_status" jdbcType="VARCHAR" property="lastExecStatus" />
<result column="extra_data" jdbcType="VARCHAR" property="extraData" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
...@@ -76,7 +77,7 @@ ...@@ -76,7 +77,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, table_id, `name`, `type`, start_time, rate, cron, `end`, end_time, create_time, id, table_id, `name`, `type`, start_time, rate, cron, `end`, end_time, create_time,
last_exec_time, `status`, last_exec_status last_exec_time, `status`, last_exec_status, extra_data
</sql> </sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.DatasetTableTaskExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.dataease.base.domain.DatasetTableTaskExample" resultMap="BaseResultMap">
select select
...@@ -113,12 +114,12 @@ ...@@ -113,12 +114,12 @@
`type`, start_time, rate, `type`, start_time, rate,
cron, `end`, end_time, cron, `end`, end_time,
create_time, last_exec_time, `status`, create_time, last_exec_time, `status`,
last_exec_status) last_exec_status, extra_data)
values (#{id,jdbcType=VARCHAR}, #{tableId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{tableId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{rate,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{rate,jdbcType=VARCHAR},
#{cron,jdbcType=VARCHAR}, #{end,jdbcType=VARCHAR}, #{endTime,jdbcType=BIGINT}, #{cron,jdbcType=VARCHAR}, #{end,jdbcType=VARCHAR}, #{endTime,jdbcType=BIGINT},
#{createTime,jdbcType=BIGINT}, #{lastExecTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{lastExecTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
#{lastExecStatus,jdbcType=VARCHAR}) #{lastExecStatus,jdbcType=VARCHAR}, #{extraData,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTableTask"> <insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTableTask">
insert into dataset_table_task insert into dataset_table_task
...@@ -162,6 +163,9 @@ ...@@ -162,6 +163,9 @@
<if test="lastExecStatus != null"> <if test="lastExecStatus != null">
last_exec_status, last_exec_status,
</if> </if>
<if test="extraData != null">
extra_data,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
...@@ -203,6 +207,9 @@ ...@@ -203,6 +207,9 @@
<if test="lastExecStatus != null"> <if test="lastExecStatus != null">
#{lastExecStatus,jdbcType=VARCHAR}, #{lastExecStatus,jdbcType=VARCHAR},
</if> </if>
<if test="extraData != null">
#{extraData,jdbcType=VARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.dataease.base.domain.DatasetTableTaskExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.dataease.base.domain.DatasetTableTaskExample" resultType="java.lang.Long">
...@@ -253,6 +260,9 @@ ...@@ -253,6 +260,9 @@
<if test="record.lastExecStatus != null"> <if test="record.lastExecStatus != null">
last_exec_status = #{record.lastExecStatus,jdbcType=VARCHAR}, last_exec_status = #{record.lastExecStatus,jdbcType=VARCHAR},
</if> </if>
<if test="record.extraData != null">
extra_data = #{record.extraData,jdbcType=VARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
...@@ -272,7 +282,8 @@ ...@@ -272,7 +282,8 @@
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
last_exec_time = #{record.lastExecTime,jdbcType=BIGINT}, last_exec_time = #{record.lastExecTime,jdbcType=BIGINT},
`status` = #{record.status,jdbcType=VARCHAR}, `status` = #{record.status,jdbcType=VARCHAR},
last_exec_status = #{record.lastExecStatus,jdbcType=VARCHAR} last_exec_status = #{record.lastExecStatus,jdbcType=VARCHAR},
extra_data = #{record.extraData,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
...@@ -316,6 +327,9 @@ ...@@ -316,6 +327,9 @@
<if test="lastExecStatus != null"> <if test="lastExecStatus != null">
last_exec_status = #{lastExecStatus,jdbcType=VARCHAR}, last_exec_status = #{lastExecStatus,jdbcType=VARCHAR},
</if> </if>
<if test="extraData != null">
extra_data = #{extraData,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
...@@ -332,7 +346,8 @@ ...@@ -332,7 +346,8 @@
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
last_exec_time = #{lastExecTime,jdbcType=BIGINT}, last_exec_time = #{lastExecTime,jdbcType=BIGINT},
`status` = #{status,jdbcType=VARCHAR}, `status` = #{status,jdbcType=VARCHAR},
last_exec_status = #{lastExecStatus,jdbcType=VARCHAR} last_exec_status = #{lastExecStatus,jdbcType=VARCHAR},
extra_data = #{extraData,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>
\ No newline at end of file
package io.dataease.commons.constants; package io.dataease.commons.constants;
public enum ScheduleType { public enum ScheduleType {
CRON, SIMPLE CRON, SIMPLE, SIMPLE_CRON
} }
...@@ -30,7 +30,7 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve ...@@ -30,7 +30,7 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
List<DatasetTableTask> list = dataSetTableTaskService.list(new DatasetTableTask()); List<DatasetTableTask> list = dataSetTableTaskService.list(new DatasetTableTask());
for (DatasetTableTask task : list) { for (DatasetTableTask task : list) {
try { try {
if (StringUtils.equalsIgnoreCase(task.getRate(), ScheduleType.CRON.toString())) { if (!StringUtils.equalsIgnoreCase(task.getRate(), ScheduleType.SIMPLE.toString())) {
if (StringUtils.equalsIgnoreCase(task.getEnd(), "1")) { if (StringUtils.equalsIgnoreCase(task.getEnd(), "1")) {
if (task.getEndTime() != null && task.getEndTime() > 0) { if (task.getEndTime() != null && task.getEndTime() > 0) {
if (task.getEndTime() > System.currentTimeMillis()) { if (task.getEndTime() > System.currentTimeMillis()) {
......
...@@ -28,7 +28,7 @@ public class ScheduleService { ...@@ -28,7 +28,7 @@ public class ScheduleService {
ExtractDataJob.class, ExtractDataJob.class,
new Date(datasetTableTask.getStartTime()), new Date(datasetTableTask.getStartTime()),
scheduleManager.getDefaultJobDataMap(datasetTableTask.getTableId(), datasetTableTask.getCron(), datasetTableTask.getId(), datasetTableTask.getType())); scheduleManager.getDefaultJobDataMap(datasetTableTask.getTableId(), datasetTableTask.getCron(), datasetTableTask.getId(), datasetTableTask.getType()));
} else if (StringUtils.equalsIgnoreCase(datasetTableTask.getRate(), ScheduleType.CRON.toString())) { } else {
Date endTime; Date endTime;
if (StringUtils.equalsIgnoreCase(datasetTableTask.getEnd(), "1")) { if (StringUtils.equalsIgnoreCase(datasetTableTask.getEnd(), "1")) {
if (datasetTableTask.getEndTime() == null || datasetTableTask.getEndTime() == 0) { if (datasetTableTask.getEndTime() == null || datasetTableTask.getEndTime() == 0) {
......
...@@ -10,6 +10,7 @@ import io.dataease.base.mapper.ext.ExtDataSetTableMapper; ...@@ -10,6 +10,7 @@ import io.dataease.base.mapper.ext.ExtDataSetTableMapper;
import io.dataease.base.mapper.ext.UtilMapper; import io.dataease.base.mapper.ext.UtilMapper;
import io.dataease.commons.constants.JobStatus; import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.constants.ScheduleType; import io.dataease.commons.constants.ScheduleType;
import io.dataease.commons.constants.TaskStatus;
import io.dataease.commons.utils.*; import io.dataease.commons.utils.*;
import io.dataease.controller.request.dataset.DataSetGroupRequest; import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.controller.request.dataset.DataSetTableRequest; import io.dataease.controller.request.dataset.DataSetTableRequest;
...@@ -110,6 +111,7 @@ public class DataSetTableService { ...@@ -110,6 +111,7 @@ public class DataSetTableService {
datasetTableTask.setType("all_scope"); datasetTableTask.setType("all_scope");
datasetTableTask.setName(datasetTable.getName() + " 更新设置"); datasetTableTask.setName(datasetTable.getName() + " 更新设置");
datasetTableTask.setEnd("0"); datasetTableTask.setEnd("0");
datasetTableTask.setStatus(TaskStatus.Underway.name());
datasetTableTask.setStartTime(System.currentTimeMillis()); datasetTableTask.setStartTime(System.currentTimeMillis());
dataSetTaskRequest.setDatasetTableTask(datasetTableTask); dataSetTaskRequest.setDatasetTableTask(datasetTableTask);
dataSetTableTaskService.save(dataSetTaskRequest); dataSetTableTaskService.save(dataSetTaskRequest);
......
...@@ -61,7 +61,7 @@ public class DataSetTableTaskService { ...@@ -61,7 +61,7 @@ public class DataSetTableTaskService {
dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig()); dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig());
} }
// check // check
if (StringUtils.equalsIgnoreCase(datasetTableTask.getRate(),"CRON")){ if (!StringUtils.equalsIgnoreCase(datasetTableTask.getRate(), ScheduleType.SIMPLE.toString())){
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"));
...@@ -96,6 +96,7 @@ public class DataSetTableTaskService { ...@@ -96,6 +96,7 @@ public class DataSetTableTaskService {
scheduleService.addSchedule(datasetTableTask); scheduleService.addSchedule(datasetTableTask);
}else { }else {
if(datasetTableTask.getStatus().equalsIgnoreCase(JobStatus.Underway.name())){ if(datasetTableTask.getStatus().equalsIgnoreCase(JobStatus.Underway.name())){
System.out.println(new Gson().toJson(datasetTableTask));
scheduleService.addSchedule(datasetTableTask); scheduleService.addSchedule(datasetTableTask);
} }
} }
......
...@@ -12,3 +12,4 @@ update dataset_table_task set rate='SIMPLE' where rate='SIMPLE_COMPLETE'; ...@@ -12,3 +12,4 @@ update dataset_table_task set rate='SIMPLE' where rate='SIMPLE_COMPLETE';
ALTER TABLE `dataset_table_task_log` ADD COLUMN `trigger_type` VARCHAR(45) NULL AFTER `create_time`; ALTER TABLE `dataset_table_task_log` ADD COLUMN `trigger_type` VARCHAR(45) NULL AFTER `create_time`;
update dataset_table_task_log set trigger_type='Cron'; update dataset_table_task_log set trigger_type='Cron';
ALTER TABLE `dataset_table_task` ADD COLUMN `extra_data` LONGTEXT NULL AFTER `last_exec_status`;
...@@ -74,7 +74,9 @@ ...@@ -74,7 +74,9 @@
<!-- </table>--> <!-- </table>-->
<!-- <table tableName="v_dataset"/>--> <!-- <table tableName="v_dataset"/>-->
<!-- <table tableName="sys_auth_detail"/>--> <!-- <table tableName="sys_auth_detail"/>-->
<table tableName="dataset_table_field"/> <table tableName="dataset_table_task">
<columnOverride column="extra_data" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>
</context> </context>
......
...@@ -857,6 +857,7 @@ export default { ...@@ -857,6 +857,7 @@ export default {
select_data_time: 'Select date time', select_data_time: 'Select date time',
execute_rate: 'Execution frequency', execute_rate: 'Execution frequency',
execute_once: 'Execution Now', execute_once: 'Execution Now',
simple_cron: 'Simple repeat',
cron_config: 'Expression setting', cron_config: 'Expression setting',
no_limit: 'No limit', no_limit: 'No limit',
set_end_time: 'Set the end time', set_end_time: 'Set the end time',
...@@ -1213,7 +1214,10 @@ export default { ...@@ -1213,7 +1214,10 @@ export default {
week_start: 'From week', week_start: 'From week',
week_end: 'to week', week_end: 'to week',
every_year: 'Every year', every_year: 'Every year',
week_tips: 'Tips:1-7 mapping SUN-SAT' week_tips: 'Tips:1-7 mapping SUN-SAT',
minute_limit: 'Minutes cannot be less than 1 and greater than 59',
hour_limit: 'Hours cannot be less than 1 and greater than 23',
day_limit: 'Days cannot be less than 1 and greater than 31'
}, },
dept: { dept: {
can_not_move_change_sort: 'Cannot move to change sort', can_not_move_change_sort: 'Cannot move to change sort',
......
...@@ -856,6 +856,7 @@ export default { ...@@ -856,6 +856,7 @@ export default {
add_scope: '增量更新', add_scope: '增量更新',
select_data_time: '選擇日期時間', select_data_time: '選擇日期時間',
execute_rate: '執行頻率', execute_rate: '執行頻率',
simple_cron: '簡單重複',
execute_once: '立即執行', execute_once: '立即執行',
cron_config: '表達時設定', cron_config: '表達時設定',
no_limit: '無限製', no_limit: '無限製',
...@@ -1213,7 +1214,10 @@ export default { ...@@ -1213,7 +1214,10 @@ export default {
week_start: '從星期', week_start: '從星期',
week_end: '至星期', week_end: '至星期',
every_year: '每年', every_year: '每年',
week_tips: '說明:1-7 分別對應 周日-周六' week_tips: '说明:1-7 分别对应 周日-周六',
minute_limit: '分鐘不能小於1,大於59',
hour_limit: '小時不能小於1,大於523',
day_limit: '天不能小於1,大於531'
}, },
dept: { dept: {
can_not_move_change_sort: '不能移動以改變排序', can_not_move_change_sort: '不能移動以改變排序',
......
...@@ -857,6 +857,7 @@ export default { ...@@ -857,6 +857,7 @@ export default {
select_data_time: '选择日期时间', select_data_time: '选择日期时间',
execute_rate: '执行频率', execute_rate: '执行频率',
execute_once: '立即执行', execute_once: '立即执行',
simple_cron: '简单重复',
cron_config: '表达式设定', cron_config: '表达式设定',
no_limit: '无限制', no_limit: '无限制',
set_end_time: '设定结束时间', set_end_time: '设定结束时间',
...@@ -1215,7 +1216,10 @@ export default { ...@@ -1215,7 +1216,10 @@ export default {
week_start: '从星期', week_start: '从星期',
week_end: '至星期', week_end: '至星期',
every_year: '每年', every_year: '每年',
week_tips: '说明:1-7 分别对应 周日-周六' week_tips: '说明:1-7 分别对应 周日-周六',
minute_limit: '分钟不能小于1,大于59',
hour_limit: '小时不能小于1,大于23',
day_limit: '天不能小于1,大于31'
}, },
dept: { dept: {
can_not_move_change_sort: '不能移动以改变排序', can_not_move_change_sort: '不能移动以改变排序',
......
...@@ -122,6 +122,10 @@ ...@@ -122,6 +122,10 @@
:label="$t('dataset.execute_once')" :label="$t('dataset.execute_once')"
value="SIMPLE" value="SIMPLE"
/> />
<el-option
:label="$t('dataset.simple_cron')"
value="SIMPLE_CRON"
/>
<el-option <el-option
:label="$t('dataset.cron_config')" :label="$t('dataset.cron_config')"
value="CRON" value="CRON"
...@@ -135,7 +139,26 @@ ...@@ -135,7 +139,26 @@
<el-input slot="reference" v-model="taskForm.cron" size="mini" style="width: 50%" @click="cronEdit = true" /> <el-input slot="reference" v-model="taskForm.cron" size="mini" style="width: 50%" @click="cronEdit = true" />
</el-popover> </el-popover>
</el-form-item> </el-form-item>
<el-form-item v-if="taskForm.rate === 'CRON'" :label="$t('dataset.start_time')" prop="startTime">
<el-form-item v-if="taskForm.rate === 'SIMPLE_CRON'" label="">
<el-form :inline="true">
<el-form-item :label="$t('cron.every')" >
<el-input v-model="taskForm.extraData.simple_cron_value" size="mini" type="number" min="1" @change="onSimpleCronChange()" />
</el-form-item>
<el-form-item class="form-item">
<el-select v-model="taskForm.extraData.simple_cron_type" filterable size="mini" @change="onSimpleCronChange()" >
<el-option :label="$t('cron.minute')" value="minute" />
<el-option :label="$t('cron.hour')" value="hour" />
<el-option :label="$t('cron.day')" value="day" />
</el-select>
</el-form-item>
<el-form-item class="form-item" :label="$t('cron.every_exec')">
</el-form-item>
</el-form>
</el-form-item>
<el-form-item v-if="taskForm.rate !== 'SIMPLE'" :label="$t('dataset.start_time')" prop="startTime">
<el-date-picker <el-date-picker
v-model="taskForm.startTime" v-model="taskForm.startTime"
type="datetime" type="datetime"
...@@ -143,7 +166,7 @@ ...@@ -143,7 +166,7 @@
size="mini" size="mini"
/> />
</el-form-item> </el-form-item>
<el-form-item v-if="taskForm.rate === 'CRON'" :label="$t('dataset.end_time')" prop="end"> <el-form-item v-if="taskForm.rate !== 'SIMPLE'" :label="$t('dataset.end_time')" prop="end">
<el-select v-model="taskForm.end" size="mini"> <el-select v-model="taskForm.end" size="mini">
<el-option <el-option
:label="$t('dataset.no_limit')" :label="$t('dataset.no_limit')"
...@@ -193,7 +216,7 @@ ...@@ -193,7 +216,7 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.rate === 'SIMPLE'">{{ $t('dataset.execute_once') }}</span> <span v-if="scope.row.rate === 'SIMPLE'">{{ $t('dataset.execute_once') }}</span>
<span v-if="scope.row.rate === 'SIMPLE_COMPLETE'">{{ $t('dataset.execute_once') }}</span> <span v-if="scope.row.rate === 'SIMPLE_CRON'">{{ $t('dataset.simple_cron') }}</span>
<span v-if="scope.row.rate === 'CRON'">{{ $t('dataset.cron_config') }}</span> <span v-if="scope.row.rate === 'CRON'">{{ $t('dataset.cron_config') }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -206,7 +229,7 @@ ...@@ -206,7 +229,7 @@
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-edit"
circle circle
:disabled="scope.row.rate === 'SIMPLE_COMPLETE'" :disabled="scope.row.rate === 'SIMPLE'"
@click="addTask(scope.row)" @click="addTask(scope.row)"
/> />
<el-button <el-button
...@@ -323,7 +346,11 @@ export default { ...@@ -323,7 +346,11 @@ export default {
rate: 'SIMPLE', rate: 'SIMPLE',
cron: '', cron: '',
endTime: '', endTime: '',
end: '0' end: '0',
extraData: {
simple_cron_type: 'hour',
simple_cron_value: 1
}
}, },
page: { page: {
currentPage: 1, currentPage: 1,
...@@ -459,6 +486,7 @@ export default { ...@@ -459,6 +486,7 @@ export default {
} else { } else {
// update // update
this.taskForm = JSON.parse(JSON.stringify(task)) this.taskForm = JSON.parse(JSON.stringify(task))
this.taskForm.extraData = JSON.parse(this.taskForm.extraData)
this.update_task_dialog_title = this.$t('dataset.task_edit_title') this.update_task_dialog_title = this.$t('dataset.task_edit_title')
} }
this.update_task = true this.update_task = true
...@@ -505,8 +533,10 @@ export default { ...@@ -505,8 +533,10 @@ export default {
task.startTime = new Date(task.startTime).getTime() task.startTime = new Date(task.startTime).getTime()
task.endTime = new Date(task.endTime).getTime() task.endTime = new Date(task.endTime).getTime()
task.tableId = this.table.id task.tableId = this.table.id
const form = JSON.parse(JSON.stringify(task))
form.extraData = JSON.stringify(form.extraData)
const dataSetTaskRequest = { const dataSetTaskRequest = {
datasetTableTask: task, datasetTableTask: form,
datasetTableIncrementalConfig: this.incrementalConfig datasetTableIncrementalConfig: this.incrementalConfig
} }
post('/dataset/task/save', dataSetTaskRequest).then(response => { post('/dataset/task/save', dataSetTaskRequest).then(response => {
...@@ -544,12 +574,42 @@ export default { ...@@ -544,12 +574,42 @@ export default {
this.update_task = false this.update_task = false
this.resetTaskForm() this.resetTaskForm()
}, },
onSimpleCronChange() {
if (this.taskForm.extraData.simple_cron_type === 'minute') {
if(this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value > 59){
this.$message({message: this.$t('cron.minute_limit'), type: 'warning', showClose: true})
this.taskForm.extraData.simple_cron_value = 59
}
this.taskForm.cron = '0 0/'+ this.taskForm.extraData.simple_cron_value + ' * * * ? *'
return
}
if (this.taskForm.extraData.simple_cron_type === 'hour') {
if(this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value > 23){
this.$message({message: this.$t('cron.hour_limit'), type: 'warning', showClose: true})
this.taskForm.extraData.simple_cron_value = 23
}
this.taskForm.cron = '0 0 0/'+ this.taskForm.extraData.simple_cron_value + ' * * ? *'
return
}
if (this.taskForm.extraData.simple_cron_type === 'day') {
if(this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value > 31){
this.$message({message: this.$t('cron.day_limit'), type: 'warning', showClose: true})
this.taskForm.extraData.simple_cron_value = 31
}
this.taskForm.cron = '0 0 0 1/'+ this.taskForm.extraData.simple_cron_value + ' * ? *'
return
}
},
onRateChange() { onRateChange() {
if (this.taskForm.rate === 'SIMPLE') { if (this.taskForm.rate === 'SIMPLE') {
this.taskForm.end = '0' this.taskForm.end = '0'
this.taskForm.endTime = '' this.taskForm.endTime = ''
this.taskForm.cron = '' this.taskForm.cron = ''
} else { }
if (this.taskForm.rate === 'SIMPLE_CRON'){
this.taskForm.cron = '0 0 0/1 * * ? *'
}
if (this.taskForm.rate === 'CRON'){
this.taskForm.cron = '00 00 * ? * * *' this.taskForm.cron = '00 00 * ? * * *'
} }
}, },
...@@ -575,7 +635,11 @@ export default { ...@@ -575,7 +635,11 @@ export default {
startTime: '', startTime: '',
rate: 'SIMPLE', rate: 'SIMPLE',
endTime: '', endTime: '',
end: '0' end: '0',
extraData: {
simple_cron_type: 'hour',
simple_cron_value: 1
}
} }
}, },
showSQL(val) { showSQL(val) {
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
<el-table-column prop="rate" :label="$t('dataset.execute_rate')"> <el-table-column prop="rate" :label="$t('dataset.execute_rate')">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.rate === 'SIMPLE'">{{ $t('dataset.execute_once') }}</span> <span v-if="scope.row.rate === 'SIMPLE'">{{ $t('dataset.execute_once') }}</span>
<span v-if="scope.row.rate === 'SIMPLE_COMPLETE'">{{ $t('dataset.execute_once') }}</span>
<span v-if="scope.row.rate === 'CRON'">{{ $t('dataset.cron_config') }}</span> <span v-if="scope.row.rate === 'CRON'">{{ $t('dataset.cron_config') }}</span>
<span v-if="scope.row.rate === 'SIMPLE_CRON'">{{ $t('dataset.simple_cron') }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
<el-select v-model="taskForm.rate" size="mini" @change="onRateChange"> <el-select v-model="taskForm.rate" size="mini" @change="onRateChange">
<el-option :label="$t('dataset.execute_once')" value="SIMPLE"/> <el-option :label="$t('dataset.execute_once')" value="SIMPLE"/>
<el-option :label="$t('dataset.cron_config')" value="CRON"/> <el-option :label="$t('dataset.cron_config')" value="CRON"/>
<el-option :label="$t('dataset.simple_cron')" value="SIMPLE_CRON"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -89,6 +90,25 @@ ...@@ -89,6 +90,25 @@
<el-input slot="reference" v-model="taskForm.cron" size="mini" style="width: 50%" @click="cronEdit = true" /> <el-input slot="reference" v-model="taskForm.cron" size="mini" style="width: 50%" @click="cronEdit = true" />
</el-popover> </el-popover>
</el-form-item> </el-form-item>
<el-form-item v-if="taskForm.rate === 'SIMPLE_CRON'" label="">
<el-form :inline="true">
<el-form-item :label="$t('cron.every')" >
<el-input v-model="taskForm.extraData.simple_cron_value" size="mini" type="number" min="1" @change="onSimpleCronChange()" />
</el-form-item>
<el-form-item class="form-item">
<el-select v-model="taskForm.extraData.simple_cron_type" filterable size="mini" @change="onSimpleCronChange()" >
<el-option :label="$t('cron.minute')" value="minute" />
<el-option :label="$t('cron.hour')" value="hour" />
<el-option :label="$t('cron.day')" value="day" />
</el-select>
</el-form-item>
<el-form-item class="form-item" :label="$t('cron.every_exec')">
</el-form-item>
</el-form>
</el-form-item>
<el-form-item v-if="taskForm.rate === 'CRON'" :label="$t('dataset.start_time')" prop="startTime"> <el-form-item v-if="taskForm.rate === 'CRON'" :label="$t('dataset.start_time')" prop="startTime">
<el-date-picker v-model="taskForm.startTime" type="datetime" :placeholder="$t('dataset.select_data_time')" size="mini"/> <el-date-picker v-model="taskForm.startTime" type="datetime" :placeholder="$t('dataset.select_data_time')" size="mini"/>
</el-form-item> </el-form-item>
...@@ -182,7 +202,11 @@ export default { ...@@ -182,7 +202,11 @@ export default {
rate: 'SIMPLE', rate: 'SIMPLE',
cron: '', cron: '',
endTime: '', endTime: '',
end: '0' end: '0',
extraData: {
simple_cron_type: 'hour',
simple_cron_value: 1
}
}, },
update_task: false, update_task: false,
header: '', header: '',
...@@ -254,7 +278,7 @@ export default { ...@@ -254,7 +278,7 @@ export default {
cronEdit: false, cronEdit: false,
lang: this.$store.getters.language === 'en_US' ? 'en' : 'cn', lang: this.$store.getters.language === 'en_US' ? 'en' : 'cn',
selectDatasetFlag: false, selectDatasetFlag: false,
table: {}, table: {}
} }
}, },
computed: { computed: {
...@@ -370,7 +394,50 @@ export default { ...@@ -370,7 +394,50 @@ export default {
startTime: '', startTime: '',
rate: 'SIMPLE', rate: 'SIMPLE',
endTime: '', endTime: '',
end: '0' end: '0',
extraData: {
simple_cron_type: 'hour',
simple_cron_value: 1
}
}
},
onSimpleCronChange() {
if (this.taskForm.extraData.simple_cron_type === 'minute') {
if(this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value > 59){
this.$message({message: this.$t('cron.minute_limit'), type: 'warning', showClose: true})
this.taskForm.extraData.simple_cron_value = 59
}
this.taskForm.cron = '0 0/'+ this.taskForm.extraData.simple_cron_value + ' * * * ? *'
return
}
if (this.taskForm.extraData.simple_cron_type === 'hour') {
if(this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value > 23){
this.$message({message: this.$t('cron.hour_limit'), type: 'warning', showClose: true})
this.taskForm.extraData.simple_cron_value = 23
}
this.taskForm.cron = '0 0 0/'+ this.taskForm.extraData.simple_cron_value + ' * * ? *'
return
}
if (this.taskForm.extraData.simple_cron_type === 'day') {
if(this.taskForm.extraData.simple_cron_value < 1 || this.taskForm.extraData.simple_cron_value > 31){
this.$message({message: this.$t('cron.day_limit'), type: 'warning', showClose: true})
this.taskForm.extraData.simple_cron_value = 31
}
this.taskForm.cron = '0 0 0 1/'+ this.taskForm.extraData.simple_cron_value + ' * ? *'
return
}
},
onRateChange() {
if (this.taskForm.rate === 'SIMPLE') {
this.taskForm.end = '0'
this.taskForm.endTime = ''
this.taskForm.cron = ''
}
if (this.taskForm.rate === 'SIMPLE_CRON'){
this.taskForm.cron = '0 0 0/1 * * ? *'
}
if (this.taskForm.rate === 'CRON'){
this.taskForm.cron = '00 00 * ? * * *'
} }
}, },
incrementalUpdateTypeChange: function() { incrementalUpdateTypeChange: function() {
...@@ -454,6 +521,7 @@ export default { ...@@ -454,6 +521,7 @@ export default {
} else { // update } else { // update
this.getIncrementalConfig(task.tableId) this.getIncrementalConfig(task.tableId)
this.taskForm = JSON.parse(JSON.stringify(task)) this.taskForm = JSON.parse(JSON.stringify(task))
this.taskForm.extraData = JSON.parse(this.taskForm.extraData)
this.update_task_dialog_title = this.$t('dataset.task_edit_title') this.update_task_dialog_title = this.$t('dataset.task_edit_title')
} }
this.update_task = true this.update_task = true
...@@ -484,8 +552,10 @@ export default { ...@@ -484,8 +552,10 @@ export default {
} }
task.startTime = new Date(task.startTime).getTime() task.startTime = new Date(task.startTime).getTime()
task.endTime = new Date(task.endTime).getTime() task.endTime = new Date(task.endTime).getTime()
const form = JSON.parse(JSON.stringify(task))
form.extraData = JSON.stringify(form.extraData)
const dataSetTaskRequest = { const dataSetTaskRequest = {
datasetTableTask: task, datasetTableTask: form,
datasetTableIncrementalConfig: task.type === 'add_scope' ? this.incrementalConfig : undefined datasetTableIncrementalConfig: task.type === 'add_scope' ? this.incrementalConfig : undefined
} }
post('/dataset/task/save', dataSetTaskRequest).then(response => { post('/dataset/task/save', dataSetTaskRequest).then(response => {
...@@ -499,15 +569,6 @@ export default { ...@@ -499,15 +569,6 @@ export default {
this.search() this.search()
}) })
}, },
onRateChange() {
if (this.taskForm.rate === 'SIMPLE') {
this.taskForm.end = '0'
this.taskForm.endTime = ''
this.taskForm.cron = ''
} else {
this.taskForm.cron = '00 00 * ? * * *'
}
},
handleClose() { handleClose() {
this.depts = null this.depts = null
this.formType = 'add' this.formType = 'add'
......
...@@ -28,6 +28,19 @@ ...@@ -28,6 +28,19 @@
</el-table-column> </el-table-column>
</complex-table> </complex-table>
</el-row> </el-row>
<el-dialog
v-dialogDrag
:title="$t('dataset.detail')"
:visible="show_error_massage"
:show-close="false"
width="50%"
class="dialog-css"
>
<span>{{ error_massage }}</span>
<span slot="footer" class="dialog-footer">
<el-button size="mini" @click="show_error_massage = false">{{ $t('dataset.close') }}</el-button>
</span>
</el-dialog>
</el-col> </el-col>
</template> </template>
...@@ -86,6 +99,8 @@ export default { ...@@ -86,6 +99,8 @@ export default {
formType: 'add', formType: 'add',
orderConditions: [], orderConditions: [],
last_condition: null, last_condition: null,
show_error_massage: false,
error_massage: ''
} }
}, },
created() { created() {
...@@ -120,7 +135,6 @@ export default { ...@@ -120,7 +135,6 @@ export default {
}, },
search(condition) { search(condition) {
this.last_condition = condition this.last_condition = condition
console.log(condition)
condition = formatQuickCondition(condition, 'dataset_table_task.name') condition = formatQuickCondition(condition, 'dataset_table_task.name')
const temp = formatCondition(condition) const temp = formatCondition(condition)
const param = temp || {} const param = temp || {}
...@@ -130,22 +144,9 @@ export default { ...@@ -130,22 +144,9 @@ export default {
this.paginationConfig.total = response.data.itemCount this.paginationConfig.total = response.data.itemCount
}) })
}, },
deleteTask(task) { showErrorMassage(massage) {
this.$confirm(this.$t('dataset.confirm_delete'), this.$t('dataset.tips'), { this.show_error_massage = true
confirmButtonText: this.$t('dataset.confirm'), this.error_massage = massage
cancelButtonText: this.$t('dataset.cancel'),
type: 'warning'
}).then(() => {
post('/dataset/task/delete/' + task.id, null).then(response => {
this.$message({
message: this.$t('dataset.delete_success'),
type: 'success',
showClose: true
})
this.search()
})
}).catch(() => {
})
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论