feat(数据更新): 同步

This commit is contained in:
junjie 2021-03-03 14:26:41 +08:00
parent 8c50976dcd
commit b427e0b95f
13 changed files with 252 additions and 35 deletions

View File

@ -15,6 +15,8 @@ public class DatasetTable implements Serializable {
private String type;
private Integer mode;
private String createBy;
private Long createTime;

View File

@ -454,6 +454,66 @@ public class DatasetTableExample {
return (Criteria) this;
}
public Criteria andModeIsNull() {
addCriterion("`mode` is null");
return (Criteria) this;
}
public Criteria andModeIsNotNull() {
addCriterion("`mode` is not null");
return (Criteria) this;
}
public Criteria andModeEqualTo(Integer value) {
addCriterion("`mode` =", value, "mode");
return (Criteria) this;
}
public Criteria andModeNotEqualTo(Integer value) {
addCriterion("`mode` <>", value, "mode");
return (Criteria) this;
}
public Criteria andModeGreaterThan(Integer value) {
addCriterion("`mode` >", value, "mode");
return (Criteria) this;
}
public Criteria andModeGreaterThanOrEqualTo(Integer value) {
addCriterion("`mode` >=", value, "mode");
return (Criteria) this;
}
public Criteria andModeLessThan(Integer value) {
addCriterion("`mode` <", value, "mode");
return (Criteria) this;
}
public Criteria andModeLessThanOrEqualTo(Integer value) {
addCriterion("`mode` <=", value, "mode");
return (Criteria) this;
}
public Criteria andModeIn(List<Integer> values) {
addCriterion("`mode` in", values, "mode");
return (Criteria) this;
}
public Criteria andModeNotIn(List<Integer> values) {
addCriterion("`mode` not in", values, "mode");
return (Criteria) this;
}
public Criteria andModeBetween(Integer value1, Integer value2) {
addCriterion("`mode` between", value1, value2, "mode");
return (Criteria) this;
}
public Criteria andModeNotBetween(Integer value1, Integer value2) {
addCriterion("`mode` not between", value1, value2, "mode");
return (Criteria) this;
}
public Criteria andCreateByIsNull() {
addCriterion("create_by is null");
return (Criteria) this;

View File

@ -7,6 +7,7 @@
<result column="scene_id" jdbcType="VARCHAR" property="sceneId" />
<result column="data_source_id" jdbcType="VARCHAR" property="dataSourceId" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="mode" jdbcType="INTEGER" property="mode" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</resultMap>
@ -72,7 +73,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, scene_id, data_source_id, `type`, create_by, create_time
id, `name`, scene_id, data_source_id, `type`, `mode`, create_by, create_time
</sql>
<sql id="Blob_Column_List">
info
@ -127,11 +128,13 @@
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.DatasetTable">
insert into dataset_table (id, `name`, scene_id,
data_source_id, `type`, create_by,
create_time, info)
data_source_id, `type`, `mode`,
create_by, create_time, info
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{sceneId,jdbcType=VARCHAR},
#{dataSourceId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{info,jdbcType=LONGVARCHAR})
#{dataSourceId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{mode,jdbcType=INTEGER},
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{info,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTable">
insert into dataset_table
@ -151,6 +154,9 @@
<if test="type != null">
`type`,
</if>
<if test="mode != null">
`mode`,
</if>
<if test="createBy != null">
create_by,
</if>
@ -177,6 +183,9 @@
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="mode != null">
#{mode,jdbcType=INTEGER},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
@ -212,6 +221,9 @@
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.mode != null">
`mode` = #{record.mode,jdbcType=INTEGER},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
@ -233,6 +245,7 @@
scene_id = #{record.sceneId,jdbcType=VARCHAR},
data_source_id = #{record.dataSourceId,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
`mode` = #{record.mode,jdbcType=INTEGER},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
info = #{record.info,jdbcType=LONGVARCHAR}
@ -247,6 +260,7 @@
scene_id = #{record.sceneId,jdbcType=VARCHAR},
data_source_id = #{record.dataSourceId,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
`mode` = #{record.mode,jdbcType=INTEGER},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}
<if test="_parameter != null">
@ -268,6 +282,9 @@
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="mode != null">
`mode` = #{mode,jdbcType=INTEGER},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
@ -286,6 +303,7 @@
scene_id = #{sceneId,jdbcType=VARCHAR},
data_source_id = #{dataSourceId,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
`mode` = #{mode,jdbcType=INTEGER},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
info = #{info,jdbcType=LONGVARCHAR}
@ -297,6 +315,7 @@
scene_id = #{sceneId,jdbcType=VARCHAR},
data_source_id = #{dataSourceId,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
`mode` = #{mode,jdbcType=INTEGER},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}

View File

@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table`
`scene_id` varchar(50) NOT NULL COMMENT '场景ID',
`data_source_id` varchar(50) NOT NULL COMMENT '数据源ID',
`type` varchar(50) COMMENT 'db,sql,excel,custom',
`mode` int(10) DEFAULT 0 COMMENT '连接模式0-直连1-定时同步',
`info` longtext COMMENT '表原始信息',
`create_by` varchar(50) COMMENT '创建人ID',
`create_time` bigint(13) COMMENT '创建时间',
@ -19,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table_field`
`origin_name` varchar(255) NOT NULL COMMENT '原始名',
`name` varchar(255) NOT NULL COMMENT '字段名',
`type` varchar(50) NOT NULL COMMENT '原始字段类型',
`de_type` int(10) NOT NULL COMMENT 'dataease字段类型0-文本1-时间2-数值...',
`de_type` int(10) NOT NULL COMMENT 'dataease字段类型0-文本1-时间2-数值...',
`checked` tinyint(1) NOT NULL DEFAULT true COMMENT '是否选中',
`column_index` int(10) NOT NULL COMMENT '列位置',
`last_sync_time` bigint(13) COMMENT '同步时间',

View File

@ -512,6 +512,8 @@ export default {
this.$post('/chart/group/getScene/' + sceneId, null, response => {
this.currGroup = response.data;
})
} else {
this.$router.push('/chart');
}
}
},

View File

@ -27,6 +27,10 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item class="form-item">
<el-radio v-model="mode" label="0">{{$t('dataset.direct_connect')}}</el-radio>
<el-radio v-model="mode" label="1">{{$t('dataset.sync_data')}}</el-radio>
</el-form-item>
<el-form-item class="form-item" style="float: right;">
<el-input
size="mini"
@ -62,7 +66,8 @@ export default {
dataSource: '',
tables: [],
checkTableList: [],
scene: null
scene: null,
mode: '0'
}
},
mounted() {
@ -86,12 +91,14 @@ export default {
let sceneId = this.scene.id;
let dataSourceId = this.dataSource;
let tables = [];
let mode = this.mode;
this.checkTableList.forEach(function (name) {
tables.push({
name: name,
sceneId: sceneId,
dataSourceId: dataSourceId,
type: 'db'
type: 'db',
mode: parseInt(mode)
})
});
this.$post('/dataset/table/batchAdd', tables, response => {

View File

@ -82,6 +82,10 @@
<span>
({{data.type}})
</span>
<span>
<span style="margin-left: 6px" v-if="data.mode === 0"><i class="el-icon-s-operation"></i></span>
<span style="margin-left: 6px" v-if="data.mode === 1"><i class="el-icon-time"></i></span>
</span>
<span style="margin-left: 6px">{{ data.name }}</span>
</span>
</span>

View File

@ -0,0 +1,94 @@
<template>
<el-col>
<el-row>
<el-button icon="el-icon-setting" size="mini" @click="showConfig">
{{$t('dataset.update_setting')}}
</el-button>
</el-row>
<el-row style="margin-top: 10px;">
<!--TODO-->
<el-table
size="mini"
:data="tableData"
border
style="width: 100%">
<el-table-column
prop="date"
label="日期"
width="180">
</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="180">
</el-table-column>
<el-table-column
prop="address"
label="地址">
</el-table-column>
</el-table>
</el-row>
<el-dialog :title="table.name+' '+$t('dataset.update_setting')" :visible="update_setting" :show-close="false"
width="50%" class="dialog-css">
<el-row>
<el-button icon="el-icon-download" size="mini">
{{$t('dataset.sync_now')}}
</el-button>
<el-button icon="el-icon-plus" size="mini">
{{$t('dataset.add_task')}}
</el-button>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="update_setting = false">{{$t('dataset.cancel')}}</el-button>
<el-button type="primary" size="mini" @click="update_setting = false">{{$t('dataset.confirm')}}</el-button>
</div>
</el-dialog>
</el-col>
</template>
<script>
export default {
props: {
table: Object,
},
name: "UpdateInfo",
data() {
return {
update_setting: false,
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}]
}
},
methods: {
showConfig() {
this.update_setting = true;
}
}
}
</script>
<style scoped>
.dialog-css >>> .el-dialog__header {
padding: 20px 20px 0;
}
.dialog-css >>> .el-dialog__body {
padding: 10px 20px 20px;
}
</style>

View File

@ -10,9 +10,9 @@
<el-button size="mini" @click="edit">
{{$t('dataset.edit')}}
</el-button>
<!-- <el-button size="mini" type="primary" @click="createChart">-->
<!-- {{$t('dataset.create_view')}}-->
<!-- </el-button>-->
<!-- <el-button size="mini" type="primary" @click="createChart">-->
<!-- {{$t('dataset.create_view')}}-->
<!-- </el-button>-->
</el-row>
</el-row>
<el-divider/>
@ -25,14 +25,8 @@
关联视图 TODO
</el-tab-pane>
<el-tab-pane :label="$t('dataset.update_info')" name="updateInfo">
更新信息 TODO
<update-info :table="table"/>
</el-tab-pane>
<!-- <el-tab-pane label="tab3" name="tab3">-->
<!-- tab3-->
<!-- </el-tab-pane>-->
<!-- <el-tab-pane label="tab4" name="tab4">-->
<!-- tab4-->
<!-- </el-tab-pane>-->
</el-tabs>
<el-dialog :title="table.name" :visible.sync="editField" :fullscreen="true" :show-close="false">
@ -66,20 +60,20 @@
</div>
</el-dialog>
<el-dialog title="view" :visible.sync="createViewDialog" :fullscreen="true">
<chart-edit/>
</el-dialog>
<!-- <el-dialog title="view" :visible.sync="createViewDialog" :fullscreen="true">-->
<!-- <chart-edit/>-->
<!-- </el-dialog>-->
</el-row>
</el-col>
</template>
<script>
import TabDataPreview from "./TabDataPreview";
import ChartEdit from "../../chart/view/ChartEdit";
import UpdateInfo from "./UpdateInfo";
export default {
name: "ViewTable",
components: {ChartEdit, TabDataPreview},
components: {UpdateInfo, TabDataPreview},
data() {
return {
createViewDialog: false,

View File

@ -143,12 +143,12 @@
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button type="primary" size="mini" plain>
{{$t('dataset.update')}}
</el-button>
<el-button type="primary" size="mini" plain>
{{$t('dataset.process')}}
</el-button>
<!-- <el-button type="primary" size="mini" plain>-->
<!-- {{$t('dataset.update')}}-->
<!-- </el-button>-->
<!-- <el-button type="primary" size="mini" plain>-->
<!-- {{$t('dataset.process')}}-->
<!-- </el-button>-->
</el-row>
<el-row>
<el-form>
@ -174,6 +174,10 @@
<span>
({{data.type}})
</span>
<span>
<span style="margin-left: 6px" v-if="data.mode === 0"><i class="el-icon-s-operation"></i></span>
<span style="margin-left: 6px" v-if="data.mode === 1"><i class="el-icon-time"></i></span>
</span>
<span style="margin-left: 6px">{{ data.name }}</span>
</span>
<span>
@ -187,8 +191,8 @@
</el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-edit-outline" :command="beforeClickMore('renameTable',data,node)">
{{$t('dataset.rename')}}
<el-dropdown-item icon="el-icon-edit-outline" :command="beforeClickMore('editTable',data,node)">
{{$t('dataset.edit')}}
</el-dropdown-item>
<!-- <el-dropdown-item icon="el-icon-right" :command="beforeClickMore('move',data,node)">-->
<!-- {{$t('dataset.move_to')}}-->
@ -208,6 +212,10 @@
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="tableForm.name"></el-input>
</el-form-item>
<el-form-item :label="$t('dataset.mode')" prop="mode">
<el-radio v-model="tableForm.mode" label="0">{{$t('dataset.direct_connect')}}</el-radio>
<el-radio v-model="tableForm.mode" label="1">{{$t('dataset.sync_data')}}</el-radio>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="closeTable()" size="mini">{{$t('dataset.cancel')}}</el-button>
@ -243,6 +251,7 @@ export default {
},
tableForm: {
name: '',
mode: '',
sort: 'type asc,create_time desc,name asc'
},
groupFormRules: {
@ -254,6 +263,9 @@ export default {
name: [
{required: true, message: this.$t('commons.input_content'), trigger: 'blur'},
],
mode: [
{required: true, message: this.$t('commons.input_content'), trigger: 'blur'},
],
}
}
},
@ -305,9 +317,10 @@ export default {
case 'delete':
this.delete(param.data);
break;
case 'renameTable':
case 'editTable':
this.editTable = true;
this.tableForm = JSON.parse(JSON.stringify(param.data));
this.tableForm.mode = this.tableForm.mode + '';
break;
case 'deleteTable':
this.deleteTable(param.data);
@ -362,6 +375,7 @@ export default {
saveTable(table) {
console.log(table);
table.mode = parseInt(table.mode);
this.$refs['tableForm'].validate((valid) => {
if (valid) {
this.$post("/dataset/table/update", table, response => {
@ -538,6 +552,8 @@ export default {
this.$post('/dataset/group/getScene/' + sceneId, null, response => {
this.currGroup = response.data;
})
} else {
this.$router.push('/dataset');
}
}
},

View File

@ -1600,6 +1600,12 @@ export default {
join_view: 'Relation View',
text: 'Text',
time: 'Time',
value: 'Value'
value: 'Value',
mode:'Mode',
direct_connect:'Direct',
sync_data:'Sync',
update_setting:'Config',
sync_now:'Sync Now',
add_task:'Add Task'
}
};

View File

@ -1621,7 +1621,13 @@ export default {
join_view: '关联视图',
text: '文本',
time: '时间',
value: '数值'
value: '数值',
mode:'模式',
direct_connect:'直连',
sync_data:'定时同步',
update_setting:'更新设置',
sync_now:'立即更新',
add_task:'添加任务'
},
datasource: {
create: '新建数据连接',

View File

@ -1601,6 +1601,12 @@ export default {
join_view: '關聯視圖',
text: '文本',
time: '時間',
value: '數值'
value: '數值',
mode:'模式',
direct_connect:'直連',
sync_data:'定時同步',
update_setting:'更新設置',
sync_now:'立即更新',
add_task:'添加任務'
}
};