From cd4806ac3a7c459b3c8ff91904b17de4e94587da Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 8 Jul 2021 15:05:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(=E6=95=B8=E6=93=9A=E9=9B=86):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=9D=9E=E7=9B=B4=E8=BF=9E=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=99=82=EF=BC=8C=E9=BB=98=E8=AE=A4=E5=85=A8=E9=87=8F?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/dataset/DataSetTableRequest.java | 1 + .../service/dataset/DataSetTableService.java | 28 +++++++++++++++---- frontend/src/lang/en.js | 3 +- frontend/src/lang/tw.js | 3 +- frontend/src/lang/zh.js | 3 +- frontend/src/views/dataset/add/AddDB.vue | 11 ++++++++ frontend/src/views/dataset/add/AddSQL.vue | 9 ++++++ 7 files changed, 50 insertions(+), 8 deletions(-) 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 8803969e9c..fb69869a9d 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 6d27f20c83..6ddc5c15da 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -919,7 +919,8 @@ export default { m2: ' To', char_can_not_more_50: 'Dataset name can not more 50', task_add_title: 'Add Task', - task_edit_title: 'Edit Task' + task_edit_title: 'Edit Task', + sync_latter: 'Sync latter' }, datasource: { datasource: 'Data Source', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index a0d47a4a67..7099ffd7b0 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -919,7 +919,8 @@ export default { m2: ' 移動到', char_can_not_more_50: '數據集名稱不能超過50個字符', task_add_title: '添加任務', - task_edit_title: '編輯任務' + task_edit_title: '編輯任務', + sync_latter: '稍後同步' }, datasource: { datasource: '數據源', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 45ab54d628..c5b3cff9ad 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -919,7 +919,8 @@ export default { m2: ' 移动到', char_can_not_more_50: '数据集名称不能超过50个字符', task_add_title: '添加任务', - task_edit_title: '编辑任务' + task_edit_title: '编辑任务', + sync_latter: '稍后同步' }, datasource: { datasource: '数据源', 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() }) From 7f388f1edd226aef058dd9a32dd24ecf5304bcac Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 8 Jul 2021 15:11:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(=E6=95=B8=E6=93=9A=E9=9B=86):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=9D=9E=E7=9B=B4=E8=BF=9E=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=99=82=EF=BC=8C=E9=BB=98=E8=AE=A4=E5=85=A8=E9=87=8F?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/system/task/DatasetTaskList.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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' },