Merge branch 'main' of github.com:dataease/dataease into main

This commit is contained in:
taojinlong 2021-05-10 18:06:28 +08:00
commit 26b6bddee7
3 changed files with 24 additions and 6 deletions

View File

@ -2,16 +2,19 @@ package io.dataease.commons.utils;
public class DorisTableUtils { public class DorisTableUtils {
public static String dorisName(String datasetId){ public static String dorisName(String datasetId) {
return "ds_" + datasetId.replace("-", "_"); return "ds_" + datasetId.replace("-", "_");
} }
public static String dorisTmpName(String dorisName){ public static String dorisTmpName(String dorisName) {
return "tmp_" + dorisName; return "tmp_" + dorisName;
} }
public static String dorisDeleteName(String dorisName){ public static String dorisDeleteName(String dorisName) {
return "delete_" + dorisName; return "delete_" + dorisName;
} }
public static String dorisFieldName(String dorisName) {
return "f_" + Md5Utils.md5(dorisName);
}
} }

View File

@ -371,6 +371,20 @@ public class DataSetTableService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
// 获取每个字段在当前de数据库中的name作为sql查询后的remarks返回前端展示
List<DatasetTableField> checkedFieldList = new ArrayList<>();
dataTableInfoDTO.getList().forEach(ele -> {
checkedFieldList.addAll(dataSetTableFieldsService.getListByIds(ele.getCheckedFields()));
});
for (DatasetTableField datasetTableField : checkedFieldList) {
for (TableFiled tableFiled : fields) {
if (StringUtils.equalsIgnoreCase(tableFiled.getFieldName(), DorisTableUtils.dorisFieldName(datasetTableField.getTableId() + "_" + datasetTableField.getDataeaseName()))) {
tableFiled.setRemarks(datasetTableField.getName());
break;
}
}
}
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("fields", fields); map.put("fields", fields);
map.put("data", jsonArray); map.put("data", jsonArray);
@ -379,11 +393,11 @@ public class DataSetTableService {
} }
private String getCustomSQL(DataTableInfoDTO dataTableInfoDTO, List<DataSetTableUnionDTO> list) { private String getCustomSQL(DataTableInfoDTO dataTableInfoDTO, List<DataSetTableUnionDTO> list) {
Map<String, String[]> customInfo = new HashMap<>(); Map<String, String[]> customInfo = new TreeMap<>();
dataTableInfoDTO.getList().forEach(ele -> { dataTableInfoDTO.getList().forEach(ele -> {
String table = DorisTableUtils.dorisName(ele.getTableId()); String table = DorisTableUtils.dorisName(ele.getTableId());
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIds(ele.getCheckedFields()); List<DatasetTableField> fields = dataSetTableFieldsService.getListByIds(ele.getCheckedFields());
String[] array = fields.stream().map(f -> table + "." + f.getDataeaseName()).toArray(String[]::new); String[] array = fields.stream().map(f -> table + "." + f.getDataeaseName() + " AS " + DorisTableUtils.dorisFieldName(ele.getTableId() + "_" + f.getDataeaseName())).toArray(String[]::new);
customInfo.put(table, array); customInfo.put(table, array);
}); });
DataTableInfoCustomUnion first = dataTableInfoDTO.getList().get(0); DataTableInfoCustomUnion first = dataTableInfoDTO.getList().get(0);
@ -468,6 +482,7 @@ public class DataSetTableService {
datasetTableField.setId(null); datasetTableField.setId(null);
datasetTableField.setTableId(datasetTable.getId()); datasetTableField.setTableId(datasetTable.getId());
datasetTableField.setColumnIndex(i); datasetTableField.setColumnIndex(i);
datasetTableField.setDataeaseName(DorisTableUtils.dorisFieldName(datasetTable.getId() + "_" + datasetTableField.getDataeaseName()));
} }
dataSetTableFieldsService.batchEdit(fieldList); dataSetTableFieldsService.batchEdit(fieldList);
// custom 创建doris视图 // custom 创建doris视图

View File

@ -28,7 +28,7 @@
<el-col class="panel-height" style="width: 235px;border-top:solid 1px #dcdfe6;padding: 0 15px;overflow-y: auto;"> <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" /> <dataset-custom-field :table="table" :checked-list="checkedList" @getChecked="getChecked" />
</el-col> </el-col>
<el-col class="panel-height" style="flex: 1;"> <el-col class="panel-height" style="flex: 1;overflow: scroll;">
<ux-grid <ux-grid
ref="plxTable" ref="plxTable"
size="mini" size="mini"