diff --git a/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java b/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java index a71b592fc4..9a7ba2f7ac 100644 --- a/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java +++ b/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java @@ -17,6 +17,7 @@ public class DataSetTableRequest extends DatasetTable { private List tableNames; private String row = "1000"; private String userId; + private String syncType; private Integer editType; private Boolean isRename; private List typeFilter; diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index a74d4d1793..36d023133e 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -9,9 +9,11 @@ import io.dataease.base.mapper.ext.ExtDataSetGroupMapper; import io.dataease.base.mapper.ext.ExtDataSetTableMapper; import io.dataease.base.mapper.ext.UtilMapper; import io.dataease.commons.constants.JobStatus; +import io.dataease.commons.constants.ScheduleType; import io.dataease.commons.utils.*; import io.dataease.controller.request.dataset.DataSetGroupRequest; import io.dataease.controller.request.dataset.DataSetTableRequest; +import io.dataease.controller.request.dataset.DataSetTaskRequest; import io.dataease.datasource.dto.TableFiled; import io.dataease.datasource.provider.DatasourceProvider; import io.dataease.datasource.provider.JdbcProvider; @@ -94,6 +96,26 @@ public class DataSetTableService { } } + private void extractData(DataSetTableRequest datasetTable) throws Exception{ + if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) { + commonThreadPool.addTask(() -> { + extractDataService.extractData(datasetTable.getId(), null, "all_scope", null); + }); + } + if (StringUtils.isNotEmpty(datasetTable.getSyncType()) && datasetTable.getSyncType().equalsIgnoreCase("sync_now")) { + DataSetTaskRequest dataSetTaskRequest = new DataSetTaskRequest(); + DatasetTableTask datasetTableTask = new DatasetTableTask(); + datasetTableTask.setTableId(datasetTable.getId()); + datasetTableTask.setRate(ScheduleType.SIMPLE.toString()); + datasetTableTask.setType("all_scope"); + datasetTableTask.setName(datasetTable.getName() + " 更新设置"); + datasetTableTask.setEnd("0"); + datasetTableTask.setStartTime(System.currentTimeMillis()); + dataSetTaskRequest.setDatasetTableTask(datasetTableTask); + dataSetTableTaskService.save(dataSetTaskRequest); + } + } + public DatasetTable save(DataSetTableRequest datasetTable) throws Exception { checkName(datasetTable); if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) { @@ -110,11 +132,7 @@ public class DataSetTableService { // 添加表成功后,获取当前表字段和类型,抽象到dataease数据库 if (insert == 1) { saveTableField(datasetTable); - if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) { - commonThreadPool.addTask(() -> { - extractDataService.extractData(datasetTable.getId(), null, "all_scope", null); - }); - } + extractData(datasetTable); } } else { int update = datasetTableMapper.updateByPrimaryKeySelective(datasetTable); diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index b9e542ec96..555a33eba1 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -921,6 +921,7 @@ export default { char_can_not_more_50: 'Dataset name can not more 50', task_add_title: 'Add Task', task_edit_title: 'Edit Task', + sync_latter: 'Sync latter', task: { list: 'Task list', record: 'Execution record', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index e3fd7e00d5..081d10fbd6 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -921,6 +921,7 @@ export default { char_can_not_more_50: '數據集名稱不能超過50個字符', task_add_title: '添加任務', task_edit_title: '編輯任務', + sync_latter: '稍後同步', task: { list: '任務列表', record: '執行紀錄', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index d7713672e2..c53c83bd07 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -921,6 +921,7 @@ export default { char_can_not_more_50: '数据集名称不能超过50个字符', task_add_title: '添加任务', task_edit_title: '编辑任务', + sync_latter: '稍后同步', task: { list: '任务列表', record: '执行记录', diff --git a/frontend/src/views/dataset/add/AddDB.vue b/frontend/src/views/dataset/add/AddDB.vue index c0348a44da..c9534b7913 100644 --- a/frontend/src/views/dataset/add/AddDB.vue +++ b/frontend/src/views/dataset/add/AddDB.vue @@ -32,6 +32,14 @@ + + + + + + + + + + + + + + + @@ -143,6 +150,7 @@ export default { data: [], fields: [], mode: '0', + syncType: 'sync_now', height: 500, kettleRunning: false } @@ -260,6 +268,7 @@ export default { sceneId: this.param.id, dataSourceId: this.dataSource, type: 'sql', + syncType: this.syncType, mode: parseInt(this.mode), // info: '{"sql":"' + this.sql + '"}', info: JSON.stringify({ sql: this.sql.trim() }) diff --git a/frontend/src/views/system/task/DatasetTaskList.vue b/frontend/src/views/system/task/DatasetTaskList.vue index c938a3119a..c5c8e8b244 100644 --- a/frontend/src/views/system/task/DatasetTaskList.vue +++ b/frontend/src/views/system/task/DatasetTaskList.vue @@ -189,7 +189,7 @@ export default { columns: [], buttons: [ { - label: this.$t('commons.edit'), icon: 'el-icon-edit', type: 'primary', click: this.addTask + label: this.$t('commons.edit'), icon: 'el-icon-edit', type: 'primary', click: this.addTask, disabled: this.disableEdit }, { label: this.$t('dataset.task.exec'), icon: 'el-icon-video-play', type: 'success', click: this.execTask, disabled: this.disableExec @@ -422,6 +422,9 @@ export default { cronChange(val) { this.taskForm.cron = val }, + disableEdit(task) { + return task.rate === 'SIMPLE' + }, disableExec(task) { return task.status === 'Stopped' },