فهرست منبع

Merge branch 'develop' of 192.168.0.144:xj-aks/dcuc/app-service into huangzqa-add-data-auth-20221002

 Conflicts:
	dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/facade/DataResourceFacade.java
huangzqa 2 سال پیش
والد
کامیت
a15d0dc39b

+ 1 - 1
dcuc-app-api/src/main/java/com/dragoninfo/dcuc/app/facade/IDataResourceFacade.java

@@ -38,7 +38,7 @@ public interface IDataResourceFacade {
     @ApiOperation(value = "数据资源树")
     @ApiImplicitParam(name = "attrType", value = "数据属性类型 TABLE:表 COLUMN:列")
     @GetMapping(value = "getAllDataResourceTree")
-    List<DataResourceClassifyVo> getAllDataResourceTree(@RequestParam("attrType") String attrType);
+    List<DataResourceClassifyVo> getAllDataResourceTree(@RequestParam(value = "attrType", required = false) String attrType);
 
     @ApiOperation(value = "数据资源树")
     @ApiImplicitParam(name = "typeCode", value = "typeCode类型(数据分级:DATA_CLASSIFY;数据资源分类:DATA_RESOURCE_CLASSIFY;数据安全级别:DATA_SECURITY_LEVEL;字段分类:COLUMN_CLASSIFY)")

+ 5 - 1
dcuc-app-model/src/main/java/com/dragoninfo/dcuc/app/enumresources/DataResourceEnum.java

@@ -34,7 +34,11 @@ public enum DataResourceEnum {
     /**
      * 字段关系
      */
-    COLUMN_RELATION_CATALOG("COLUMN_RELATION_CATALOG", "字段分类", "COLUMN_RELATION_CATALOG", DataAttrTypeEnum.DATA_ATTR_COLUMN);
+    COLUMN_RELATION_CATALOG("COLUMN_RELATION_CATALOG", "字段分类", "COLUMN_RELATION_CATALOG", DataAttrTypeEnum.DATA_ATTR_COLUMN),
+
+    TAB("TAB", "表", "TAB", DataAttrTypeEnum.DATA_ATTR_TABLE),
+
+    COL("TAB", "列", "COL", DataAttrTypeEnum.DATA_ATTR_COLUMN);
 
     DataResourceEnum(String code, String label, String dataType, DataAttrTypeEnum attrType) {
         this.code = code;

+ 4 - 5
dcuc-app-model/src/main/java/com/dragoninfo/dcuc/app/vo/DataResourceTreeVo.java

@@ -2,8 +2,10 @@ package com.dragoninfo.dcuc.app.vo;
 
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 import lombok.experimental.Tolerate;
 
 import java.util.List;
@@ -14,6 +16,8 @@ import java.util.List;
  */
 @Data
 @Builder
+@NoArgsConstructor
+@AllArgsConstructor
 @ApiModel(value = "数据资源树对象")
 public class DataResourceTreeVo {
 
@@ -41,9 +45,4 @@ public class DataResourceTreeVo {
 
     @ApiModelProperty(value = "内部使用唯一标识id")
     private String innerId;
-    /**
-     * 添加无参构造器,便于调用端序列化
-     */
-    @Tolerate
-    DataResourceTreeVo() {}
 }

+ 13 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/cons/CommonCons.java

@@ -6,6 +6,8 @@ package com.dragoninfo.dcuc.app.cons;
  */
 public interface CommonCons {
 
+    String ID_SEPARATOR = "|";
+
     String PATH_SEP = "-";
 
     Integer PATH_LEVEL_FIR = 1;
@@ -16,4 +18,15 @@ public interface CommonCons {
 
     Integer PATH_LEVEL_FOUR = 4;
 
+
+    String LAB_CLA_FIR = "RESOURCE_SJZYBQ1";
+
+    String LAB_CLA_SEC = "RESOURCE_SJZYBQ2";
+
+    String LAB_CLA_THI = "RESOURCE_SJZYBQ3";
+
+    String LAB_CLA_FOUR = "RESOURCE_SJZYBQ4";
+
+    String LAB_CLA_FIV = "RESOURCE_SJZYBQ5";
+
 }

+ 33 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/entity/DataColInfo.java

@@ -0,0 +1,33 @@
+package com.dragoninfo.dcuc.app.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * @author mazq
+ * @date 2022/9/29
+ */
+@Data
+@TableName("T_AUTH_DATA_COLINFO")
+public class DataColInfo {
+
+    /** ID */
+    @TableId(type = IdType.UUID)
+    private String id ;
+    /** NAME */
+    private String name ;
+    /** CODE */
+    private String code ;
+    /** TA_CODE */
+    private String taCode ;
+    /** SECU_LEV */
+    private String secuLev ;
+    /** COL_CLA_FIR */
+    private String colClaFir ;
+    /** COL_CLA_SEC */
+    private String colClaSec ;
+
+
+}

+ 41 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/entity/DataTabInfo.java

@@ -0,0 +1,41 @@
+package com.dragoninfo.dcuc.app.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * @author mazq
+ * @date 2022/9/29
+ */
+@Data
+@TableName("T_AUTH_DATA_TABINFO")
+public class DataTabInfo {
+
+    /** ID */
+    @TableId(type = IdType.UUID)
+    private String id ;
+    /** NAME */
+    private String name ;
+    /** CODE */
+    private String code ;
+    /** DATA_LEV_FIR */
+    private String dataLevFir ;
+    /** DATA_CLA_FIR */
+    private String dataClaFir ;
+    /** DATA_CLA_SEC */
+    private String dataClaSec ;
+    /** LAB_FIR */
+    private String labFir ;
+    /** LAB_SEC */
+    private String labSec ;
+    /** LAB_THR */
+    private String labThr ;
+    /** LAB_FOUR */
+    private String labFour ;
+    /** LAB_FIV */
+    private String labFiv ;
+
+
+}

+ 240 - 48
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/facade/DataResourceFacade.java

@@ -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());
     }
 
     /**

+ 11 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/mapper/DataColInfoMapper.java

@@ -0,0 +1,11 @@
+package com.dragoninfo.dcuc.app.mapper;
+
+import com.dragoninfo.dcuc.app.entity.DataColInfo;
+import com.dragonsoft.duceap.mybaitsplus.core.BaseMybatisMapper;
+
+/**
+ * @author mazq
+ * @date 2022/9/29
+ */
+public interface DataColInfoMapper extends BaseMybatisMapper<DataColInfo> {
+}

+ 11 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/mapper/DataTabInfoMapper.java

@@ -0,0 +1,11 @@
+package com.dragoninfo.dcuc.app.mapper;
+
+import com.dragoninfo.dcuc.app.entity.DataTabInfo;
+import com.dragonsoft.duceap.mybaitsplus.core.BaseMybatisMapper;
+
+/**
+ * @author mazq
+ * @date 2022/9/29
+ */
+public interface DataTabInfoMapper extends BaseMybatisMapper<DataTabInfo> {
+}

+ 15 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/service/IDataColInfoService.java

@@ -0,0 +1,15 @@
+package com.dragoninfo.dcuc.app.service;
+
+import com.dragoninfo.dcuc.app.entity.DataColInfo;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2022/9/29
+ */
+public interface IDataColInfoService {
+
+
+    List<DataColInfo> getAllColInfos();
+}

+ 16 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/service/IDataTabInfoService.java

@@ -0,0 +1,16 @@
+package com.dragoninfo.dcuc.app.service;
+
+import com.dragoninfo.dcuc.app.entity.DataTabInfo;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2022/9/29
+ */
+public interface IDataTabInfoService {
+
+
+    List<DataTabInfo> getAllTabInfos();
+
+}

+ 26 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/service/impl/DataColInfoServiceImpl.java

@@ -0,0 +1,26 @@
+package com.dragoninfo.dcuc.app.service.impl;
+
+import com.dragoninfo.dcuc.app.entity.DataColInfo;
+import com.dragoninfo.dcuc.app.mapper.DataColInfoMapper;
+import com.dragoninfo.dcuc.app.service.IDataColInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2022/9/29
+ */
+@Service
+public class DataColInfoServiceImpl implements IDataColInfoService {
+
+    @Autowired
+    private DataColInfoMapper colInfoMapper;
+
+
+    @Override
+    public List<DataColInfo> getAllColInfos() {
+        return colInfoMapper.selectList(null);
+    }
+}

+ 25 - 0
dcuc-app-service/src/main/java/com/dragoninfo/dcuc/app/service/impl/DataTabInfoServiceImpl.java

@@ -0,0 +1,25 @@
+package com.dragoninfo.dcuc.app.service.impl;
+
+import com.dragoninfo.dcuc.app.entity.DataTabInfo;
+import com.dragoninfo.dcuc.app.mapper.DataTabInfoMapper;
+import com.dragoninfo.dcuc.app.service.IDataTabInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2022/9/29
+ */
+@Service
+public class DataTabInfoServiceImpl implements IDataTabInfoService {
+
+    @Autowired
+    private DataTabInfoMapper tabInfoMapper;
+
+    @Override
+    public List<DataTabInfo> getAllTabInfos() {
+        return tabInfoMapper.selectList(null);
+    }
+}