feat:数据接入:同步代码

master_fei
Yunfei Du 2024-05-01 15:05:06 +08:00
parent b8057ede4a
commit 7a77754b15
10 changed files with 661 additions and 424 deletions

View File

@ -2,7 +2,7 @@ import request from '@/utils/request'
export function getDataSourceList(dataSourceQueryReq) {
return request({
url: '/dataSource/source/list',
url: '/dataSource/source/getDataSourceList',
method: 'post',
data: dataSourceQueryReq
})
@ -15,9 +15,9 @@ export function getAllDataType() {
})
}
export function insertDataSource(dataSource) {
export function editDataSource(dataSource) {
return request({
url: '/dataSource/source/insertDataSource',
url: '/dataSource/source/editDataSource',
method: 'post',
data: dataSource
})

View File

@ -314,7 +314,7 @@ export default {
"userId": 1,
"deptId": 103,
"userName": "admin",
"nickName": "智能车联",
"nickName": "数据处理",
"email": "ry@163.com",
"phonenumber": "15888888888",
"isAuth": true,
@ -331,7 +331,7 @@ export default {
"userId": 2,
"deptId": 105,
"userName": "ry",
"nickName": "智能车联",
"nickName": "数据处理",
"email": "ry@qq.com",
"phonenumber": "15666666666",
"dept": {

View File

@ -332,7 +332,7 @@ export default {
"userId": 1,
"deptId": 103,
"userName": "admin",
"nickName": "智能车联",
"nickName": "数据处理",
"email": "ry@163.com",
"phonenumber": "15888888888",
"isAuth": true,
@ -349,7 +349,7 @@ export default {
"userId": 2,
"deptId": 105,
"userName": "ry",
"nickName": "智能车联",
"nickName": "数据处理",
"email": "ry@qq.com",
"phonenumber": "15666666666",
"dept": {

View File

@ -9,7 +9,7 @@
:props="defaultProps">
<div class="custom-tree-node" slot-scope="{ node, data }">
<div v-if="data.type === 'dataSource'">{{ data.name + '('+data.databaseName + '-' + data.systemName+')' }}</div>
<div @click="getTableStructure" v-if="data.type === 'dataTable'">{{ data.name + '-'+data.as + '(' + data.dataTotal+')' }}</div>
<div v-if="data.type === 'dataTable'">{{ data.name + '-'+data.as + '(' + data.dataTotal+')' }}</div>
</div>
</el-tree>
</el-aside>
@ -25,15 +25,9 @@
import AuthDataSource from './auth/AuthDataSource.vue'
import AuthTable from './auth/AuthTable.vue'
import {Table} from "element-ui";
export default {
name: 'assetStructure',
computed: {
Table() {
return Table
}
},
components: { AuthTable, AuthDataSource },
data() {
return {

View File

@ -0,0 +1,156 @@
<template>
<el-container :style="{height: mainHeight + 'px'}">
<el-aside>
<el-tree :data="assetStructureList"
:load="expandTable"
:expand-on-click-node="false"
lazy
@node-click="(data) => showAuth=data.type"
:props="defaultProps">
<div class="custom-tree-node" slot-scope="{ node, data }">
<div v-if="data.type === 'dataSource'">{{ data.name + '('+data.databaseName + '-' + data.systemName+')' }}</div>
<div v-if="data.type === 'dataTable'">{{ data.name + '-'+data.as + '(' + data.dataTotal+')' }}</div>
</div>
</el-tree>
</el-aside>
<el-container>
<el-main>
<el-card>
<div slot="header" class="clearfix">
<span>资产模型基本信息</span>
</div>
<el-descriptions border :column="2">
<el-descriptions-item label="表名称">sys_user</el-descriptions-item>
<el-descriptions-item label="表备注">用户表</el-descriptions-item>
<el-descriptions-item label="数据量">12536</el-descriptions-item>
<el-descriptions-item label="是否核心">
<el-tag size="small"></el-tag>
</el-descriptions-item>
</el-descriptions>
</el-card>
<el-card class="box-card" style="margin-top: 20px">
<div slot="header" class="clearfix">
<span>模型数据</span>
</div>
<el-row :gutter="20">
<el-col :span="6" v-for="asset in assetShowList" style="margin-top: 20px">
<el-descriptions :title="asset.key" direction="vertical" border :column="1">
<el-descriptions-item label="Type">
<el-tag size="small">{{asset.type}}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Value">{{asset.value}}</el-descriptions-item>
</el-descriptions>
</el-col>
</el-row>
</el-card>
</el-main>
</el-container>
</el-container>
</template>
<script>
export default {
name: "AssetShow",
data() {
return {
mainHeight: window.innerHeight - 85,
defaultProps: {
children: 'childrenList',
label: 'name'
},
showAuth: null,
assetStructureList: [
{
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
type: "dataSource"
},
{
name: "测试2",
systemName: "网站系统",
databaseName: "wangzhan",
type: "dataSource"
},
{
name: "测试3",
systemName: "物联网系统",
databaseName: "wulianwang",
type: "dataSource"
},
{
name: "测试4",
systemName: "传媒系统",
databaseName: "chuanmei",
type: "dataSource"
},
],
childrenList: [
{
name: "sys_user",
as: "用户表",
dataTotal: 635847,
type: "dataTable",
childrenList: []
},
{
name: "sys_dept",
as: "部门表",
dataTotal: 362548,
type: "dataTable",
childrenList: []
},
{
name: "sys_notice",
as: "通知公告",
dataTotal: 6347,
type: "dataTable",
childrenList: []
}
],
assetShowList: [
{key: "测试.sys_user.id", type: "String", value: 1},
{key: "测试.sys_user.name", type: "String", value: "张三"},
{key: "测试.sys_user.age", type: "Integer", value: 18},
{key: "测试.sys_user.email", type: "String", value: "123@136.com"},
{key: "测试.sys_user.sex", type: "String", value: "Y"},
]
}
},
created() {
},
methods: {
expandTable( node, resolve){
if (node.level === 0) return resolve(this.assetStructureList);
const {data} = node;
if (data.type === 'dataTable') {
return resolve([])
}
setTimeout(() => {
resolve(this.childrenList)
}, 500);
}
}
}
</script>
<style scoped>
.el-aside {
margin: 0;
padding: 0;
width: 400px;
background-color: white;
}
.el-main {
background-color: #f1f1f1;
}
.custom-tree-node{
height: 30px;
}
.el-descriptions-row>th{
width: 200px;
}
</style>

View File

@ -1,13 +1,13 @@
<template>
<div>
<div v-if="tableParams != null">
<el-card>
<div slot="header" class="clearfix">
<span>资产模型基本信息</span>
</div>
<el-descriptions border :column="2">
<el-descriptions-item label="表名称">{{ tableInfo.tableName }}</el-descriptions-item>
<el-descriptions-item label="表备注">{{tableInfo.tableAnnotation}}</el-descriptions-item>
<el-descriptions-item label="数据量">{{ tableInfo.recordCount }}</el-descriptions-item>
<el-descriptions-item label="表名称">{{tableParams.tableName}}</el-descriptions-item>
<el-descriptions-item label="表备注">{{tableParams.tableAsName}}</el-descriptions-item>
<el-descriptions-item label="数据量">12536</el-descriptions-item>
<el-descriptions-item label="是否核心">
<el-tag size="small"></el-tag>
</el-descriptions-item>
@ -18,40 +18,40 @@
<span>资产模型详细信息</span>
</div>
<el-table
:data="assetsModelList"
:data="tableData"
style="width: 100%;">
<el-table-column prop="fieldsName" label="名称" />
<el-table-column prop="fieldsAnnotation" label="注释" />
<el-table-column prop="isDictionary" label="是否主键" >
<el-table-column prop="name" label="名称" />
<el-table-column prop="comment" label="注释" />
<el-table-column prop="isPrimaryKey" label="是否主键" >
<template slot-scope="scope">
<el-tag size="small" :type="scope.row.isDictionary === 1 ? 'success' : ''">
{{scope.row.isDictionary}}
<el-tag size="small" :type="scope.row.isPrimaryKey === 'Y' ? 'success' : ''">
{{scope.row.isPrimaryKey}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="baseType" label="类型" />
<el-table-column prop="javaType" label="映射类型" />
<el-table-column prop="fieldsLength" label="长度" />
<el-table-column prop="decimalPlace" label="小数位" />
<el-table-column prop="isEmpty" label="是否为空" >
<el-table-column prop="type" label="类型" />
<el-table-column prop="mappingType" label="映射类型" />
<el-table-column prop="length" label="长度" />
<el-table-column prop="decimalPlaces" label="小数位" />
<el-table-column prop="isNull" label="是否为空" >
<template slot-scope="scope">
<el-tag size="small" :type="scope.row.isNull === 1 ? 'success' : 'danger'">
{{scope.row.isEmpty}}
<el-tag size="small" :type="scope.row.isNull === 'Y' ? 'success' : 'danger'">
{{scope.row.isNull}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="defaultValue" label="默认值" />
<el-table-column prop="isDict" label="是否字典" >
<template slot-scope="scope">
<el-tag v-if="scope.row.isDictionary === 1" size="small" type="success">
{{scope.row.isDictionary}}
<el-tag v-if="scope.row.isDict === 'Y'" size="small" type="success">
{{scope.row.isDict}}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="reflectionDictionary" label="映射字典" >
<el-table-column prop="dictKey" label="映射字典" >
<template slot-scope="scope">
<el-popover
v-if="scope.row.isDictionary === 1"
v-if="scope.row.isDict === 'Y'"
placement="left"
width="200"
trigger="hover">
@ -69,28 +69,221 @@
</el-table-column>
<el-table-column prop="id" label="操作" >
<template slot-scope="scope">
<el-button type="text">编辑</el-button>
<el-button type="text" @click="update(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<el-dialog title="资产结构修改" width="80%" :visible.sync="formStatus">
<el-form :model="form" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="名称">
<el-input v-model="form.name" readonly autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="注释">
<el-input v-model="form.comment" readonly autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="是否主键">
<el-tag size="small" :type="form.isPrimaryKey === 'Y' ? 'success' : 'danger'">
{{form.isPrimaryKey}}
</el-tag>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数据类型">
<el-input v-model="form.type" readonly autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="数据长度">
<el-input v-model="form.length" readonly autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="小数位">
<el-input v-model="form.decimalPlaces" readonly autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="是否为空">
<el-tag size="small" :type="form.isNull === 'Y' ? 'success' : 'danger'">
{{form.isNull}}
</el-tag>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="默认值">
<el-input v-model="form.defaultValue" readonly autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="映射字段">
<el-input v-model="form.mappingType" readonly autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否字典">
<el-switch
v-model="form.isDict"
active-value="Y"
inactive-value="N"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="form.isDict === 'Y'">
<el-col :span="24">
<el-form-item label="字典">
<el-select v-model="form.dictKey">
<el-option v-for="(value, key) in dictMap" :key="key" :label="key" :value="key"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item>
<el-table :data="dictMap[form.dictKey]" striped border>
<el-table-column property="label" label="字典标签"/>
<el-table-column property="val" label="字典值"/>
</el-table>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="formStatus = false"> </el-button>
<el-button type="primary" @click="formStatus = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'OverallAssetStructure',
props: {
assetsModelList: {
type: Array
tableParams: {
type: Object,
default: null
}
},
tableInfo: {
type: Object
watch: {
tableParams: {
handler(val) {
if (val != null){
this.init()
}
},
deep: true,
immediate: true
}
},
data() {
return {
tableData: [
{
id: 1,
name: "id",
comment: "主键",
isPrimaryKey: "Y",
type: "bigint",
mappingType: "Long",
length: "-",
decimalPlaces: "-",
isNull: "N",
defaultValue: "-",
isDict: "N",
dictKey: "-",
}, {
id: 2,
name: "name",
comment: "姓名",
isPrimaryKey: "N",
type: "varchar",
mappingType: "String",
length: "64",
decimalPlaces: "-",
isNull: "N",
defaultValue: "-",
isDict: "N",
dictKey: "-",
}, {
id: 3,
name: "sex",
comment: "性别",
isPrimaryKey: "N",
type: "char",
mappingType: "String",
length: "1",
decimalPlaces: "-",
isNull: "N",
defaultValue: "-",
isDict: "Y",
dictKey: "system_sex",
}, {
id: 4,
name: "price",
comment: "金额",
isPrimaryKey: "N",
type: "double",
mappingType: "BigDecimal",
length: "10",
decimalPlaces: "2",
isNull: "N",
defaultValue: "0.00",
isDict: "N",
dictKey: "-",
}, {
id: 5,
name: "create_time",
comment: "创建时间",
isPrimaryKey: "N",
type: "datetime",
mappingType: "Date",
length: "-",
decimalPlaces: "-",
isNull: "Y",
defaultValue: "-",
isDict: "N",
dictKey: "-",
}, ],
form: {},
formStatus: false,
dictMap: {
"system_sex": [
{ label: '男', val: '1', isEdit: false },
{ label: '女', val: '2', isEdit: false },
{ label: '未知', val: '0', isEdit: false },
],
"system_y_n": [
{ label: '是', val: '1', isEdit: false },
{ label: '否', val: '0', isEdit: false }
],
}
}
},
methods: {
init(){
console.log("查询")
},
update(row) {
this.form = row;
this.formStatus = true;
}
}
}
</script>
<style scoped lang="scss">

View File

@ -12,7 +12,7 @@
<div class="card-panel-text">
数据接入
</div>
<count-to :duration="2600" :end-val="dataSourceCount" :start-val="0" class="card-panel-num"/>
<count-to :duration="2600" :end-val="4" :start-val="0" class="card-panel-num"/>
</div>
</div>
</el-col>
@ -25,7 +25,7 @@
<div class="card-panel-text">
资产模型
</div>
<count-to :duration="3000" :end-val="allTableCount" :start-val="0" class="card-panel-num"/>
<count-to :duration="3000" :end-val="96" :start-val="0" class="card-panel-num"/>
</div>
</div>
</el-col>
@ -38,7 +38,7 @@
<div class="card-panel-text">
数据模型
</div>
<count-to :duration="3200" :end-val="allDataModelCount" :start-val="0" class="card-panel-num"/>
<count-to :duration="3200" :end-val="560" :start-val="0" class="card-panel-num"/>
</div>
</div>
</el-col>
@ -49,17 +49,6 @@
import CountTo from 'vue-count-to'
export default {
props: {
dataSourceCount: {
type :Number
},
allTableCount: {
type :Number
},
allDataModelCount: {
type :Number
}
},
components: {
CountTo
},

View File

@ -1,9 +1,7 @@
<template>
<el-row :gutter="40" class="panel-group">
<div class="title-header">
{{dataSourceObj.dataSource.fromSystem}} - 资产结构概述
{{title}} - 资产结构概述
</div>
<el-col :sm="12" :xs="12" class="card-panel-col">
<div class="card-panel" @click="handleSetLineChartData('messages')">
@ -14,7 +12,7 @@
<div class="card-panel-text">
资产模型
</div>
<count-to :duration="3000" :end-val="dataSourceObj.dataSource.tableCount" :start-val="0" class="card-panel-num"/>
<count-to :duration="3000" :end-val="15" :start-val="0" class="card-panel-num"/>
</div>
</div>
</el-col>
@ -27,7 +25,7 @@
<div class="card-panel-text">
数据模型
</div>
<count-to :duration="3200" :end-val="dataSourceObj.dataSource.dataModelCount" :start-val="0" class="card-panel-num"/>
<count-to :duration="3200" :end-val="230" :start-val="0" class="card-panel-num"/>
</div>
</div>
</el-col>
@ -49,7 +47,7 @@
trigger="click">
<el-row :gutter="20">
<el-col :span="18">
<el-input v-model="dictionary.dictionaryName"></el-input>
<el-input v-model="dictAddName"></el-input>
</el-col>
<el-col :span="6">
<el-button @click="addDict"></el-button>
@ -59,40 +57,40 @@
</el-popover>
</div>
<el-row :gutter="20">
<el-col v-for="dictionaryInfoResp in dictionaryInfoRespList" :md="8" :sm="24" :xs="12">
<el-col v-for="(val,key) in dictMap" :md="8" :sm="24" :xs="12">
<el-card class="box-card" style="height: 300px">
<div slot="header" class="clearfix">
<span>{{dictionaryInfoResp.dictionary.dictionaryName+'(+'+dictionaryInfoResp.dictionary.dictionaryValue+')'}}</span>
<span>{{key}}</span>
<el-button style="float: right; padding: 3px 0"
type="text"
@click="dictionaryInfoResp.dictionaryInfoList.push({ value: null, label: null, isEdit: true })"
@click="val.push({ label: null, val: null, isEdit: true })"
>新增</el-button>
</div>
<el-table :data="dictionaryInfoResp.dictionaryInfoList" style="width: 100%" height="280px">
<el-table-column label="标签">
<template slot-scope="scope">
<span v-if="!scope.row.isEdit">{{scope.row.value}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.value" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column label="值">
<el-table :data="val" style="width: 100%" height="280px">
<el-table-column prop="label" label="标签">
<template slot-scope="scope">
<span v-if="!scope.row.isEdit">{{scope.row.label}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.label" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column label="操作">
<el-table-column prop="val" label="值">
<template slot-scope="scope">
<span v-if="!scope.row.isEdit">{{scope.row.val}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.val" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column prop="val" label="操作">
<template slot-scope="scope">
<el-button
v-if="!scope.row.isEdit"
size="mini"
type="text"
icon="el-icon-edit"
@click="$set(scope.row,'isEdit',true)"
@click="scope.row.isEdit = true"
>修改</el-button>
<el-button
v-if="scope.row.isEdit"
@click="editConfirm(scope.row,dictionaryInfoResp.dictionary.id)"
@click="editConfirm(scope.row)"
size="mini"
type="text"
icon="el-icon-finished"
@ -106,10 +104,11 @@
</el-card>
</el-col>
<el-col :span="24">
<el-tabs v-model="activeName" type="border-card" >
<el-tab-pane :name="assetsModelResp.dataTable.tableName" :label="assetsModelResp.dataTable.tableName" :key="assetsModelResp.dataTable.id" v-for="assetsModelResp in assetsModelRespArrayList">
<overall-asset-structure :tableInfo="assetsModelResp.dataTable" :assetsModelList="assetsModelResp.assetsModelList" />
<el-col :span="24" style="margin-top: 20px">
<el-tabs v-model="activeName" type="border-card" @tab-click="checkTableName">
<el-tab-pane v-for="table in tableList" :label="table.tableName+'('+table.tableAsName+')'"
:name="table.tableName">
<overall-asset-structure v-if="table.tableName === tableParams.tableName" :table-params="tableParams"/>
</el-tab-pane>
</el-tabs>
</el-col>
@ -120,106 +119,77 @@
<script>
import CountTo from 'vue-count-to'
import OverallAssetStructure from './OverallAssetStructure.vue'
import {getDictionaryRespByDataSourceId, insertDictionary, insertDictionaryInfo} from "@/api/dataSource/dictionary";
export default {
watch:{
assetsModelRespArrayList:{
// variable
handler(item1,item2){
console.log("新值",item1)
this.activeName=item1[0].dataTable.tableName
console.log("name:",this.activeName)
console.log("旧址",item2)
}
}
},
props: {
assetsModelRespArrayList: {
type: Array
},
dataSourceObj: {
type: Object
},
dictionaryInfoRespList: {
type: Array
title: {
type: String,
default: "-"
}
},
data() {
return {
nowTime: null,
activeName: '',
dictionary: {},
giveObj: []
activeName: null,
dictAddName: null,
dictMap: {
"性别(system_sex)": [
{ label: '男', val: '1', isEdit: false },
{ label: '女', val: '2', isEdit: false },
{ label: '未知', val: '0', isEdit: false },
],
"开关(system_y_n)": [
{ label: '是', val: '1', isEdit: false },
{ label: '否', val: '0', isEdit: false }
],
},
tableList: [],
tableParams: null
}
},
components: {
OverallAssetStructure,
CountTo
},
created() {
this.init();
},
methods: {
// updateEdit(row) {
// this.$set(row,'isEdit',true)
// console.log(":"+row)
// this.dictionaryInfoRespList.forEach(dictionaryInfoResp => {
// dictionaryInfoResp.dictionaryInfoList.forEach(dictionaryInfo => {
// if (dictionaryInfo.id == row){
// console.log("",dictionaryInfo.isEdit)
// this.$set(dictionaryInfo,'isEdit',true)
// dictionaryInfo.isEdit = true
// }
// })
// })
// },
editConfirm(row,dictionaryId){
if (!row.label || !row.value) {
checkTableName(checkTab){
this.tableParams = this.tableList.findLast(item => item.tableName === checkTab.name)
},
init(){
let rows = [
{
tableName: "sys_user",
tableAsName: "用户表"
},
{
tableName: "sys_dept",
tableAsName: "部门表"
},
];
this.tableList = rows;
this.activeName = rows[0].tableName;
this.tableParams = rows[0]
},
editConfirm(row){
if (!row.label || !row.val) {
this.$message.error('字典标签或字典值,不可为空');
return;
}
row.isEdit = false;
row.dictionaryId=dictionaryId
insertDictionaryInfo(row).then(
res => {
console.log("插入字典",res)
}
)
this.getDictionaryResp()
},
getDictionaryResp() {
getDictionaryRespByDataSourceId(this.dataSourceObj.dataSource.id).then(
res => {
console.log("字典表响应对象:",res.data)
this.giveObj = res.data
this.giveObj.forEach(dictionaryInfoResp => {
dictionaryInfoResp.dictionaryInfoList.forEach(dictionaryInfo => {
this.$set(dictionaryInfo,'isEdit',false)
})
})
this.$emit('handleSetLineChartData', this.giveObj)
}
)
},
handleSetLineChartData(type) {
this.$emit('handleSetLineChartData', type)
},
addDict(){
if (!this.dictionary.dictionaryName){
if (!this.dictAddName){
this.$message.error('数据字典,不可为空');
return;
}
this.dictionary.dictionaryName=this.dictionaryNameAndVue.split('(')[0].trim()
this.dictionary.dictionaryValue=this.dictionaryNameAndVue.match(/\(([^)]+)\)/)[1];
this.dictionary.dataSourceId=this.dataSourceId
console.log(this.dictionary)
insertDictionary(this.dictionary).then(
res=>{
console.log("插入字典",res)
this.$message.success("插入字典成功")
this.dictionary = {}
this.getDictionaryResp()
}
)
this.dictMap[this.dictAddName] = []
this.dictAddName = null
},
handleSetLineChartData(type) {
this.$emit('handleSetLineChartData', type)
}
}
}
</script>

View File

@ -5,19 +5,19 @@
:expand-on-click-node="false"
:load="expandTable"
lazy
@node-click="(data) => showAssets=data.type"
@node-click="showAssetsFun"
:props="defaultProps">
<div class="custom-tree-node" slot-scope="{ node, data }">
<div @click="getNowDataSource(data)" v-if="data.type === 'dataSource'">{{ data.dataSource.name + '('+data.dataSource.dataSourceDatabaseName + '-' + data.dataSource.fromSystem+')' }}</div>
<div @click="getTableStructure(data)" v-if="data.type === 'dataTable'">{{ data.dataTable.tableName + '-'+data.dataTable.tableAnnotation + '(' + data.dataTable.recordCount+')' }}</div>
<div v-if="data.type === 'dataSource'">{{ data.name + '('+data.databaseName + '-' + data.systemName+')' }}</div>
<div v-if="data.type === 'dataTable'">{{ data.name + '-'+data.as + '(' + data.dataTotal+')' }}</div>
</div>
</el-tree>
</el-aside>
<el-container>
<el-main>
<OverallAssets :dataSourceCount="dataSourceCount" :allTableCount="allTableCount" :allDataModelCount="allDataModelCount" v-if="showAssets == null"/>
<overall-specific-assets :dictionaryInfoRespList="dictionaryInfoRespList" :dataSourceId="dataSourceId" :dataSourceObj="dataSourceObj" :assetsModelRespArrayList="assetsModelRespArrayList" v-if="showAssets === 'dataSource'" :title="title"/>
<overall-asset-structure :tableInfo="tableInfo" :assetsModelList="assetsModelList" v-if="showAssets === 'dataTable'" :title="title"/>
<OverallAssets v-if="showAssets == null"/>
<overall-specific-assets v-if="showAssets === 'dataSource'" :title="title"/>
<overall-asset-structure v-if="showAssets === 'dataTable'" :table-params="tableParams" :title="title"/>
</el-main>
</el-container>
</el-container>
@ -26,104 +26,97 @@
import OverallAssets from './dashboard/OverallAssets.vue'
import OverallSpecificAssets from './dashboard/OverallSpecificAssets.vue'
import OverallAssetStructure from './dashboard/OverallAssetStructure.vue'
import {queryBigStructure, queryTableStructure} from "@/api/dataSource/data";
import {getAssetsModelByDataTableId, getAssetsModelListByTableIds} from "@/api/dataSource/assets";
import {getDictionaryRespByDataSourceId} from "@/api/dataSource/dictionary";
export default {
name: 'assetStructure',
components: { OverallAssetStructure, OverallSpecificAssets, OverallAssets },
data() {
return {
dataSourceId: 0,
tableInfo: {},
assetsModelList: [],
dataSourceObj: null,
tableCount:0,
dataModelCount:0,
dataSourceCount: 0,
allTableCount: 0,
allDataModelCount: 0,
dataBaseConnectObj: {},
tableData: [],
mainHeight: window.innerHeight - 85,
defaultProps: {
children: 'childrenList',
label: 'name'
},
assetStructureList: [],
childrenList: [],
assetStructureList: [
{
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
type: "dataSource"
},
{
name: "测试2",
systemName: "网站系统",
databaseName: "wangzhan",
type: "dataSource"
},
{
name: "测试3",
systemName: "物联网系统",
databaseName: "wulianwang",
type: "dataSource"
},
{
name: "测试4",
systemName: "传媒系统",
databaseName: "chuanmei",
type: "dataSource"
},
],
childrenList: [
{
name: "sys_user",
as: "用户表",
dataTotal: 635847,
type: "dataTable",
childrenList: []
},
{
name: "sys_dept",
as: "部门表",
dataTotal: 362548,
type: "dataTable",
childrenList: []
},
{
name: "sys_notice",
as: "通知公告",
dataTotal: 6347,
type: "dataTable",
childrenList: []
}
],
showAssets: null,
title: null,
tableIds: [],
assetsModelRespArrayList: [],
dictionaryInfoRespList: []
tableParams: null
}
},
methods: {
getNowDataSource(data) {
console.log(data)
this.tableIds = data.dataTableList.map(dataTable => dataTable.dataTable.id);
console.log("idList",this.tableIds)
getAssetsModelListByTableIds(this.tableIds).then(
res => {
this.assetsModelRespArrayList = res.data
console.log("this.assetsModelRespArrayList",this.assetsModelRespArrayList)
}
)
this.dataSourceId = data.dataSource.id
this.dataSourceObj = data
getDictionaryRespByDataSourceId(this.dataSourceId).then(
res => {
console.log("字典表响应对象:",res.data)
let info = res.data
this.dictionaryInfoRespList = info
}
)
},
getTableStructure(data) {
console.log(data.dataTable.id)
getAssetsModelByDataTableId(data.dataTable.id).then(
res => {
console.log("根据表ID",res.data)
this.assetsModelList = res.data.assetsModelList
this.tableInfo = res.data.dataTable
console.log(this.tableInfo)
}
)
},
getBigStructure() {
queryBigStructure().then(
res => {
this.assetStructureList = res.data.dataSourceDecorationList
this.dataSourceCount = this.assetStructureList.length
this.allTableCount = res.data.allTableCount
this.allDataModelCount = res.data.allDataModelCount
console.log("BigStructure",this.assetStructureList)
this.assetsModelList = this.assetStructureList
}
)
},
expandTable( node, resolve){
if (node.level === 0) return resolve(this.assetStructureList);
if (node.level > 1) return resolve([]);
const {data} = node;
if (data.type === 'dataSource') {
this.title = data.name + '('+data.dataSource.dataSourceDatabaseName + '-' + data.dataSource.fromSystem+')'
}
this.showAssets = data.type;
if (data.type === 'dataTable') {
this.title = data.tableName + '('+data.dataTable.tableAnnotation + '-' + data.dataTable.recordCount+')'
this.tableParams = {
tableName: data.name,
tableAsName: data.as
}
return resolve([])
}
setTimeout(() => {
resolve(data.dataTableList)
this.showAuth = data.type;
resolve(this.childrenList)
}, 500);
}
},
created() {
this.getBigStructure()
showAssetsFun(data){
this.title = data.name + '('+data.databaseName + '-' + data.systemName+')'
this.showAssets = data.type;
if (data.type === "dataTable"){
this.tableParams = {
tableName: data.name,
tableAsName: data.as
}
}
}
}
}
</script>
@ -137,4 +130,7 @@ export default {
.el-main {
background-color: #f1f1f1;
}
.custom-tree-node{
height: 30px;
}
</style>

View File

@ -1,25 +1,26 @@
<template>
<!-- 数据访问(数据接人)-->
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="130px">
<el-form-item label="接入源名称" prop="name">
<el-input
v-model="queryParams.name"
v-model="queryParams.dataSourceName"
placeholder="请输入接入源名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="数据来源系统名称" prop="fromSystem">
<el-form-item label="数据来源系统名称" prop="systemName">
<el-input
v-model="queryParams.fromSystem"
v-model="queryParams.systemName"
placeholder="请输入数据来源系统名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="数据库名称" prop="dataSourceDatabaseName">
<el-form-item label="数据库名称" prop="databaseName">
<el-input
v-model="queryParams.dataSourceDatabaseName"
v-model="queryParams.databaseName"
placeholder="请输入数据库名称"
clearable
@keyup.enter.native="handleQuery"
@ -42,17 +43,6 @@
v-hasPermi="['system:access:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:access:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
@ -79,15 +69,29 @@
<el-table v-loading="loading" :data="accessList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="接入源名称" align="center" prop="name" />
<el-table-column label="数据来源系统名称" align="center" prop="fromSystem" />
<el-table-column label="主机地址" align="center" prop="dataSourceIp" />
<el-table-column label="端口号" align="center" prop="dataSourcePort" />
<el-table-column label="数据接入类型" align="center" prop="dataType" />
<el-table-column label="数据库名称" align="center" prop="dataSourceDatabaseName" />
<el-table-column label="接入源名称" align="center" prop="dataSourceName" />
<el-table-column label="数据来源系统名称" align="center" prop="systemName" />
<el-table-column label="主机地址" align="center" prop="linkAddress" />
<el-table-column label="主机地址" align="center" prop="port" />
<el-table-column label="数据接入类型" align="center" prop="type" />
<el-table-column label="数据库名称" align="center" prop="databaseName" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-connection"
@click="syncAssetsStructure(scope.row)"
v-hasPermi="['system:access:edit']"
>同步资产结构</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-video-play"
@click="testConnection(scope.row)"
v-hasPermi="['system:access:edit']"
>测试</el-button>
<el-button
size="mini"
type="text"
@ -102,27 +106,6 @@
@click="handleDelete(scope.row)"
v-hasPermi="['system:access:remove']"
>删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="testConnect(scope.row)"
v-hasPermi="['system:access:remove']"
>测试连接</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="dataSynchronization(scope.row)"
v-hasPermi="['system:access:remove']"
>同步数据</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="queryDataBase(scope.row)"
v-hasPermi="['system:access:remove']"
>查询此数据库</el-button>
</template>
</el-table-column>
</el-table>
@ -145,50 +128,51 @@
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="接入源名称" prop="name">
<el-input v-model="form.name" placeholder="请输入接入源名称" />
<el-input v-model="form.dataSourceName" placeholder="请输入接入源名称" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="数据来源系统名称" prop="systemName">
<el-input v-model="form.fromSystem" placeholder="请输入数据来源系统名称" />
<el-input v-model="form.systemName" placeholder="请输入数据来源系统名称" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="主机地址" prop="host">
<el-input v-model="form.dataSourceIp" placeholder="请输入主机地址" />
<el-form-item label="主机地址" prop="linkAddress">
<el-input v-model="form.linkAddress" placeholder="请输入主机地址" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="端口号" prop="port">
<el-input v-model="form.dataSourcePort" placeholder="请输入主机地址" />
<el-form-item label="主机地址" prop="port">
<el-input v-model="form.port" placeholder="请输入主机地址" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="数据接入类型" prop="type">
<el-select style="width: 100%" v-model="form.typeId">
<el-option v-for="type in typeList" :label="type.dataType" :value="type.id" ></el-option>
<el-select style="width: 100%" v-model="form.type">
<el-option label="MySql" value="MySql">MySql</el-option>
<el-option label="Oracle" value="Oracle">Oracle</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="数据库名称" prop="databaseName">
<el-input v-model="form.dataSourceDatabaseName" placeholder="请输入数据库名称" />
<el-input v-model="form.databaseName" placeholder="请输入数据库名称" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="用户" prop="dataSourceUsername">
<el-input v-model="form.dataSourceUsername" placeholder="请输入用户"/>
<el-form-item label="数据库用户" prop="username">
<el-input v-model="form.username" placeholder="请输入数据库用户" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="密码" prop="dataSourcePassword">
<el-input v-model="form.dataSourcePassword" placeholder="请输入密码"/>
<el-form-item label="数据库密码" prop="password">
<el-input v-model="form.password" placeholder="请输入数据库密码" />
</el-form-item>
</el-col>
</el-row>
@ -198,8 +182,8 @@
<span>数据连接参数</span>
</div>
<el-col :sm="24">
<el-form-item label="数据连接参数" prop="additionalConfiguration">
<el-input v-model="form.additionalConfiguration" placeholder="请输入内容" />
<el-form-item label="数据连接参数" prop="connectionParam">
<el-input v-model="form.connectionParam" placeholder="请输入内容" />
</el-form-item>
</el-col>
<el-row :gutter="10" style="margin: 10px 0">
@ -233,25 +217,25 @@
</div>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="初始连接数量" prop="initialNumberOfConnections">
<el-input v-model="form.initialNumberOfConnections" placeholder="请输入初始连接数量" />
<el-form-item label="初始连接数量" prop="initNum">
<el-input v-model="form.initNum" placeholder="请输入初始连接数量" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="最大连接数量" prop="maximumNumberOfConnections">
<el-input v-model="form.maximumNumberOfConnections" placeholder="请输入最大连接数量" />
<el-form-item label="最大连接数量" prop="maxNum">
<el-input v-model="form.maxNum" placeholder="请输入最大连接数量" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="最大等待时间" prop="maximumWaitingTime">
<el-input v-model="form.maximumWaitingTime" placeholder="请输入最大等待时间" />
<el-form-item label="最大等待时间" prop="maxWaitTime">
<el-input v-model="form.maxWaitTime" placeholder="请输入最大等待时间" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="最大等待次数" prop="maximumWaitingTimes">
<el-input v-model="form.maximumWaitingTimes" placeholder="请输入最大等待次数" />
<el-form-item label="最大等待次数" prop="maxWaitSize">
<el-input v-model="form.maxWaitSize" placeholder="请输入最大等待次数" />
</el-form-item>
</el-col>
</el-row>
@ -267,46 +251,22 @@
</el-card>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="testConnection(null)"> </el-button>
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog title="查询结构" :visible.sync="dialogTableVisible">
<el-form>
<el-form-item label="选择表" prop="type">
<el-select style="width: 100%" v-model="selectTableName">
<el-option v-for="table in tableList" :label="table" :value="table" ></el-option>
</el-select>
</el-form-item>
</el-form>
<el-button @click="queryTableStructure"></el-button>
</el-dialog>
</div>
</template>
<script>
import {
dataSynchronization,
getAllDataType,
getDataSourceList,
insertDataSource,
queryStructure,
testConnect
} from "@/api/dataSource/data";
import {dataSynchronization, editDataSource, getDataSourceList} from "@/api/dataSource/source";
export default {
name: "Access",
data() {
return {
selectTableName: "",
tableList:[],
dialogTableVisible: false,
dataSourceQueryReq: {
typeId: null,
name: "",
dataSourceDatabaseName: ""
},
//
loading: true,
//
@ -321,59 +281,59 @@ export default {
total: 0,
//
accessList: [],
//
typeList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
fromSystem: null,
dataSourceDatabaseName: null
systemName: null,
databaseName: null
},
//
form: {},
//
rules: {
name: [
dataSourceName: [
{required: true, message: "接入源名称不能为空", trigger: "blur"}
],
fromSystem: [
systemName: [
{required: true, message: "数据来源系统名称不能为空", trigger: "blur"}
],
typeId: [
type: [
{required: true, message: "数据接入类型不能为空", trigger: "blur"}
],
dataSourceIp: [
linkAddress: [
{required: true, message: "主机地址不能为空", trigger: "blur"}
],
dataSourcePort: [
port: [
{required: true, message: "主机地址不能为空", trigger: "blur"}
],
dataSourceDatabaseName: [
username: [
{required: true, message: "数据库用户不能为空", trigger: "blur"}
],
password: [
{required: true, message: "数据库密码不能为空", trigger: "blur"}
],
databaseName: [
{required: true, message: "数据库名称不能为空", trigger: "blur"}
],
additionalConfiguration: [
connectionParam: [
{required: true, message: "数据连接参数不能为空", trigger: "blur"}
],
dataSourceUsername: [
{required: true, message: "用户名不能为空", trigger: "blur"}
],
dataSourcePassword: [
{required: true, message: "密码不能为空", trigger: "blur"}
],
initialNumberOfConnections: [
initNum: [
{required: true, message: "初始连接数量不能为空", trigger: "blur"}
],
maximumNumberOfConnections: [
maxNum: [
{required: true, message: "最大连接数量不能为空", trigger: "blur"}
],
maximumWaitingTime: [
maxWaitTime: [
{required: true, message: "最大等待时间不能为空", trigger: "blur"}
],
maximumWaitingTimes: [
maxWaitSize: [
{required: true, message: "最大等待次数不能为空", trigger: "blur"}
]
},
@ -384,13 +344,22 @@ export default {
val: null
}
]
};
},
created() {
this.getList();
this.getDataTypeList()
},
methods: {
syncAssetsStructure(row){
dataSynchronization(row).then(res=>{
if (res.code == 200){
this.$modal.msgSuccess("同步资产结构成功");
}else {
this.$modal.msgError("同步资产结构失败");
}
})
},
//
addParam(){
this.dataSourceParamList.push({
@ -409,30 +378,25 @@ export default {
},
//
processParam(){
this.form.additionalConfiguration = this.dataSourceParamList
this.form.connectionParam = this.dataSourceParamList
.filter(item => item.name != null || item.val != null)
.map(item => {
return item.name + "=" + item.val;
}).join("&")
console.log(this.form.additionalConfiguration)
console.log(this.form.connectionParam)
},
/** 查询数据接入列表 */
getList() {
getList(){
getDataSourceList(this.queryParams).then(res=>{
this.loading = true;
getDataSourceList(this.queryParams).then(res => {
this.accessList = res.data;
console.log(res.data)
this.accessList= res.data.rows;
this.total=res.data.total;
this.loading=false;
})
this.loading = false;
},
getDataTypeList() {
getAllDataType().then(
res => {
this.typeList = res.data
console.log("typeList:",this.typeList)
}
)
},
//
cancel() {
this.open = false;
@ -443,16 +407,18 @@ export default {
this.form = {
id: null,
name: null,
typeId: null,
fromSystem: null,
dataSourceIp: null,
dataSourcePort: null,
dataSourceDatabaseName: null,
additionalConfiguration: null,
initialNumberOfConnections: 5,
maximumNumberOfConnections: 20,
maximumWaitingTime: 3000,
maximumWaitingTimes: 3,
type: null,
systemName: null,
host: null,
port: null,
databaseName: null,
username: null,
password: null,
connectionParam: null,
initNum: 5,
maxNum: 20,
maxWaitTime: 3000,
maxWaitSize: 3,
createBy: null,
createTime: null,
updateBy: null,
@ -463,6 +429,7 @@ export default {
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
@ -482,12 +449,14 @@ export default {
this.open = true;
this.title = "添加数据接入";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.form = row;
this.dataSourceParamList = [];
this.form.additionalConfiguration.split("&").forEach(param => {
this.form.connectionParam.split("&").forEach(param => {
let paramArr = param.split("=");
this.dataSourceParamList.push({
name: paramArr[0],
@ -496,33 +465,31 @@ export default {
})
this.open = true;
this.title = "修改数据接入";
},
/**
* 查询表结构
*/
queryTableStructure(){
},
/** 提交按钮 */
submitForm() {
console.log('from:',this.form)
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
this.$modal.msgSuccess("修改成功");
editDataSource(this.form).then(res=>{
this.$modal.msgSuccess("编辑成功");
this.open = false;
} else {
insertDataSource(this.form).then(
res => {
this.$modal.msgSuccess("新增成功");
this.open = false;
}
)
}
this.getList()
})
}
});
},
/** 测试连接 */
testConnection(row) {
if (row){
this.$modal.msgSuccess("测试连接成功");
}else {
this.$refs["form"].validate(valid => {
if (valid) {
this.$modal.msgSuccess("测试连接成功");
}
});
}
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
@ -530,34 +497,6 @@ export default {
this.$modal.msgSuccess("删除成功");
});
},
queryDataBase(row) {
queryStructure(row).then(
res => {
console.log(res.data)
this.tableList = res.data
this.dialogTableVisible = true
}
)
},
dataSynchronization(row) {
dataSynchronization(row).then(
res => {
if (res.code ===200){
this.$message.success(res.msg)
}else {
this.$message.error(res.msg)
}
}
)
},
testConnect(row) {
testConnect(row).then(
res => {
this.$message (res==true?"成功":"失败");
}
)
console.log("test:",row)
},
/** 导出按钮操作 */
handleExport() {
this.$modal.msgSuccess("导出成功");