Merge pull request #186 from dataease/pr@dev@dataset

feat(數據集): 添加非直连数据集時,默认全量同步一次
This commit is contained in:
taojinlong 2021-07-08 15:13:06 +08:00 committed by GitHub
commit 38487c5b58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 6 deletions

View File

@ -17,6 +17,7 @@ public class DataSetTableRequest extends DatasetTable {
private List<String> tableNames;
private String row = "1000";
private String userId;
private String syncType;
private Integer editType;
private Boolean isRename;
private List<String> typeFilter;

View File

@ -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);

View File

@ -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',

View File

@ -921,6 +921,7 @@ export default {
char_can_not_more_50: '數據集名稱不能超過50個字符',
task_add_title: '添加任務',
task_edit_title: '編輯任務',
sync_latter: '稍後同步',
task: {
list: '任務列表',
record: '執行紀錄',

View File

@ -921,6 +921,7 @@ export default {
char_can_not_more_50: '数据集名称不能超过50个字符',
task_add_title: '添加任务',
task_edit_title: '编辑任务',
sync_latter: '稍后同步',
task: {
list: '任务列表',
record: '执行记录',

View File

@ -32,6 +32,14 @@
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!kettleRunning" />
</el-select>
</el-form-item>
<el-form-item class="form-item" v-if="mode === '1'">
<el-select v-model="syncType" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.sync_now')" value="sync_now" />
<el-option :label="$t('dataset.sync_latter')" value="sync_latter" />
</el-select>
</el-form-item>
<el-form-item class="form-item" style="float: right;">
<el-input
v-model="searchTable"
@ -76,6 +84,7 @@ export default {
tables: [],
checkTableList: [],
mode: '0',
syncType: 'sync_now',
tableData: [],
kettleRunning: false
}
@ -130,12 +139,14 @@ export default {
const dataSourceId = this.dataSource
const tables = []
const mode = this.mode
const syncType = this.syncType
this.checkTableList.forEach(function(name) {
tables.push({
name: ds.name + '_' + name,
sceneId: sceneId,
dataSourceId: dataSourceId,
type: 'db',
syncType: syncType,
mode: parseInt(mode),
info: JSON.stringify({ table: name })
})

View File

@ -36,6 +36,13 @@
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!kettleRunning" />
</el-select>
</el-form-item>
<el-form-item class="form-item" v-if="mode === '1'">
<el-select v-model="syncType" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
<el-option :label="$t('dataset.sync_now')" value="sync_now" />
<el-option :label="$t('dataset.sync_latter')" value="sync_latter" />
</el-select>
</el-form-item>
</el-form>
</el-row>
<el-row>
@ -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() })

View File

@ -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'
},