|
@@ -1,18 +1,24 @@
|
|
|
package com.dragoninfo.dcuc.app.facade;
|
|
|
|
|
|
import com.dragoninfo.dcuc.app.business.IDataCatalogBusiness;
|
|
|
+import com.dragoninfo.dcuc.app.cons.CommonCons;
|
|
|
import com.dragoninfo.dcuc.app.dto.dataresource.ChildResourceClassify;
|
|
|
import com.dragoninfo.dcuc.app.dto.dataresource.ResourceClassify;
|
|
|
-import com.dragoninfo.dcuc.app.enumresources.DataResourceEnum;
|
|
|
-import com.dragoninfo.dcuc.app.service.IDataResourceService;
|
|
|
import com.dragoninfo.dcuc.app.dto.sub.DataClaAcceptDTO;
|
|
|
import com.dragoninfo.dcuc.app.dto.sub.FieldClaAcceptDTO;
|
|
|
+import com.dragoninfo.dcuc.app.entity.DataColInfo;
|
|
|
+import com.dragoninfo.dcuc.app.entity.DataTabInfo;
|
|
|
import com.dragoninfo.dcuc.app.entity.sub.DataCla;
|
|
|
import com.dragoninfo.dcuc.app.entity.sub.DataLevel;
|
|
|
import com.dragoninfo.dcuc.app.entity.sub.DataSec;
|
|
|
import com.dragoninfo.dcuc.app.entity.sub.FieldCla;
|
|
|
+import com.dragoninfo.dcuc.app.enumresources.DataAttrTypeEnum;
|
|
|
+import com.dragoninfo.dcuc.app.enumresources.DataResourceEnum;
|
|
|
import com.dragoninfo.dcuc.app.enumresources.sub.DataClaTypeEnum;
|
|
|
import com.dragoninfo.dcuc.app.enumresources.sub.FieldClaTypeEnum;
|
|
|
+import com.dragoninfo.dcuc.app.service.IDataColInfoService;
|
|
|
+import com.dragoninfo.dcuc.app.service.IDataResourceService;
|
|
|
+import com.dragoninfo.dcuc.app.service.IDataTabInfoService;
|
|
|
import com.dragoninfo.dcuc.app.service.sub.*;
|
|
|
import com.dragoninfo.dcuc.app.vo.*;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
@@ -24,13 +30,13 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.context.request.RequestAttributes;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* Created by lidr on 2021/4/14
|
|
@@ -40,8 +46,6 @@ import java.util.stream.Collectors;
|
|
|
@RequestMapping(value = "/dcuc/app/dataResourceFacade")
|
|
|
public class DataResourceFacade implements IDataResourceFacade {
|
|
|
|
|
|
- public static final String ID_SEPARATOR = "|";
|
|
|
-
|
|
|
@Autowired
|
|
|
private IDataResourceService dataResourceService;
|
|
|
|
|
@@ -57,6 +61,12 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
@Autowired
|
|
|
private IFieldClaService fieldClaService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IDataTabInfoService tabInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IDataColInfoService colInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IDataCatalogBusiness dataCatalogBusiness;
|
|
|
|
|
@@ -65,17 +75,27 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public List<DataResourceClassifyVo> getAllDataResourceTree(@RequestParam("attrType") String attrType) {
|
|
|
+ public List<DataResourceClassifyVo> getAllDataResourceTree(String attrType) {
|
|
|
List<DataResourceClassifyVo> result = Lists.newArrayList();
|
|
|
-
|
|
|
//列:数据安全级别 字段分类
|
|
|
//表:数据分级 数据资源分类
|
|
|
- if ("TABLE".equals(attrType)) {
|
|
|
+ if (DataAttrTypeEnum.DATA_ATTR_TABLE.getValue().equals(attrType)) {
|
|
|
+ // 查询所有的表和列
|
|
|
+ List<DataTabInfo> tabInfos = tabInfoService.getAllTabInfos();
|
|
|
+ List<DataColInfo> colInfos = colInfoService.getAllColInfos();
|
|
|
result.add(getDataLevelTree());
|
|
|
- result.add(getDataClassifyTree());
|
|
|
+ result.add(getDataClassifyTree(tabInfos, colInfos));
|
|
|
+ } else if (DataAttrTypeEnum.DATA_ATTR_COLUMN.getValue().equals(attrType)) {
|
|
|
+ List<DataColInfo> colInfos = colInfoService.getAllColInfos();
|
|
|
+ result.add(getSecurityLevelTree());
|
|
|
+ result.add(getFieldClassifyTree(colInfos));
|
|
|
} else {
|
|
|
+ List<DataTabInfo> tabInfos = tabInfoService.getAllTabInfos();
|
|
|
+ List<DataColInfo> colInfos = colInfoService.getAllColInfos();
|
|
|
+ result.add(getDataLevelTree());
|
|
|
+ result.add(getDataClassifyTree(tabInfos, colInfos));
|
|
|
result.add(getSecurityLevelTree());
|
|
|
- result.add(getFieldClassifyTree());
|
|
|
+ result.add(getFieldClassifyTree(colInfos));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -84,19 +104,23 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
public DataResourceClassifyVo getDataResourceTree(String typeCode) {
|
|
|
DataResourceClassifyVo result = null;
|
|
|
DataResourceEnum dataResourceEnum = Enum.valueOf(DataResourceEnum.class, typeCode);
|
|
|
+ List<DataColInfo> colInfos = null;
|
|
|
+ List<DataTabInfo> tabInfos = null;
|
|
|
switch (dataResourceEnum) {
|
|
|
case DATA_CLASSIFY:
|
|
|
result = getDataLevelTree();
|
|
|
break;
|
|
|
case COLUMN_CLASSIFY:
|
|
|
- result = getFieldClassifyTree();
|
|
|
+ colInfos = colInfoService.getAllColInfos();
|
|
|
+ result = getFieldClassifyTree(colInfos);
|
|
|
break;
|
|
|
-
|
|
|
case DATA_SECURITY_LEVEL:
|
|
|
result = getSecurityLevelTree();
|
|
|
break;
|
|
|
case DATA_RESOURCE_CLASSIFY:
|
|
|
- result = getDataClassifyTree();
|
|
|
+ tabInfos = tabInfoService.getAllTabInfos();
|
|
|
+ colInfos = colInfoService.getAllColInfos();
|
|
|
+ result = getDataClassifyTree(tabInfos, colInfos);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -120,11 +144,11 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
.build();
|
|
|
List<DataLevelVo> dataLevelList = getDataLevelList();
|
|
|
List<DataResourceTreeVo> child = dataLevelList.stream().map(item -> DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(dataLevelTreeVo.getId(), item.getLevelCode()))
|
|
|
+ .id(Joiner.on(CommonCons.ID_SEPARATOR).join(dataLevelTreeVo.getId(), item.getLevelCode()))
|
|
|
.code(item.getLevelCode())
|
|
|
.label(item.getLevelName())
|
|
|
.dataType(item.getTypeCode())
|
|
|
- .codeDataTypeStr(UUIDUtils.getUUID() + ID_SEPARATOR + item.getLevelCode() + ID_SEPARATOR + item.getTypeCode())
|
|
|
+ .codeDataTypeStr(UUIDUtils.getUUID() + CommonCons.ID_SEPARATOR + item.getLevelCode() + CommonCons.ID_SEPARATOR + item.getTypeCode())
|
|
|
.treeNode(false)
|
|
|
.pId(dataLevelTreeVo.getId())
|
|
|
.innerId(item.getInnerId()).build()).collect(Collectors.toList());
|
|
@@ -159,11 +183,11 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
List<DataLevelVo> securityLevelList = getSecurityLevelList();
|
|
|
|
|
|
List<DataResourceTreeVo> child = securityLevelList.stream().map(item -> DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(securityLevelTree.getId(), item.getLevelCode()))
|
|
|
+ .id(Joiner.on(CommonCons.ID_SEPARATOR).join(securityLevelTree.getId(), item.getLevelCode()))
|
|
|
.code(item.getLevelCode())
|
|
|
.label(item.getLevelName())
|
|
|
.dataType(item.getTypeCode())
|
|
|
- .codeDataTypeStr(UUIDUtils.getUUID() + ID_SEPARATOR + item.getLevelCode() + ID_SEPARATOR + item.getTypeCode())
|
|
|
+ .codeDataTypeStr(UUIDUtils.getUUID() + CommonCons.ID_SEPARATOR + item.getLevelCode() + CommonCons.ID_SEPARATOR + item.getTypeCode())
|
|
|
.treeNode(false)
|
|
|
.pId(securityLevelTree.getId())
|
|
|
.innerId(item.getInnerId()).build()).collect(Collectors.toList());
|
|
@@ -181,7 +205,11 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
return dataResourceClassifyVo;
|
|
|
}
|
|
|
|
|
|
- private DataResourceClassifyVo getDataClassifyTree() {
|
|
|
+ private DataResourceClassifyVo getDataClassifyTree(List<DataTabInfo> tabInfos, List<DataColInfo> colInfos) {
|
|
|
+ // 将表分类映射到表
|
|
|
+ Map<String, List<DataTabInfo>> tabLabMap = getTabLabGroupMap(tabInfos);
|
|
|
+ Map<String, List<DataColInfo>> colTaMap = colInfos.stream().collect(Collectors.groupingBy(DataColInfo::getTaCode));
|
|
|
+
|
|
|
DataResourceEnum dataResourceEnum = DataResourceEnum.DATA_RESOURCE_CLASSIFY;
|
|
|
|
|
|
DataResourceClassifyVo resourceVo = DataResourceClassifyVo.builder().id(dataResourceEnum.getCode())
|
|
@@ -212,15 +240,83 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
resourceVo.setNodes(new ArrayList<>());
|
|
|
resourceVo.setTotal(0);
|
|
|
} else {
|
|
|
- //计算总数量
|
|
|
- resourceVo.setTotal(getTotalCount(topTreeVo));
|
|
|
- resourceVo.setNodes(new ArrayList<DataResourceTreeVo>() {{
|
|
|
- add(topTreeVo);
|
|
|
- }});
|
|
|
+ // 拼接表、列、pid
|
|
|
+ boolean b = combinePidAndTabCol(topTreeVo, tabLabMap, colTaMap);
|
|
|
+ if (b) {
|
|
|
+ resourceVo.setNodes(new ArrayList<>());
|
|
|
+ resourceVo.setTotal(0);
|
|
|
+ } else {
|
|
|
+ resourceVo.setNodes(new ArrayList<DataResourceTreeVo>() {{
|
|
|
+ add(topTreeVo);
|
|
|
+ }});
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return resourceVo;
|
|
|
}
|
|
|
|
|
|
+ private Map<String, List<DataTabInfo>> getTabLabGroupMap(List<DataTabInfo> tabInfos) {
|
|
|
+ Map<String, List<DataTabInfo>> group = new HashMap<>();
|
|
|
+ tabInfos.forEach(e -> {
|
|
|
+ // 一级分类
|
|
|
+ String claFir = e.getDataClaFir();
|
|
|
+ if (StringUtils.isBlank(claFir)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 二级分类
|
|
|
+ String claSec = e.getLabSec();
|
|
|
+ if (StringUtils.isBlank(claSec)) {
|
|
|
+ putInMap(group, e, claFir);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 标签1
|
|
|
+ String labFir = e.getLabFir();
|
|
|
+ if (StringUtils.isNotBlank(labFir)) {
|
|
|
+ labFir = CommonCons.LAB_CLA_FIR + CommonCons.ID_SEPARATOR + labFir;
|
|
|
+ }
|
|
|
+ // 标签2
|
|
|
+ String labSec = e.getLabSec();
|
|
|
+ if (StringUtils.isNotBlank(labSec)) {
|
|
|
+ labSec = CommonCons.LAB_CLA_SEC + CommonCons.ID_SEPARATOR + labSec;
|
|
|
+ }
|
|
|
+ // 标签3
|
|
|
+ String labThr = e.getLabThr();
|
|
|
+ if (StringUtils.isNotBlank(labThr)) {
|
|
|
+ labThr = CommonCons.LAB_CLA_THI + CommonCons.ID_SEPARATOR + labThr;
|
|
|
+ }
|
|
|
+ // 标签4
|
|
|
+ String labFour = e.getLabFour();
|
|
|
+ if (StringUtils.isNotBlank(labFour)) {
|
|
|
+ labFour = CommonCons.LAB_CLA_FOUR + CommonCons.ID_SEPARATOR + labFour;
|
|
|
+ }
|
|
|
+ // 标签5
|
|
|
+ String labFiv = e.getLabFiv();
|
|
|
+ if (StringUtils.isNotBlank(labFiv)) {
|
|
|
+ labFiv = CommonCons.LAB_CLA_FIV + CommonCons.ID_SEPARATOR + labFiv;
|
|
|
+ }
|
|
|
+ List<String> collect = Stream.of(labFir, labSec, labThr, labFour, labFiv).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
|
|
+ String key = claFir + CommonCons.ID_SEPARATOR + claSec;
|
|
|
+ if (CollectionUtils.isEmpty(collect)) {
|
|
|
+ putInMap(group, e, key);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ collect.forEach(lab -> {
|
|
|
+ String s = key + CommonCons.ID_SEPARATOR + lab;
|
|
|
+ putInMap(group, e, s);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return group;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void putInMap(Map<String, List<DataTabInfo>> group, DataTabInfo e, String claFir) {
|
|
|
+ List<DataTabInfo> list = group.get(claFir);
|
|
|
+ if (null == list) {
|
|
|
+ list = new ArrayList<>();
|
|
|
+ }
|
|
|
+ list.add(e);
|
|
|
+ group.put(claFir, list);
|
|
|
+ }
|
|
|
+
|
|
|
private DataResourceTreeVo convertDataClaToNode(DataCla item, String pid) {
|
|
|
return DataResourceTreeVo.builder()
|
|
|
.id(item.getId())
|
|
@@ -233,7 +329,10 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private DataResourceClassifyVo getFieldClassifyTree() {
|
|
|
+ private DataResourceClassifyVo getFieldClassifyTree(List<DataColInfo> colInfos) {
|
|
|
+
|
|
|
+ Map<String, List<DataColInfo>> colInfosMap = getColumnClaGroupMap(colInfos);
|
|
|
+
|
|
|
DataResourceEnum dataResourceEnum = DataResourceEnum.COLUMN_CLASSIFY;
|
|
|
|
|
|
DataResourceClassifyVo resourceVo = DataResourceClassifyVo.builder().id(dataResourceEnum.getCode())
|
|
@@ -253,14 +352,54 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
resourceVo.setNodes(new ArrayList<>());
|
|
|
resourceVo.setTotal(0);
|
|
|
} else {
|
|
|
- resourceVo.setNodes(new ArrayList<DataResourceTreeVo>() {{
|
|
|
- add(topTreeVo);
|
|
|
- }});
|
|
|
- resourceVo.setTotal(getTotalCount(topTreeVo));
|
|
|
+ boolean b = combinePidCol(topTreeVo, colInfosMap);
|
|
|
+ if (b) {
|
|
|
+ resourceVo.setNodes(new ArrayList<>());
|
|
|
+ resourceVo.setTotal(0);
|
|
|
+ } else {
|
|
|
+ resourceVo.setNodes(new ArrayList<DataResourceTreeVo>() {{
|
|
|
+ add(topTreeVo);
|
|
|
+ }});
|
|
|
+ }
|
|
|
}
|
|
|
return resourceVo;
|
|
|
}
|
|
|
|
|
|
+ private Map<String, List<DataColInfo>> getColumnClaGroupMap(List<DataColInfo> colInfos) {
|
|
|
+ return colInfos.stream().collect(Collectors.groupingBy(DataColInfo::getColClaSec));
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean combinePidCol(DataResourceTreeVo treeVo, Map<String, List<DataColInfo>> colInfosMap) {
|
|
|
+ List<DataResourceTreeVo> child = treeVo.getChild();
|
|
|
+ Iterator<DataResourceTreeVo> iterator = child.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ DataResourceTreeVo childVo = iterator.next();
|
|
|
+ childVo.setPId(treeVo.getId());
|
|
|
+ childVo.setId(Joiner.on(CommonCons.ID_SEPARATOR).join(treeVo.getId(), childVo.getCode()));
|
|
|
+ List<DataResourceTreeVo> cc = childVo.getChild();
|
|
|
+ if (CollectionUtils.isNotEmpty(cc)) {
|
|
|
+ childVo.setTreeNode(true);
|
|
|
+ boolean emptyChild = combinePidCol(childVo, colInfosMap);
|
|
|
+ if (emptyChild) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果为叶子节点,查找对应的表和列
|
|
|
+ // 如果查找不到表和列则移除
|
|
|
+ String id = childVo.getId();
|
|
|
+ List<DataColInfo> dataColInfo = colInfosMap.get(childVo.getCode());
|
|
|
+ if (dataColInfo == null) {
|
|
|
+ iterator.remove();
|
|
|
+ } else {
|
|
|
+ List<DataResourceTreeVo> tableVos = convertColumnToTreeVo(childVo.getId(), dataColInfo);
|
|
|
+ childVo.setTreeNode(true);
|
|
|
+ childVo.setChild(tableVos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return CollectionUtils.isEmpty(child);
|
|
|
+ }
|
|
|
+
|
|
|
private DataResourceTreeVo convertFieldClaToNode(FieldCla item, String pid) {
|
|
|
return DataResourceTreeVo.builder()
|
|
|
.id(item.getId())
|
|
@@ -564,49 +703,49 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
.stream()
|
|
|
.map(firstClassify -> {
|
|
|
DataResourceTreeVo firstTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(id, firstClassify.getCodeValue()))
|
|
|
+ .id(Joiner.on(CommonCons.ID_SEPARATOR).join(id, firstClassify.getCodeValue()))
|
|
|
.code(firstClassify.getCodeValue())
|
|
|
.label(firstClassify.getCodeName())
|
|
|
.treeNode(true)
|
|
|
.pId(id)
|
|
|
.dataType(firstClassify.getTypeCode())
|
|
|
- .codeDataTypeStr(UUIDUtils.getUUID() + ID_SEPARATOR + firstClassify.getCodeValue() + ID_SEPARATOR + firstClassify.getTypeCode())
|
|
|
+ .codeDataTypeStr(UUIDUtils.getUUID() + CommonCons.ID_SEPARATOR + firstClassify.getCodeValue() + CommonCons.ID_SEPARATOR + firstClassify.getTypeCode())
|
|
|
.build();
|
|
|
|
|
|
firstTreeVo.setChild(getFirstChildResourceClassifies(firstClassify.getChildrenType()).stream()
|
|
|
.map(secondClassify -> {
|
|
|
DataResourceTreeVo secondTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(firstTreeVo.getId(), secondClassify.getCodeValue()))
|
|
|
+ .id(Joiner.on(CommonCons.ID_SEPARATOR).join(firstTreeVo.getId(), secondClassify.getCodeValue()))
|
|
|
.code(secondClassify.getCodeValue())
|
|
|
.label(secondClassify.getCodeName())
|
|
|
.treeNode(true)
|
|
|
.pId(firstTreeVo.getId())
|
|
|
.dataType(secondClassify.getTypeCode())
|
|
|
- .codeDataTypeStr(UUIDUtils.getUUID() + ID_SEPARATOR + secondClassify.getCodeValue() + ID_SEPARATOR + secondClassify.getTypeCode())
|
|
|
+ .codeDataTypeStr(UUIDUtils.getUUID() + CommonCons.ID_SEPARATOR + secondClassify.getCodeValue() + CommonCons.ID_SEPARATOR + secondClassify.getTypeCode())
|
|
|
.build();
|
|
|
|
|
|
secondTreeVo.setChild(getChildrenTypeList(secondClassify.getChildrenType()).stream()
|
|
|
.map(thirdClassify -> {
|
|
|
DataResourceTreeVo thirdTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(secondTreeVo.getId(), thirdClassify.getTypeCode()))
|
|
|
+ .id(Joiner.on(CommonCons.ID_SEPARATOR).join(secondTreeVo.getId(), thirdClassify.getTypeCode()))
|
|
|
.code(thirdClassify.getTypeCode())
|
|
|
.label(thirdClassify.getTypeName())
|
|
|
.treeNode(true)
|
|
|
.pId(secondTreeVo.getId())
|
|
|
.dataType(thirdClassify.getTypeCode())
|
|
|
- .codeDataTypeStr(UUIDUtils.getUUID() + ID_SEPARATOR + thirdClassify.getTypeCode() + ID_SEPARATOR + thirdClassify.getTypeCode())
|
|
|
+ .codeDataTypeStr(UUIDUtils.getUUID() + CommonCons.ID_SEPARATOR + thirdClassify.getTypeCode() + CommonCons.ID_SEPARATOR + thirdClassify.getTypeCode())
|
|
|
.build();
|
|
|
|
|
|
thirdTreeVo.setChild(thirdClassify.getDataList().stream()
|
|
|
.map(fourClassify -> {
|
|
|
DataResourceTreeVo fourTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(thirdTreeVo.getId(), fourClassify.getCodeValue()))
|
|
|
+ .id(Joiner.on(CommonCons.ID_SEPARATOR).join(thirdTreeVo.getId(), fourClassify.getCodeValue()))
|
|
|
.code(fourClassify.getCodeValue())
|
|
|
.label(fourClassify.getCodeName())
|
|
|
.treeNode(false).child(null)
|
|
|
.pId(thirdTreeVo.getId())
|
|
|
.dataType(thirdClassify.getTypeCode())
|
|
|
- .codeDataTypeStr(UUIDUtils.getUUID() + ID_SEPARATOR + fourClassify.getCodeValue() + ID_SEPARATOR + thirdClassify.getTypeCode())
|
|
|
+ .codeDataTypeStr(UUIDUtils.getUUID() + CommonCons.ID_SEPARATOR + fourClassify.getCodeValue() + CommonCons.ID_SEPARATOR + thirdClassify.getTypeCode())
|
|
|
.build();
|
|
|
return fourTreeVo;
|
|
|
}).collect(Collectors.toList()));
|
|
@@ -630,26 +769,26 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
.stream()
|
|
|
.map(firstClassify -> {
|
|
|
DataResourceTreeVo firstTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(id, firstClassify.getCodeValue()))
|
|
|
+ .id(Joiner.on(CommonCons.ID_SEPARATOR).join(id, firstClassify.getCodeValue()))
|
|
|
.code(firstClassify.getCodeValue())
|
|
|
.label(firstClassify.getCodeName())
|
|
|
.dataType(firstClassify.getTypeCode())
|
|
|
.treeNode(true)
|
|
|
.pId(id)
|
|
|
- .codeDataTypeStr(UUIDUtils.getUUID() + ID_SEPARATOR + firstClassify.getCodeValue() + ID_SEPARATOR + firstClassify.getTypeCode())
|
|
|
+ .codeDataTypeStr(UUIDUtils.getUUID() + CommonCons.ID_SEPARATOR + firstClassify.getCodeValue() + CommonCons.ID_SEPARATOR + firstClassify.getTypeCode())
|
|
|
.build();
|
|
|
|
|
|
firstTreeVo.setChild(getFirstChildResourceClassifies(firstClassify.getChildrenType())
|
|
|
.stream()
|
|
|
.map(secondClassify -> {
|
|
|
DataResourceTreeVo secondTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(firstTreeVo.getId(), secondClassify.getCodeValue()))
|
|
|
+ .id(Joiner.on(CommonCons.ID_SEPARATOR).join(firstTreeVo.getId(), secondClassify.getCodeValue()))
|
|
|
.code(secondClassify.getCodeValue())
|
|
|
.label(secondClassify.getCodeName())
|
|
|
.treeNode(false)
|
|
|
.dataType(secondClassify.getTypeCode())
|
|
|
.pId(firstTreeVo.getId())
|
|
|
- .codeDataTypeStr(UUIDUtils.getUUID() + ID_SEPARATOR + secondClassify.getCodeValue() + ID_SEPARATOR + secondClassify.getTypeCode())
|
|
|
+ .codeDataTypeStr(UUIDUtils.getUUID() + CommonCons.ID_SEPARATOR + secondClassify.getCodeValue() + CommonCons.ID_SEPARATOR + secondClassify.getTypeCode())
|
|
|
.build();
|
|
|
return secondTreeVo;
|
|
|
}
|
|
@@ -660,27 +799,80 @@ public class DataResourceFacade implements IDataResourceFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 拼接表、列、pid
|
|
|
+ *
|
|
|
* 计算treeVo所有最底层子节点数量,不包含叶节点
|
|
|
*
|
|
|
* @param treeVo
|
|
|
+ * @param tabInfosMap
|
|
|
+ * @param colInfosMap
|
|
|
* @return
|
|
|
*/
|
|
|
- private int getTotalCount(DataResourceTreeVo treeVo) {
|
|
|
- int count = 0;
|
|
|
+ private boolean combinePidAndTabCol(DataResourceTreeVo treeVo, Map<String, List<DataTabInfo>> tabInfosMap, Map<String, List<DataColInfo>> colInfosMap) {
|
|
|
List<DataResourceTreeVo> child = treeVo.getChild();
|
|
|
- for (DataResourceTreeVo childVo : child) {
|
|
|
+ Iterator<DataResourceTreeVo> iterator = child.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ DataResourceTreeVo childVo = iterator.next();
|
|
|
childVo.setPId(treeVo.getId());
|
|
|
- childVo.setId(Joiner.on(ID_SEPARATOR).join(treeVo.getId(), childVo.getCode()));
|
|
|
+ childVo.setId(Joiner.on(CommonCons.ID_SEPARATOR).join(treeVo.getId(), childVo.getCode()));
|
|
|
List<DataResourceTreeVo> cc = childVo.getChild();
|
|
|
if (CollectionUtils.isNotEmpty(cc)) {
|
|
|
childVo.setTreeNode(true);
|
|
|
- count += getTotalCount(childVo);
|
|
|
+ boolean emptyChild = combinePidAndTabCol(childVo, tabInfosMap, colInfosMap);
|
|
|
+ if (emptyChild) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
} else {
|
|
|
- childVo.setTreeNode(false);
|
|
|
- count += 1;
|
|
|
+ // 如果为叶子节点,查找对应的表和列
|
|
|
+ // 如果查找不到表和列则移除
|
|
|
+ String id = childVo.getId();
|
|
|
+ String classifyCode = DataResourceEnum.DATA_RESOURCE_CLASSIFY.getCode();
|
|
|
+ if (id.startsWith(classifyCode)) {
|
|
|
+ String replace = id.replace(classifyCode + CommonCons.ID_SEPARATOR, "");
|
|
|
+ List<DataTabInfo> dataTabInfo = tabInfosMap.get(replace);
|
|
|
+ if (dataTabInfo == null) {
|
|
|
+ iterator.remove();
|
|
|
+ } else {
|
|
|
+ List<DataResourceTreeVo> tableVos = convertTableToTreeVo(childVo, dataTabInfo, colInfosMap);
|
|
|
+ childVo.setTreeNode(true);
|
|
|
+ childVo.setChild(tableVos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- return count;
|
|
|
+ return CollectionUtils.isEmpty(child);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DataResourceTreeVo> convertTableToTreeVo(DataResourceTreeVo childVo, List<DataTabInfo> dataTabInfo, Map<String, List<DataColInfo>> colInfosMap) {
|
|
|
+ return dataTabInfo.stream().map(e -> {
|
|
|
+ DataResourceTreeVo vo = new DataResourceTreeVo();
|
|
|
+ vo.setId(e.getId());
|
|
|
+ vo.setPId(childVo.getId());
|
|
|
+ vo.setLabel(e.getName());
|
|
|
+ vo.setDataType(DataResourceEnum.TAB.getCode());
|
|
|
+ List<DataColInfo> colInfoList = colInfosMap.get(e.getCode());
|
|
|
+ if (CollectionUtils.isNotEmpty(colInfoList)) {
|
|
|
+ List<DataResourceTreeVo> colVos = convertColumnToTreeVo(e.getId(), colInfoList);
|
|
|
+ vo.setChild(colVos);
|
|
|
+ vo.setTreeNode(true);
|
|
|
+ } else {
|
|
|
+ vo.setChild(Collections.emptyList());
|
|
|
+ vo.setTreeNode(false);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DataResourceTreeVo> convertColumnToTreeVo(String pid, List<DataColInfo> colInfoList) {
|
|
|
+ return colInfoList.stream().map(e -> {
|
|
|
+ DataResourceTreeVo vo = new DataResourceTreeVo();
|
|
|
+ vo.setId(e.getId());
|
|
|
+ vo.setPId(pid);
|
|
|
+ vo.setLabel(e.getName());
|
|
|
+ vo.setDataType(DataResourceEnum.COL.getCode());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**
|