Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
45a93030f3
|
|
@ -95,6 +95,7 @@ export function addCreateDateRange(params, dateRange) {
|
|||
|
||||
// 回显数据字典
|
||||
export function selectDictLabel(datas, value) {
|
||||
console.log(datas)
|
||||
let actions = [];
|
||||
Object.keys(datas).some((key) => {
|
||||
if (datas[key].dictValue === ('' + value)) {
|
||||
|
|
|
|||
|
|
@ -60,23 +60,38 @@
|
|||
<right-toolbar :showSearch.sync="showSearch" @queryTable="handleQuery"></right-toolbar>
|
||||
</el-row>
|
||||
<el-table :data="realDate.data">
|
||||
<span v-for="(item,index) in realDate.header">
|
||||
<el-table-column v-if="checkDateType(item.prop)"
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop">
|
||||
<template slot-scope="scope">
|
||||
{{ parseDateOrTime(scope.row[item.prop]) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-else
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop"
|
||||
/>
|
||||
</span>
|
||||
<el-table-column v-for="(item,index) in realDate.header"
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="checkDateType(item.prop)">
|
||||
{{ parseDateOrTime(scope.row[item.prop]) }}
|
||||
</span>
|
||||
<span v-else-if="item.dictType!=null">
|
||||
{{ dictFormat(item.dictType, scope.row[item.prop]) }}
|
||||
</span>
|
||||
<span v-else>{{ scope.row[item.prop] }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <span v-for="(item,index) in realDate.header">-->
|
||||
<!-- <el-table-column v-if="checkDateType(item.prop)"-->
|
||||
<!-- :label="item.label"-->
|
||||
<!-- align="center"-->
|
||||
<!-- :key="index"-->
|
||||
<!-- :prop="item.prop">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- {{ parseDateOrTime(scope.row[item.prop]) }}-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column v-else-->
|
||||
<!-- :label="item.label"-->
|
||||
<!-- align="center"-->
|
||||
<!-- :key="index"-->
|
||||
<!-- :prop="item.prop"-->
|
||||
<!-- />-->
|
||||
<!-- </span>-->
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
|
|
@ -114,6 +129,7 @@ export default {
|
|||
data: [],
|
||||
header: [],
|
||||
},
|
||||
dictTypeDataList:{},
|
||||
total: 0,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
|
|
@ -127,10 +143,21 @@ export default {
|
|||
let data = res.data
|
||||
this.uconList = listInit(data.uniCons)
|
||||
this.realDate.header = data.infoList
|
||||
this.dictTypeDataList = data.dictList
|
||||
})
|
||||
|
||||
this.handleQuery()
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 字典渲染
|
||||
* @param dictType
|
||||
* @param data
|
||||
* @returns {*}
|
||||
*/
|
||||
dictFormat(dictType, data) {
|
||||
return this.selectDictLabel(this.dictTypeDataList[dictType], data)
|
||||
},
|
||||
outPlaceholder(item) {
|
||||
return "请输入" + item.ucName
|
||||
},
|
||||
|
|
|
|||
|
|
@ -130,23 +130,40 @@
|
|||
</div>
|
||||
<div class="el-table">
|
||||
<el-table v-show="previewDate.open" :data="previewDate.data">
|
||||
<span v-for="(item,index) in previewDate.header">
|
||||
<el-table-column v-if="checkDateType(item.prop)"
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop">
|
||||
<template slot-scope="scope">
|
||||
<el-table-column v-for="(item,index) in previewDate.header"
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="checkDateType(item.prop)">
|
||||
{{ parseDateOrTime(scope.row[item.prop]) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-else
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop"
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
<span v-else-if="item.dictType!=null">
|
||||
{{ dictFormat(item.dictType, scope.row[item.prop]) }}
|
||||
</span>
|
||||
<span v-else>{{ scope.row[item.prop] }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
<!-- <span v-for="(item,index) in previewDate.header">-->
|
||||
<!-- <el-table-column v-if="checkDateType(item.prop)"-->
|
||||
<!-- :label="item.label"-->
|
||||
<!-- align="center"-->
|
||||
<!-- :key="index"-->
|
||||
<!-- :prop="item.prop">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- {{ parseDateOrTime(scope.row[item.prop]) }}-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column v-else-->
|
||||
<!-- :label="item.label"-->
|
||||
<!-- align="center"-->
|
||||
<!-- :key="index"-->
|
||||
<!-- :prop="item.prop"-->
|
||||
<!-- />-->
|
||||
<!-- </span>-->
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
|
|
@ -161,7 +178,7 @@
|
|||
:visible.sync="columnInfo.open"
|
||||
width="40%"
|
||||
>
|
||||
<el-table ref="columnInfoTable" :data="columnInfo.list" row-key="column">
|
||||
<el-table max-height="650px" ref="columnInfoTable" :data="columnInfo.list" row-key="column">
|
||||
<el-table-column label="字段信息" min-width="10%">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.prop"></el-input>
|
||||
|
|
@ -172,7 +189,7 @@
|
|||
<el-input v-model="scope.row.label"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="字典类型" min-width="10%">
|
||||
<el-table-column label="显示字典类型" min-width="10%">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
|
||||
<el-option
|
||||
|
|
@ -309,6 +326,7 @@ export default {
|
|||
data: [],
|
||||
header: []
|
||||
},
|
||||
dictTypeDataList:{},
|
||||
rules: {
|
||||
uqName: [{required: true, message: '请输入名称', trigger: 'blur'}],
|
||||
uqDescribe: [{required: true, message: '请输入描述', trigger: 'blur'}]
|
||||
|
|
@ -337,9 +355,25 @@ export default {
|
|||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 字典渲染
|
||||
* @param dictType
|
||||
* @param data
|
||||
* @returns {*}
|
||||
*/
|
||||
dictFormat(dictType, data) {
|
||||
return this.selectDictLabel(this.dictTypeDataList[dictType], data)
|
||||
},
|
||||
/**
|
||||
* 字段信息列删除
|
||||
* @param index
|
||||
*/
|
||||
columnInfoDelete(index) {
|
||||
this.columnInfo.list.splice(index, 1)
|
||||
},
|
||||
/**
|
||||
* 重置字段信息
|
||||
*/
|
||||
resetFieldExtract() {
|
||||
this.columnInfo.list = []
|
||||
this.previewDate.header = []
|
||||
|
|
@ -378,6 +412,7 @@ export default {
|
|||
return
|
||||
}
|
||||
let columnList = []
|
||||
this.columnInfo.list = []
|
||||
this.previewDate.header.forEach(item => {
|
||||
columnList.push({
|
||||
prop: item.key,
|
||||
|
|
@ -475,15 +510,14 @@ export default {
|
|||
})
|
||||
},
|
||||
/** 预览 */
|
||||
previewQuery() {
|
||||
this.$refs['elForm'].validate(valid => {
|
||||
previewQuery(){
|
||||
this.$refs['elForm'].validate( valid=>{
|
||||
if (valid) {
|
||||
let list = JSONString(this.columns)
|
||||
let data = {
|
||||
pageNum: this.queryParams.pageNum,
|
||||
pageSize: this.queryParams.pageSize,
|
||||
uqSql: this.info.uqSql
|
||||
|
||||
}
|
||||
if (list.length > 0) {
|
||||
if (this.changUniCon(list)) {
|
||||
|
|
@ -492,6 +526,17 @@ export default {
|
|||
return
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < this.columnInfo.list.length; i++) {
|
||||
let info = this.columnInfo.list[i]
|
||||
if (info.dictType!=null){
|
||||
this.getDicts(info.dictType).then(res=>{
|
||||
this.dictTypeDataList[info.dictType] = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 预览数据请求
|
||||
*/
|
||||
previewQueryData(data).then(res => {
|
||||
this.previewDate.data = res.rows
|
||||
this.total = res.total
|
||||
|
|
@ -624,6 +669,7 @@ export default {
|
|||
return
|
||||
}
|
||||
}
|
||||
data.infoList = that.columnInfo.list
|
||||
return exportMock(data)
|
||||
}).then(response => {
|
||||
that.columns = JSONParse(list)
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<el-dialog :title="selectedNodeParams.label" width="1200px"
|
||||
<el-dialog :title="selectedNodeParams.label" width="1300px"
|
||||
:visible.sync="tableColumnEditOpen"
|
||||
@close="closeEditColumns">
|
||||
<el-table
|
||||
|
|
@ -203,7 +203,8 @@
|
|||
<el-input v-model="scope.row.ucName" placeholder="请输入条件描述"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="条件">
|
||||
<el-table-column label="条件"
|
||||
width="150px">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.ucCon" @change="ucTypeChang(scope.$index,scope.row)">
|
||||
<el-option label="=" value="EQ"/>
|
||||
|
|
@ -217,7 +218,8 @@
|
|||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="显示类型">
|
||||
<el-table-column label="显示类型"
|
||||
width="150px">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.ucType" @change="ucTypeChang(scope.$index,scope.row)">
|
||||
<el-option label="文本框" value="input"/>
|
||||
|
|
@ -225,7 +227,8 @@
|
|||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="模拟数据">
|
||||
<el-table-column label="模拟数据"
|
||||
width="260px">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-if="scope.row.type == 1" placeholder="请输入模拟数据" v-model="scope.row.ucMock"></el-input>
|
||||
<div v-else-if="scope.row.type == 2">
|
||||
|
|
@ -258,6 +261,20 @@
|
|||
></el-date-picker>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="显示字典类型" width="150px">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
|
||||
<el-option
|
||||
v-for="dict in dictTypeList"
|
||||
:key="dict.dictType"
|
||||
:label="dict.dictName"
|
||||
:value="dict.dictType">
|
||||
<span style="float: left">{{ dict.dictName }}</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
|
@ -325,6 +342,7 @@ export default {
|
|||
nodes: [],
|
||||
edges: []
|
||||
},
|
||||
dictTypeList:[],
|
||||
// 表格Column设置弹窗开关
|
||||
tableColumnEditOpen:false,
|
||||
loading: false,
|
||||
|
|
@ -332,11 +350,6 @@ export default {
|
|||
clientHeight: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
|
||||
//todo 设置线段的选择 er图中只有一种线
|
||||
edgeShapeList: [
|
||||
// { guid: "top-line", label: "直线", class: "iconfont icon-flow-line" },
|
||||
// { guid: "dice-er-edge", label: "连线", class: "iconfont icon-flow-line" },
|
||||
// { guid: "top-brokenline", label: "折线", class: "iconfont icon-flow-broken" },
|
||||
// { guid: "top-polyline", label: "多段线", class: "iconfont icon-flow-broken" },
|
||||
// { guid: "top-cubic", label: "曲线", class: "iconfont icon-flow-curve" }
|
||||
],
|
||||
graph: null,
|
||||
grid: null,
|
||||
|
|
@ -510,7 +523,6 @@ export default {
|
|||
// 修改字段信息
|
||||
editColumns() {
|
||||
this.tableColumnEditOpen = true
|
||||
|
||||
},
|
||||
// 连线的三个选择框触发实践
|
||||
tableCommentChang(e) {
|
||||
|
|
@ -583,6 +595,9 @@ export default {
|
|||
},
|
||||
dragendHandler() {
|
||||
},
|
||||
tranDictData(list){
|
||||
this.dictTypeList = list
|
||||
},
|
||||
initTopo(graphData) {
|
||||
let self = this
|
||||
if (self.graph) {
|
||||
|
|
@ -1162,6 +1177,7 @@ export default {
|
|||
item.type = 1
|
||||
item.ucMock = ''
|
||||
item.ucName = item.columnComment
|
||||
item.dictType = null
|
||||
columns.push(item)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,23 +80,21 @@
|
|||
<right-toolbar :showSearch.sync="previewDate.showSearch" @queryTable="handleQuery"></right-toolbar>
|
||||
</el-row>
|
||||
<el-table :data="previewDate.data">
|
||||
<span v-for="(item,index) in previewDate.header">
|
||||
<el-table-column v-if="checkDateType(item.prop)"
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop">
|
||||
<template slot-scope="scope">
|
||||
<el-table-column v-for="(item,index) in previewDate.header"
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="checkDateType(item.prop)">
|
||||
{{ parseDateOrTime(scope.row[item.prop]) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-else
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="index"
|
||||
:prop="item.prop"
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
<span v-else-if="item.dictType!=null">
|
||||
{{ dictFormat(item.dictType, scope.row[item.prop]) }}
|
||||
</span>
|
||||
<span v-else>{{ scope.row[item.prop] }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="previewDate.total>0"
|
||||
|
|
@ -113,13 +111,15 @@
|
|||
<script>
|
||||
/* 局部注册 */
|
||||
import Topology from './packages/topology/src/topology'
|
||||
import { deepClone } from './utils/index'
|
||||
import { getQuery, getTables, updateQuery, preview } from '@/api/tool/top'
|
||||
import { realData } from '@/api/system/data'
|
||||
import { exportReal } from '../../../api/system/data'
|
||||
import {deepClone} from './utils/index'
|
||||
import {getQuery, getTables, updateQuery, preview} from '@/api/tool/top'
|
||||
import {realData} from '@/api/system/data'
|
||||
import {exportReal} from '@/api/system/data'
|
||||
import {optionSelect} from "@/api/system/dict/type";
|
||||
import {eventBus} from "@/views/tool/top/utils/eventBus";
|
||||
import {Release} from "@/api/tool/query";
|
||||
import {Message} from "element-ui";
|
||||
|
||||
export default {
|
||||
name: 'DemoTopology',
|
||||
components: {
|
||||
|
|
@ -162,14 +162,15 @@ export default {
|
|||
tableComment: '主表字段',
|
||||
relComment: '关联字段'
|
||||
},
|
||||
autoRefreshTimer: null
|
||||
autoRefreshTimer: null,
|
||||
dictTypeDataList: {}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.topId = this.$route.params && this.$route.params.topId
|
||||
getQuery(this.topId).then(res => {
|
||||
this.baseData = res.data
|
||||
eventBus.$emit('isRelease',this.baseData.isRelease)
|
||||
eventBus.$emit('isRelease', this.baseData.isRelease)
|
||||
|
||||
console.log(res.data)
|
||||
if (res.data.topJson) {
|
||||
|
|
@ -189,8 +190,21 @@ export default {
|
|||
this.nodeTypeList = res.data.tables
|
||||
this.relationalMap = res.data.relationalMap
|
||||
})
|
||||
optionSelect().then(res => {
|
||||
this.$refs.topology.tranDictData(res.data)
|
||||
})
|
||||
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 字典渲染
|
||||
* @param dictType
|
||||
* @param data
|
||||
* @returns {*}
|
||||
*/
|
||||
dictFormat(dictType, data) {
|
||||
return this.selectDictLabel(this.dictTypeDataList[dictType], data)
|
||||
},
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
|
|
@ -206,7 +220,7 @@ export default {
|
|||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
}).then(function () {
|
||||
let data = {
|
||||
id: that.topId,
|
||||
uniCons: that.previewDate.uconList
|
||||
|
|
@ -265,21 +279,17 @@ export default {
|
|||
},
|
||||
changeOnLine(release) {
|
||||
let that = this
|
||||
this.$confirm(release === 1?'请确认top图结构无误并预览结果无误后上线?':'请确认是否撤销当前发布内容!', '警告', {
|
||||
this.$confirm(release === 1 ? '请确认top图结构无误并预览结果无误后上线?' : '请确认是否撤销当前发布内容!', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
}).then(function () {
|
||||
let data = {
|
||||
id: that.baseData.id,
|
||||
isRelease: release
|
||||
}
|
||||
Release(data).then(res => {
|
||||
that.$router.replace('/tool/er-top')
|
||||
Message({
|
||||
message: res.msg,
|
||||
type: 'success'
|
||||
})
|
||||
window.close()
|
||||
})
|
||||
})
|
||||
},
|
||||
|
|
@ -300,7 +310,7 @@ export default {
|
|||
let edges = []
|
||||
edgeList.forEach(edge => {
|
||||
edges.push({
|
||||
id:edge.id,
|
||||
id: edge.id,
|
||||
label: edge.label,
|
||||
source: edge.source,
|
||||
target: edge.target,
|
||||
|
|
@ -316,6 +326,7 @@ export default {
|
|||
id: this.topId
|
||||
}
|
||||
preview(data).then(res => {
|
||||
this.dictTypeDataList = res.dictList
|
||||
this.previewDate.data = res.rows
|
||||
this.previewDate.total = res.total
|
||||
this.previewDate.uconList = res.uconList
|
||||
|
|
@ -324,11 +335,12 @@ export default {
|
|||
}
|
||||
this.previewDate.header = []
|
||||
let infoList = res.infoList
|
||||
infoList.forEach( info=>{
|
||||
infoList.forEach(info => {
|
||||
this.previewDate.header.push({
|
||||
key: info.prop,
|
||||
label: info.label,
|
||||
prop: info.prop
|
||||
prop: info.prop,
|
||||
dictType: info.dictType
|
||||
})
|
||||
})
|
||||
this.previewDate.title = this.baseData.uqName + '数据预览'
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.ebts.web.controller.system;
|
|||
|
||||
import com.ebts.common.core.controller.BaseController;
|
||||
import com.ebts.common.core.entity.Result;
|
||||
import com.ebts.common.core.entity.entity.DictData;
|
||||
import com.ebts.common.utils.DictUtils;
|
||||
import com.ebts.common.utils.MapExcelUtil;
|
||||
import com.ebts.system.entity.RealUniQuery;
|
||||
import com.ebts.system.entity.RelColumnInfo;
|
||||
|
|
@ -40,13 +42,18 @@ public class RealQueryController extends BaseController {
|
|||
Result<List<Map<String, Object>>> result = realQueryService.RealData(realUniQuery, 1);
|
||||
List<RelColumnInfo> infoList = realQueryService.getInfoList(realUniQuery.getId());
|
||||
if (result.isSuccess()) {
|
||||
List<Map<String,String>> infoMap = infoList.stream().map(info->{
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("label",info.getLabel());
|
||||
map.put("prop",info.getProp());
|
||||
Map<String, List<DictData>> dictList = new HashMap<>();
|
||||
List<Map<String, String>> infoMap = infoList.stream().map(info -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("label", info.getLabel());
|
||||
map.put("prop", info.getProp());
|
||||
map.put("dictType", info.getDictType());
|
||||
if (info.getDictType() != null) {
|
||||
dictList.put(info.getDictType(), DictUtils.getDictCache(info.getDictType()));
|
||||
}
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return new MapExcelUtil().exportExcel(result.getData(), result.getMsg(),infoMap);
|
||||
return new MapExcelUtil().exportExcel(result.getData(), result.getMsg(), infoMap, dictList);
|
||||
} else {
|
||||
return Result.error(result.getMsg());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.InitBinder;
|
|||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
|
|
@ -71,13 +72,14 @@ public class BaseController {
|
|||
* 响应请求分页数据
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
protected TableDataTop getDataTable(List<?> list, List<?> uconList,List<?> infoList) {
|
||||
protected TableDataTop getDataTable(List<?> list, List<?> uconList, List<?> infoList, Map<String,?> dictList) {
|
||||
TableDataTop dataTop = new TableDataTop();
|
||||
dataTop.setCode(HttpStatus.SUCCESS);
|
||||
dataTop.setMsg("查询成功");
|
||||
dataTop.setRows(list);
|
||||
dataTop.setUconList(uconList);
|
||||
dataTop.setInfoList(infoList);
|
||||
dataTop.setDictList(dictList);
|
||||
dataTop.setTotal(new PageInfo(list).getTotal());
|
||||
return dataTop;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ebts.common.core.page;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 表格分页数据对象
|
||||
|
|
@ -24,6 +25,8 @@ public class TableDataTop implements Serializable {
|
|||
private List<?> uconList;
|
||||
|
||||
private List<?> infoList;
|
||||
private Map<String,?> dictList;
|
||||
|
||||
|
||||
/**
|
||||
* 消息状态码
|
||||
|
|
@ -100,4 +103,12 @@ public class TableDataTop implements Serializable {
|
|||
public void setInfoList(List<?> infoList) {
|
||||
this.infoList = infoList;
|
||||
}
|
||||
|
||||
public Map<String, ?> getDictList() {
|
||||
return dictList;
|
||||
}
|
||||
|
||||
public void setDictList(Map<String, ?> dictList) {
|
||||
this.dictList = dictList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ebts.common.utils;
|
|||
|
||||
import com.ebts.common.config.EBTSConfig;
|
||||
import com.ebts.common.core.entity.Result;
|
||||
import com.ebts.common.core.entity.entity.DictData;
|
||||
import com.ebts.common.exception.CustomException;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
|
|
@ -56,6 +57,7 @@ public class MapExcelUtil {
|
|||
* 注解列表
|
||||
*/
|
||||
private List<Map<String, String>> herders;
|
||||
private Map<String,List<DictData>> dictList;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -70,8 +72,9 @@ public class MapExcelUtil {
|
|||
return exportExcel();
|
||||
}
|
||||
|
||||
public <T>Result<T> exportExcel(List<Map<String, Object>> list, String sheetName,List<Map<String,String>> infoMap) {
|
||||
public <T>Result<T> exportExcel(List<Map<String, Object>> list, String sheetName, List<Map<String,String>> infoMap, Map<String,List<DictData>> dictList) {
|
||||
this.herders = infoMap;
|
||||
this.dictList = dictList;
|
||||
this.init(list, sheetName);
|
||||
return exportExcel();
|
||||
}
|
||||
|
|
@ -180,27 +183,31 @@ public class MapExcelUtil {
|
|||
int k = 0;
|
||||
for (Map<String, String> herder : herders) {
|
||||
// 填充单元格的值
|
||||
this.addCell(row, herder.get("prop"), i, k++);
|
||||
this.addCell(row, herder, i, k++);
|
||||
}
|
||||
// for (String key : herders) {
|
||||
// // 填充单元格的值
|
||||
// this.addCell(row, key, i, k++);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加单元格
|
||||
*/
|
||||
public Cell addCell(Row row, String key, int column, Integer k) {
|
||||
public Cell addCell(Row row, Map<String, String> herder, int column, Integer k) {
|
||||
Cell cell = null;
|
||||
try {
|
||||
Object value = this.list.get(column).get(herder.get("prop"));
|
||||
String dictType = herder.get("dictType");
|
||||
if (dictType!=null&&!"".equals(dictType)){
|
||||
for (DictData dictData : dictList.get(dictType)) {
|
||||
if (dictData.getDictValue().equals(value.toString())){
|
||||
value = dictData.getDictLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 设置行高
|
||||
row.setHeight((short) 280);
|
||||
// 创建cell
|
||||
cell = row.createCell(k);
|
||||
cell.setCellStyle(styles.get("data"));
|
||||
Object value = this.list.get(column).get(key);
|
||||
cell.setCellValue(value.toString());
|
||||
} catch (Exception e) {
|
||||
logger.error("导出Excel失败{}", e);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.ebts.generator.controller;
|
|||
|
||||
import com.ebts.common.core.controller.BaseController;
|
||||
import com.ebts.common.core.entity.Result;
|
||||
import com.ebts.common.core.entity.entity.DictData;
|
||||
import com.ebts.common.utils.DictUtils;
|
||||
import com.ebts.common.utils.MapExcelUtil;
|
||||
import com.ebts.common.utils.StringUtils;
|
||||
import com.ebts.generator.entity.UniColumnInfo;
|
||||
|
|
@ -18,9 +20,8 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +71,7 @@ public class QueryController extends BaseController {
|
|||
@PreAuthorize("@ebts.hasPermi('query:edit')")
|
||||
@PutMapping
|
||||
public Result<Integer> edit(@Validated @RequestBody UniQuery uniQuery) {
|
||||
if (uniQuery.getInfoList().size() == 0){
|
||||
if (uniQuery.getInfoList().size() == 0) {
|
||||
return Result.error("字段信息为空,请提取字段信息!");
|
||||
}
|
||||
return queryService.updateQueryInfo(uniQuery);
|
||||
|
|
@ -87,7 +88,28 @@ public class QueryController extends BaseController {
|
|||
public Result<Map<String, Object>> export(@Validated @RequestBody UniQuery uniQuery) {
|
||||
Result<List<Map<String, Object>>> result = queryService.previewQuery(uniQuery);
|
||||
if (result.isSuccess()) {
|
||||
return new MapExcelUtil().exportExcel(result.getData(), uniQuery.getUqName());
|
||||
List<UniColumnInfo> infoList;
|
||||
Map<String, List<DictData>> dictList = new HashMap<>();
|
||||
if (uniQuery.getInfoList().size() != 0) {
|
||||
infoList = uniQuery.getInfoList();
|
||||
} else {
|
||||
infoList = new ArrayList<>();
|
||||
Set<String> keySet = result.getData().get(0).keySet();
|
||||
keySet.forEach(s -> {
|
||||
infoList.add(new UniColumnInfo(uniQuery.getId(), s, s, null));
|
||||
});
|
||||
}
|
||||
List<Map<String, String>> infoMap = infoList.stream().map(info -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("label", info.getLabel());
|
||||
map.put("prop", info.getProp());
|
||||
map.put("dictType", info.getDictType());
|
||||
if (info.getDictType() != null) {
|
||||
dictList.put(info.getDictType(), DictUtils.getDictCache(info.getDictType()));
|
||||
}
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return new MapExcelUtil().exportExcel(result.getData(), uniQuery.getUqName(), infoMap, dictList);
|
||||
} else {
|
||||
return Result.error(result.getMsg());
|
||||
}
|
||||
|
|
@ -103,7 +125,7 @@ public class QueryController extends BaseController {
|
|||
@PutMapping("preview")
|
||||
public Serializable Preview(@Validated @RequestBody UniQueryBo uniQuery) {
|
||||
UniQuery query = new UniQuery();
|
||||
BeanUtils.copyProperties(uniQuery,query);
|
||||
BeanUtils.copyProperties(uniQuery, query);
|
||||
startPage(uniQuery);
|
||||
Result<List<Map<String, Object>>> result = queryService.previewQuery(query);
|
||||
if (result.isSuccess()) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class TopQueryController extends BaseController {
|
|||
Result<TopResult> result = topQueryService.preview(params.get("jsonData"), params.get("id"));
|
||||
if (result.isSuccess()){
|
||||
TopResult data = result.getData();
|
||||
return getDataTable(data.getDataMap(),data.getUniCons(),data.getInfoList());
|
||||
return getDataTable(data.getDataMap(),data.getUniCons(),data.getInfoList(),data.getDictList());
|
||||
}else {
|
||||
return Result.error(result.getMsg());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ebts.generator.dto;
|
||||
|
||||
import com.ebts.common.core.entity.entity.DictData;
|
||||
import com.ebts.generator.entity.UniColumnInfo;
|
||||
import com.ebts.generator.entity.UniCon;
|
||||
|
||||
|
|
@ -17,11 +18,14 @@ public class TopResult {
|
|||
private List<UniCon> uniCons;
|
||||
private List<UniColumnInfo> infoList;
|
||||
|
||||
private Map<String,List<DictData>> dictList;
|
||||
|
||||
public TopResult(List<Map<String, Object>> dataMap, List<UniCon> uniCons,List<UniColumnInfo> infoList) {
|
||||
|
||||
public TopResult(List<Map<String, Object>> dataMap, List<UniCon> uniCons,List<UniColumnInfo> infoList,Map<String,List<DictData>> dictList) {
|
||||
this.dataMap = dataMap;
|
||||
this.uniCons = uniCons;
|
||||
this.infoList = infoList;
|
||||
this.dictList = dictList;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getDataMap() {
|
||||
|
|
@ -47,4 +51,12 @@ public class TopResult {
|
|||
public void setInfoList(List<UniColumnInfo> infoList) {
|
||||
this.infoList = infoList;
|
||||
}
|
||||
|
||||
public Map<String, List<DictData>> getDictList() {
|
||||
return dictList;
|
||||
}
|
||||
|
||||
public void setDictList(Map<String, List<DictData>> dictList) {
|
||||
this.dictList = dictList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ public class QueryServiceImpl implements QueryService {
|
|||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||
public Result<Integer> updateQueryInfo(UniQuery uniQuery) {
|
||||
uniQueryDao.updateUniQuery(uniQuery);
|
||||
queryDao.deleteUniCon(uniQuery.getId());
|
||||
if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) {
|
||||
queryDao.deleteUniCon(uniQuery.getId());
|
||||
queryDao.insertUniCon(uniQuery.getUniCons());
|
||||
resetColumnInfo(uniQuery);
|
||||
}
|
||||
resetColumnInfo(uniQuery);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ebts.common.core.entity.Result;
|
||||
import com.ebts.common.core.entity.entity.DictData;
|
||||
import com.ebts.common.utils.DictUtils;
|
||||
import com.ebts.common.utils.SecurityUtils;
|
||||
import com.ebts.common.utils.ServerResult;
|
||||
import com.ebts.generator.dao.*;
|
||||
|
|
@ -41,6 +43,8 @@ public class TopQueryServiceImpl implements TopQueryService {
|
|||
private UniQueryDao uniQueryDao;
|
||||
@Resource
|
||||
private UniColumnInfoDao uniColumnInfoDao;
|
||||
// @Resource
|
||||
// private Dict
|
||||
|
||||
@Override
|
||||
public Map<String, Object> selectTopSearchTables() {
|
||||
|
|
@ -147,7 +151,15 @@ public class TopQueryServiceImpl implements TopQueryService {
|
|||
sql.append(selectQuery);
|
||||
PageHelper.startPage(1, 10, "");
|
||||
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql.toString());
|
||||
TopResult topResult = new TopResult(dataMap, uniCons,infoList);
|
||||
Map<String,List<DictData>> dictList = new HashMap<>();
|
||||
infoList.forEach(info ->{
|
||||
if (info.getDictType()!=null){
|
||||
//todo 后期优化不适用循环
|
||||
dictList.put(info.getDictType(),DictUtils.getDictCache(info.getDictType()));
|
||||
}
|
||||
});
|
||||
|
||||
TopResult topResult = new TopResult(dataMap, uniCons,infoList,dictList);
|
||||
return Result.ok(topResult);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ public class RelColumnInfo {
|
|||
private String prop;
|
||||
private String label;
|
||||
|
||||
private String dictType;
|
||||
|
||||
public long getQueryId() {
|
||||
return queryId;
|
||||
}
|
||||
|
|
@ -29,4 +31,12 @@ public class RelColumnInfo {
|
|||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType) {
|
||||
this.dictType = dictType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,17 +4,20 @@ import com.ebts.system.entity.RealUniQuery;
|
|||
import com.ebts.system.entity.RelColumnInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RealInfo {
|
||||
private List<RealUniQuery> uniCons;
|
||||
private List<RelColumnInfo> infoList;
|
||||
private Map<String,?> dictList;
|
||||
|
||||
public RealInfo() {
|
||||
}
|
||||
|
||||
public RealInfo(List<RealUniQuery> uniCons, List<RelColumnInfo> infoList) {
|
||||
public RealInfo(List<RealUniQuery> uniCons, List<RelColumnInfo> infoList,Map<String,?> dictList) {
|
||||
this.uniCons = uniCons;
|
||||
this.infoList = infoList;
|
||||
this.dictList = dictList;
|
||||
}
|
||||
|
||||
public List<RealUniQuery> getUniCons() {
|
||||
|
|
@ -29,7 +32,16 @@ public class RealInfo {
|
|||
return infoList;
|
||||
}
|
||||
|
||||
public Map<String, ?> getDictList() {
|
||||
return dictList;
|
||||
}
|
||||
|
||||
public void setDictList(Map<String, ?> dictList) {
|
||||
this.dictList = dictList;
|
||||
}
|
||||
|
||||
public void setInfoList(List<RelColumnInfo> infoList) {
|
||||
|
||||
this.infoList = infoList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.ebts.system.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ebts.common.constant.ReturnConstants;
|
||||
import com.ebts.common.core.entity.Result;
|
||||
import com.ebts.common.core.entity.entity.DictData;
|
||||
import com.ebts.common.utils.DictUtils;
|
||||
import com.ebts.system.dao.RealQueryServiceDao;
|
||||
import com.ebts.system.entity.RealUniCon;
|
||||
import com.ebts.system.entity.RealUniQuery;
|
||||
|
|
@ -18,6 +20,7 @@ import org.springframework.transaction.annotation.Propagation;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -42,7 +45,13 @@ public class RealQueryServiceImpl implements RealQueryService {
|
|||
public Result<RealInfo> RealInfo(Long id) {
|
||||
List<RealUniQuery> uniCons = realQueryServiceDao.queryRealInfo(id);
|
||||
List<RelColumnInfo> infoList = realQueryServiceDao.queryRealColumnInfo(id);
|
||||
return Result.ok(new RealInfo(uniCons,infoList));
|
||||
Map<String,List<DictData>> dictList = new HashMap<>();
|
||||
infoList.forEach(info->{
|
||||
if (info.getDictType()!=null){
|
||||
dictList.put(info.getDictType(), DictUtils.getDictCache(info.getDictType()));
|
||||
}
|
||||
});
|
||||
return Result.ok(new RealInfo(uniCons,infoList,dictList));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -43,6 +43,6 @@
|
|||
${paramSQL}
|
||||
</select>
|
||||
<select id="queryRealColumnInfo" resultType="com.ebts.system.entity.RelColumnInfo">
|
||||
select label,prop from gen_uni_column_info where query_id = #{id}
|
||||
select label,prop,dict_type from gen_uni_column_info where query_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue