Unverified 提交 f8bc421a authored 作者: XiaJunjie2020's avatar XiaJunjie2020 提交者: GitHub

Merge pull request #242 from dataease/pr@dev@feat_同数据源直连数据集之间支持数据关联

feat: 同数据源直连数据集之间支持数据关联
......@@ -20,12 +20,14 @@ import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.datasource.service.DatasourceService;
import io.dataease.dto.chart.*;
import io.dataease.dto.dataset.DataSetTableUnionDTO;
import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.i18n.Translator;
import io.dataease.listener.util.CacheUtils;
import io.dataease.provider.QueryProvider;
import io.dataease.service.dataset.DataSetTableFieldsService;
import io.dataease.service.dataset.DataSetTableService;
import io.dataease.service.dataset.DataSetTableUnionService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -56,6 +58,8 @@ public class ChartViewService {
private DataSetTableFieldsService dataSetTableFieldsService;
@Resource
private ExtChartGroupMapper extChartGroupMapper;
@Resource
private DataSetTableUnionService dataSetTableUnionService;
//默认使用非公平
private ReentrantLock lock = new ReentrantLock();
......@@ -197,6 +201,15 @@ public class ChartViewService {
} else {
datasourceRequest.setQuery(qp.getSQLAsTmp(dataTableInfoDTO.getSql(), xAxis, yAxis, customFilter, extFilterList));
}
} else if (StringUtils.equalsIgnoreCase(table.getType(), "custom")) {
DataTableInfoDTO dt = new Gson().fromJson(table.getInfo(), DataTableInfoDTO.class);
List<DataSetTableUnionDTO> list = dataSetTableUnionService.listByTableId(dt.getList().get(0).getTableId());
String sql = dataSetTableService.getCustomSQLDatasource(dt, list, ds);
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType())) {
datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, customFilter, extFilterList));
} else {
datasourceRequest.setQuery(qp.getSQLAsTmp(sql, xAxis, yAxis, customFilter, extFilterList));
}
}
data = datasourceProvider.getData(datasourceRequest);
/**
......
......@@ -954,7 +954,8 @@ export default {
left_join: 'LEFT JOIN',
right_join: 'RIGHT JOIN',
inner_join: 'INNER JOIN',
full_join: 'FULL JOIN'
full_join: 'FULL JOIN',
can_not_union_diff_datasource: 'Union dataset must have same data source'
},
datasource: {
datasource: 'Data Source',
......
......@@ -954,7 +954,8 @@ export default {
left_join: '左連接',
right_join: '右連接',
inner_join: '內連接',
full_join: '全連接'
full_join: '全連接',
can_not_union_diff_datasource: '被關聯數據集必須與當前數據集的數據源一致'
},
datasource: {
datasource: '數據源',
......
......@@ -954,7 +954,8 @@ export default {
left_join: '左连接',
right_join: '右连接',
inner_join: '内连接',
full_join: '全连接'
full_join: '全连接',
can_not_union_diff_datasource: '被关联数据集必须与当前数据集的数据源一致'
},
datasource: {
datasource: '数据源',
......
......@@ -23,7 +23,7 @@
</el-row>
<el-col style="display: flex;flex-direction: row">
<el-col class="panel-height" style="width: 220px;border-right:solid 1px #dcdfe6;border-top:solid 1px #dcdfe6;padding-right: 15px;overflow-y: auto;">
<dataset-group-selector :custom-type="customType" :table="table" :mode="1" :checked-list="checkedList" :union-data="unionData" @getTable="getTable" />
<dataset-group-selector :custom-type="customType" :table="table" :checked-list="checkedList" :union-data="unionData" @getTable="getTable" />
</el-col>
<el-col class="panel-height" style="width: 235px;border-top:solid 1px #dcdfe6;padding: 0 15px;overflow-y: auto;">
<dataset-custom-field :table="table" :checked-list="checkedList" @getChecked="getChecked" />
......@@ -151,9 +151,9 @@ export default {
id: this.param.tableId,
name: this.name,
sceneId: this.param.id,
dataSourceId: null,
dataSourceId: this.param.tableId ? this.param.table.dataSourceId : this.table.dataSourceId,
type: 'custom',
mode: 1,
mode: this.param.tableId ? this.param.table.mode : this.table.mode,
info: '{"list":' + JSON.stringify(this.checkedList) + '}'
}
post('/dataset/table/customPreview', table).then(response => {
......@@ -202,9 +202,9 @@ export default {
id: this.param.tableId,
name: this.name,
sceneId: this.param.id,
dataSourceId: null,
dataSourceId: this.table.dataSourceId,
type: 'custom',
mode: 1,
mode: this.table.mode,
info: '{"list":' + JSON.stringify(this.checkedList) + '}'
}
post('/dataset/table/update', table).then(response => {
......
......@@ -265,7 +265,9 @@ export default {
mode: this.mode < 0 ? null : this.mode,
typeFilter: this.customType ? this.customType : null
}, false).then(response => {
this.tables = response.data
this.tables = response.data.filter(ele => {
return !(ele.mode === 0 && ele.type === 'sql')
})
for (let i = 0; i < this.tables.length; i++) {
if (this.tables[i].mode === 1 && this.kettleRunning === false) {
this.$set(this.tables[i], 'disabled', true)
......
......@@ -81,16 +81,16 @@
</el-table-column>
<el-table-column property="originName" :label="$t('dataset.field_origin_name')" width="100">
<template slot-scope="scope">
<span :title="scope.row.originName" class="field-class" style="display: inline-block;width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
{{ scope.row.originName }}
<span :title="scope.row.originName" class="field-class" style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<span style="font-size: 12px;">{{ scope.row.originName }}</span>
</span>
</template>
</el-table-column>
<el-table-column property="groupType" :label="$t('dataset.field_group_type')" width="180">
<template slot-scope="scope">
<el-radio-group v-model="scope.row.groupType">
<el-radio label="d">{{ $t('chart.dimension') }}</el-radio>
<el-radio label="q">{{ $t('chart.quota') }}</el-radio>
<el-radio-group v-model="scope.row.groupType" size="mini">
<el-radio-button label="d">{{ $t('chart.dimension') }}</el-radio-button>
<el-radio-button label="q">{{ $t('chart.quota') }}</el-radio-button>
</el-radio-group>
</template>
</el-table-column>
......
......@@ -94,7 +94,7 @@
<el-radio class="union-relation-css" label="1:N">{{ $t('dataset.left_join') }}</el-radio>
<el-radio class="union-relation-css" label="N:1">{{ $t('dataset.right_join') }}</el-radio>
<el-radio class="union-relation-css" label="1:1">{{ $t('dataset.inner_join') }}</el-radio>
<el-radio class="union-relation-css" label="N:N">{{ $t('dataset.full_join') }}</el-radio>
<!-- <el-radio class="union-relation-css" label="N:N">{{ $t('dataset.full_join') }}</el-radio>-->
</el-radio-group>
</el-col>
......@@ -105,7 +105,7 @@
width="500"
trigger="click"
>
<dataset-group-selector-tree :fix-height="true" show-mode="union" :custom-type="customType" :mode="1" @getTable="getTable" />
<dataset-group-selector-tree :fix-height="true" show-mode="union" :custom-type="customType" :mode="table.mode" @getTable="getTable" />
<el-button slot="reference" size="mini" style="width: 100%;">
<p class="table-name-css" :title="targetTable.name || $t('dataset.pls_slc_union_table')">{{ targetTable.name || $t('dataset.pls_slc_union_table') }}</p>
</el-button>
......@@ -204,6 +204,9 @@ export default {
},
initUnion() {
if (this.table.id) {
if (this.table.mode === 0) {
this.customType = ['db']
}
post('dataset/union/listByTableId/' + this.table.id, {}).then(response => {
// console.log(response)
this.unionData = response.data
......@@ -301,6 +304,16 @@ export default {
})
return
}
if (this.table.mode === 0) {
if (param.dataSourceId !== this.table.dataSourceId) {
this.$message({
type: 'error',
message: this.$t('dataset.can_not_union_diff_datasource'),
showClose: true
})
return
}
}
this.targetTable = param
this.union.targetTableId = param.id
this.union.targetTableFieldId = ''
......
......@@ -48,7 +48,7 @@
<el-tab-pane :label="$t('dataset.data_preview')" name="dataPreview">
<tab-data-preview :param="param" :table="table" :fields="fields" :data="data" :page="page" :form="tableViewRowForm" @reSearch="reSearch" />
</el-tab-pane>
<el-tab-pane v-if="table.type !== 'custom' && table.mode === 1" :label="$t('dataset.join_view')" name="joinView">
<el-tab-pane v-if="table.type !== 'custom'" :label="$t('dataset.join_view')" name="joinView">
<union-view :param="param" :table="table" />
</el-tab-pane>
<el-tab-pane v-if="table.mode === 1 && (table.type === 'db' || table.type === 'sql')" :label="$t('dataset.update_info')" name="updateInfo">
......@@ -156,10 +156,10 @@ export default {
},
editSql() {
this.$emit('switchComponent', { name: 'AddSQL', param: { id: this.table.sceneId, tableId: this.table.id }})
this.$emit('switchComponent', { name: 'AddSQL', param: { id: this.table.sceneId, tableId: this.table.id, table: this.table }})
},
editCustom() {
this.$emit('switchComponent', { name: 'AddCustom', param: { id: this.table.sceneId, tableId: this.table.id }})
this.$emit('switchComponent', { name: 'AddCustom', param: { id: this.table.sceneId, tableId: this.table.id, table: this.table }})
},
reSearch(val) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论