|
@@ -184,7 +184,10 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
.attrType(dataResourceEnum.getAttrType().getValue()).label(dataResourceEnum.getLabel()).build();
|
|
|
|
|
|
DataResourceTreeVo topTreeVo = DataResourceTreeVo.builder().id(dataResourceEnum.getCode()).label("全部")
|
|
|
- .code(dataResourceEnum.getCode()).treeNode(true).build();
|
|
|
+ .code(dataResourceEnum.getCode())
|
|
|
+ .classifyCode(dataResourceEnum.getCode())
|
|
|
+ .treeNode(true)
|
|
|
+ .build();
|
|
|
List<DataCla> dataClaList = dataClaService.getAllDataCla();
|
|
|
Map<String, List<DataCla>> levelMap = dataClaList.stream().collect(Collectors.groupingBy(DataCla::getLevel));
|
|
|
//一级节点
|
|
@@ -209,8 +212,8 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
resourceVo.setTotal(0);
|
|
|
} else {
|
|
|
// 拼接表、列、pid
|
|
|
- boolean b = combinePidAndTableInfo(topTreeVo, tabLabMap, dataResourceEnum);
|
|
|
- if (b) {
|
|
|
+ int count = combinePidAndTableInfo(topTreeVo, tabLabMap, dataResourceEnum);
|
|
|
+ if (count == 0) {
|
|
|
resourceVo.setNodes(new ArrayList<>());
|
|
|
resourceVo.setTotal(0);
|
|
|
} else {
|
|
@@ -218,7 +221,7 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
add(topTreeVo);
|
|
|
}});
|
|
|
}
|
|
|
-
|
|
|
+ resourceVo.setTotal(count);
|
|
|
}
|
|
|
return resourceVo;
|
|
|
}
|
|
@@ -291,6 +294,7 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
.pId(pid)
|
|
|
.label(item.getName())
|
|
|
.code(item.getCode())
|
|
|
+ .classifyCode(DataResourceEnum.DATA_RESOURCE_CLASSIFY.getCode())
|
|
|
.build();
|
|
|
}
|
|
|
|
|
@@ -319,7 +323,10 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
.attrType(dataResourceEnum.getAttrType().getValue()).label(dataResourceEnum.getLabel()).build();
|
|
|
|
|
|
DataResourceTreeVo topTreeVo = DataResourceTreeVo.builder().id(dataResourceEnum.getCode()).label("全部")
|
|
|
- .code(dataResourceEnum.getCode()).treeNode(true).build();
|
|
|
+ .code(dataResourceEnum.getCode())
|
|
|
+ .classifyCode(dataResourceEnum.getCode())
|
|
|
+ .treeNode(true)
|
|
|
+ .build();
|
|
|
List<FieldCla> fieldClaList = fieldClaService.getAllFieldCla();
|
|
|
Map<String, List<FieldCla>> levelMap = fieldClaList.stream().collect(Collectors.groupingBy(FieldCla::getLevel));
|
|
|
List<DataResourceTreeVo> firNodes = Optional.ofNullable(levelMap.get(FieldClaTypeEnum.FIR.getLevel())).orElse(new ArrayList<>())
|
|
@@ -332,8 +339,8 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
resourceVo.setNodes(new ArrayList<>());
|
|
|
resourceVo.setTotal(0);
|
|
|
} else {
|
|
|
- boolean b = combinePidTabAndCol(topTreeVo, tableMap, colInfosMap, dataResourceEnum);
|
|
|
- if (b) {
|
|
|
+ int count = combinePidTabAndCol(topTreeVo, tableMap, colInfosMap, dataResourceEnum);
|
|
|
+ if (count == 0) {
|
|
|
resourceVo.setNodes(new ArrayList<>());
|
|
|
resourceVo.setTotal(0);
|
|
|
} else {
|
|
@@ -341,6 +348,7 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
add(topTreeVo);
|
|
|
}});
|
|
|
}
|
|
|
+ resourceVo.setTotal(count);
|
|
|
}
|
|
|
return resourceVo;
|
|
|
}
|
|
@@ -349,7 +357,8 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
return colInfos.stream().collect(Collectors.groupingBy(AppDataItemInfo::getColumnClassify));
|
|
|
}
|
|
|
|
|
|
- private boolean combinePidTabAndCol(DataResourceTreeVo treeVo, Map<String, AppDataResourceInfo> tableMap, Map<String, List<AppDataItemInfo>> colInfosMap, DataResourceEnum resourceEnum) {
|
|
|
+ private int combinePidTabAndCol(DataResourceTreeVo treeVo, Map<String, AppDataResourceInfo> tableMap, Map<String, List<AppDataItemInfo>> colInfosMap, DataResourceEnum resourceEnum) {
|
|
|
+ int count = 0;
|
|
|
List<DataResourceTreeVo> child = treeVo.getChild();
|
|
|
Iterator<DataResourceTreeVo> iterator = child.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
@@ -359,9 +368,11 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
List<DataResourceTreeVo> cc = childVo.getChild();
|
|
|
if (CollectionUtils.isNotEmpty(cc)) {
|
|
|
childVo.setTreeNode(true);
|
|
|
- boolean emptyChild = combinePidTabAndCol(childVo, tableMap, colInfosMap, resourceEnum);
|
|
|
- if (emptyChild) {
|
|
|
+ int childCount = combinePidTabAndCol(childVo, tableMap, colInfosMap, resourceEnum);
|
|
|
+ if (childCount == 0) {
|
|
|
iterator.remove();
|
|
|
+ } else {
|
|
|
+ count += childCount;
|
|
|
}
|
|
|
} else {
|
|
|
// 如果为叶子节点,查找对应的表和列
|
|
@@ -379,10 +390,11 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
}).flatMap(List::stream).collect(Collectors.toList());
|
|
|
childVo.setTreeNode(true);
|
|
|
childVo.setChild(tableVos);
|
|
|
+ count += dataColInfo.size();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return CollectionUtils.isEmpty(child);
|
|
|
+ return count;
|
|
|
}
|
|
|
|
|
|
private DataResourceTreeVo convertFieldClaToNode(FieldCla item, String pid) {
|
|
@@ -390,6 +402,7 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
.id(item.getId())
|
|
|
.pId(pid)
|
|
|
.label(item.getName())
|
|
|
+ .classifyCode(DataResourceEnum.COLUMN_CLASSIFY.getCode())
|
|
|
.code(item.getCode())
|
|
|
.build();
|
|
|
}
|
|
@@ -785,7 +798,8 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
* @param dataResourceEnum
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean combinePidAndTableInfo(DataResourceTreeVo treeVo, Map<String, List<AppDataResourceInfo>> tabInfosMap, DataResourceEnum dataResourceEnum) {
|
|
|
+ private int combinePidAndTableInfo(DataResourceTreeVo treeVo, Map<String, List<AppDataResourceInfo>> tabInfosMap, DataResourceEnum dataResourceEnum) {
|
|
|
+ int count = 0;
|
|
|
List<DataResourceTreeVo> child = treeVo.getChild();
|
|
|
Iterator<DataResourceTreeVo> iterator = child.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
@@ -795,49 +809,54 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
List<DataResourceTreeVo> cc = childVo.getChild();
|
|
|
if (CollectionUtils.isNotEmpty(cc)) {
|
|
|
childVo.setTreeNode(true);
|
|
|
- boolean emptyChild = combinePidAndTableInfo(childVo, tabInfosMap, dataResourceEnum);
|
|
|
- if (emptyChild) {
|
|
|
+ int childCount = combinePidAndTableInfo(childVo, tabInfosMap, dataResourceEnum);
|
|
|
+ if (childCount == 0) {
|
|
|
iterator.remove();
|
|
|
+ } else {
|
|
|
+ count += childCount;
|
|
|
}
|
|
|
} else {
|
|
|
// 如果为叶子节点,查找对应的表和列
|
|
|
+ // 为字段分类添加表
|
|
|
// 如果查找不到表和列则移除
|
|
|
String id = childVo.getId();
|
|
|
String classifyCode = DataResourceEnum.DATA_RESOURCE_CLASSIFY.getCode();
|
|
|
- if (id.startsWith(classifyCode)) {
|
|
|
- String replace = id.replace(classifyCode + CommonCons.ID_SEPARATOR, "");
|
|
|
- List<AppDataResourceInfo> dataTabInfo = tabInfosMap.get(replace);
|
|
|
- if (dataTabInfo == null) {
|
|
|
- iterator.remove();
|
|
|
- } else {
|
|
|
- List<DataResourceTreeVo> tableVos = convertTableToTreeVo(childVo.getId(), dataTabInfo, null, dataResourceEnum);
|
|
|
- childVo.setTreeNode(true);
|
|
|
- childVo.setChild(tableVos);
|
|
|
- }
|
|
|
+ String replace = id.replace(classifyCode + CommonCons.ID_SEPARATOR, "");
|
|
|
+ List<AppDataResourceInfo> dataTabInfo = tabInfosMap.get(replace);
|
|
|
+ if (dataTabInfo == null) {
|
|
|
+ iterator.remove();
|
|
|
+ } else {
|
|
|
+ List<DataResourceTreeVo> tableVos = convertTableToTreeVo(childVo.getId(), dataTabInfo, null, dataResourceEnum);
|
|
|
+ childVo.setTreeNode(true);
|
|
|
+ childVo.setChild(tableVos);
|
|
|
+ count += tableVos.size();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
- return CollectionUtils.isEmpty(child);
|
|
|
+ return count;
|
|
|
}
|
|
|
|
|
|
private List<DataResourceTreeVo> convertTableToTreeVo(String pid, List<AppDataResourceInfo> dataTabInfo, Map<String, List<AppDataItemInfo>> colInfosMap, DataResourceEnum resourceEnum) {
|
|
|
return dataTabInfo.stream().map(e -> {
|
|
|
DataResourceTreeVo vo = new DataResourceTreeVo();
|
|
|
- vo.setId(e.getId());
|
|
|
+ // 因为表可能属于多个字段分类,前端树结构需要唯一id
|
|
|
+ vo.setId(pid + CommonCons.ID_SEPARATOR + e.getId());
|
|
|
vo.setPId(pid);
|
|
|
vo.setLabel(e.getTableName());
|
|
|
vo.setClassifyCode(resourceEnum.getCode());
|
|
|
if (null != colInfosMap) {
|
|
|
List<AppDataItemInfo> colInfoList = colInfosMap.get(e.getId());
|
|
|
if (CollectionUtils.isNotEmpty(colInfoList)) {
|
|
|
- List<DataResourceTreeVo> colVos = convertColumnToTreeVo(e.getId(), colInfoList, resourceEnum);
|
|
|
+ List<DataResourceTreeVo> colVos = convertColumnToTreeVo(vo.getId(), colInfoList, resourceEnum);
|
|
|
vo.setChild(colVos);
|
|
|
vo.setTreeNode(true);
|
|
|
} else {
|
|
|
vo.setChild(Collections.emptyList());
|
|
|
vo.setTreeNode(false);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ vo.setChild(Collections.emptyList());
|
|
|
+ vo.setTreeNode(false);
|
|
|
}
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
@@ -850,6 +869,7 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
vo.setPId(pid);
|
|
|
vo.setLabel(e.getColumnName());
|
|
|
vo.setClassifyCode(resourceEnum.getCode());
|
|
|
+ vo.setTreeNode(false);
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|