forked from github/dataease
feat(数据集): 关联数据集
This commit is contained in:
parent
9dd4178566
commit
a1909f59cd
@ -1083,9 +1083,7 @@ public class DataSetTableService {
|
||||
DEException.throwException(Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
DEException.throwException(Translator.get("i18n_cst_ds_tb_or_field_deleted") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
|
||||
String[] array = fields.stream().map(f -> table + "." + f.getDataeaseName() + " AS " + DorisTableUtils.dorisFieldName(tableId + "_" + f.getDataeaseName())).toArray(String[]::new);
|
||||
checkedInfo.put(table, array);
|
||||
checkedFields.addAll(fields);
|
||||
@ -1103,7 +1101,7 @@ public class DataSetTableService {
|
||||
Map.Entry<String, String[]> next = iterator.next();
|
||||
field.append(StringUtils.join(next.getValue(), ",")).append(",");
|
||||
}
|
||||
String f = field.substring(0, field.length() - 1);
|
||||
String f = subPrefixSuffixChar(field.toString());
|
||||
// join
|
||||
StringBuilder join = new StringBuilder();
|
||||
for (UnionParamDTO unionParamDTO : unionList) {
|
||||
@ -1134,13 +1132,13 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(f)) {
|
||||
DEException.throwException(Translator.get("i18n_custom_ds_delete"));
|
||||
DEException.throwException(Translator.get("i18n_union_ds_no_checked"));
|
||||
}
|
||||
sql = MessageFormat.format("SELECT {0} FROM {1}", f, DorisTableUtils.dorisName(union.get(0).getCurrentDs().getId())) + join.toString();
|
||||
} else {
|
||||
String f = StringUtils.join(checkedInfo.get(DorisTableUtils.dorisName(union.get(0).getCurrentDs().getId())), ",");
|
||||
if (StringUtils.isEmpty(f)) {
|
||||
throw new RuntimeException(Translator.get("i18n_custom_ds_delete"));
|
||||
throw new RuntimeException(Translator.get("i18n_union_ds_no_checked"));
|
||||
}
|
||||
sql = MessageFormat.format("SELECT {0} FROM {1}", f, DorisTableUtils.dorisName(union.get(0).getCurrentDs().getId()));
|
||||
}
|
||||
@ -1162,9 +1160,7 @@ public class DataSetTableService {
|
||||
DEException.throwException(Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
DEException.throwException(Translator.get("i18n_cst_ds_tb_or_field_deleted") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
|
||||
String[] array = fields.stream().map(f -> table + "." + f.getDataeaseName() + " AS " + DorisTableUtils.dorisFieldName(tableId + "_" + f.getDataeaseName())).toArray(String[]::new);
|
||||
checkedInfo.put(table, array);
|
||||
checkedFields.addAll(fields);
|
||||
@ -1196,9 +1192,7 @@ public class DataSetTableService {
|
||||
DEException.throwException(Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
DEException.throwException(Translator.get("i18n_cst_ds_tb_or_field_deleted") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
|
||||
String[] array = fields.stream().map(f -> String.format(keyword, table) + "." + String.format(keyword, f.getOriginName()) + " AS " + DorisTableUtils.dorisFieldNameShort(tableId + "_" + f.getOriginName())).toArray(String[]::new);
|
||||
checkedInfo.put(table, array);
|
||||
checkedFields.addAll(fields);
|
||||
@ -1216,7 +1210,7 @@ public class DataSetTableService {
|
||||
Map.Entry<String, String[]> next = iterator.next();
|
||||
field.append(StringUtils.join(next.getValue(), ",")).append(",");
|
||||
}
|
||||
String f = field.substring(0, field.length() - 1);
|
||||
String f = subPrefixSuffixChar(field.toString());
|
||||
// join
|
||||
StringBuilder join = new StringBuilder();
|
||||
for (UnionParamDTO unionParamDTO : unionList) {
|
||||
@ -1249,13 +1243,13 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(f)) {
|
||||
DEException.throwException(Translator.get("i18n_custom_ds_delete"));
|
||||
DEException.throwException(Translator.get("i18n_union_ds_no_checked"));
|
||||
}
|
||||
sql = MessageFormat.format("SELECT {0} FROM {1}", f, String.format(keyword, tableName)) + join.toString();
|
||||
} else {
|
||||
String f = StringUtils.join(checkedInfo.get(tableName), ",");
|
||||
if (StringUtils.isEmpty(f)) {
|
||||
throw new RuntimeException(Translator.get("i18n_custom_ds_delete"));
|
||||
throw new RuntimeException(Translator.get("i18n_union_ds_no_checked"));
|
||||
}
|
||||
sql = MessageFormat.format("SELECT {0} FROM {1}", f, String.format(keyword, tableName));
|
||||
}
|
||||
@ -1266,6 +1260,16 @@ public class DataSetTableService {
|
||||
return map;
|
||||
}
|
||||
|
||||
private String subPrefixSuffixChar(String str) {
|
||||
while (StringUtils.startsWith(str, ",")) {
|
||||
str = str.substring(1, str.length());
|
||||
}
|
||||
while (StringUtils.endsWith(str, ",")) {
|
||||
str = str.substring(0, str.length() - 1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
// 递归计算出所有子级的checkedFields和unionParam
|
||||
private void getUnionSQLDatasourceJoin(List<UnionDTO> childrenDs, Map<String, String[]> checkedInfo, List<UnionParamDTO> unionList, String keyword, List<DatasetTableField> checkedFields) {
|
||||
for (int i = 0; i < childrenDs.size(); i++) {
|
||||
@ -1279,9 +1283,7 @@ public class DataSetTableService {
|
||||
String table = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
|
||||
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
DEException.throwException(Translator.get("i18n_cst_ds_tb_or_field_deleted") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
|
||||
String[] array = fields.stream().map(f -> String.format(keyword, table) + "." + String.format(keyword, f.getOriginName()) + " AS " + DorisTableUtils.dorisFieldNameShort(tableId + "_" + f.getOriginName())).toArray(String[]::new);
|
||||
checkedInfo.put(table, array);
|
||||
checkedFields.addAll(fields);
|
||||
|
@ -289,4 +289,5 @@ i18n_Exec=Running
|
||||
i18n_no_trigger=The current setting does not trigger task generation.
|
||||
i18n_dataset_field_delete=Union field deleted,please set again and redo.
|
||||
i18n_es_limit=Elasticsearch version cannot be less than 6.3
|
||||
i18n_ds_error=Preview fail:Execute SQL error。Cause field、table、dataset changed,please check
|
||||
i18n_ds_error=Preview fail:Execute SQL error。Cause field、table、dataset changed,please check
|
||||
i18n_union_ds_no_checked=This union dataset no checked field,please edit
|
@ -289,3 +289,4 @@ i18n_no_trigger=当前设置没有触发任务生成
|
||||
i18n_dataset_field_delete=该自定义数据集有关联字段被删除,请重新确认关联关系并重做该数据集
|
||||
i18n_es_limit=Elasticsearch 版本不能小于6.3
|
||||
i18n_ds_error=预览数据错误:执行SQL失败。可能因相关字段、表、数据集等元素发生变更,请检查
|
||||
i18n_union_ds_no_checked=当前关联数据集,无选中字段,请重新编辑
|
||||
|
@ -291,4 +291,5 @@ i18n_Exec=運行中
|
||||
i18n_no_trigger=当前设置没有触发任务生成 當前設置沒有觸發任務生成.
|
||||
i18n_dataset_field_delete=該自定義數據集有關聯字段被刪除,請重新確認關聯關系並重做該數據集
|
||||
i18n_es_limit=Elasticsearch 版本不能小於6.3
|
||||
i18n_ds_error=預覽數據錯誤:執行SQL失敗。可能因相關字段、表、數據集等元素發生變更,請檢查
|
||||
i18n_ds_error=預覽數據錯誤:執行SQL失敗。可能因相關字段、表、數據集等元素發生變更,請檢查
|
||||
i18n_union_ds_no_checked=當前關聯數據集,無選中字段,請重新編輯
|
@ -310,8 +310,8 @@ export default {
|
||||
}
|
||||
.union-container{
|
||||
display: flex;
|
||||
width:100%;
|
||||
height:400px;
|
||||
width: 100%;
|
||||
height: calc(100vh - 200px);
|
||||
overflow: auto;
|
||||
}
|
||||
.form-item{
|
||||
|
Loading…
Reference in New Issue
Block a user