forked from github/dataease
refactor(仪表板、数据大屏): 优化Excel、API数据源应用的兼容问题
This commit is contained in:
parent
5ba3cd166b
commit
4b7b7099c8
@ -53,6 +53,20 @@ public class ApiUtils {
|
||||
return tableDescs;
|
||||
}
|
||||
|
||||
public static Map<String,String> getTableNamesMap(String configration) throws DEException {
|
||||
Map<String,String> result = new HashMap<>();
|
||||
try {
|
||||
JsonNode rootNode = objectMapper.readTree(configration);
|
||||
for (int i = 0; i < rootNode.size(); i++) {
|
||||
result.put(rootNode.get(i).get("name").asText(),rootNode.get(i).get("deTableName").asText());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static Map<String, Object> fetchResultField(DatasourceRequest datasourceRequest) throws DEException {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
@ -16,6 +16,7 @@ import io.dataease.dataset.manage.DatasetDataManage;
|
||||
import io.dataease.dataset.manage.DatasetGroupManage;
|
||||
import io.dataease.datasource.dao.auto.entity.CoreDatasource;
|
||||
import io.dataease.datasource.dao.auto.mapper.CoreDatasourceMapper;
|
||||
import io.dataease.datasource.provider.ApiUtils;
|
||||
import io.dataease.datasource.provider.ExcelUtils;
|
||||
import io.dataease.extensions.datasource.dto.DatasetTableDTO;
|
||||
import io.dataease.extensions.datasource.dto.DatasetTableFieldDTO;
|
||||
@ -203,16 +204,24 @@ public class DataVisualizationServer implements DataVisualizationApi {
|
||||
appCoreDatasourceVO.forEach(datasourceOld ->{
|
||||
newDatasourceId.add(datasourceOld.getSystemDatasourceId());
|
||||
// Excel 数据表明映射
|
||||
if (StringUtils.isNotEmpty(datasourceOld.getConfiguration()) && datasourceOld.getType().equals(DatasourceConfiguration.DatasourceType.Excel.name())) {
|
||||
dsTableNamesMap.put(datasourceOld.getId(),ExcelUtils.getTableNamesMap(datasourceOld.getConfiguration()));
|
||||
if (StringUtils.isNotEmpty(datasourceOld.getConfiguration())) {
|
||||
if( datasourceOld.getType().equals(DatasourceConfiguration.DatasourceType.Excel.name())){
|
||||
dsTableNamesMap.put(datasourceOld.getId(),ExcelUtils.getTableNamesMap(datasourceOld.getConfiguration()));
|
||||
}else if(datasourceOld.getType().equals(DatasourceConfiguration.DatasourceType.API.name())){
|
||||
dsTableNamesMap.put(datasourceOld.getId(), ApiUtils.getTableNamesMap(datasourceOld.getConfiguration()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<CoreDatasource> systemDatasource = coreDatasourceMapper.selectBatchIds(newDatasourceId);
|
||||
systemDatasource.forEach(datasourceNew ->{
|
||||
// Excel 数据表明映射
|
||||
if (StringUtils.isNotEmpty(datasourceNew.getConfiguration()) && datasourceNew.getType().equals(DatasourceConfiguration.DatasourceType.Excel.name())) {
|
||||
dsTableNamesMap.put(datasourceNew.getId(),ExcelUtils.getTableNamesMap(datasourceNew.getConfiguration()));
|
||||
if (StringUtils.isNotEmpty(datasourceNew.getConfiguration())) {
|
||||
if(datasourceNew.getType().equals(DatasourceConfiguration.DatasourceType.Excel.name())){
|
||||
dsTableNamesMap.put(datasourceNew.getId(),ExcelUtils.getTableNamesMap(datasourceNew.getConfiguration()));
|
||||
}else if(datasourceNew.getType().equals(DatasourceConfiguration.DatasourceType.API.name())){
|
||||
dsTableNamesMap.put(datasourceNew.getId(), ApiUtils.getTableNamesMap(datasourceNew.getConfiguration()));
|
||||
}
|
||||
}
|
||||
});
|
||||
datasourceIdMap.putAll(appData.getDatasourceInfo().stream()
|
||||
|
@ -1,8 +1,12 @@
|
||||
package io.dataease.visualization.utils;
|
||||
|
||||
|
||||
import io.dataease.datasource.provider.ApiUtils;
|
||||
import io.dataease.datasource.provider.ExcelUtils;
|
||||
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
|
||||
import io.dataease.extensions.view.dto.ChartViewDTO;
|
||||
import io.dataease.utils.JsonUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -131,6 +131,7 @@ import {
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElMessage,
|
||||
ElTreeSelect
|
||||
} from 'element-plus-secondary'
|
||||
import { computed, PropType, reactive, ref, toRefs } from 'vue'
|
||||
@ -289,6 +290,16 @@ const close = () => {
|
||||
}
|
||||
|
||||
const saveApp = () => {
|
||||
let datasourceMatchReady = true
|
||||
state.appData.datasourceInfo.forEach(datasource => {
|
||||
if (!datasource.systemDatasourceId) {
|
||||
datasourceMatchReady = false
|
||||
}
|
||||
})
|
||||
if (!datasourceMatchReady) {
|
||||
ElMessage.error('存在未配置的数据源')
|
||||
return
|
||||
}
|
||||
appSaveForm.value?.validate(valid => {
|
||||
if (valid) {
|
||||
// 还原datasource
|
||||
|
Loading…
Reference in New Issue
Block a user