|
@@ -1,42 +1,35 @@
|
|
|
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.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.entity.sub.*;
|
|
|
+import com.dragoninfo.dcuc.app.enumresources.AppDataTypeEnum;
|
|
|
+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.sub.IDataClaService;
|
|
|
-import com.dragoninfo.dcuc.app.service.sub.IDataLevelService;
|
|
|
-import com.dragoninfo.dcuc.app.service.sub.IDataSecService;
|
|
|
-import com.dragoninfo.dcuc.app.service.sub.IFieldClaService;
|
|
|
+import com.dragoninfo.dcuc.app.service.IDataResourceService;
|
|
|
+import com.dragoninfo.dcuc.app.service.sub.*;
|
|
|
import com.dragoninfo.dcuc.app.vo.*;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
-import com.dragonsoft.duceap.commons.util.UUIDUtils;
|
|
|
import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
|
|
|
-import com.dragonsoft.duceap.web.utils.RequestUtils;
|
|
|
import com.google.common.base.Joiner;
|
|
|
import com.google.common.collect.Lists;
|
|
|
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 org.springframework.web.servlet.support.RequestContextUtils;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* Created by lidr on 2021/4/14
|
|
@@ -44,10 +37,7 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/dcuc/app/dataResourceFacade")
|
|
|
-public class DataResourceFacade implements IDataResourceFacade
|
|
|
-{
|
|
|
-
|
|
|
- public static final String ID_SEPARATOR = "|";
|
|
|
+public class DataResourceFacade implements IDataResourceFacade {
|
|
|
|
|
|
@Autowired
|
|
|
private IDataResourceService dataResourceService;
|
|
@@ -64,19 +54,43 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
@Autowired
|
|
|
private IFieldClaService fieldClaService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IAppDataResourceInfoService tabInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAppDataItemInfoService colInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IDataCatalogBusiness dataCatalogBusiness;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAppColumnRelationService appColumnRelationService;
|
|
|
+
|
|
|
|
|
|
@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<AppDataResourceInfo> tabInfos = tabInfoService.getHasClassifyTables();
|
|
|
result.add(getDataLevelTree());
|
|
|
- result.add(getDataClassifyTree());
|
|
|
+ result.add(getDataClassifyTree(tabInfos));
|
|
|
+ } else if (DataAttrTypeEnum.DATA_ATTR_COLUMN.getValue().equals(attrType)) {
|
|
|
+ List<AppDataResourceInfo> tabInfos = tabInfoService.getAllTabInfos();
|
|
|
+ List<AppDataItemInfo> colInfos = colInfoService.getHasClassifyColInfos();
|
|
|
+ result.add(getSecurityLevelTree());
|
|
|
+ result.add(getFieldClassifyTree(tabInfos, colInfos));
|
|
|
+ result.add(getColumnRelTree());
|
|
|
} else {
|
|
|
+ List<AppDataResourceInfo> tabInfos = tabInfoService.getAllTabInfos();
|
|
|
+ List<AppDataItemInfo> colInfos = colInfoService.getHasClassifyColInfos();
|
|
|
+ result.add(getDataLevelTree());
|
|
|
+ result.add(getDataClassifyTree(tabInfos));
|
|
|
result.add(getSecurityLevelTree());
|
|
|
- result.add(getFieldClassifyTree());
|
|
|
+ result.add(getFieldClassifyTree(tabInfos, colInfos));
|
|
|
+ result.add(getColumnRelTree());
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -85,28 +99,40 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
public DataResourceClassifyVo getDataResourceTree(String typeCode) {
|
|
|
DataResourceClassifyVo result = null;
|
|
|
DataResourceEnum dataResourceEnum = Enum.valueOf(DataResourceEnum.class, typeCode);
|
|
|
- switch (dataResourceEnum){
|
|
|
- case DATA_CLASSIFY:
|
|
|
+ List<AppDataItemInfo> colInfos = null;
|
|
|
+ List<AppDataResourceInfo> tabInfos = null;
|
|
|
+ switch (dataResourceEnum) {
|
|
|
+ case DATA_LEVEL:
|
|
|
result = getDataLevelTree();
|
|
|
break;
|
|
|
case COLUMN_CLASSIFY:
|
|
|
- result = getFieldClassifyTree();
|
|
|
+ tabInfos = tabInfoService.getAllTabInfos();
|
|
|
+ colInfos = colInfoService.getHasClassifyColInfos();
|
|
|
+ result = getFieldClassifyTree(tabInfos, colInfos);
|
|
|
break;
|
|
|
-
|
|
|
- case DATA_SECURITY_LEVEL:
|
|
|
+ case COLUMN_SECURITY_LEVEL:
|
|
|
result = getSecurityLevelTree();
|
|
|
break;
|
|
|
case DATA_RESOURCE_CLASSIFY:
|
|
|
- result = getDataClassifyTree();
|
|
|
+ tabInfos = tabInfoService.getHasClassifyTables();
|
|
|
+ result = getDataClassifyTree(tabInfos);
|
|
|
+ break;
|
|
|
+ case COLUMN_RELATION_CATALOG:
|
|
|
+ result = getColumnRelTree();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
break;
|
|
|
- default:
|
|
|
- break;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private DataResourceClassifyVo getDataLevelTree() {
|
|
|
- DataResourceEnum dataResourceEnum = DataResourceEnum.DATA_CLASSIFY;
|
|
|
+ DataResourceEnum dataResourceEnum = DataResourceEnum.DATA_LEVEL;
|
|
|
+ List<DataLevelVo> dataLevelList = getDataLevelList();
|
|
|
+ return getOneLevelTree(dataResourceEnum, dataLevelList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private DataResourceClassifyVo getOneLevelTree(DataResourceEnum dataResourceEnum, List<DataLevelVo> dataLevelList) {
|
|
|
DataResourceClassifyVo dataResourceClassifyVo = DataResourceClassifyVo.builder()
|
|
|
.id(dataResourceEnum.getCode())
|
|
|
.attrType(dataResourceEnum.getAttrType().getValue())
|
|
@@ -117,23 +143,25 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
.id(dataResourceEnum.getCode())
|
|
|
.label("全部")
|
|
|
.code(dataResourceEnum.getCode())
|
|
|
+ .classifyCode(dataResourceEnum.getCode())
|
|
|
.treeNode(true)
|
|
|
.build();
|
|
|
- List<DataLevelVo> dataLevelList = getDataLevelList();
|
|
|
+
|
|
|
List<DataResourceTreeVo> child = dataLevelList.stream().map(item -> DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(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())
|
|
|
- .treeNode(false)
|
|
|
- .pId(dataLevelTreeVo.getId())
|
|
|
- .innerId(item.getInnerId()).build()).collect(Collectors.toList());
|
|
|
+ .id(item.getId())
|
|
|
+ .code(item.getLevelCode())
|
|
|
+ .label(item.getLevelName())
|
|
|
+ .classifyCode(dataResourceEnum.getCode())
|
|
|
+ .treeNode(false)
|
|
|
+ .pId(dataLevelTreeVo.getId())
|
|
|
+ .build()).collect(Collectors.toList());
|
|
|
dataLevelTreeVo.setChild(child);
|
|
|
- if(child.size() == 0) {
|
|
|
+ if (child.size() == 0) {
|
|
|
dataResourceClassifyVo.setNodes(new ArrayList<>());
|
|
|
} else {
|
|
|
- dataResourceClassifyVo.setNodes(new ArrayList<DataResourceTreeVo>(){{add(dataLevelTreeVo);}});
|
|
|
+ dataResourceClassifyVo.setNodes(new ArrayList<DataResourceTreeVo>() {{
|
|
|
+ add(dataLevelTreeVo);
|
|
|
+ }});
|
|
|
}
|
|
|
//设置总数量
|
|
|
dataResourceClassifyVo.setTotal(child.size());
|
|
@@ -141,51 +169,25 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
}
|
|
|
|
|
|
private DataResourceClassifyVo getSecurityLevelTree() {
|
|
|
- DataResourceEnum dataResourceEnum = DataResourceEnum.DATA_SECURITY_LEVEL;
|
|
|
-
|
|
|
- DataResourceClassifyVo dataResourceClassifyVo = DataResourceClassifyVo.builder()
|
|
|
- .id(dataResourceEnum.getCode())
|
|
|
- .attrType(dataResourceEnum.getAttrType().getValue())
|
|
|
- .label(dataResourceEnum.getLabel())
|
|
|
- .build();
|
|
|
-
|
|
|
- DataResourceTreeVo securityLevelTree = DataResourceTreeVo.builder()
|
|
|
- .id(dataResourceEnum.getCode())
|
|
|
- .label("全部")
|
|
|
- .code(dataResourceEnum.getCode())
|
|
|
- .treeNode(true)
|
|
|
- .build();
|
|
|
+ DataResourceEnum dataResourceEnum = DataResourceEnum.COLUMN_SECURITY_LEVEL;
|
|
|
List<DataLevelVo> securityLevelList = getSecurityLevelList();
|
|
|
-
|
|
|
- List<DataResourceTreeVo> child = securityLevelList.stream().map(item -> DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(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())
|
|
|
- .treeNode(false)
|
|
|
- .pId(securityLevelTree.getId())
|
|
|
- .innerId(item.getInnerId()).build()).collect(Collectors.toList());
|
|
|
- securityLevelTree.setChild(child);
|
|
|
- if(child.size() == 0) {
|
|
|
- dataResourceClassifyVo.setNodes(new ArrayList<>());
|
|
|
- dataResourceClassifyVo.setTotal(0);
|
|
|
- } else {
|
|
|
- dataResourceClassifyVo.setNodes(new ArrayList<DataResourceTreeVo>(){{add(securityLevelTree);}} );
|
|
|
- //设置总数量
|
|
|
- dataResourceClassifyVo.setTotal(child.size());
|
|
|
- }
|
|
|
- return dataResourceClassifyVo;
|
|
|
+ return getOneLevelTree(dataResourceEnum, securityLevelList);
|
|
|
}
|
|
|
|
|
|
- private DataResourceClassifyVo getDataClassifyTree() {
|
|
|
+ private DataResourceClassifyVo getDataClassifyTree(List<AppDataResourceInfo> tabInfos) {
|
|
|
+ // 将表分类映射到表
|
|
|
+ Map<String, List<AppDataResourceInfo>> tabLabMap = getTabLabGroupMap(tabInfos);
|
|
|
+
|
|
|
DataResourceEnum dataResourceEnum = DataResourceEnum.DATA_RESOURCE_CLASSIFY;
|
|
|
|
|
|
DataResourceClassifyVo resourceVo = DataResourceClassifyVo.builder().id(dataResourceEnum.getCode())
|
|
|
.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));
|
|
|
//一级节点
|
|
@@ -205,37 +207,126 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
combineTreeNode(secNodes, thirdNodes);
|
|
|
combineTreeNode(thirdNodes, fourNodes);
|
|
|
topTreeVo.setChild(firNodes);
|
|
|
- if(firNodes.size() == 0) {
|
|
|
+ if (firNodes.size() == 0) {
|
|
|
resourceVo.setNodes(new ArrayList<>());
|
|
|
resourceVo.setTotal(0);
|
|
|
} else {
|
|
|
- //计算总数量
|
|
|
- resourceVo.setTotal(getTotalCount(topTreeVo));
|
|
|
- resourceVo.setNodes(new ArrayList<DataResourceTreeVo>(){{add(topTreeVo);}});
|
|
|
+ // 拼接表、列、pid
|
|
|
+ int count = combinePidAndTableInfo(topTreeVo, tabLabMap, dataResourceEnum);
|
|
|
+ if (count == 0) {
|
|
|
+ resourceVo.setNodes(new ArrayList<>());
|
|
|
+ resourceVo.setTotal(0);
|
|
|
+ } else {
|
|
|
+ resourceVo.setNodes(new ArrayList<DataResourceTreeVo>() {{
|
|
|
+ add(topTreeVo);
|
|
|
+ }});
|
|
|
+ }
|
|
|
+ resourceVo.setTotal(count);
|
|
|
}
|
|
|
return resourceVo;
|
|
|
}
|
|
|
|
|
|
+ private Map<String, List<AppDataResourceInfo>> getTabLabGroupMap(List<AppDataResourceInfo> tabInfos) {
|
|
|
+ Map<String, List<AppDataResourceInfo>> group = new HashMap<>();
|
|
|
+ tabInfos.forEach(e -> {
|
|
|
+ // 一级分类
|
|
|
+ String claFir = e.getDataClassifyOneCode();
|
|
|
+ if (StringUtils.isBlank(claFir)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 二级分类
|
|
|
+ String claSec = e.getDataClassifyTwoCode();
|
|
|
+ if (StringUtils.isBlank(claSec)) {
|
|
|
+ putInMap(group, e, claFir);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 标签1
|
|
|
+ String labFir = e.getDataLabelOneCode();
|
|
|
+ if (StringUtils.isNotBlank(labFir)) {
|
|
|
+ labFir = CommonCons.LAB_CLA_FIR + CommonCons.ID_SEPARATOR + labFir;
|
|
|
+ }
|
|
|
+ // 标签2
|
|
|
+ String labSec = e.getDataLabelTwoCode();
|
|
|
+ if (StringUtils.isNotBlank(labSec)) {
|
|
|
+ labSec = CommonCons.LAB_CLA_SEC + CommonCons.ID_SEPARATOR + labSec;
|
|
|
+ }
|
|
|
+ // 标签3
|
|
|
+ String labThr = e.getDataLabelThreeCode();
|
|
|
+ if (StringUtils.isNotBlank(labThr)) {
|
|
|
+ labThr = CommonCons.LAB_CLA_THI + CommonCons.ID_SEPARATOR + labThr;
|
|
|
+ }
|
|
|
+ // 标签4
|
|
|
+ String labFour = e.getDataLabelFourCode();
|
|
|
+ if (StringUtils.isNotBlank(labFour)) {
|
|
|
+ labFour = CommonCons.LAB_CLA_FOUR + CommonCons.ID_SEPARATOR + labFour;
|
|
|
+ }
|
|
|
+ // 标签5
|
|
|
+ String labFiv = e.getDataLabelFiveCode();
|
|
|
+ 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<AppDataResourceInfo>> group, AppDataResourceInfo e, String claFir) {
|
|
|
+ List<AppDataResourceInfo> 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())
|
|
|
.pId(pid)
|
|
|
- .dataType(item.getDataType())
|
|
|
.label(item.getName())
|
|
|
.code(item.getCode())
|
|
|
- .innerId(item.getId())
|
|
|
+ .classifyCode(DataResourceEnum.DATA_RESOURCE_CLASSIFY.getCode())
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
+ private DataResourceClassifyVo getColumnRelTree() {
|
|
|
+ DataResourceEnum dataResourceEnum = DataResourceEnum.COLUMN_RELATION_CATALOG;
|
|
|
+ List<DataLevelVo> columnRelationList = getColumnRelationList();
|
|
|
+ return getOneLevelTree(dataResourceEnum, columnRelationList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DataLevelVo> getColumnRelationList() {
|
|
|
+ List<AppColumnRelation> all = appColumnRelationService.findAll();
|
|
|
+ return all.stream()
|
|
|
+ .map(item -> new DataLevelVo(item.getId(), item.getCodeValue(), item.getCodeName(), DataResourceEnum.COLUMN_RELATION_CATALOG.getDataType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private DataResourceClassifyVo getFieldClassifyTree(List<AppDataResourceInfo> tabInfos, List<AppDataItemInfo> colInfos) {
|
|
|
+ Map<String, AppDataResourceInfo> tableMap = tabInfos
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(AppDataResourceInfo::getId, e -> e));
|
|
|
+ Map<String, List<AppDataItemInfo>> colInfosMap = getColumnClaGroupMap(colInfos);
|
|
|
|
|
|
- private DataResourceClassifyVo getFieldClassifyTree() {
|
|
|
DataResourceEnum dataResourceEnum = DataResourceEnum.COLUMN_CLASSIFY;
|
|
|
|
|
|
DataResourceClassifyVo resourceVo = DataResourceClassifyVo.builder().id(dataResourceEnum.getCode())
|
|
|
.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<>())
|
|
@@ -244,30 +335,81 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
.stream().map(item -> convertFieldClaToNode(item, item.getFirId())).collect(Collectors.toList());
|
|
|
combineTreeNode(firNodes, secNodes);
|
|
|
topTreeVo.setChild(firNodes);
|
|
|
- if(firNodes.size() == 0) {
|
|
|
+ if (firNodes.size() == 0) {
|
|
|
resourceVo.setNodes(new ArrayList<>());
|
|
|
resourceVo.setTotal(0);
|
|
|
} else {
|
|
|
- resourceVo.setNodes(new ArrayList<DataResourceTreeVo>(){{add(topTreeVo);}});
|
|
|
- resourceVo.setTotal(getTotalCount(topTreeVo));
|
|
|
+ int count = combinePidTabAndCol(topTreeVo, tableMap, colInfosMap, dataResourceEnum);
|
|
|
+ if (count == 0) {
|
|
|
+ resourceVo.setNodes(new ArrayList<>());
|
|
|
+ resourceVo.setTotal(0);
|
|
|
+ } else {
|
|
|
+ resourceVo.setNodes(new ArrayList<DataResourceTreeVo>() {{
|
|
|
+ add(topTreeVo);
|
|
|
+ }});
|
|
|
+ }
|
|
|
+ resourceVo.setTotal(count);
|
|
|
}
|
|
|
return resourceVo;
|
|
|
}
|
|
|
|
|
|
+ private Map<String, List<AppDataItemInfo>> getColumnClaGroupMap(List<AppDataItemInfo> colInfos) {
|
|
|
+ return colInfos.stream().collect(Collectors.groupingBy(AppDataItemInfo::getColumnClassify));
|
|
|
+ }
|
|
|
+
|
|
|
+ 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()) {
|
|
|
+ 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);
|
|
|
+ int childCount = combinePidTabAndCol(childVo, tableMap, colInfosMap, resourceEnum);
|
|
|
+ if (childCount == 0) {
|
|
|
+ iterator.remove();
|
|
|
+ } else {
|
|
|
+ count += childCount;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果为叶子节点,查找对应的表和列
|
|
|
+ // 如果查找不到表和列则移除
|
|
|
+ List<AppDataItemInfo> dataColInfo = colInfosMap.get(childVo.getCode());
|
|
|
+ if (dataColInfo == null) {
|
|
|
+ iterator.remove();
|
|
|
+ } else {
|
|
|
+ Map<String, List<AppDataItemInfo>> tableGroup = dataColInfo.stream()
|
|
|
+ .collect(Collectors.groupingBy(AppDataItemInfo::getResourceTableId));
|
|
|
+ List<DataResourceTreeVo> tableVos = tableGroup.entrySet().stream().map(e -> {
|
|
|
+ String tableId = e.getKey();
|
|
|
+ AppDataResourceInfo table = tableMap.get(tableId);
|
|
|
+ return convertTableToTreeVo(childVo.getId(), Collections.singletonList(table), tableGroup, resourceEnum);
|
|
|
+ }).flatMap(List::stream).collect(Collectors.toList());
|
|
|
+ childVo.setTreeNode(true);
|
|
|
+ childVo.setChild(tableVos);
|
|
|
+ count += dataColInfo.size();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
private DataResourceTreeVo convertFieldClaToNode(FieldCla item, String pid) {
|
|
|
return DataResourceTreeVo.builder()
|
|
|
.id(item.getId())
|
|
|
.pId(pid)
|
|
|
- .dataType(item.getDataType())
|
|
|
.label(item.getName())
|
|
|
+ .classifyCode(DataResourceEnum.COLUMN_CLASSIFY.getCode())
|
|
|
.code(item.getCode())
|
|
|
- .innerId(item.getId())
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
private void combineTreeNode(List<DataResourceTreeVo> firNodes, List<DataResourceTreeVo> secNodes) {
|
|
|
Map<String, List<DataResourceTreeVo>> secMap = secNodes.stream().collect(Collectors.groupingBy(DataResourceTreeVo::getPId));
|
|
|
- firNodes.forEach(item->{
|
|
|
+ firNodes.forEach(item -> {
|
|
|
List<DataResourceTreeVo> childes = secMap.get(item.getId());
|
|
|
item.setChild(childes);
|
|
|
});
|
|
@@ -284,7 +426,7 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
|
|
|
@Override
|
|
|
public List<DataLevelVo> getSecurityLevelList() {
|
|
|
- List<DataSec> all = dataSecService.getAll();
|
|
|
+ List<FieldSec> all = dataSecService.getAll();
|
|
|
return all.stream()
|
|
|
.map(item -> new DataLevelVo(item.getId(), item.getSecCode(), item.getSecName(), item.getDataType()))
|
|
|
.collect(Collectors.toList());
|
|
@@ -310,7 +452,7 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
@Override
|
|
|
public List<DataFieldClassifyVo> getFieldClassifyList() {
|
|
|
List<FieldClaAcceptDTO> list = fieldClaService.getAll();
|
|
|
- return list.stream().map(item-> {
|
|
|
+ return list.stream().map(item -> {
|
|
|
DataFieldClassifyVo vo = new DataFieldClassifyVo();
|
|
|
vo.setFirstLevelCode(item.getFirCode());
|
|
|
vo.setFirstLevelName(item.getFirName());
|
|
@@ -330,7 +472,7 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
//方法内部有从ThreadLocal获取信息
|
|
|
//CompletableFuture默认使用ForkJoin线程池,不要使用1.8的新线程开启方法
|
|
|
//如果使用线程池需要用包装类将线程包装后设置RequestContextHolder
|
|
|
- Runnable r = ()-> {
|
|
|
+ Runnable r = () -> {
|
|
|
RequestContextHolder.setRequestAttributes(requestAttributes);
|
|
|
try {
|
|
|
List<DataLevelVo> list = getDataLevelListFromRemote();
|
|
@@ -344,6 +486,30 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
return ResponseStatus.success();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseStatus columnRelationSync() {
|
|
|
+ //因为子线程中需要调用总线需要用到请求头中的信息
|
|
|
+ //需要将requestAttributes设置到子线程中的RequestContextHolder
|
|
|
+ //SpringWeb暂时未提供RequestContextHolder父子线程共享ThreadLocal中的数据的配置,需要手动设置
|
|
|
+ RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
|
|
+ //开启父子线程
|
|
|
+ //方法内部有从ThreadLocal获取信息
|
|
|
+ //CompletableFuture默认使用ForkJoin线程池,不要使用1.8的新线程开启方法
|
|
|
+ //如果使用线程池需要用包装类将线程包装后设置RequestContextHolder
|
|
|
+ Runnable r = () -> {
|
|
|
+ RequestContextHolder.setRequestAttributes(requestAttributes);
|
|
|
+ try {
|
|
|
+ List<AppColumnRelationVO> list = getColumnRelationCatalogFromRemote();
|
|
|
+ appColumnRelationService.sync(list);
|
|
|
+ } finally {
|
|
|
+ RequestContextHolder.resetRequestAttributes();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Thread t = new Thread(r);
|
|
|
+ t.start();
|
|
|
+ return ResponseStatus.success();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ResponseStatus dataSecSync() {
|
|
|
//因为子线程中需要调用总线需要用到请求头中的信息
|
|
@@ -354,7 +520,7 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
//方法内部有从ThreadLocal获取信息
|
|
|
//CompletableFuture默认使用ForkJoin线程池,不要使用1.8的新线程开启方法
|
|
|
//如果使用线程池需要用包装类将线程包装后设置RequestContextHolder
|
|
|
- Runnable r = ()-> {
|
|
|
+ Runnable r = () -> {
|
|
|
RequestContextHolder.setRequestAttributes(requestAttributes);
|
|
|
try {
|
|
|
List<DataLevelVo> list = getSecurityLevelListFromRemote();
|
|
@@ -378,10 +544,10 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
//方法内部有从ThreadLocal获取信息
|
|
|
//CompletableFuture默认使用ForkJoin线程池,不要使用1.8的新线程开启方法
|
|
|
//如果使用线程池需要用包装类将线程包装后设置RequestContextHolder
|
|
|
- Runnable r = ()-> {
|
|
|
+ Runnable r = () -> {
|
|
|
try {
|
|
|
RequestContextHolder.setRequestAttributes(requestAttributes);
|
|
|
- List<DataResourceTreeVo> nodes = getDataClassifyTreeFromRemote();
|
|
|
+ List<DataResourceSyncTreeVo> nodes = getDataClassifyTreeFromRemote();
|
|
|
dataClaService.sync(nodes, null);
|
|
|
} finally {
|
|
|
RequestContextHolder.resetRequestAttributes();
|
|
@@ -403,10 +569,10 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
//方法内部有从ThreadLocal获取信息
|
|
|
//CompletableFuture默认使用ForkJoin线程池,不要使用1.8的新线程开启方法
|
|
|
//如果使用线程池需要用包装类将线程包装后设置RequestContextHolder
|
|
|
- Runnable r = ()-> {
|
|
|
+ Runnable r = () -> {
|
|
|
try {
|
|
|
RequestContextHolder.setRequestAttributes(requestAttributes);
|
|
|
- List<DataResourceTreeVo> nodes = getFieldClassifyTreeFromRemote();
|
|
|
+ List<DataResourceSyncTreeVo> nodes = getFieldClassifyTreeFromRemote();
|
|
|
fieldClaService.sync(nodes, null);
|
|
|
} finally {
|
|
|
RequestContextHolder.resetRequestAttributes();
|
|
@@ -418,60 +584,66 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
return ResponseStatus.success();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseStatus syncTableAndColumn() {
|
|
|
+ dataCatalogBusiness.syncTableAndColumn();
|
|
|
+ return ResponseStatus.success();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<DataLevelVo> getDetailByIdsAndClaType(List<String> ids, String classifyType) {
|
|
|
- List<DataLevelVo> vos= new ArrayList<>();
|
|
|
- if(CollectionUtils.isEmpty(ids)) {
|
|
|
+ List<DataLevelVo> vos = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
return vos;
|
|
|
}
|
|
|
- if(StringUtils.isBlank(classifyType)) {
|
|
|
+ if (StringUtils.isBlank(classifyType)) {
|
|
|
return vos;
|
|
|
}
|
|
|
DataResourceEnum anEnum = DataResourceEnum.getByCode(classifyType);
|
|
|
- if(null == anEnum) {
|
|
|
+ if (null == anEnum) {
|
|
|
return vos;
|
|
|
- } else if(DataResourceEnum.COLUMN_CLASSIFY.equals(anEnum)) {
|
|
|
+ } else if (DataResourceEnum.COLUMN_CLASSIFY.equals(anEnum)) {
|
|
|
List<FieldCla> list = fieldClaService.getByIds(ids);
|
|
|
- list.stream().map(item->{
|
|
|
+ list.stream().map(item -> {
|
|
|
DataLevelVo vo = new DataLevelVo();
|
|
|
vo.setTypeCode(item.getDataType());
|
|
|
vo.setLevelName(item.getName());
|
|
|
vo.setLevelCode(item.getCode());
|
|
|
- vo.setInnerId(item.getId());
|
|
|
+ vo.setId(item.getId());
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
- } else if(DataResourceEnum.DATA_CLASSIFY.equals(anEnum)) {
|
|
|
+ } else if (DataResourceEnum.DATA_LEVEL.equals(anEnum)) {
|
|
|
List<DataLevel> list = dataLevelService.getByIds(ids);
|
|
|
- list.stream().map(item->{
|
|
|
+ list.stream().map(item -> {
|
|
|
DataLevelVo vo = new DataLevelVo();
|
|
|
vo.setTypeCode(item.getDataType());
|
|
|
vo.setLevelName(item.getLevelName());
|
|
|
vo.setLevelCode(item.getLevelCode());
|
|
|
- vo.setInnerId(item.getId());
|
|
|
+ vo.setId(item.getId());
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
- } else if(DataResourceEnum.DATA_RESOURCE_CLASSIFY.equals(anEnum)) {
|
|
|
+ } else if (DataResourceEnum.DATA_RESOURCE_CLASSIFY.equals(anEnum)) {
|
|
|
List<DataCla> list = dataClaService.getByIds(ids);
|
|
|
- list.stream().map(item->{
|
|
|
+ list.stream().map(item -> {
|
|
|
DataLevelVo vo = new DataLevelVo();
|
|
|
vo.setTypeCode(item.getDataType());
|
|
|
vo.setLevelName(item.getName());
|
|
|
vo.setLevelCode(item.getCode());
|
|
|
- vo.setInnerId(item.getId());
|
|
|
+ vo.setId(item.getId());
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
- } else if(DataResourceEnum.DATA_SECURITY_LEVEL.equals(anEnum)) {
|
|
|
- List<DataSec> list = dataSecService.getByIds(ids);
|
|
|
- list.stream().map(item->{
|
|
|
+ } else if (DataResourceEnum.COLUMN_SECURITY_LEVEL.equals(anEnum)) {
|
|
|
+ List<FieldSec> list = dataSecService.getByIds(ids);
|
|
|
+ list.stream().map(item -> {
|
|
|
DataLevelVo vo = new DataLevelVo();
|
|
|
vo.setTypeCode(item.getDataType());
|
|
|
vo.setLevelName(item.getSecName());
|
|
|
vo.setLevelCode(item.getSecCode());
|
|
|
- vo.setInnerId(item.getId());
|
|
|
+ vo.setId(item.getId());
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
@@ -480,34 +652,34 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
|
|
|
@Override
|
|
|
public DataLevelVo getDetailByIdAndClaType(String id, String classifyType) {
|
|
|
- if(StringUtils.isAnyBlank(id, classifyType)) {
|
|
|
+ if (StringUtils.isAnyBlank(id, classifyType)) {
|
|
|
return null;
|
|
|
}
|
|
|
DataLevelVo vo = new DataLevelVo();
|
|
|
DataResourceEnum anEnum = DataResourceEnum.getByCode(classifyType);
|
|
|
- if(null == anEnum) {
|
|
|
+ if (null == anEnum) {
|
|
|
return null;
|
|
|
- } else if(DataResourceEnum.COLUMN_CLASSIFY.equals(anEnum)) {
|
|
|
+ } else if (DataResourceEnum.COLUMN_CLASSIFY.equals(anEnum)) {
|
|
|
FieldCla fieldCla = fieldClaService.getById(id);
|
|
|
- vo.setInnerId(fieldCla.getId());
|
|
|
+ vo.setId(fieldCla.getId());
|
|
|
vo.setLevelCode(fieldCla.getCode());
|
|
|
vo.setLevelName(fieldCla.getName());
|
|
|
vo.setTypeCode(fieldCla.getDataType());
|
|
|
- } else if(DataResourceEnum.DATA_CLASSIFY.equals(anEnum)) {
|
|
|
+ } else if (DataResourceEnum.DATA_LEVEL.equals(anEnum)) {
|
|
|
DataLevel dataLevel = dataLevelService.getById(id);
|
|
|
- vo.setInnerId(dataLevel.getId());
|
|
|
+ vo.setId(dataLevel.getId());
|
|
|
vo.setLevelCode(dataLevel.getLevelCode());
|
|
|
vo.setLevelName(dataLevel.getLevelName());
|
|
|
vo.setTypeCode(dataLevel.getDataType());
|
|
|
- } else if(DataResourceEnum.DATA_RESOURCE_CLASSIFY.equals(anEnum)) {
|
|
|
+ } else if (DataResourceEnum.DATA_RESOURCE_CLASSIFY.equals(anEnum)) {
|
|
|
DataCla dataCla = dataClaService.getById(id);
|
|
|
- vo.setInnerId(dataCla.getId());
|
|
|
+ vo.setId(dataCla.getId());
|
|
|
vo.setLevelCode(dataCla.getId());
|
|
|
vo.setLevelName(dataCla.getName());
|
|
|
vo.setTypeCode(dataCla.getCode());
|
|
|
- } else if(DataResourceEnum.DATA_SECURITY_LEVEL.equals(anEnum)) {
|
|
|
- DataSec dataSec = dataSecService.getById(id);
|
|
|
- vo.setInnerId(dataSec.getId());
|
|
|
+ } else if (DataResourceEnum.COLUMN_SECURITY_LEVEL.equals(anEnum)) {
|
|
|
+ FieldSec dataSec = dataSecService.getById(id);
|
|
|
+ vo.setId(dataSec.getId());
|
|
|
vo.setLevelCode(dataSec.getSecCode());
|
|
|
vo.setLevelName(dataSec.getSecName());
|
|
|
vo.setTypeCode(dataSec.getDataType());
|
|
@@ -521,55 +693,51 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<DataResourceTreeVo> getDataClassifyTreeFromRemote() {
|
|
|
+ private List<DataResourceSyncTreeVo> getDataClassifyTreeFromRemote() {
|
|
|
String id = DataResourceEnum.DATA_RESOURCE_CLASSIFY.getCode();
|
|
|
- List<DataResourceTreeVo> collect = getFirstChildResourceClassifies(dataResourceService.getDataClassifyList())
|
|
|
+ List<DataResourceSyncTreeVo> collect = getFirstChildResourceClassifies(dataResourceService.getDataClassifyList())
|
|
|
.stream()
|
|
|
.map(firstClassify -> {
|
|
|
- DataResourceTreeVo firstTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(id, firstClassify.getCodeValue()))
|
|
|
+ DataResourceSyncTreeVo firstTreeVo = DataResourceSyncTreeVo.builder()
|
|
|
+ .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())
|
|
|
.build();
|
|
|
|
|
|
firstTreeVo.setChild(getFirstChildResourceClassifies(firstClassify.getChildrenType()).stream()
|
|
|
.map(secondClassify -> {
|
|
|
- DataResourceTreeVo secondTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(firstTreeVo.getId(), secondClassify.getCodeValue()))
|
|
|
+ DataResourceSyncTreeVo secondTreeVo = DataResourceSyncTreeVo.builder()
|
|
|
+ .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())
|
|
|
.build();
|
|
|
|
|
|
secondTreeVo.setChild(getChildrenTypeList(secondClassify.getChildrenType()).stream()
|
|
|
.map(thirdClassify -> {
|
|
|
- DataResourceTreeVo thirdTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(secondTreeVo.getId(), thirdClassify.getTypeCode()))
|
|
|
+ DataResourceSyncTreeVo thirdTreeVo = DataResourceSyncTreeVo.builder()
|
|
|
+ .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())
|
|
|
.build();
|
|
|
|
|
|
thirdTreeVo.setChild(thirdClassify.getDataList().stream()
|
|
|
.map(fourClassify -> {
|
|
|
- DataResourceTreeVo fourTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(thirdTreeVo.getId(), fourClassify.getCodeValue()))
|
|
|
+ DataResourceSyncTreeVo fourTreeVo = DataResourceSyncTreeVo.builder()
|
|
|
+ .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())
|
|
|
.build();
|
|
|
return fourTreeVo;
|
|
|
}).collect(Collectors.toList()));
|
|
@@ -587,32 +755,30 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<DataResourceTreeVo> getFieldClassifyTreeFromRemote() {
|
|
|
+ private List<DataResourceSyncTreeVo> getFieldClassifyTreeFromRemote() {
|
|
|
String id = DataResourceEnum.COLUMN_CLASSIFY.getCode();
|
|
|
- List<DataResourceTreeVo> collect = getFirstChildResourceClassifies(dataResourceService.getFieldClassifyList())
|
|
|
+ List<DataResourceSyncTreeVo> collect = getFirstChildResourceClassifies(dataResourceService.getFieldClassifyList())
|
|
|
.stream()
|
|
|
.map(firstClassify -> {
|
|
|
- DataResourceTreeVo firstTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(id, firstClassify.getCodeValue()))
|
|
|
+ DataResourceSyncTreeVo firstTreeVo = DataResourceSyncTreeVo.builder()
|
|
|
+ .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())
|
|
|
.build();
|
|
|
|
|
|
firstTreeVo.setChild(getFirstChildResourceClassifies(firstClassify.getChildrenType())
|
|
|
.stream()
|
|
|
.map(secondClassify -> {
|
|
|
- DataResourceTreeVo secondTreeVo = DataResourceTreeVo.builder()
|
|
|
- .id(Joiner.on(ID_SEPARATOR).join(firstTreeVo.getId(), secondClassify.getCodeValue()))
|
|
|
+ DataResourceSyncTreeVo secondTreeVo = DataResourceSyncTreeVo.builder()
|
|
|
+ .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())
|
|
|
.build();
|
|
|
return secondTreeVo;
|
|
|
}
|
|
@@ -623,41 +789,119 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 拼接表、列、pid
|
|
|
+ *
|
|
|
* 计算treeVo所有最底层子节点数量,不包含叶节点
|
|
|
+ *
|
|
|
* @param treeVo
|
|
|
+ * @param tabInfosMap
|
|
|
+ * @param dataResourceEnum
|
|
|
* @return
|
|
|
*/
|
|
|
- private int getTotalCount(DataResourceTreeVo treeVo) {
|
|
|
+ private int combinePidAndTableInfo(DataResourceTreeVo treeVo, Map<String, List<AppDataResourceInfo>> tabInfosMap, DataResourceEnum dataResourceEnum) {
|
|
|
int count = 0;
|
|
|
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)){
|
|
|
+ if (CollectionUtils.isNotEmpty(cc)) {
|
|
|
childVo.setTreeNode(true);
|
|
|
- count += getTotalCount(childVo);
|
|
|
- }else {
|
|
|
- childVo.setTreeNode(false);
|
|
|
- count += 1;
|
|
|
+ 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();
|
|
|
+ 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 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();
|
|
|
+ // 因为表可能属于多个字段分类,前端树结构需要唯一id
|
|
|
+ vo.setId(pid + CommonCons.ID_SEPARATOR + e.getId());
|
|
|
+ vo.setPId(pid);
|
|
|
+ vo.setLabel(e.getStandardDataName());
|
|
|
+ vo.setClassifyCode(resourceEnum.getCode());
|
|
|
+ if (null != colInfosMap) {
|
|
|
+ List<AppDataItemInfo> colInfoList = colInfosMap.get(e.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(colInfoList)) {
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DataResourceTreeVo> convertColumnToTreeVo(String pid, List<AppDataItemInfo> colInfoList, DataResourceEnum resourceEnum) {
|
|
|
+ return colInfoList.stream().map(e -> {
|
|
|
+ DataResourceTreeVo vo = new DataResourceTreeVo();
|
|
|
+ vo.setId(e.getId());
|
|
|
+ vo.setPId(pid);
|
|
|
+ vo.setLabel(e.getStandardDataItemName());
|
|
|
+ vo.setClassifyCode(resourceEnum.getCode());
|
|
|
+ vo.setTreeNode(false);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 从数据资源目录获取数据-数据分级
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private List<DataLevelVo> getDataLevelListFromRemote() {
|
|
|
return getFirstChildResourceClassifies(dataResourceService.getDataLevelList())
|
|
|
.stream()
|
|
|
- .map(childResourceClassify -> new DataLevelVo(null, childResourceClassify.getCodeValue(), childResourceClassify.getCodeName(),childResourceClassify.getTypeCode()))
|
|
|
+ .map(childResourceClassify -> new DataLevelVo(null, childResourceClassify.getCodeValue(), childResourceClassify.getCodeName(), childResourceClassify.getTypeCode()))
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 从数据资源目录获取数据-字段关系
|
|
|
+ *
|
|
|
+ * @return 列表
|
|
|
+ */
|
|
|
+ private List<AppColumnRelationVO> getColumnRelationCatalogFromRemote() {
|
|
|
+ return getFirstChildResourceClassifies(dataResourceService.getColumnRelationCatalog())
|
|
|
+ .stream()
|
|
|
+ .map(childResourceClassify -> new AppColumnRelationVO(null, childResourceClassify.getCodeValue(), childResourceClassify.getCodeName()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 从数据资源目录获取数据-安全级别数据
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private List<DataLevelVo> getSecurityLevelListFromRemote() {
|
|
@@ -673,7 +917,7 @@ public class DataResourceFacade implements IDataResourceFacade
|
|
|
.map(resourceClassify -> {
|
|
|
//设置节点的dataType,dataType为上级的typeCode字段
|
|
|
List<ChildResourceClassify> dataList = Optional.ofNullable(resourceClassify.getDataList()).orElse(Lists.newArrayList());
|
|
|
- dataList.stream().forEach(item-> item.setTypeCode(resourceClassify.getTypeCode()));
|
|
|
+ dataList.stream().forEach(item -> item.setTypeCode(resourceClassify.getTypeCode()));
|
|
|
return dataList;
|
|
|
})
|
|
|
.orElse(Lists.newArrayList());
|