Rgx 2 éve
szülő
commit
228ca9ec6d
35 módosított fájl, 3860 hozzáadás és 3 törlés
  1. 35 0
      src/main/java/io/renren/common/utils/RandomGen.java
  2. 35 0
      src/main/java/io/renren/common/utils/SubString.java
  3. 47 0
      src/main/java/io/renren/common/utils/ToEnglish.java
  4. 4 1
      src/main/java/io/renren/modules/dataSet/controller/SnoopProxyControlle.java
  5. 2 2
      src/main/java/io/renren/modules/dataSet/service/impl/DynamicSystemServiceImpl.java
  6. 335 0
      src/main/java/io/renren/modules/levelManage/controller/LevelController.java
  7. 124 0
      src/main/java/io/renren/modules/levelManage/controller/LevelRelationController.java
  8. 157 0
      src/main/java/io/renren/modules/levelManage/controller/LevelTableController.java
  9. 373 0
      src/main/java/io/renren/modules/levelManage/controller/ProjectAttributesController.java
  10. 873 0
      src/main/java/io/renren/modules/levelManage/controller/UniversalTableController.java
  11. 35 0
      src/main/java/io/renren/modules/levelManage/dao/LevelDao.java
  12. 26 0
      src/main/java/io/renren/modules/levelManage/dao/LevelRelationDao.java
  13. 33 0
      src/main/java/io/renren/modules/levelManage/dao/LevelTableDao.java
  14. 63 0
      src/main/java/io/renren/modules/levelManage/dao/ProjectAttributesDao.java
  15. 56 0
      src/main/java/io/renren/modules/levelManage/dao/UniversalTableDao.java
  16. 91 0
      src/main/java/io/renren/modules/levelManage/entity/LevelEntity.java
  17. 44 0
      src/main/java/io/renren/modules/levelManage/entity/LevelRelationEntity.java
  18. 54 0
      src/main/java/io/renren/modules/levelManage/entity/LevelTableEntity.java
  19. 41 0
      src/main/java/io/renren/modules/levelManage/entity/ProjectAttributesEntity.java
  20. 49 0
      src/main/java/io/renren/modules/levelManage/entity/UniversalTableEntity.java
  21. 38 0
      src/main/java/io/renren/modules/levelManage/service/LevelRelationService.java
  22. 42 0
      src/main/java/io/renren/modules/levelManage/service/LevelService.java
  23. 37 0
      src/main/java/io/renren/modules/levelManage/service/LevelTableService.java
  24. 61 0
      src/main/java/io/renren/modules/levelManage/service/ProjectAttributesService.java
  25. 63 0
      src/main/java/io/renren/modules/levelManage/service/UniversalTableService.java
  26. 221 0
      src/main/java/io/renren/modules/levelManage/service/impl/LevelRelationServiceImpl.java
  27. 104 0
      src/main/java/io/renren/modules/levelManage/service/impl/LevelServiceImpl.java
  28. 69 0
      src/main/java/io/renren/modules/levelManage/service/impl/LevelTableServiceImpl.java
  29. 125 0
      src/main/java/io/renren/modules/levelManage/service/impl/ProjectAttributesServiceImpl.java
  30. 144 0
      src/main/java/io/renren/modules/levelManage/service/impl/UniversalTableServiceImpl.java
  31. 57 0
      src/main/resources/mapper/levelManage/LevelDao.xml
  32. 29 0
      src/main/resources/mapper/levelManage/LevelRelationDao.xml
  33. 58 0
      src/main/resources/mapper/levelManage/LevelTableDao.xml
  34. 152 0
      src/main/resources/mapper/levelManage/ProjectAttributesDao.xml
  35. 183 0
      src/main/resources/mapper/levelManage/UniversalTableDao.xml

+ 35 - 0
src/main/java/io/renren/common/utils/RandomGen.java

@@ -0,0 +1,35 @@
+package io.renren.common.utils;
+
+import java.util.Random;
+
+public class RandomGen {
+    /**
+     * 随机生成n位的4进制字符串
+     *
+     * @return
+     */
+    private static String randomlyGenerateCharacters() {
+        Random random = new Random();
+        StringBuilder res = new StringBuilder();
+        for (int i = 0; i < 4; i++) {
+            int rand = random.nextInt(36);
+            if (rand < 10) {
+                res.append((char) ('0' + rand));
+            } else {
+                res.append((char) ('a' + (rand - 10)));
+            }
+        }
+        return res.toString();
+    }
+
+    /**
+     * 格式化名字
+     *
+     * @return
+     */
+    public static String formatName(String name) {
+        String res = "";
+        res = randomlyGenerateCharacters() + name.toLowerCase();
+        return res;
+    }
+}

+ 35 - 0
src/main/java/io/renren/common/utils/SubString.java

@@ -0,0 +1,35 @@
+package io.renren.common.utils;
+
+import java.util.List;
+import java.util.Map;
+
+public class SubString {
+    /**
+     * 返回数据时,将名称前端的随机数进行删除
+     * 用于Map的key为字段名,value为字段值,即列表展示的情景
+     * 展示多个实体,每个实体都只有简单的属性
+     */
+    public static void subStringList(List<Map<String, Object>> data){
+        for(Map<String,Object> rowData :data)
+        {
+            rowData.put("name",rowData.get("name").toString().substring(4));
+        }
+    }
+
+    /**
+     * 返回数据时,将名称前端的随机数进行删除
+     * 用于Map的key为单个字段的多个属性,value为单个字段的值
+     * 展示某一个实体,List的每一个项都是一个字段
+     */
+    public static void subStringRow(List<Map<String,Object>> data)
+    {
+        for(Map<String,Object> colData:data)
+        {
+            if(colData.get("name").equals("name"))
+            {
+                colData.put("value",colData.get("value").toString().substring(4));
+            }
+        }
+    }
+
+}

+ 47 - 0
src/main/java/io/renren/common/utils/ToEnglish.java

@@ -0,0 +1,47 @@
+package io.renren.common.utils;
+
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+
+public class ToEnglish {
+    /**
+     * 将中文名转化成拼音
+     * @param inputString
+     * @return
+     */
+    public static String getPinYin(String inputString) {
+        HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
+        format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
+        format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+        format.setVCharType(HanyuPinyinVCharType.WITH_U_UNICODE);
+
+        char[] input = inputString.trim().toCharArray();
+        String output = "";
+        try {
+            for (int i = 0; i < input.length; i++) {
+                if (Character.toString(input[i]).matches("[\\u4E00-\\u9FA5]+")) {  //判断字符是否是中文
+                    //toHanyuPinyinStringArray 如果传入的不是汉字,就不能转换成拼音,那么直接返回null
+                    //由于中文有很多是多音字,所以这些字会有多个String,在这里我们默认的选择第一个作为pinyin
+                    String[] temp = PinyinHelper.toHanyuPinyinStringArray(input[i], format);
+                    if(input[i] == '臂'){
+                        output += temp[1];
+                    }else{
+                        output += temp[0];
+                    }
+
+                } else {
+                    output += Character.toString(input[i]);
+                }
+            }
+        } catch (BadHanyuPinyinOutputFormatCombination e) {
+            e.printStackTrace();
+//    		Log.v(TAG, "BadHanyuPinyinOutputFormatCombination");
+        }
+        return output;
+    }
+
+}

+ 4 - 1
src/main/java/io/renren/modules/dataSet/controller/SnoopProxyControlle.java

@@ -1,6 +1,7 @@
 package io.renren.modules.dataSet.controller;
 
 
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.MediaType;
 import org.springframework.http.client.ClientHttpRequest;
@@ -23,7 +24,9 @@ import java.util.List;
 
 @RestController
 public class SnoopProxyControlle {
-    private String targetAddr = "http://lab2:8099";
+
+    @Value("${griffin}")
+    private String targetAddr;
 
     /**
      * 代理所有请求

+ 2 - 2
src/main/java/io/renren/modules/dataSet/service/impl/DynamicSystemServiceImpl.java

@@ -150,7 +150,7 @@ public class DynamicSystemServiceImpl implements DynamicSystemService {
                     Cell cell = var8[var10];
                     String key = Bytes.toString(CellUtil.cloneQualifier(cell));
                     String value = Bytes.toString(CellUtil.cloneValue(cell));
-                        if (key.contains("after")) {
+                        if (key!=null && !key.isEmpty()) {
                             map.put(key, value);
                         }
                         if (!map.containsKey("time")) {
@@ -259,7 +259,7 @@ public class DynamicSystemServiceImpl implements DynamicSystemService {
                     Cell cell = var8[var10];
                     String key = Bytes.toString(CellUtil.cloneQualifier(cell));
                     String value = Bytes.toString(CellUtil.cloneValue(cell));
-                        if (key.contains("after") ) {
+                        if (key != null || !key.isEmpty()) {
                             map.put(key, value);
                         }
                         if (!map.containsKey("time")){

+ 335 - 0
src/main/java/io/renren/modules/levelManage/controller/LevelController.java

@@ -0,0 +1,335 @@
+package io.renren.modules.levelManage.controller;
+
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.R;
+import io.renren.modules.levelManage.entity.LevelEntity;
+import io.renren.modules.levelManage.service.LevelService;
+import io.renren.modules.sys.controller.AbstractController;
+import io.renren.modules.sys.entity.SysUserEntity;
+import io.renren.modules.sys.service.SysMenuService;
+import io.renren.modules.sys.service.SysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+
+/**
+ * 层级关系表
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-28 17:07:26
+ */
+@RestController // @ResponseBody 它的作用简短截说就是指该类中所有的API接口返回的数据,甭管你对应的方法返回Map或是其他Object,它会以Json字符串的形式返回给客户端
+@RequestMapping("/level")
+public class LevelController extends AbstractController {
+    @Autowired
+    private LevelService levelService;
+    @Autowired
+    private SysUserService sysUserService;
+    @Autowired
+    private SysMenuService sysMenuService;
+
+    /**
+     * 列表
+     */
+    @RequestMapping("/list")
+    public R list(@RequestParam Map<String, Object> params){
+        PageUtils page = levelService.queryPage(params);
+        return R.ok().put("page", page);
+    }
+
+    /**
+     * 根据名称进行搜索
+     */
+    @RequestMapping("selectByName")
+    public R selectByName(@RequestParam(defaultValue = "1") Integer page,
+                          @RequestParam(defaultValue = "100") Integer size,
+                          @RequestParam(value = "name") String name)
+    {
+        List<LevelEntity> levelList = levelService.selectByName(page,size,name);
+        Integer total = levelService.getCountByName(name);
+        return R.ok().put("count",total).put("levelList",levelList);
+    }
+
+
+    /**
+     * 按层级关系展示的列表
+     */
+    @RequestMapping("/listParent")
+    public R list(){
+        List<LevelEntity> levelEntityList =levelService.list();
+
+        //将所有层级关系放入hashmap中
+        HashMap<Long, LevelEntity> levelMap = new HashMap<>();
+        for (LevelEntity level : levelEntityList) {
+            levelMap.put(level.getId(), level);
+        }
+        //对用户名同理
+        List<SysUserEntity> userEntityList = sysUserService.list();
+        HashMap<Long,SysUserEntity> userMap=new HashMap<>();
+        for(SysUserEntity user: userEntityList)
+        {
+            userMap.put(user.getUserId(),user);
+        }
+        //对每一个level,通过他的parentid,将parent名放进去,对用户一样
+        for (LevelEntity level : levelEntityList) {
+            LevelEntity parent = levelMap.get(level.getParentId());
+            if (Objects.nonNull(parent)) {
+                level.setParentName(parent.getName());
+            }
+            SysUserEntity user= userMap.get(level.getUid());
+            if(Objects.nonNull(user))
+            {
+                level.setUName(user.getUsername());
+            }
+        }
+
+        return R.ok().put("levelList",levelEntityList);
+    }
+
+    /**
+     * 层级关系信息,加上一个第0层级,用于新加入层级时的父层级选择
+     */
+    @GetMapping("/listParentWithZero")
+    public R  listParentWithZero(){
+
+        List<LevelEntity> levelEntityList =levelService.list();
+        //将所有层级关系放入hashmap中
+        HashMap<Long, LevelEntity> levelMap = new HashMap<>();
+        for (LevelEntity level : levelEntityList) {
+            levelMap.put(level.getId(), level);
+        }
+        //对每一个level,通过他的parentid,将parent名放进去,对用户一样
+        for (LevelEntity level : levelEntityList) {
+            LevelEntity parent = levelMap.get(level.getParentId());
+            if (Objects.nonNull(parent)) {
+                level.setParentName(parent.getName());
+            }
+        }
+        LevelEntity zero =new LevelEntity();
+        zero.setLevel(0L);
+        zero.setParentId((long) 0);
+        zero.setId((long) 0);
+        zero.setName("根层级");
+
+        levelEntityList.add(zero);
+        return R.ok().put("levelList",levelEntityList);
+    }
+
+    /**
+     * 获取某一个层级的信息
+     */
+    @RequestMapping("/getById")
+    public R getLevelById(@RequestParam("id") Integer id)
+    {
+        LevelEntity levelEntity=levelService.getById(id);
+        return R.ok().put("levelEntity",levelEntity);
+    }
+
+    /**
+     * 获取某一个层级的子层级
+     */
+    @RequestMapping("/getSonLevel")
+    public R getSonLevel(@RequestParam("id") Long id)
+    {
+        List<LevelEntity> levelEntityList=levelService.getSonLevel(id);
+        return R.ok().put("data",levelEntityList);
+    }
+
+    /**
+     * 信息
+     */
+    @RequestMapping("/info/{id}")
+    public R info(@PathVariable("id") Long id){
+		LevelEntity level = levelService.getById(id);
+
+        return R.ok().put("level", level);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    public R save(@RequestBody LevelEntity level){
+        LevelEntity parent = levelService.getById(level.getParentId());
+        level.setCreateDate(new Date());
+        level.setUid(getUserId());
+        if(parent!=null)
+            level.setLevel(parent.getLevel()+1);
+        else
+        {
+            level.setLevel(1L);
+            level.setParentId(0L);
+        }
+        levelService.save(level);
+        return R.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    public R update(@RequestBody LevelEntity level){
+        LevelEntity parent = levelService.getById(level.getParentId());
+        level.setCreateDate(new Date());
+        level.setUid(getUserId());
+        if(parent!=null)
+            level.setLevel(parent.getLevel()+1);
+        else
+        {
+            level.setLevel(1L);
+            level.setParentId(0L);
+        }
+		levelService.updateById(level);
+        return R.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    public R delete(@RequestBody Long[] ids){
+		levelService.removeByIds(Arrays.asList(ids));
+
+        return R.ok();
+    }
+
+
+    /**
+     * 查询已启用的层级数,作为是否可以启用层级的标记
+     */
+    @RequestMapping("/getEnabledCount")
+    public R queryEnabledCount()
+    {
+        Integer count = levelService.queryEnabledCount();
+        return R.ok().put("enabledCount",count);
+    }
+
+    /**
+     * 根据子层级id,进行其所有父层级的启用
+     */
+    @RequestMapping("/setEnabled")
+    public R setEnabled(@RequestParam("id") Long id,@RequestParam("projectId") Long projectId)
+    {
+        //启用层级,分为4步:1.查出当前层级的所有父层级;2.进行父层级状态查询,没有表的直接返回错误信息;
+        // 3.修改每一个表的enable标志,同时将parentid植入
+        // 目前否定;4.将父层级加入到菜单表里面,暂定菜单名为层级名,属于menu_id为44的层级管理
+//        Long parentId=44L;
+        List<LevelEntity> enabledEntity= levelService.getAllParentById(id);
+        for(LevelEntity level:enabledEntity)
+        {
+            if (level.getCreateTable()==0)
+                return R.error().put("msg","当前层级或其父层级没有创建表格");
+            else
+                level.setEnabled(1);
+            level.setProjectId(projectId);
+        }
+        if(!levelService.saveOrUpdateBatch(enabledEntity))
+        {
+            return R.error().put("msg","当前层级或其父层级启用状态修改失败");
+        }
+//        List<SysMenuEntity> menuList=new ArrayList<>();
+//        int i=0;
+//        for(LevelEntity level:enabledEntity)
+//        {
+//            SysMenuEntity menuEntity=new SysMenuEntity();
+//            menuEntity.setParentId(parentId);
+//            menuEntity.setName(level.getName());
+//            menuEntity.setUrl("universalTable");
+//            menuEntity.setType(1);
+//            menuEntity.setOrderNum(++i);
+//            menuEntity.setTableId(level.getId());
+//            menuList.add(menuEntity);
+//        }
+//        if(!sysMenuService.saveBatch(menuList))
+//        {
+//            for(LevelEntity level:enabledEntity)
+//            {
+//                level.setEnabled(0);
+//            }
+//            if(!levelService.saveBatch(enabledEntity))
+//            {
+//                return R.error().put("msg","系统菜单插入失败,层级状态回滚失败");
+//            }
+//            return R.error().put("msg","系统菜单插入失败,层级状态已回滚");
+//        }
+        return R.ok();
+    }
+
+    /**
+     * 清除所有启用信息
+     */
+    @RequestMapping("/clearEnabled")
+    public R clclearEnabled()
+    {
+        //进行已启用层级的删除,分为3步:1.查找所有启用的层级 2.将这些层级的启用标志进行修改 3.从菜单页面删除url是universalTable的行
+        String url="universalTable";
+        List<LevelEntity> enabledLevelList=levelService.getEnabledLevels();
+        for(LevelEntity level: enabledLevelList)
+        {
+            level.setEnabled(0);
+            level.setProjectId(0L);
+        }
+        if(!levelService.saveOrUpdateBatch(enabledLevelList))
+        {
+            return R.error().put("msg","层级状态修改失败");
+        }
+        //目前暂不考虑菜单相关
+//        if(!sysMenuService.deleteByURL(url))
+//        {
+//            return R.error().put("msg","删除菜单页面失败");
+//        }
+
+        return R.ok();
+    }
+
+    @RequestMapping("/isLeaf")
+    public R isLeaf(@RequestParam("id") Long id)
+    {
+        /**
+         * 通过判断启用的节点中,是否有节点的父节点id为传入参数,判断该节点是否为叶子
+         * 叶子不会是其它的parent,所以一定为0
+         * 因为是叶子,所以传真值,即1
+         * 其它传0
+         */
+        Integer parentCount=levelService.queryEnabledCountWithParentId(id);
+        if(parentCount.equals(0))
+            return R.ok().put("data",0);
+        else
+            return R.ok().put("data",1);
+    }
+
+    @RequestMapping("/getEnabledSon")
+    public R getEnabledSon(@RequestParam("id") Long id)
+    {
+        LevelEntity levelEntity=levelService.getEnabledSon(id);
+        return R.ok().put("data",levelEntity);
+    }
+
+    @RequestMapping("/getParentList")
+    public R gegetEnabledList(@RequestParam("id") Long id)
+    {
+        List<LevelEntity> parentList=levelService.getAllParentById(id);
+        return R.ok().put("data",parentList);
+    }
+
+    /**
+     * 为了防止出现同一父层级的多个子层级同时启用,因此需要在启用前对层级的父层级是否启用进行判断
+     * 当enable=0时,代表不能启用,1时代表可以
+     * @param id
+     * @return
+     */
+    @RequestMapping("/enablebility")
+    public R hasEnablebility(@RequestParam("id") Long id){
+        List<LevelEntity> parentList=levelService.getAllParentById(id);
+        for(LevelEntity level: parentList){
+            if(level.getEnabled()==null || level.getEnabled()==0)
+                continue;
+            else
+                return R.ok().put("enable",0);
+        }
+        return R.ok().put("enable",1);
+    }
+}

+ 124 - 0
src/main/java/io/renren/modules/levelManage/controller/LevelRelationController.java

@@ -0,0 +1,124 @@
+package io.renren.modules.levelManage.controller;
+
+import io.renren.common.utils.MinIoUtils;
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.R;
+import io.renren.modules.levelManage.entity.LevelRelationEntity;
+import io.renren.modules.levelManage.service.LevelRelationService;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 用于存储层级直接,具体数据的关系
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-04-08 17:49:50
+ */
+@RestController
+@RequestMapping("/levelrelation")
+public class LevelRelationController {
+    @Autowired
+    private LevelRelationService levelRelationService;
+
+    @RequestMapping("/uploadFile")
+    public R filesupload(@RequestParam MultipartFile[] files) throws Exception {
+        try {
+            for (MultipartFile file : files) {
+                try{
+                    MinIoUtils.uploadMultipartFile(file,"level",file.getOriginalFilename());
+                } catch (Exception e) {
+                    return R.error(file.getOriginalFilename()+ "上传失败,原因为:\n\t"
+                    +e.getMessage()).put("analysis",0);
+                }
+            }
+            return R.ok("上传成功").put("analysis",1);
+        } catch (Exception e) {
+            if(null != e.getMessage()){
+                return R.error(e.getMessage());
+            }
+            return R.error("上传失败").put("analysis",0);
+        }
+    }
+    @PostMapping("/analysisFiles")
+    public R analysisFiles(@RequestBody List<String> fileNames) throws Exception{
+        for(String fileName:fileNames){
+            try {
+                if(levelRelationService.tableHasBuilted(fileName)){
+                    return R.error().put("msg",fileName+"中含有重复或已存在的表,无法进行层级建立");
+                }
+                InputStream file= MinIoUtils.getFileInputStream("level",fileName);
+                SAXReader reader=new SAXReader();
+                Document document= reader.read(file);
+                Element root=document.getRootElement();
+                levelRelationService.analysisLevel(root,0L, 1L);
+            }
+            catch (Exception e){
+                return R.error().put("msg",fileName+"解析失败,原因为:"+e.getMessage());
+            }
+        }
+        return R.ok().put("msg","解析成功");
+    }
+
+    /**
+     * 列表
+     */
+    @RequestMapping("/list")
+    public R list(@RequestParam Map<String, Object> params){
+        PageUtils page = levelRelationService.queryPage(params);
+
+        return R.ok().put("page", page);
+    }
+
+
+    /**
+     * 信息
+     */
+    @RequestMapping("/info/{id}")
+    public R info(@PathVariable("id") Long id){
+		LevelRelationEntity levelRelation = levelRelationService.getById(id);
+
+        return R.ok().put("levelRelation", levelRelation);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    public R save(@RequestBody LevelRelationEntity levelRelation){
+		levelRelationService.save(levelRelation);
+
+        return R.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    public R update(@RequestBody LevelRelationEntity levelRelation){
+		levelRelationService.updateById(levelRelation);
+
+        return R.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    public R delete(@RequestBody Long[] ids){
+		levelRelationService.removeByIds(Arrays.asList(ids));
+
+        return R.ok();
+    }
+
+}

+ 157 - 0
src/main/java/io/renren/modules/levelManage/controller/LevelTableController.java

@@ -0,0 +1,157 @@
+package io.renren.modules.levelManage.controller;
+
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.R;
+import io.renren.modules.levelManage.entity.LevelEntity;
+import io.renren.modules.levelManage.entity.LevelTableEntity;
+import io.renren.modules.levelManage.service.LevelService;
+import io.renren.modules.levelManage.service.LevelTableService;
+import io.renren.modules.sys.controller.AbstractController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+
+/**
+ * 
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-30 16:57:16
+ */
+@RestController
+@RequestMapping("/leveltable")
+public class LevelTableController extends AbstractController {
+    @Autowired
+    private LevelTableService levelTableService;
+    @Autowired
+    private LevelService levelService;
+    @Autowired
+    private LevelController levelController;
+
+
+    @RequestMapping("/createTable")
+    public R createTable(@RequestBody Map<String,Object> map)
+    {
+        String tableName= (String) map.get("tableName");
+        if (tableName==null)
+            return R.error().put("msg","未输入表格名称");
+        List<Map<String,String>> colName= ( List<Map<String,String>>) map.get("col");
+        Long levelId = Long.valueOf(map.get("id").toString()) ;
+        Long userId = getUserId();
+
+        //无效数据的清洗
+        List<Map<String,String>> trueCols=new ArrayList<>();
+        for(Map<String,String> item :colName)
+        {
+            String type = item.get("type");
+            String comment = item.get("remark");
+            String name = item.get("name");
+            if(comment==null)
+                comment=name;
+            if(name==null && type==null)
+                continue;
+            if(type==null || name==null)
+                return R.error().put("msg","表格属性输入错误");
+            HashMap<String,String> temp = new HashMap<>();
+            temp.put("name",name);
+            temp.put("type",trans(type));
+            temp.put("comment",comment);
+            trueCols.add(temp);
+        }
+        //表格的建立,以及对应关系的插入
+        if(levelTableService.createTable(tableName,trueCols)==0)
+        {
+            for(Map<String,String> item : trueCols)
+            {
+                LevelTableEntity levelTable=new LevelTableEntity();
+                levelTable.setLevelId(levelId);
+                levelTable.setCreateDate(new Date());
+                levelTable.setCreateUser(userId);
+                levelTable.setName(item.get("name"));
+                levelTable.setType(item.get("type"));
+                levelTable.setRemark(item.get("comment"));
+                if(!levelTableService.save(levelTable))
+                {
+                    return R.error().put("msg","表格创建成功,关联关系记录失败");
+                }
+            }
+            LevelEntity levelEntity=levelService.getById(levelId);
+            levelEntity.setCreateTable(1);
+            levelEntity.setTableName(tableName);
+
+            levelController.update(levelEntity);
+
+            return R.ok();
+        }
+        return R.error().put("msg","创建表格失败");
+    }
+    /**
+     * 列表
+     */
+    @RequestMapping("/list")
+    public R list(@RequestParam Map<String, Object> params){
+        PageUtils page = levelTableService.queryPage(params);
+
+        return R.ok().put("page", page);
+    }
+
+    @RequestMapping("/listByLevelId")
+    public R list(@RequestParam("levelId") Long id)
+    {
+        List<Map<String,Object>> data=levelTableService.listByLevelId(id);
+        LevelEntity level=levelService.getById(id);
+        String tablename=level.getTableName();
+        return R.ok().put("data",data).put("tableName",tablename);
+    }
+
+
+    /**
+     * 信息
+     */
+    @RequestMapping("/info/{id}")
+    public R info(@PathVariable("id") Long id){
+		LevelTableEntity levelTable = levelTableService.getById(id);
+
+        return R.ok().put("levelTable", levelTable);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    public R save(@RequestBody LevelTableEntity levelTable){
+		levelTableService.save(levelTable);
+
+        return R.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    public R update(@RequestBody LevelTableEntity levelTable){
+		levelTableService.updateById(levelTable);
+
+        return R.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    public R delete(@RequestBody Long[] ids){
+		levelTableService.removeByIds(Arrays.asList(ids));
+
+        return R.ok();
+    }
+
+
+    private String trans(String type)
+    {
+        if(type.equals("varchar"))
+            type="varchar(255)";
+        return type;
+    }
+}

+ 373 - 0
src/main/java/io/renren/modules/levelManage/controller/ProjectAttributesController.java

@@ -0,0 +1,373 @@
+package io.renren.modules.levelManage.controller;
+
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.R;
+import io.renren.common.utils.RandomGen;
+import io.renren.common.utils.SubString;
+import io.renren.modules.levelManage.entity.LevelEntity;
+import io.renren.modules.levelManage.entity.ProjectAttributesEntity;
+import io.renren.modules.levelManage.service.LevelService;
+import io.renren.modules.levelManage.service.ProjectAttributesService;
+import io.renren.modules.sys.controller.AbstractController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+/**
+ * 
+ *
+ * @author Noth
+ * @email sunlightcs@gmail.com
+ * @date 2022-09-17 17:20:39
+ */
+@RestController
+@RequestMapping("/levelManage/projectattributes")
+public class ProjectAttributesController extends AbstractController {
+    @Autowired
+    private ProjectAttributesService projectAttributesService;
+    @Autowired
+    private LevelService levelService;
+    @Value("${cengji}")
+    private String schema;
+
+
+    @RequestMapping("/projectToLevel")
+    public R projectToLevel(@RequestParam("id") Long id){
+        if(projectAttributesService.countProjectLevel(id).equals("0"))
+            return R.ok().put("state",0);
+        else {
+            Integer tableId=projectAttributesService.selectRootLevel(id);
+            return R.ok().put("tableId",tableId).put("state",1);
+        }
+    }
+
+    @RequestMapping("/getProjectInfoForLevel")
+    public R getProjectInfoForLevel()
+    {
+        List<Map<String,Object>> projects=projectAttributesService.listProjectName();
+
+        for(Map<String,Object> project:projects){
+            project.put("disabled",projectAttributesService.countProjectLevel((Long) project.get("id")));
+        }
+        SubString.subStringList(projects);
+        return R.ok().put("data",projects);
+    }
+
+    @RequestMapping("/getProjectInfo")
+    public R getProjectInfo(@RequestParam("page") Integer page,@RequestParam("size") Integer size)
+    {
+
+        List<String> tableCols =projectAttributesService.listCols();
+        List<Map<String,Object>> data=projectAttributesService.listData(tableCols,page,size);
+        //data是<列名,具体值>的list
+
+        //对bool值需要修改为是/否,否则前端不显示(应该在前端解决,但是做不到,先在后端进行)
+        //先获取所有是bool的列,通过遍历list,用列名对所有value修改
+        List<String> boolCols=projectAttributesService.listBoolCols();
+
+        for(Map<String,Object> map :data)
+        {
+            for(String col: boolCols)
+            {
+                if((boolean) map.get(col))
+                {
+                    map.put(col,"是");
+                }
+                else
+                    map.put(col,"否");
+            }
+        }
+        SubString.subStringList(data);
+        Integer count=projectAttributesService.countProject();
+        return R.ok().put("data",data).put("count",count);
+    }
+
+    @RequestMapping("/hasProject")
+    public R count(){
+        int count=projectAttributesService.hasProject(schema);
+        return R.ok().put("count",count);
+    }
+
+    @RequestMapping("/createTable")
+    public R createTable(@RequestBody Map<String,Object> map)
+    {
+        if(projectAttributesService.hasProject(schema)==1)
+            return R.error().put("msg","项目表格已存在");
+
+        List<Map<String,String>> colName= ( List<Map<String,String>>) map.get("col");
+        Long userId = getUserId();
+
+        //无效数据的清洗
+        List<Map<String,String>> trueCols=new ArrayList<>();
+        for(Map<String,String> item :colName)
+        {
+            String type = item.get("type");
+            String comment = item.get("remark");
+            String name = item.get("name");
+            if(comment==null)
+                comment=name;
+            if(name==null && type==null)
+                continue;
+            if(type==null || name==null)
+                return R.error().put("msg","表格属性输入错误");
+            HashMap<String,String> temp = new HashMap<>();
+            temp.put("name",name);
+            temp.put("type",trans(type));
+            temp.put("comment",comment);
+            trueCols.add(temp);
+        }
+
+        //将属性存入project_attribute表中
+        for(Map<String,String> attribute: trueCols){
+            ProjectAttributesEntity projectAttributesEntity=new ProjectAttributesEntity();
+            projectAttributesEntity.setName(attribute.get("name"));
+            projectAttributesEntity.setType(attribute.get("type"));
+            projectAttributesEntity.setRemark(attribute.get("comment"));
+            if(!projectAttributesService.save(projectAttributesEntity))
+                return R.error().put("msg","保存失败");
+        }
+
+        //利用属性建立project表
+        projectAttributesService.createTable(trueCols);
+        return R.ok();
+    }
+
+    @RequestMapping("/getCols")
+    public R getCols()
+    {
+        //因为实际上给的应该是 字段名、中文名、类型
+        List<Map<String,Object>> data=projectAttributesService.listAttribute();
+
+        return R.ok().put("data",data);
+    }
+
+    @RequestMapping("/getInfo")
+    public R getInfo(@RequestParam("rowId") Long id){
+        //获取列,list里面的Map的key为 name,remark,type
+        List<Map<String,Object>> data=projectAttributesService.listAttribute();
+        //在list里面的Map添加新的key,值为value
+        //先获取所有的值
+        List<String> tableCols = projectAttributesService.listCols();
+        Map<String,Object> valueMap=projectAttributesService.selectById(id,tableCols);
+        //在list里面添加上面map的值,存到key为value的对里面
+        for (Map<String,Object> item : data)
+        {
+            item.put("value", String.valueOf(valueMap.get(item.get("name"))));
+        }
+
+        SubString.subStringRow(data);
+        return R.ok().put("data",data);
+    }
+
+    @RequestMapping("/selectByName")
+    public R selectByName(@RequestParam("page") Integer page,@RequestParam("limit") Integer limit,
+                          @RequestParam("name") String name)
+    {
+        //获取查询需要的参数
+        List<String> tableCols =projectAttributesService.listCols();
+
+        List<Map<String,Object>> data=projectAttributesService.selectByName(tableCols,page,limit,name);
+        SubString.subStringList(data);
+        Integer count = projectAttributesService.getCountByName(name);
+        return R.ok().put("data",data).put("count",count);
+    }
+
+    /**
+     * 列表
+     */
+    @RequestMapping("/list")
+    public R list(@RequestParam Map<String, Object> params){
+        PageUtils page = projectAttributesService.queryPage(params);
+
+        return R.ok().put("page", page);
+    }
+
+
+    /**
+     * 信息
+     */
+    @RequestMapping("/info/{id}")
+    public R info(@PathVariable("id") Long id){
+		ProjectAttributesEntity projectAttributes = projectAttributesService.getById(id);
+
+        return R.ok().put("projectAttributes", projectAttributes);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    public R save(@RequestBody Map<String,Object> map) throws ParseException {
+        //先抽取属性,形成表结构,然后存进表里,最后返回ok
+        //真正需要的字段
+        List<Map<String,Object>> trueCols= new ArrayList<>();
+
+        //获取的数据,需要进行处理
+        List<Map<String,Object>> cols= (List<Map<String, Object>>) map.get("cols");
+        Long uid=getUserId();
+
+        //save没有字段id
+        //对cols进行处理,去除没有value的字段,将特定字段:create_user进行修改
+        for(Map<String,Object> col :cols)
+        {
+            if(col.get("cols").equals("name"))
+            {
+                col.put("value",RandomGen.formatName(col.get("value").toString()));
+            }
+            else if(col.get("cols").equals("create_user"))
+            {
+                col.put("value",uid);
+            }
+            else if(col.get("cols").equals("create_time"))
+            {
+                col.put("value",new Date());
+            }
+            else if (col.get("cols").equals("id"))
+            {
+                continue;
+            }
+            else if(col.get("type").equals("date"))
+            {
+                String  str= col.get("value").toString();
+                DateFormat format=new SimpleDateFormat("yyyy-MM-dd");
+                Date date=format.parse(str);
+                col.put("value",date);
+            }
+            trueCols.add(col);
+        }
+        //直接通过map进行存储,同时,需要将动态列作为参数传入,在map里面进行动态插入
+        projectAttributesService.saveWithCols(trueCols);
+
+        return R.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    public R update(@RequestBody Map<String,Object> map) throws ParseException{
+
+        //先抽取属性,形成表结构,然后存进表里,最后返回ok
+        //真正需要的字段
+        List<Map<String,Object>> trueCols= new ArrayList<>();
+
+        //获取的数据,需要进行处理
+        List<Map<String,Object>> cols= (List<Map<String, Object>>) map.get("cols");
+        Long id=Long.valueOf(map.get("id").toString());
+        Long uid=getUserId();
+        String orginRowName = projectAttributesService.selectProjectNameById(id);
+
+        //和save不同,update有字段id,但是实际上cols中不需要id,id需要作为另外的参数传入
+        //对cols进行处理,去除没有value的字段,将特定字段进行修改
+        for(Map<String,Object> col :cols)
+        {
+            if(col.get("cols").equals("name"))
+            {
+                //cols中的name是处理过的name,因此不需要再次substring
+                if(col.get("value").toString().equals(orginRowName.substring(4)))
+                {
+                    col.put("value",orginRowName);
+                }
+                else{
+                    col.put("value",RandomGen.formatName(col.get("value").toString()));
+                }
+            }
+            else if(col.get("cols").equals("create_user"))
+            {
+                col.put("value",uid);
+            }
+            else if(col.get("cols").equals("create_time"))
+            {
+                col.put("value",new Date());
+            }
+            else if (col.get("cols").equals("id"))
+            {
+                continue;
+            }
+            else if(col.get("type").equals("date"))
+            {
+                String  str= col.get("value").toString();
+                DateFormat format=new SimpleDateFormat("yyyy-MM-dd");
+                Date date=format.parse(str);
+                col.put("value",date);
+            }
+            trueCols.add(col);
+        }
+        //直接存储不可以,因为还是需要进行类的变化,因此需要将动态列作为参数传入,在map里面进行动态插入
+        //因为dao里面不一样,所以不能直接用save
+        projectAttributesService.updateWithCols(trueCols,id);
+        return R.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    public R delete(@RequestBody Long[] ids){
+//		projectAttributesService.removeByIds(Arrays.asList(ids));
+        projectAttributesService.removeProjectByIds(Arrays.asList(ids));
+        List<LevelEntity> enabledLevelList=levelService.getEnabledLevelByProject(Arrays.asList(ids));
+        for(LevelEntity levelEntity:enabledLevelList){
+            levelEntity.setProjectId(0L);
+            levelEntity.setEnabled(0);
+        }
+        if(!levelService.saveOrUpdateBatch(enabledLevelList))
+        {
+            return R.error().put("msg","层级状态修改失败");
+        }
+        return R.ok();
+    }
+
+    @RequestMapping("/dropProject")
+    public R RequestMapping(){
+        projectAttributesService.dropProject();
+        return R.ok();
+    }
+
+    private String trans(String type)
+    {
+        if(type.equals("varchar"))
+            type="varchar(255)";
+        return type;
+    }
+
+    /**
+     * 获取第一层级(项目)的信息,包括id和名称,本次获取应该在页面刷新时进行,并且此时获取的数据仅有页面左侧区域
+     * @return
+     */
+    @RequestMapping("/getAllProject")
+    public R getAllProject(){
+        int count=projectAttributesService.hasProject(schema);
+        if(count==0)
+            return R.error("暂未设定项目属性");
+        else {
+            return getProjectInfoForLevel();
+        }
+    }
+
+    /**
+     * 获取目标用户创建的项目的信息
+     */
+    @RequestMapping("/getProjectWithUid")
+    public R getProjectWithUid(@RequestParam Long uid){
+        int count=projectAttributesService.hasProject(schema);
+        if(count==0)
+            return R.error("暂未设定项目属性");
+        else {
+            List<Map<String,Object>> projects=projectAttributesService.listProjectByUid(uid);
+
+            for(Map<String,Object> project:projects){
+                project.put("disabled",projectAttributesService.countProjectLevel((Long) project.get("id")));
+            }
+            SubString.subStringList(projects);
+            return R.ok().put("data",projects);
+        }
+    }
+
+}

+ 873 - 0
src/main/java/io/renren/modules/levelManage/controller/UniversalTableController.java

@@ -0,0 +1,873 @@
+package io.renren.modules.levelManage.controller;
+
+import cn.hutool.core.collection.CollectionUtil;
+import io.renren.common.utils.R;
+import io.renren.common.utils.RandomGen;
+import io.renren.common.utils.SubString;
+import io.renren.common.utils.ToEnglish;
+import io.renren.modules.levelManage.entity.LevelEntity;
+import io.renren.modules.levelManage.entity.LevelRelationEntity;
+import io.renren.modules.levelManage.entity.UniversalTableEntity;
+import io.renren.modules.levelManage.service.*;
+import io.renren.modules.sys.controller.AbstractController;
+import lgh.springboot.starter.hbase.template.HBaseTemplate;
+import org.apache.hadoop.hbase.io.compress.Compression;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+/**
+ *
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-30 16:57:16
+ */
+@RestController
+@RequestMapping("/universaltable")
+public class UniversalTableController extends AbstractController {
+
+    @Autowired
+    private UniversalTableService universalTableService;
+    @Autowired
+    private LevelService levelService;
+    @Autowired
+    private LevelTableService levelTableService;
+    @Autowired
+    private LevelRelationService levelRelationService;
+    @Autowired
+    private HBaseTemplate hBaseTemplate;
+    @Autowired
+    private ProjectAttributesService projectAttributesService;
+    /**
+     * 列表
+     */
+    @RequestMapping("/list")
+    public R list(@RequestParam("tableId") Long tableId,@RequestParam("page") Integer page,@RequestParam("size") Integer size)
+    {
+        LevelEntity levelEntity = levelService.getById(tableId);
+        String tableName = levelEntity.getTableName();
+        List<String> tableCols = levelTableService.listColsByLevelId(tableId);
+        List<Map<String,Object>> data=universalTableService.list(tableName,tableCols,page,size);
+        //data是<列名,具体值>的list
+
+        //对bool值需要修改为是/否,否则前端不显示(应该在前端解决,但是做不到,先在后端进行)
+        //先获取所有是bool的列,通过遍历list,用列名对所有value修改
+        List<String> boolCols=levelTableService.listBoolColsById(tableId);
+
+        for(Map<String,Object> map :data)
+        {
+            for(String col: boolCols)
+            {
+                if((boolean) map.get(col))
+                {
+                    map.put(col,"是");
+                }
+                else
+                    map.put(col,"否");
+            }
+        }
+        SubString.subStringList(data);
+        Integer count=universalTableService.getCount(tableName);
+        return R.ok().put("data",data).put("count",count);
+    }
+
+    /**
+     * 根据父层级具体内容的id进行查询
+     */
+    @RequestMapping("/listWithParentRowId")
+    public R listWithParentRowId(@RequestParam("parentTableId") Long parentTableId,@RequestParam("parentRowId") Long parentRowId,
+            @RequestParam("tableId") Long tableId,@RequestParam("page") Integer page,@RequestParam("size") Integer size)
+    {
+        //通过id拿表名,方便使用
+        LevelEntity levelEntity = levelService.getById(tableId);
+        String tableName = levelEntity.getTableName();
+        //获取表的字段,一会传数据回去的时候需要列的信息
+        List<String> tableCols = levelTableService.listColsByLevelId(tableId);
+
+        //原先的逻辑是通过父表id和父表行id,锁定子表id和子表行id,通过对子表id进行匹配,搜索出子表行
+        //现在优化了逻辑,因为子表只有一个父表,因此只需要子表行和父表id,就可以锁定子表行
+        List<LevelRelationEntity> relations= levelRelationService.selectByParentRowAndSonTable(tableId,parentRowId);
+        //将所有应获取的子表行id写入ids
+        List<Long> ids = new ArrayList<>();
+        for(LevelRelationEntity relation: relations)
+        {
+            ids.add(relation.getSonRowId());
+        }
+        if(ids.size()==0)
+        {
+            return R.ok().put("count",0);
+        }
+
+        //通过ids和页面个数限制,查找所有的值
+        List<Map<String,Object>> data=universalTableService.listBySonIds(tableName,tableCols,ids,page,size);
+
+        //对bool值需要修改为是/否,否则前端不显示
+        //先获取表中类型为bool的列,然后遍历data的值,将bool列的value修改为是/否
+        List<String> boolCols=levelTableService.listBoolColsById(tableId);
+
+        for(Map<String,Object> map :data)
+        {
+            for(String col: boolCols)
+            {
+                if((boolean) map.get(col))
+                {
+                    map.put(col,"是");
+                }
+                else
+                    map.put(col,"否");
+            }
+        }
+        SubString.subStringList(data);
+        //总计个数就是ids的个数
+        Integer count=ids.size();
+        return R.ok().put("data",data).put("count",count);
+    }
+
+    /**
+     * 获取信息,包括表名和表内内容
+     */
+    @RequestMapping("/selectById")
+    public R list(@RequestParam("id") Long id,@RequestParam("tableId") Long tableId)
+    {
+        LevelEntity levelEntity = levelService.getById(tableId);
+        String tableName = levelEntity.getTableName();
+        List<String> tableCols = levelTableService.listColsByLevelId(tableId);
+        Map<String,Object> data=universalTableService.selectById(id,tableName,tableCols);
+        return R.ok().put("data",data);
+    }
+
+    /**
+     * 获取字段信息
+     */
+    @RequestMapping("/getCols")
+    public R getCols(@RequestParam("tableId") Long id)
+    {
+        //因为实际上给的应该是 字段名、中文名、类型
+//        List<String> cols = levelTableService.listColsByLevelId(id);
+//        List<String> comment = levelTableService.listCommentByLevelId(id);
+//        List<String> type =levelTableService.listTypeByLevelId(id);
+        //刚好有之前写的
+        List<Map<String,Object>> data=levelTableService.listByLevelId(id);
+        //不能直接map,会丢失顺序
+
+        //先获取parentLevel,然后获取parentLevel的item作为新增时选择的候选值
+        LevelEntity nowLevel=levelService.getById(id);
+        Long parentId=nowLevel.getParentId();
+
+        List<Map<String,Object>> parentItem=levelTableService.listByLevelId(parentId);
+        return R.ok().put("data",data).put("parentItem",parentItem);
+    }
+
+    /**
+     * 获取字段具体信息,用于修改,是selectById的变形
+     */
+    @RequestMapping("/getInfo")
+    public R getInfo(@RequestParam("tableId") Long tableId,@RequestParam("rowId") Long id)
+    {
+        //获取列,list里面的Map的key为 name,remark,type
+        List<Map<String,Object>> data=levelTableService.listByLevelId(tableId);
+        //在list里面的Map添加新的key,值为value
+        //先获取所有的值
+        LevelEntity levelEntity = levelService.getById(tableId);
+        String tableName = levelEntity.getTableName();
+        List<String> tableCols = levelTableService.listColsByLevelId(tableId);
+        Map<String,Object> valueMap=universalTableService.selectById(id,tableName,tableCols);
+        //在list里面添加上面map的值,存到key为value的对里面
+        for (Map<String,Object> item : data)
+        {
+            item.put("value", String.valueOf(valueMap.get(item.get("name"))));
+        }
+
+        SubString.subStringRow(data);
+        return R.ok().put("data",data);
+    }
+
+    /**
+     * 用于识别是否为特殊层级
+     * @param id
+     * @return
+     */
+    @RequestMapping("/hasHbaseTable")
+    public R hasHbaseTable(@RequestParam("tableId") Long id)
+    {
+        LevelEntity levelEntity= levelService.getById(id);
+        return R.ok().put("data",levelEntity.getHasHbasetable());
+    }
+
+    /**
+     * 搜索
+     */
+    @RequestMapping("/selectByName")
+    public R selectByName(@RequestParam("page") Integer page,@RequestParam("limit") Integer limit,
+                          @RequestParam("tableId") Long id,@RequestParam("name") String name)
+    {
+        //获取查询需要的参数
+        LevelEntity levelEntity = levelService.getById(id);
+        String tableName = levelEntity.getTableName();
+        List<String> tableCols = levelTableService.listColsByLevelId(id);
+
+        List<Map<String,Object>> data=universalTableService.selectByName(tableName,tableCols,page,limit,name);
+        SubString.subStringList(data);
+        Integer count = universalTableService.getCountByName(tableName,name);
+        return R.ok().put("data",data).put("count",count);
+    }
+
+    @RequestMapping("/selectByNameWithParent")
+    public R selectByNameWithParent(@RequestParam("page") Integer page,@RequestParam("limit") Integer limit,
+                          @RequestParam("tableId") Long id,@RequestParam("name") String name,
+                          @RequestParam("parentRowId") Long parentRowId)
+    {
+        //获取查询需要的参数
+        LevelEntity levelEntity = levelService.getById(id);
+        String tableName = levelEntity.getTableName();
+        List<String> tableCols = levelTableService.listColsByLevelId(id);
+        List<Map<String,Object>> data=universalTableService.selectByNameWithParent(tableName,tableCols,page,limit,name,parentRowId,id);
+        SubString.subStringList(data);
+        Integer count = universalTableService.getCountByNameWithParent(tableName,name,parentRowId,id);
+        return R.ok().put("data",data).put("count",count);
+    }
+
+//    @RequestMapping("/info/{id}")
+//    public R info(@PathVariable("id") Long id){
+//        LevelTableEntity levelTable = levelTableService.getById(id);
+//
+//        return R.ok().put("levelTable", levelTable);
+//    }
+//
+    /**
+     * 保存/新增
+     */
+    @RequestMapping("/save")
+    public R save(@RequestBody Map<String,Object> map) throws ParseException{
+        //先抽取属性,形成表结构,然后存进表里,最后返回ok
+        //真正需要的字段
+        List<Map<String,Object>> trueCols= new ArrayList<>();
+
+        //获取的数据,需要进行处理
+        List<Map<String,Object>> cols= (List<Map<String, Object>>) map.get("cols");
+        Long uid=getUserId();
+        Long tableId=Long.valueOf(map.get("tableId").toString());
+        LevelEntity levelEntity = levelService.getById(tableId);
+        String tableName = levelEntity.getTableName();
+        Long parentTableId=0L;
+        if(map.containsKey("parentTableId") && !map.get("parentTableId").toString().equals("undefined"))
+        {
+            parentTableId=Long.valueOf(map.get("parentTableId").toString());
+        }
+        Long parentRowId=0L;
+        if(map.containsKey("parentRowId") && !map.get("parentRowId").toString().equals("undefined"))
+        {
+            parentRowId=Long.valueOf(map.get("parentRowId").toString());
+        }
+
+        //save没有字段id
+        //先创建一个universalTable作为缓冲
+        UniversalTableEntity universalTable=new UniversalTableEntity();
+        universalTable.setCreateUser(uid);
+        universalTable.setCreateDate(new Date());
+        //对cols进行处理,去除没有value的字段,将特定字段:create_user进行修改
+        for(Map<String,Object> col :cols)
+        {
+            if(col.get("cols").equals("name"))
+            {
+                universalTable.setName(RandomGen.formatName(col.get("value").toString()));
+                col.put("value",universalTable.getName() );
+            }
+            else if(col.get("cols").equals("create_user"))
+            {
+                col.put("value",universalTable.getCreateUser());
+            }
+            else if(col.get("cols").equals("create_time"))
+            {
+                col.put("value",universalTable.getCreateDate());
+            }
+            else if (col.get("cols").equals("id"))
+            {
+                continue;
+            }
+            else if(col.get("cols").equals("hbaseTableName"))
+            {
+                //占位用,因为如果有hbaseTableName,必须有值,不然不能插入表中,这里插入的值后续需要被改掉,理论上没有用,但是还是先写整齐一些
+                col.put("value","level_"+ToEnglish.getPinYin(universalTable.getName())+"_"+tableId+"_"+universalTable.getId());
+            }
+            else if(col.get("type").equals("date"))
+            {
+                String  str= col.get("value").toString();
+                DateFormat format=new SimpleDateFormat("yyyy-MM-dd");
+                Date date=format.parse(str);
+                col.put("value",date);
+            }
+            trueCols.add(col);
+        }
+        //不可以直接通过map进行存储,需要通过类型接受一下,因为类型接受可以获取id,同时,需要将动态列作为参数传入,在map里面进行动态插入
+        Long insert =universalTableService.saveWithCols(tableName,trueCols,universalTable);
+
+        //进行关联表的存储
+        //如果是第一层级的表,关系表里面不需要进行插入
+        //如果不是第一层级的表,获取其parentTableId和parentRowId,进行插入
+        if(parentTableId!=0)
+        {
+            LevelRelationEntity relationEntity=new LevelRelationEntity();
+            relationEntity.setParentTableId(parentTableId);
+            relationEntity.setParentRowId(parentRowId);
+            relationEntity.setSonTableId(tableId);
+            relationEntity.setSonRowId(universalTable.getId());
+            if(!levelRelationService.save(relationEntity))
+            {
+                R.error().put("msg","表间关系存储失败");
+            }
+        }
+
+        //进行hbase表的创建
+        if(levelEntity.getHasHbasetable()==1)
+        {
+            List<String> info=new ArrayList<>();
+            info.add("data");
+            Compression.Algorithm algorithm = Compression.Algorithm.NONE;
+            hBaseTemplate.createTable(("level_"+ToEnglish.getPinYin(universalTable.getName())+"_"+tableId+"_"+universalTable.getId()),info,algorithm);
+            //关于hbaseName---level_用户输入的name_tableId_当前项插入表之后的id
+            //但是插入的项中就有hbaseTableName
+            //所以应该先插入项,然后获取了该项的id,再更新项
+            if(!universalTableService.updateHbaseTableName(tableName, universalTable.getId(),
+                "level_"+ToEnglish.getPinYin(universalTable.getName())+"_"+tableId+"_"+universalTable.getId()))
+            {
+                return R.error().put("msg","hbase信息更新失败");
+            }
+        }
+
+
+        return R.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    public R update(@RequestBody Map<String,Object> map) throws ParseException{
+
+        //先抽取属性,形成表结构,然后存进表里,最后返回ok
+        //真正需要的字段
+        List<Map<String,Object>> trueCols= new ArrayList<>();
+
+        //获取的数据,需要进行处理
+        List<Map<String,Object>> cols= (List<Map<String, Object>>) map.get("cols");
+        Long id=Long.valueOf(map.get("id").toString());
+        Long uid=getUserId();
+        Long tableId=Long.valueOf(map.get("tableId").toString());
+        LevelEntity levelEntity = levelService.getById(tableId);
+        String tableName = levelEntity.getTableName();
+        String orginRowName = universalTableService.selectNameById(tableName,id);
+
+        Long parentTableId=0L;
+        if(map.containsKey("parentTableId") && !map.get("parentTableId").toString().equals("undefined"))
+        {
+            parentTableId=Long.valueOf(map.get("parentTableId").toString());
+        }
+        Long parentRowId=0L;
+        if(map.containsKey("parentRowId") && !map.get("parentRowId").toString().equals("undefined"))
+        {
+            parentRowId=Long.valueOf(map.get("parentRowId").toString());
+        }
+        //和save不同,update有字段id,但是实际上cols中不需要id,id需要作为另外的参数传入
+        //先创建一个universalTable作为缓冲
+        UniversalTableEntity universalTable=new UniversalTableEntity();
+        universalTable.setCreateUser(uid);
+        universalTable.setCreateDate(new Date());
+        //对cols进行处理,去除没有value的字段,将特定字段进行修改
+        for(Map<String,Object> col :cols)
+        {
+            if(col.get("cols").equals("name"))
+            {
+                //cols中的name是处理过的name,因此不需要再次substring
+                if(col.get("value").toString().equals(orginRowName.substring(4)))
+                {
+                    universalTable.setName(orginRowName);
+                    col.put("value",universalTable.getName());
+                }
+                else{
+                    universalTable.setName(RandomGen.formatName(col.get("value").toString()));
+                    col.put("value",universalTable.getName() );
+                }
+
+            }
+            else if(col.get("cols").equals("create_user"))
+            {
+                col.put("value",universalTable.getCreateUser());
+            }
+            else if(col.get("cols").equals("create_time"))
+            {
+                col.put("value",universalTable.getCreateDate());
+            }
+            else if (col.get("cols").equals("id"))
+            {
+                continue;
+            }
+            else if(col.get("cols").equals("hbaseTableName"))
+            {
+                //这个hbaseTableName不能变,直接跳过
+                continue;
+            }
+            else if(col.get("type").equals("date"))
+            {
+                String  str= col.get("value").toString();
+                DateFormat format=new SimpleDateFormat("yyyy-MM-dd");
+                Date date=format.parse(str);
+                col.put("value",date);
+            }
+            trueCols.add(col);
+        }
+        //直接存储不可以,因为还是需要进行类的变化,因此需要将动态列作为参数传入,在map里面进行动态插入
+        //因为dao里面不一样,所以不能直接用save
+        universalTableService.updateWithCols(tableName,trueCols,id);
+
+        //进行关联表的存储
+        //关联中,本身是不能改变的,但是parent层级可以修改
+        if(parentTableId!=0)
+        {
+            LevelRelationEntity relationEntity=levelRelationService.selectBySon(tableId,id);
+            relationEntity.setParentTableId(parentTableId);
+            relationEntity.setParentRowId(parentRowId);
+            if(!levelRelationService.updateById(relationEntity))
+            {
+                R.error().put("msg","表间关系存储失败");
+            }
+        }
+        //hbase的也不进行修改
+        return R.ok();
+    }
+//
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    public R delete(@RequestParam("tableId") Long id,@RequestBody Long[] ids){
+
+        LevelEntity tableName = levelService.getById(id);
+        universalTableService.removeByIdsFromTableName(Arrays.asList(ids),tableName.getTableName());
+        levelRelationService.deleteBySonTidRids(id,Arrays.asList(ids));
+        return R.ok();
+    }
+
+    @RequestMapping("/listAllItem")
+    public R listAllItem(@RequestParam("id") Long id)
+    {
+        LevelEntity levelEntity=levelService.getById(id);
+        List<Map<String,Object>> items= universalTableService.listAllItem(levelEntity.getTableName());
+        return R.ok().put("data",items);
+    }
+
+    @RequestMapping("/listNotLeafItem")
+    public R listNotLeafItem(@RequestParam("id") Long id)
+    {
+        LevelEntity levelEntity=levelService.getById(id);
+        List<Map<String,Object>> items= universalTableService.listNotLeafItem(levelEntity.getTableName());
+        return R.ok().put("data",items);
+    }
+
+    /**
+     * 用于显示第二层级的所有信息,与list的差别在于没有页面控制以及没有替换truefalse为是否
+     * @param id    project的id
+     * @return
+     */
+    @RequestMapping("/getRootAllItem")
+    public R getRootAllItem(@RequestParam("id") Long id)
+    {
+        if(projectAttributesService.countProjectLevel(id).equals("0"))
+            return R.ok("该项目未绑定层级!\n");
+        Integer tableId=projectAttributesService.selectRootLevel(id);
+        LevelEntity levelEntity=levelService.getById(tableId);
+        List<String> tableCols = levelTableService.listColsByLevelId(levelEntity.getId());
+        List<Map<String,Object>> items= universalTableService.listAllItemInfo(levelEntity.getTableName(),tableCols);
+        //data是<列名,具体值>的list
+        //应该不需要将true/false替换是否
+        //去除名字前面的随机数
+        SubString.subStringList(items);
+        return R.ok().put("data",items).put("levelId",tableId);
+    }
+
+    /**
+     * 用于显示第二层级的所有信息,与list的差别在于没有页面控制以及没有替换truefalse为是否
+     * @param id    project的id
+     * @param page  分页信息
+     * @param size  分页信息
+     * @return
+     */
+    @RequestMapping("/getRootAllItemWithLimit")
+    public R getRootAllItemWithLimit(@RequestParam("id") Long id,@RequestParam("page") Integer page,@RequestParam("size") Integer size)
+    {
+        if(projectAttributesService.countProjectLevel(id).equals("0"))
+            return R.ok("该项目未绑定层级!\n");
+        Integer tableId=projectAttributesService.selectRootLevel(id);
+        LevelEntity levelEntity=levelService.getById(tableId);
+        List<String> tableCols = levelTableService.listColsByLevelId(levelEntity.getId());
+        List<Map<String,Object>> items= universalTableService.listAllItemInfo(levelEntity.getTableName(),tableCols);
+        //data是<列名,具体值>的list
+        //应该不需要将true/false替换是否
+        //去除名字前面的随机数
+        SubString.subStringList(items);
+        //分页筛选
+        page=(page-1)*size;
+        List<Map<String,Object>> subData= CollectionUtil.sub(items,page,page+size);
+        return R.ok().put("data",subData).put("levelId",tableId).put("count",items.size());
+    }
+
+    /**
+     * 获取第二层级的页面左侧的信息,取所有属性
+     * 应当在用户点击了第一层级的具体item后进行
+     * @param id    project的id
+     * @return
+     */
+    @RequestMapping(value={"/getRootLevel","/getRootLeafNotItem"})
+    public R getRootLeafNotItem(@RequestParam Long id){
+        //1.获取所有parent_id=0,并且project_id为所选id,并且enabled=1的level,应该只有一个
+        List<LevelEntity> candidateLevel=levelService.getRootLevel(id);
+        LevelEntity level=candidateLevel.get(0);
+        //2.获取该level的表,并且从该表中查询所有数据
+        //因为最后一层(测点)是不可操作的,我们可选的是倒数第二层,因此这里不应该展示任何叶子节点
+        String tableName=level.getTableName();
+        //为了显示所有信息,这里需要获取列字段
+        List<String> tableCols = levelTableService.listColsByLevelId(level.getId());
+        List<Map<String,Object>> data=universalTableService.listNotLeafItemInfo(tableName,tableCols);
+        //data是<列名,具体值>的list
+        //对bool值需要修改为是/否,否则前端不显示
+        List<String> boolCols=levelTableService.listBoolColsById(level.getId());
+        modifyBool(data,boolCols);
+        //去除名字前面的随机数
+        SubString.subStringList(data);
+        return R.ok().put("data",data).put("levelId",level.getId());
+    }
+
+     /**
+     * 获取第二层级的页面左侧的信息,需要名称、id,这里的一定不是叶子,因此不取其它属性
+     * 应当在用户点击了第一层级的具体item后进行
+     * @param id    project的id
+     * @param page  分页信息
+     * @param size  分页信息
+     * @return
+     */
+    @RequestMapping(value={"/getRootLevelWithLimit","/getRootLeafNotItemWithLimit"})
+    public R getRootLeafNotItemWithLimit(@RequestParam Long id,@RequestParam("page") Integer page,@RequestParam("size") Integer size){
+        //1.获取所有parent_id=0,并且project_id为所选id,并且enabled=1的level,应该只有一个
+        List<LevelEntity> candidateLevel=levelService.getRootLevel(id);
+        LevelEntity level=candidateLevel.get(0);
+        //2.获取该level的表,并且从该表中查询所有数据
+        //因为最后一层(测点)是不可操作的,我们可选的是倒数第二层,因此这里不应该展示任何叶子节点
+        String tableName=level.getTableName();
+        //为了显示所有信息,这里需要获取列字段
+        List<String> tableCols = levelTableService.listColsByLevelId(level.getId());
+        List<Map<String,Object>> data=universalTableService.listNotLeafItemInfo(tableName,tableCols);
+        //data是<列名,具体值>的list
+        //对bool值需要修改为是/否,否则前端不显示
+        List<String> boolCols=levelTableService.listBoolColsById(level.getId());
+        modifyBool(data,boolCols);
+        //去除名字前面的随机数
+        SubString.subStringList(data);
+        //分页筛选
+        page=(page-1)*size;
+        List<Map<String,Object>> subData= CollectionUtil.sub(data,page,page+size);
+        return R.ok().put("data",subData).put("levelId",level.getId()).put("count",data.size());
+    }
+
+    /**
+     * 获取第二层级的页面右侧的信息,需要获取所有的数据进行展示
+     * 前端逻辑1.用户点击了第一层级的具体item2.前端获取列名3.执行该函数,将数据对应上列,填入表中
+     * @param id    project的id
+     * @return
+     */
+    @RequestMapping(value = {"/getRootLeafLevel","/getRootLeafItem"})
+    public R getRootLeafItem(@RequestParam Long id){
+        //1.获取所有parent_id=0,并且project_id为所选id,并且enabled=1的level,应该只有一个
+        List<LevelEntity> candidateLevel=levelService.getRootLevel(id);
+        LevelEntity level=candidateLevel.get(0);
+        //2.获取该level的表,并且从该表中查询所有数据
+        //这里展示的时页面右侧的值,即叶子节点的值
+        String tableName=level.getTableName();
+        //因为要获取所有的信息进行展示,因此需要获取列字段
+        List<String> tableCols = levelTableService.listColsByLevelId(level.getId());
+        List<Map<String,Object>> data=universalTableService.listLeafItem(tableName,tableCols);
+        //data是<列名,具体值>的list
+        //对bool值需要修改为是/否,否则前端不显示
+        List<String> boolCols=levelTableService.listBoolColsById(level.getId());
+        modifyBool(data,boolCols);
+        //去除名字前面的随机数
+        SubString.subStringList(data);
+        return R.ok().put("data",data).put("levelId",level.getId());
+    }
+
+    /**
+     * 获取第二层级的页面右侧的信息,需要获取所有的数据进行展示
+     * 前端逻辑1.用户点击了第一层级的具体item2.前端获取列名3.执行该函数,将数据对应上列,填入表中
+     * @param id    project的id
+     * @param page  分页信息
+     * @param size  分页信息
+     * @return
+     */
+    @RequestMapping(value = {"/getRootLeafLevelWithLimit","/getRootLeafItemWithLimit"})
+    public R getRootLeafItemWithLimit(@RequestParam Long id,@RequestParam("page") Integer page,@RequestParam("size") Integer size){
+        //1.获取所有parent_id=0,并且project_id为所选id,并且enabled=1的level,应该只有一个
+        List<LevelEntity> candidateLevel=levelService.getRootLevel(id);
+        LevelEntity level=candidateLevel.get(0);
+        //2.获取该level的表,并且从该表中查询所有数据
+        //这里展示的时页面右侧的值,即叶子节点的值
+        String tableName=level.getTableName();
+        //因为要获取所有的信息进行展示,因此需要获取列字段
+        List<String> tableCols = levelTableService.listColsByLevelId(level.getId());
+        List<Map<String,Object>> data=universalTableService.listLeafItem(tableName,tableCols);
+        //data是<列名,具体值>的list
+        //对bool值需要修改为是/否,否则前端不显示
+        List<String> boolCols=levelTableService.listBoolColsById(level.getId());
+        modifyBool(data,boolCols);
+        //去除名字前面的随机数
+        SubString.subStringList(data);
+        //分页筛选
+        page=(page-1)*size;
+        List<Map<String,Object>> subData= CollectionUtil.sub(data,page,page+size);
+        return R.ok().put("data",subData).put("levelId",level.getId()).put("count",data.size());
+    }
+
+    /**
+     * 获取第三层级及以后的所有子层级信息
+     * @param tableId   当前点击的item所在层级id(parent_table_id)
+     * @param id        当前点击的item的id(parent_row_id)
+     * @return levelId是下一层级,即子层级的id
+     */
+    @RequestMapping("/getOtherAllItem")
+    public R getOtherAllItem(@RequestParam Long tableId,@RequestParam Long id){
+        //以防万一,采用三条件查询
+        //1.获取子表id
+        LevelEntity sonTable= levelService.getEnabledSon(tableId);
+        //2.获取选中的item的相关子item的id
+        List<LevelRelationEntity> sonRelaitons= levelRelationService.selectByParentAndSonTable(tableId,id,sonTable.getId());
+        List<Long> sonIds=new ArrayList<>();
+        for(LevelRelationEntity sonRelaiton:sonRelaitons){
+            sonIds.add(sonRelaiton.getSonRowId());
+        }
+        if(sonIds.isEmpty()){
+            List<Map<String,Object>> data=new ArrayList<>();
+            return R.ok().put("data",data).put("levelId",sonTable.getId());
+        }
+        //3.在表中获取对应的获取子节点信息
+        List<String> tableCols = levelTableService.listColsByLevelId(sonTable.getId());
+        List<Map<String,Object>> data=universalTableService.listBySonIdsNotLimit(sonTable.getTableName(),tableCols,sonIds);
+        SubString.subStringList(data);
+        return R.ok().put("data",data).put("levelId",sonTable.getId());
+    }
+
+    /**
+     * 获取第三层级及以后的所有子层级信息
+     * @param tableId   当前点击的item所在层级id(parent_table_id)
+     * @param id        当前点击的item的id(parent_row_id)
+     * @return levelId是下一层级,即子层级的id
+     */
+    @RequestMapping("/getOtherAllItemWithLimit")
+    public R getOtherAllItemWithLimit(@RequestParam Long tableId,@RequestParam Long id,@RequestParam("page") Integer page,@RequestParam("size") Integer size){
+        //以防万一,采用三条件查询
+        //1.获取子表id
+        LevelEntity sonTable= levelService.getEnabledSon(tableId);
+        //2.获取选中的item的相关子item的id
+        List<LevelRelationEntity> sonRelaitons= levelRelationService.selectByParentAndSonTable(tableId,id,sonTable.getId());
+        List<Long> sonIds=new ArrayList<>();
+        for(LevelRelationEntity sonRelaiton:sonRelaitons){
+            sonIds.add(sonRelaiton.getSonRowId());
+        }
+        if(sonIds.isEmpty()){
+            List<Map<String,Object>> data=new ArrayList<>();
+            return R.ok().put("data",data).put("levelId",sonTable.getId());
+        }
+        //3.在表中获取对应的获取子节点信息
+        List<String> tableCols = levelTableService.listColsByLevelId(sonTable.getId());
+        List<Map<String,Object>> data=universalTableService.listBySonIds(sonTable.getTableName(),tableCols,sonIds,page,size);
+        SubString.subStringList(data);
+        return R.ok().put("data",data).put("levelId",sonTable.getId()).put("count",sonIds.size());
+    }
+
+    /**
+     * 获取第三层级以及之后的左侧信息
+     * @param tableId   选择的item所在层级的id
+     * @param id        选择的item的id
+     * @return
+     */
+    @RequestMapping(value = {"/getSonLevel","/getOtherNotLeafItem"})
+    public R getOtherNotLeafItem(@RequestParam Long tableId,@RequestParam Long id){
+        //1.获取选中的item的相关子item
+        List<LevelRelationEntity> levelRelationEntities= levelRelationService.selectByParent(tableId,id);
+        //2.获取子表名
+        LevelEntity sonLevel=levelService.getEnabledSon(tableId);
+        String sonTableName=sonLevel.getTableName();
+        //3.在表中获取对应的非叶子节点信息
+        List<String> tableCols = levelTableService.listColsByLevelId(sonLevel.getId());
+        List<Map<String,Object>> candidateItem=universalTableService.listNotLeafItemInfo(sonTableName,tableCols);
+        //4.通过检查levelRelationEntities和candidateItem中的重合部分,获取目标item,为了加速,用了HashMap
+        List<Map<String,Object>> data=new ArrayList<>();
+        //用一个map装所有的item,之后遍历关系,将其中的item信息取出,发给前端
+        HashMap<Object,Object> cItemId_lRelationSonId=new HashMap<>();
+        for(int i=0;i<candidateItem.size();i++){
+            cItemId_lRelationSonId.put(candidateItem.get(i).get("id"),i);
+        }
+        for(LevelRelationEntity levelRelation:levelRelationEntities){
+            if(cItemId_lRelationSonId.get(levelRelation.getSonRowId())!=null){
+                int itemId= (int) cItemId_lRelationSonId.get(levelRelation.getSonRowId());
+                data.add(candidateItem.get(itemId));
+            }
+        }
+        //data是<列名,具体值>的list
+        //对bool值需要修改为是/否,否则前端不显示
+        List<String> boolCols=levelTableService.listBoolColsById(sonLevel.getId());
+        modifyBool(data,boolCols);
+        //去除名字前面的随机数
+        SubString.subStringList(data);
+        return R.ok().put("data",data).put("levelId",sonLevel.getId());
+    }
+
+    /**
+     * 获取第三层级以及之后的左侧信息
+     * @param tableId   选择的item所在层级的id
+     * @param id        选择的item的id
+     * @param page      分页条件
+     * @param size      分页条件
+     * @return
+     */
+    @RequestMapping(value = {"/getSonLevelWithLimit","/getOtherNotLeafItemWithLimit"})
+    public R getOtherNotLeafItemWithLimit(@RequestParam Long tableId,@RequestParam Long id,@RequestParam("page") Integer page,@RequestParam("size") Integer size){
+        //1.获取选中的item的相关子item
+        List<LevelRelationEntity> levelRelationEntities= levelRelationService.selectByParent(tableId,id);
+        //2.获取子表名
+        LevelEntity sonLevel=levelService.getEnabledSon(tableId);
+        String sonTableName=sonLevel.getTableName();
+        //3.在表中获取对应的非叶子节点信息
+        List<String> tableCols = levelTableService.listColsByLevelId(sonLevel.getId());
+        List<Map<String,Object>> candidateItem=universalTableService.listNotLeafItemInfo(sonTableName,tableCols);
+        //4.通过检查levelRelationEntities和candidateItem中的重合部分,获取目标item,为了加速,用了HashMap
+        List<Map<String,Object>> data=new ArrayList<>();
+        //用一个map装所有的item,之后遍历关系,将其中的item信息取出,发给前端
+        HashMap<Object,Object> cItemId_lRelationSonId=new HashMap<>();
+        for(int i=0;i<candidateItem.size();i++){
+            cItemId_lRelationSonId.put(candidateItem.get(i).get("id"),i);
+        }
+        for(LevelRelationEntity levelRelation:levelRelationEntities){
+            if(cItemId_lRelationSonId.get(levelRelation.getSonRowId())!=null){
+                int itemId= (int) cItemId_lRelationSonId.get(levelRelation.getSonRowId());
+                data.add(candidateItem.get(itemId));
+            }
+        }
+        //data是<列名,具体值>的list
+        //对bool值需要修改为是/否,否则前端不显示
+        List<String> boolCols=levelTableService.listBoolColsById(sonLevel.getId());
+        modifyBool(data,boolCols);
+        //去除名字前面的随机数
+        SubString.subStringList(data);
+        //进行数据量限制
+        page=(page-1)*size;
+        List<Map<String,Object>> subData= CollectionUtil.sub(data,page,page+size);
+        return R.ok().put("data",subData).put("levelId",sonLevel.getId()).put("count",data.size());
+    }
+
+    /**
+     * 获取一个item的叶子子节点,即获取第三层级以及以后的右面信息
+     * @param tableId 该item所在的层级的id
+     * @param id    选中的item的id
+     */
+    @RequestMapping(value = {"/getNotLeafItemByParent","/getOtherLeafItem"})    //第一个url是bug,但是已经使用了,就不修改了
+    public R getOtherLeafItem(@RequestParam Long tableId,@RequestParam Long id){
+        //1.获取选中的item的相关子item
+        List<LevelRelationEntity> levelRelationEntities= levelRelationService.selectByParent(tableId,id);
+        //2.获取子表名
+        LevelEntity sonLevel=levelService.getEnabledSon(tableId);
+        String sonTableName=sonLevel.getTableName();
+        //3.在表中获取对应的叶子节点信息
+        List<String> tableCols = levelTableService.listColsByLevelId(sonLevel.getId());
+        List<Map<String,Object>> candidateItem=universalTableService.listLeafItem(sonTableName,tableCols);
+        //4.通过检查levelRelationEntities和candidateItem中的重合部分,获取目标item,为了加速,用了HashMap
+        List<Map<String,Object>> data=new ArrayList<>();
+        //用一个map装所有的item,之后遍历关系,将其中的item信息取出,发给前端
+        HashMap<Object,Object> cItemId_lRelationSonId=new HashMap<>();
+        for(int i=0;i<candidateItem.size();i++){
+            cItemId_lRelationSonId.put(candidateItem.get(i).get("id"),i);
+        }
+        for(LevelRelationEntity levelRelation:levelRelationEntities){
+            if(cItemId_lRelationSonId.get(levelRelation.getSonRowId())!=null) {
+                int itemId = (int) cItemId_lRelationSonId.get(levelRelation.getSonRowId());
+                data.add(candidateItem.get(itemId));
+            }
+        }
+        //data是<列名,具体值>的list
+        //对bool值需要修改为是/否,否则前端不显示
+        List<String> boolCols=levelTableService.listBoolColsById(sonLevel.getId());
+        modifyBool(data,boolCols);
+        //去除名字前面的随机数
+        SubString.subStringList(data);
+        return R.ok().put("data",data).put("levelId",sonLevel.getId());
+    }
+
+    /**
+     * 获取一个item的叶子子节点,即获取第三层级以及以后的右面信息
+     * @param tableId 该item所在的层级的id
+     * @param id    选中的item的id
+     * @param page  分页条件
+     * @param size  分页条件
+     * @return
+     */
+    @RequestMapping("/getOtherLeafItemWithLimit")
+    public R getOtherLeafItemWithLimit(@RequestParam Long tableId,@RequestParam Long id,@RequestParam("page") Integer page,@RequestParam("size") Integer size){
+        //1.获取选中的item的相关子item
+        List<LevelRelationEntity> levelRelationEntities= levelRelationService.selectByParent(tableId,id);
+        //2.获取子表名
+        LevelEntity sonLevel=levelService.getEnabledSon(tableId);
+        String sonTableName=sonLevel.getTableName();
+        //3.在表中获取对应的叶子节点信息
+        List<String> tableCols = levelTableService.listColsByLevelId(sonLevel.getId());
+        List<Map<String,Object>> candidateItem=universalTableService.listLeafItem(sonTableName,tableCols);
+        //4.通过检查levelRelationEntities和candidateItem中的重合部分,获取目标item,为了加速,用了HashMap
+        List<Map<String,Object>> data=new ArrayList<>();
+        //用一个map装所有的item,之后遍历关系,将其中的item信息取出,发给前端
+        HashMap<Object,Object> cItemId_lRelationSonId=new HashMap<>();
+        for(int i=0;i<candidateItem.size();i++){
+            cItemId_lRelationSonId.put(candidateItem.get(i).get("id"),i);
+        }
+        for(LevelRelationEntity levelRelation:levelRelationEntities){
+            if(cItemId_lRelationSonId.get(levelRelation.getSonRowId())!=null) {
+                int itemId = (int) cItemId_lRelationSonId.get(levelRelation.getSonRowId());
+                data.add(candidateItem.get(itemId));
+            }
+        }
+        //data是<列名,具体值>的list
+        //对bool值需要修改为是/否,否则前端不显示
+        List<String> boolCols=levelTableService.listBoolColsById(sonLevel.getId());
+        modifyBool(data,boolCols);
+        //去除名字前面的随机数
+        SubString.subStringList(data);
+        //进行数据量限制
+        page=(page-1)*size;
+        List<Map<String,Object>> subData= CollectionUtil.sub(data,page,page+size);
+        return R.ok().put("data",subData).put("levelId",sonLevel.getId()).put("count",data.size());
+    }
+
+    /**
+     * 用于将数据中的true/false转换为是/否
+     * @param data  待转化的数据
+     * @param boolCols  数据中需要被转化的列
+     */
+    private void modifyBool(List<Map<String,Object>> data,List<String> boolCols){
+        for(Map<String,Object> map :data)
+        {
+            for(String col: boolCols)
+            {
+                if((boolean) map.get(col))
+                {
+                    map.put(col,"是");
+                }
+                else
+                    map.put(col,"否");
+            }
+        }
+    }
+}

+ 35 - 0
src/main/java/io/renren/modules/levelManage/dao/LevelDao.java

@@ -0,0 +1,35 @@
+package io.renren.modules.levelManage.dao;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.renren.modules.levelManage.entity.LevelEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 层级关系表
+ * 
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-28 17:07:26
+ */
+@Mapper
+public interface LevelDao extends BaseMapper<LevelEntity> {
+	List<LevelEntity> selectByName(@Param("page") Integer page,@Param("size") Integer size,@Param("name") String name);
+
+	Integer getCountByName(@Param("name") String name);
+
+	List<LevelEntity> getSonLevel(@Param("id") Long id);
+
+	Integer queryEnabledCount();
+
+	List<LevelEntity> getEnabledLevels();
+
+	Integer queryEnabledCountWithParentId(@Param("id") Long id);
+
+	LevelEntity getEnabledSon(@Param("id") Long id);
+
+	List<LevelEntity> getEnabledLevelByProject(@Param("ids") List<Long> ids);
+}

+ 26 - 0
src/main/java/io/renren/modules/levelManage/dao/LevelRelationDao.java

@@ -0,0 +1,26 @@
+package io.renren.modules.levelManage.dao;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.renren.modules.levelManage.entity.LevelRelationEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 用于存储层级直接,具体数据的关系
+ * 
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-04-08 17:49:50
+ */
+@Mapper
+public interface LevelRelationDao extends BaseMapper<LevelRelationEntity> {
+
+    LevelRelationEntity selectBySon(@Param("tableId") Long tableId,@Param("id") Long id);
+
+    List<LevelRelationEntity> selectByParent(@Param("tableId") Long tableId,@Param("id") Long id);
+
+    List<LevelRelationEntity> selectByParentRowAndSonTable(@Param("tableId") Long tableId,@Param("parentRowId") Long parentRowId);
+}

+ 33 - 0
src/main/java/io/renren/modules/levelManage/dao/LevelTableDao.java

@@ -0,0 +1,33 @@
+package io.renren.modules.levelManage.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.renren.modules.levelManage.entity.LevelTableEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 
+ * 
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-30 16:57:16
+ */
+@Mapper
+public interface LevelTableDao extends BaseMapper<LevelTableEntity> {
+	int createTable(@Param("tableName") String tableName,@Param("cols") List<Map<String,String>> cols);
+
+	List<Map<String,Object>> listByLevelId(@Param("id") Long id);
+
+	List<String> listColsByLevelId(@Param("id") Long id);
+
+	List<String> listCommentByLevelId(@Param("id") Long id);
+
+	List<String> listTypeByLevelId(@Param("id") Long id);
+
+	Integer removeByIdsFromTableName(@Param("ids") List<Long> ids, @Param("tableName") String tableName);
+
+	List<String> listBoolColsByLevelId(@Param("id") Long id);
+}

+ 63 - 0
src/main/java/io/renren/modules/levelManage/dao/ProjectAttributesDao.java

@@ -0,0 +1,63 @@
+package io.renren.modules.levelManage.dao;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.renren.modules.levelManage.entity.ProjectAttributesEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 
+ * 
+ * @author Noth
+ * @email sunlightcs@gmail.com
+ * @date 2022-09-17 17:20:39
+ */
+@Mapper
+public interface ProjectAttributesDao extends BaseMapper<ProjectAttributesEntity> {
+
+    Integer hasProject(@Param("schema") String schema);
+
+    int createTable(@Param("cols") List<Map<String,String>> cols);
+
+    List<Map<String,Object>> listAttribute();
+
+    Integer countProject();
+
+    List<String> listCols();
+
+    List<Map<String,Object>> list(@Param("tableCols") List<String> tableCols,@Param("page") Integer page,@Param("size") Integer size);
+
+    List<String > listBoolCols();
+
+    Map<String,Object> selectById(@Param("id") Long id,@Param("tableCols") List<String> tableCols);
+
+    Long saveWithCols(@Param("cols") List<Map<String,Object>> cols);
+
+    String  selectProjectNameById(@Param("id") Long id);
+
+    Integer updateWithCols(@Param("cols") List<Map<String,Object>> cols,@Param("id") Long id);
+
+    List<Map<String,Object>> selectByName(@Param("tableCols") List<String> tableCols, @Param("page") Integer page,
+                                          @Param("size") Integer size,@Param("name") String name);
+
+    Integer getCountByName(@Param("name") String name);
+
+    Integer removeProjectByIds(@Param("ids") List<Long> ids);
+
+    Integer dropProject();
+
+    Integer truncateProjectAttribute();
+
+    List<Map<String,Object>> listProjectName();
+
+    String countProjectLevel(@Param("id") Long id);
+
+    Integer selectRootLevel(@Param("id") Long id);
+
+    List<Map<String,Object>> listProjectByUid(@Param("uid") Long uid);
+
+}

+ 56 - 0
src/main/java/io/renren/modules/levelManage/dao/UniversalTableDao.java

@@ -0,0 +1,56 @@
+package io.renren.modules.levelManage.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.renren.modules.levelManage.entity.UniversalTableEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface UniversalTableDao extends BaseMapper<UniversalTableEntity> {
+    Map<String,Object> selectById(@Param("id") Long id,@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols);
+
+    List<Map<String,Object>> list(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,@Param("page") Integer page,@Param("size") Integer size);
+
+    List<Map<String,Object>> selectByName(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,
+                                          @Param("page") Integer page,@Param("size") Integer size,@Param("name") String name);
+
+    Integer getCountByName(@Param("tableName") String tableName,@Param("name") String name);
+
+    Long saveWithCols(@Param("tableName") String tableName,@Param("cols") List<Map<String,Object>> cols,@Param("universalTableEntity") UniversalTableEntity universalTableEntity);
+
+    Integer updateWithCols(@Param("tableName") String tableName,@Param("cols") List<Map<String,Object>> cols,@Param("id") Long id);
+
+    Integer removeByIdsFromTableName(@Param("ids") List<Long> ids, @Param("tableName") String tableName);
+
+    List<Map<String,Object>> listAllItem(@Param("tableName")String tableName);
+
+    List<Map<String,Object>> listNotLeafItem(@Param("tableName")String tableName);
+
+    List<Map<String,Object>> listLeafItem(@Param("tableName")String tableName,@Param("tableCols") List<String> tableCols);
+
+    List<Map<String, Object>> listBySonIds(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,@Param("ids") List<Long> ids,
+                                           @Param("page") Integer page,@Param("size") Integer size);
+
+    boolean updateHbaseTableName(@Param("tableName") String tableName,@Param("id") Long id,@Param("hbaseTableName") String hbaseTableName);
+
+    String selectNameById(@Param("tableName") String tableName,@Param("id") Long id);
+
+    Integer getCount(@Param("tableName") String tableName);
+
+    List<Map<String, Object>> selectByNameWithParent(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,
+                                                     @Param("page") Integer page,@Param("size") Integer size,@Param("name") String name,
+                                                     @Param("parentRowId") Long parentRowId,@Param("tableId") Long tableId);
+
+    Integer getCountByNameWithParent(@Param("tableName") String tableName,@Param("name") String name,@Param("parentRowId") Long parentRowId,@Param("tableId") Long tableId);
+
+    List<Map<String, Object>> listItemWithLeafInfo(@Param("tableName")String tableName);
+
+    List<Map<String,Object>> listNotLeafItemInfo(@Param("tableName")String tableName,@Param("tableCols") List<String> tableCols);
+
+    List<Map<String,Object>> listAllItemInfo(@Param("tableName")String tableName,@Param("tableCols") List<String> tableCols);
+
+    List<Map<String, Object>> listBySonIdsNotLimit(@Param("tableName") String tableName,@Param("tableCols") List<String> tableCols,@Param("ids") List<Long> ids);
+}

+ 91 - 0
src/main/java/io/renren/modules/levelManage/entity/LevelEntity.java

@@ -0,0 +1,91 @@
+package io.renren.modules.levelManage.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 层级关系表
+ * 
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-28 17:07:26
+ */
+@Data
+@TableName("level")
+public class LevelEntity implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 层级id
+	 */
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**
+	 * 在层级关系中的层次
+	 */
+	private Long level;
+	/**
+	 * 父层级id
+	 */
+	private Long parentId;
+	/**
+	 * 层级名称
+	 */
+	private String name;
+	/**
+	 * 父层级名称
+	 */
+	@TableField(exist = false)
+	private String parentName;
+	/**
+	 * 是否有对应hase表
+	 */
+	private Integer hasHbasetable;
+	/**
+	 * 创建时间
+	 */
+	@JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
+	private Date createDate;
+	/**
+	 * 创建者id
+	 */
+	private Long uid;
+	/**
+	 * 创建者名称
+	 */
+	@TableField(exist = false)
+	private String uName;
+	/**
+	 * 是否创建过表
+	 */
+	private Integer createTable;
+	/**
+	 * 表名称
+	 */
+	private String tableName;
+	/**
+	 * 表格是否处于启用状态
+	 */
+	private Integer enabled;
+	/**
+	 * ztree属性
+	 */
+	@TableField(exist=false)
+	private Boolean open;
+	/**
+	 * 子层级
+	 */
+	@TableField(exist=false)
+	private List<LevelEntity> list=new ArrayList<>();
+
+	private Long projectId;
+}

+ 44 - 0
src/main/java/io/renren/modules/levelManage/entity/LevelRelationEntity.java

@@ -0,0 +1,44 @@
+package io.renren.modules.levelManage.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 用于存储层级直接,具体数据的关系
+ * 
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-04-08 17:49:50
+ */
+@Data
+@TableName("level_relation")
+public class LevelRelationEntity implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * id
+	 */
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**
+	 * 父层级id
+	 */
+	private Long parentTableId;
+	/**
+	 * 父层级具体数据id
+	 */
+	private Long parentRowId;
+	/**
+	 * 子层级id
+	 */
+	private Long sonTableId;
+	/**
+	 * 子层级具体数据id
+	 */
+	private Long sonRowId;
+
+}

+ 54 - 0
src/main/java/io/renren/modules/levelManage/entity/LevelTableEntity.java

@@ -0,0 +1,54 @@
+package io.renren.modules.levelManage.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 
+ * 
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-30 16:57:16
+ */
+@Data
+@TableName("level_table")
+public class LevelTableEntity implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 记录列的id
+	 */
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**
+	 * 对应层级的id
+	 */
+	private Long levelId;
+	/**
+	 * 字段名称
+	 */
+	private String name;
+	/**
+	 * 字段类型
+	 */
+	private String type;
+	/**
+	 * 创建时间
+	 */
+	@JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
+	private Date createDate;
+	/**
+	 * 创建者
+	 */
+	private Long createUser;
+	/**
+	 * 创建时的备注
+	 */
+	private String remark;
+}

+ 41 - 0
src/main/java/io/renren/modules/levelManage/entity/ProjectAttributesEntity.java

@@ -0,0 +1,41 @@
+package io.renren.modules.levelManage.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 
+ * 
+ * @author Noth
+ * @email sunlightcs@gmail.com
+ * @date 2022-09-17 17:20:39
+ */
+@Data
+@TableName("project_attributes")
+public class ProjectAttributesEntity implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * id
+	 */
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**
+	 * 属性名称
+	 */
+	private String name;
+	/**
+	 * 属性类型
+	 */
+	private String type;
+	/**
+	 * 属性中文名称
+	 */
+	private String remark;
+
+
+}

+ 49 - 0
src/main/java/io/renren/modules/levelManage/entity/UniversalTableEntity.java

@@ -0,0 +1,49 @@
+package io.renren.modules.levelManage.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ *
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-30 16:57:16
+ */
+@Data
+public class UniversalTableEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 层级名称
+     */
+    private String name;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
+    private Date createDate;
+    /**
+     * 创建者
+     */
+    private Long createUser;
+    /**
+     * 当前行是否为叶子
+     */
+    private Integer isLeaf;
+    /**
+     * 用户自定义列
+     */
+    private List<String> dynamicColumns;
+}

+ 38 - 0
src/main/java/io/renren/modules/levelManage/service/LevelRelationService.java

@@ -0,0 +1,38 @@
+package io.renren.modules.levelManage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import io.renren.common.utils.PageUtils;
+import io.renren.modules.levelManage.entity.LevelRelationEntity;
+import org.dom4j.Element;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 用于存储层级直接,具体数据的关系
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-04-08 17:49:50
+ */
+
+public interface LevelRelationService extends IService<LevelRelationEntity> {
+
+    PageUtils queryPage(Map<String, Object> params);
+
+    LevelRelationEntity selectBySon(Long tableId,Long id);
+
+    List<LevelRelationEntity> selectByParent(Long tableId, Long id);
+
+    List<LevelRelationEntity> selectByParentRowAndSonTable(Long tableId, Long parentRowId);
+
+    void analysisLevel(Element name, long parentId, long levelNum) throws Exception;
+
+    boolean tableHasBuilted(String fileName);
+
+    boolean deleteBySonTidRids(Long id, List<Long> asList);
+
+    List<LevelRelationEntity> selectByParentAndSonTable(Long parentTableId, Long parentRowId,Long sonTableId);
+
+}
+

+ 42 - 0
src/main/java/io/renren/modules/levelManage/service/LevelService.java

@@ -0,0 +1,42 @@
+package io.renren.modules.levelManage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import io.renren.common.utils.PageUtils;
+import io.renren.modules.levelManage.entity.LevelEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 层级关系表
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-28 17:07:26
+ */
+
+public interface LevelService extends IService<LevelEntity> {
+
+    PageUtils queryPage(Map<String, Object> params);
+
+    List<LevelEntity> selectByName(Integer page, Integer size, String name);
+
+    Integer getCountByName(String name);
+
+    List<LevelEntity> getSonLevel(Long id);
+
+    Integer queryEnabledCount();
+
+    List<LevelEntity> getAllParentById(Long id);
+
+    List<LevelEntity> getEnabledLevels();
+
+    Integer queryEnabledCountWithParentId(Long id);
+
+    LevelEntity getEnabledSon(Long id);
+
+    List<LevelEntity> getEnabledLevelByProject(List<Long> id);
+
+    List<LevelEntity> getRootLevel(Long id);
+}
+

+ 37 - 0
src/main/java/io/renren/modules/levelManage/service/LevelTableService.java

@@ -0,0 +1,37 @@
+package io.renren.modules.levelManage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import io.renren.common.utils.PageUtils;
+import io.renren.modules.levelManage.entity.LevelTableEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-30 16:57:16
+ */
+
+public interface LevelTableService extends IService<LevelTableEntity> {
+
+    PageUtils queryPage(Map<String, Object> params);
+
+    Integer createTable(String tableName, List<Map<String,String>> cols);
+
+    List<Map<String,Object>> listByLevelId(Long id);
+
+    List<String> listColsByLevelId(Long id);
+
+    List<String> listCommentByLevelId(Long id);
+
+    List<String> listTypeByLevelId(Long id);
+
+    Integer removeByIdsFromTableName(List<Long> ids,String tableName);
+
+    List<String> listBoolColsById(Long id);
+
+}
+

+ 61 - 0
src/main/java/io/renren/modules/levelManage/service/ProjectAttributesService.java

@@ -0,0 +1,61 @@
+package io.renren.modules.levelManage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import io.renren.common.utils.PageUtils;
+import io.renren.modules.levelManage.entity.ProjectAttributesEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 
+ *
+ * @author Noth
+ * @email sunlightcs@gmail.com
+ * @date 2022-09-17 17:20:39
+ */
+
+public interface ProjectAttributesService extends IService<ProjectAttributesEntity> {
+
+    PageUtils queryPage(Map<String, Object> params);
+
+    Integer hasProject(String schema);
+
+    Integer createTable(List<Map<String,String>> cols);
+
+    List<Map<String,Object>> listAttribute();
+
+    Integer countProject();
+
+    List<String> listCols();
+
+    List<Map<String,Object>> listData(List<String> tableCols,Integer page,Integer size);
+
+    List<String> listBoolCols();
+
+    Map<String,Object> selectById(Long id,List<String> tableCols);
+
+    Long saveWithCols(List<Map<String,Object>> cols);
+
+    String selectProjectNameById(Long id);
+
+    Integer updateWithCols(List<Map<String,Object>> cols,Long id);
+
+    List<Map<String,Object>> selectByName(List<String> tableCols,Integer page,Integer limit,String name);
+
+    Integer getCountByName(String name);
+
+    Integer removeProjectByIds(List<Long> ids);
+
+    Integer dropProject();
+
+    List<Map<String,Object>> listProjectName();
+
+    String countProjectLevel(Long id);
+
+    Integer selectRootLevel(Long id);
+
+
+    List<Map<String, Object>> listProjectByUid(Long uid);
+}
+

+ 63 - 0
src/main/java/io/renren/modules/levelManage/service/UniversalTableService.java

@@ -0,0 +1,63 @@
+package io.renren.modules.levelManage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import io.renren.common.utils.PageUtils;
+import io.renren.modules.levelManage.entity.UniversalTableEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2022-03-30 16:57:16
+ */
+
+public interface UniversalTableService extends IService<UniversalTableEntity> {
+
+    PageUtils queryPage(Map<String, Object> params);
+
+    Integer removeByIdsFromTableName(List<Long> ids,String tableName);
+
+    Map<String,Object> selectById(Long id,String tableName,List<String> tableCols);
+
+    List<Map<String,Object>> list(String tableName,List<String> tableCols,Integer page,Integer size);
+
+    List<Map<String,Object>> selectByName(String tableName,List<String> tableCols,Integer page,Integer limit,String name);
+
+    List<Map<String,Object>> selectByNameWithParent(String tableName,List<String> tableCols,Integer page,Integer limit,
+                                                    String name,Long parentRowId,Long tableId);
+
+    Integer getCountByName(String tableName,String name);
+
+    Long saveWithCols(String tableName,List<Map<String,Object>> cols,UniversalTableEntity universalTableEntity);
+
+    Integer updateWithCols(String tableName,List<Map<String,Object>> cols,Long id);
+
+    List<Map<String,Object>> listAllItem(String tableName);
+
+    List<Map<String,Object>> listNotLeafItem(String tableName);
+
+    List<Map<String,Object>> listLeafItem(String tableName, List<String> tableCols);
+
+    List<Map<String, Object>> listBySonIds(String tableName, List<String> tableCols, List<Long> ids, Integer page, Integer size);
+
+    boolean updateHbaseTableName(String tableName, Long id, String hbaseTableName);
+
+    String selectNameById(String tableName, Long id);
+
+    Integer getCount(String tableName);
+
+    Integer getCountByNameWithParent(String tableName, String name, Long parentRowId, Long tableId);
+
+    List<Map<String,Object>> listItemWithLeafInfo(String tableName);
+
+    List<Map<String,Object>> listNotLeafItemInfo(String tableName, List<String> tableCols);
+
+    List<Map<String,Object>>  listAllItemInfo(String tableName, List<String> tableCols);
+
+    List<Map<String, Object>> listBySonIdsNotLimit(String tableName, List<String> tableCols, List<Long> sonIds);
+}
+

+ 221 - 0
src/main/java/io/renren/modules/levelManage/service/impl/LevelRelationServiceImpl.java

@@ -0,0 +1,221 @@
+package io.renren.modules.levelManage.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.Query;
+import io.renren.datasource.annotation.DataSource;
+import io.renren.modules.levelManage.dao.LevelRelationDao;
+import io.renren.modules.levelManage.entity.LevelEntity;
+import io.renren.modules.levelManage.entity.LevelRelationEntity;
+import io.renren.modules.levelManage.entity.LevelTableEntity;
+import io.renren.modules.levelManage.service.LevelRelationService;
+import io.renren.modules.levelManage.service.LevelService;
+import io.renren.modules.levelManage.service.LevelTableService;
+import org.dom4j.Element;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+
+
+@Service("levelRelationService")
+@DataSource("heBing")
+public class LevelRelationServiceImpl extends ServiceImpl<LevelRelationDao, LevelRelationEntity> implements LevelRelationService {
+
+    @Autowired
+    private LevelRelationDao levelRelationDao;
+    @Autowired
+    private LevelService levelService;
+    @Autowired
+    private LevelTableService levelTableService;
+
+    @Override
+    public PageUtils queryPage(Map<String, Object> params) {
+        IPage<LevelRelationEntity> page = this.page(
+                new Query<LevelRelationEntity>().getPage(params),
+                new QueryWrapper<LevelRelationEntity>()
+        );
+
+        return new PageUtils(page);
+    }
+
+    public LevelRelationEntity selectBySon(Long tableId,Long id)
+    {
+        return levelRelationDao.selectBySon(tableId,id);
+    }
+
+    public List<LevelRelationEntity> selectByParent(Long tableId, Long id){
+        return levelRelationDao.selectByParent(tableId,id);
+    }
+
+    public List<LevelRelationEntity> selectByParentRowAndSonTable(Long tableId, Long parentRowId)
+    {
+        return levelRelationDao.selectByParentRowAndSonTable(tableId,parentRowId);
+    }
+
+    /**
+     * 递归地分析xml结构,并且创建层级和表格
+     * @param root
+     * @param parentId
+     * @param levelNum
+     * @throws Exception
+     */
+    @Transactional
+    public void analysisLevel(Element root,long parentId,long levelNum) throws Exception{
+        //levels=son_levels
+
+        for(Iterator iterator = root.elementIterator(); iterator.hasNext();){
+            Element level= (Element) iterator.next();
+            String name =level.elementText("name");
+            int hasHbaseTable= level.elementText("has_hbasetable").equals("true")?1:0;
+            String tableName = level.elementText("table_name");
+
+            LevelEntity levelEntity=new LevelEntity();
+            levelEntity.setLevel(levelNum);
+            levelEntity.setName(name);
+            levelEntity.setHasHbasetable(hasHbaseTable);
+            levelEntity.setCreateDate(new Date());
+            levelEntity.setParentId(parentId);
+            levelEntity.setTableName(tableName);
+            levelEntity.setCreateTable(1);
+            levelService.save(levelEntity);
+
+            Element tableCol=level.element("table_messages");
+            List<Map<String,String >> cols=new ArrayList<>();
+
+            boolean hasId=false;
+            boolean hasHbaseName=false;
+            boolean hasLeaf=false;
+            boolean hasName=false;
+            boolean hasTime=false;
+            boolean hasUser=false;
+            for(Iterator iteratorCol=tableCol.elementIterator();iteratorCol.hasNext();){
+                Element tableMessage= (Element) iteratorCol.next();
+                String colEngName=tableMessage.elementText("name");
+                String type=tableMessage.elementText("type");
+                String colCHIName=tableMessage.elementText("cName");
+
+                if(colEngName.equals("id"))
+                    hasId=true;
+                if(colCHIName.equals("hbaseTableName"))
+                    hasHbaseName=true;
+                if(colCHIName.equals("is_leaf"))
+                    hasLeaf=true;
+                if(colCHIName.equals("name"))
+                    hasName=true;
+                if(colCHIName.equals("create_time"))
+                    hasTime=true;
+
+                HashMap<String ,String> temp=new HashMap<>();
+                temp.put("name",colEngName);
+                temp.put("type",type);
+                temp.put("comment",colCHIName);
+                cols.add(temp);
+            }
+            //必须要有id,name,'create_time','create_user','is_leaf'字段
+            if(!hasId){
+                HashMap<String ,String> temp=new HashMap<>();
+                temp.put("name","id");
+                temp.put("type","bigint");
+                temp.put("comment","id");
+                cols.add(temp);
+            }
+            if(!hasName){
+                HashMap<String ,String> temp=new HashMap<>();
+                temp.put("name","name");
+                temp.put("type","varchar(255)");
+                temp.put("comment","名称");
+                cols.add(temp);
+            }
+            if(!hasTime){
+                HashMap<String ,String> temp=new HashMap<>();
+                temp.put("name","create_time");
+                temp.put("type","date");
+                temp.put("comment","创建时间");
+                cols.add(temp);
+            }
+            if(!hasUser){
+                HashMap<String ,String> temp=new HashMap<>();
+                temp.put("name","create_user");
+                temp.put("type","bigint");
+                temp.put("comment","创建者id");
+                cols.add(temp);
+            }
+            if(!hasLeaf){
+                HashMap<String ,String> temp=new HashMap<>();
+                temp.put("name","is_leaf");
+                temp.put("type","bool");
+                temp.put("comment","是否为叶子节点");
+                cols.add(temp);
+            }
+            //如果层级设计了有hbase表名,那么字段里面就需要有hbaseTableName
+            if(levelEntity.getHasHbasetable()==1 && !hasHbaseName){
+                HashMap<String ,String> temp=new HashMap<>();
+                temp.put("name","hbaseTableName");
+                temp.put("type","varchar(255)");
+                temp.put("comment","hbase表名称");
+                cols.add(temp);
+            }
+
+            if(levelTableService.createTable(tableName,cols)==0)
+            {
+                for(Map<String,String> item : cols)
+                {
+                    LevelTableEntity levelTable=new LevelTableEntity();
+                    levelTable.setLevelId(levelEntity.getId());
+                    levelTable.setCreateDate(new Date());
+                    levelTable.setName(item.get("name"));
+                    levelTable.setType(item.get("type"));
+                    levelTable.setRemark(item.get("comment"));
+                    if(!levelTableService.save(levelTable))
+                    {
+                        throw new Exception("表格创建成功,关联关系记录失败");
+                    }
+                }
+            }
+            else throw new Exception("创建表格失败");
+
+            Element sonLevels= level.element("son_levels");
+            if(sonLevels!=null){
+                analysisLevel(sonLevels,levelEntity.getId(),levelNum+1);
+            }
+        }
+    }
+
+    /**
+     * 用于记录xml文件中是否有重复的表名,或者和已有的表名称重复
+     * @param fileName
+     * @return
+     */
+    public boolean tableHasBuilted(String fileName){
+        return false;
+    }
+
+    public boolean deleteBySonTidRids(Long id, List<Long> asList){
+        HashMap<String,Object> map=new HashMap<>();
+        map.put("son_table_id",id);
+        for(Long rowid : asList){
+            map.put("son_row_id",rowid);
+            try {
+                levelRelationDao.deleteByMap(map);
+            }
+            catch (Exception e){
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public List<LevelRelationEntity> selectByParentAndSonTable(Long parentTableId, Long parentRowId,Long sonTableId){
+        QueryWrapper<LevelRelationEntity> levelWrapper=new QueryWrapper<>();
+        levelWrapper.eq("parent_table_id",parentTableId)
+                .eq("parent_row_id",parentRowId)
+                .eq("son_table_id",sonTableId);
+        return levelRelationDao.selectList(levelWrapper);
+    }
+
+
+}

+ 104 - 0
src/main/java/io/renren/modules/levelManage/service/impl/LevelServiceImpl.java

@@ -0,0 +1,104 @@
+package io.renren.modules.levelManage.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.Query;
+import io.renren.datasource.annotation.DataSource;
+import io.renren.modules.levelManage.dao.LevelDao;
+import io.renren.modules.levelManage.entity.LevelEntity;
+import io.renren.modules.levelManage.service.LevelService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@Service("levelService")
+@DataSource("heBing")
+public class LevelServiceImpl extends ServiceImpl<LevelDao, LevelEntity> implements LevelService {
+
+    @Autowired
+    LevelDao levelDao;
+
+    @Override
+    public PageUtils queryPage(Map<String, Object> params) {
+        IPage<LevelEntity> page = this.page(
+                new Query<LevelEntity>().getPage(params),
+                new QueryWrapper<LevelEntity>()
+        );
+
+        return new PageUtils(page);
+    }
+
+    public List<LevelEntity> selectByName(Integer page, Integer size, String name)
+    {
+        if (page != null && size != null){
+            page = (page - 1) * size;
+        }
+        return levelDao.selectByName(page,size,name);
+    }
+
+    public Integer getCountByName(String name)
+    {
+        return levelDao.getCountByName(name);
+    }
+
+    public List<LevelEntity> getSonLevel(Long id)
+    {
+        return levelDao.getSonLevel(id);
+    }
+
+    public Integer queryEnabledCount() {return levelDao.queryEnabledCount();}
+
+
+    public List<LevelEntity> getAllParentById(Long id)
+    {
+        List<LevelEntity> allLevel=this.list();
+        Map<Long,Long> parentMap=new HashMap<>();
+        List<Long> ids=new ArrayList<>();
+        for(LevelEntity level:allLevel)
+        {
+            parentMap.put(level.getId(), level.getParentId());
+        }
+        while (id!=0)
+        {
+            ids.add(id);
+            id=parentMap.get(id);
+        }
+        return this.listByIds(ids);
+    }
+
+
+    public List<LevelEntity> getEnabledLevels()
+    {
+        return levelDao.getEnabledLevels();
+    }
+
+    public Integer queryEnabledCountWithParentId(Long id)
+    {
+        return levelDao.queryEnabledCountWithParentId(id);
+    }
+
+    public LevelEntity getEnabledSon(Long id)
+    {
+        return levelDao.getEnabledSon(id);
+    }
+
+    public List<LevelEntity> getEnabledLevelByProject(List<Long> ids){
+        return levelDao.getEnabledLevelByProject(ids);
+    }
+
+    public List<LevelEntity> getRootLevel(Long id){
+        QueryWrapper<LevelEntity> levelWrapper=new QueryWrapper<>();
+        levelWrapper.eq("project_id",id)
+                .eq("parent_id",0)
+                .eq("enabled",1);
+        return levelDao.selectList(levelWrapper);
+    }
+}

+ 69 - 0
src/main/java/io/renren/modules/levelManage/service/impl/LevelTableServiceImpl.java

@@ -0,0 +1,69 @@
+package io.renren.modules.levelManage.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.Query;
+import io.renren.datasource.annotation.DataSource;
+import io.renren.modules.levelManage.dao.LevelTableDao;
+import io.renren.modules.levelManage.entity.LevelTableEntity;
+import io.renren.modules.levelManage.service.LevelTableService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+
+@Service("levelTableService")
+@DataSource("heBing")
+public class LevelTableServiceImpl extends ServiceImpl<LevelTableDao, LevelTableEntity> implements LevelTableService {
+
+    @Autowired
+    LevelTableDao levelTableDao;
+
+    @Override
+    public PageUtils queryPage(Map<String, Object> params) {
+        IPage<LevelTableEntity> page = this.page(
+                new Query<LevelTableEntity>().getPage(params),
+                new QueryWrapper<LevelTableEntity>()
+        );
+
+        return new PageUtils(page);
+    }
+
+    public Integer createTable(String tableName, List<Map<String,String>> cols)
+    {
+        return levelTableDao.createTable(tableName,cols);
+    }
+
+    public List<Map<String,Object>> listByLevelId(Long id)
+    {
+        return levelTableDao.listByLevelId(id);
+    }
+
+    public List<String> listColsByLevelId(Long id){
+        return levelTableDao.listColsByLevelId(id);
+    };
+
+    public  List<String> listCommentByLevelId(Long id){
+        return levelTableDao.listCommentByLevelId(id);
+    }
+
+    public List<String> listTypeByLevelId(Long id){
+        return levelTableDao.listTypeByLevelId(id);
+    }
+
+    public  Integer removeByIdsFromTableName(List<Long> ids,String tableName)
+    {
+        return levelTableDao.removeByIdsFromTableName(ids,tableName);
+    }
+
+    public List<String> listBoolColsById(Long id)
+    {
+        return levelTableDao.listBoolColsByLevelId(id);
+    }
+
+}

+ 125 - 0
src/main/java/io/renren/modules/levelManage/service/impl/ProjectAttributesServiceImpl.java

@@ -0,0 +1,125 @@
+package io.renren.modules.levelManage.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.Query;
+import io.renren.datasource.annotation.DataSource;
+import io.renren.modules.levelManage.dao.ProjectAttributesDao;
+import io.renren.modules.levelManage.entity.ProjectAttributesEntity;
+import io.renren.modules.levelManage.service.ProjectAttributesService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+
+@Service("projectAttributesService")
+@DataSource("heBing")
+public class ProjectAttributesServiceImpl extends ServiceImpl<ProjectAttributesDao, ProjectAttributesEntity> implements ProjectAttributesService {
+
+    @Autowired
+    ProjectAttributesDao projectAttributesDao;
+
+    @Override
+    public PageUtils queryPage(Map<String, Object> params) {
+        IPage<ProjectAttributesEntity> page = this.page(
+                new Query<ProjectAttributesEntity>().getPage(params),
+                new QueryWrapper<ProjectAttributesEntity>()
+        );
+
+        return new PageUtils(page);
+    }
+
+    public Integer hasProject(String schema){
+        return projectAttributesDao.hasProject(schema);
+    }
+
+    public Integer createTable(List<Map<String,String>> cols)
+    {
+        return projectAttributesDao.createTable(cols);
+    }
+
+    public List<Map<String,Object>> listAttribute()
+    {
+        return projectAttributesDao.listAttribute();
+    }
+
+    public Integer countProject(){
+        return projectAttributesDao.countProject();
+    }
+
+    public List<String> listCols(){
+        return projectAttributesDao.listCols();
+    }
+
+    public List<Map<String,Object>> listData(List<String> tableCols,Integer page,Integer size){
+        if (page != null && size != null){
+            page = (page - 1) * size;
+        }
+        return projectAttributesDao.list(tableCols,page,size);
+    }
+
+    public List<String> listBoolCols(){
+        return projectAttributesDao.listBoolCols();
+    }
+
+    public Map<String,Object> selectById(Long id,List<String> tableCols){
+        return projectAttributesDao.selectById(id,tableCols);
+    }
+
+    public Long saveWithCols(List<Map<String,Object>> cols){
+        return projectAttributesDao.saveWithCols(cols);
+    }
+
+    public String selectProjectNameById(Long id){
+        return projectAttributesDao.selectProjectNameById(id);
+    }
+
+    public Integer updateWithCols(List<Map<String,Object>> cols,Long id){
+        return projectAttributesDao.updateWithCols(cols,id);
+    }
+
+    public List<Map<String,Object>> selectByName(List<String> tableCols,Integer page,Integer size,String name)
+    {
+        if (page != null && size != null){
+            page = (page - 1) * size;
+        }
+        return projectAttributesDao.selectByName(tableCols,page,size,name);
+    }
+
+    public Integer getCountByName(String name){
+        return projectAttributesDao.getCountByName(name);
+    }
+
+    public Integer removeProjectByIds(List<Long> ids){
+        return projectAttributesDao.removeProjectByIds(ids);
+    }
+
+    public Integer dropProject(){
+        return projectAttributesDao.dropProject() + projectAttributesDao.truncateProjectAttribute();
+    }
+
+    public List<Map<String,Object>> listProjectName(){
+        return projectAttributesDao.listProjectName();
+
+    }
+
+    public String countProjectLevel(Long id){
+        return projectAttributesDao.countProjectLevel(id);
+    }
+
+    public Integer selectRootLevel(Long id){
+        return projectAttributesDao.selectRootLevel(id);
+
+    }
+
+    public List<Map<String, Object>> listProjectByUid(Long uid){
+        return projectAttributesDao.listProjectByUid(uid);
+    }
+
+
+}

+ 144 - 0
src/main/java/io/renren/modules/levelManage/service/impl/UniversalTableServiceImpl.java

@@ -0,0 +1,144 @@
+package io.renren.modules.levelManage.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.Query;
+import io.renren.datasource.annotation.DataSource;
+import io.renren.modules.levelManage.dao.UniversalTableDao;
+import io.renren.modules.levelManage.entity.UniversalTableEntity;
+import io.renren.modules.levelManage.service.UniversalTableService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+
+@Service("universalTableService")
+@DataSource("heBing")
+public class UniversalTableServiceImpl extends ServiceImpl<UniversalTableDao, UniversalTableEntity> implements UniversalTableService {
+
+    @Autowired
+    UniversalTableDao universalTableDao;
+
+    @Override
+    public PageUtils queryPage(Map<String, Object> params) {
+        IPage<UniversalTableEntity> page = this.page(
+                new Query<UniversalTableEntity>().getPage(params),
+                new QueryWrapper<UniversalTableEntity>()
+        );
+
+        return new PageUtils(page);
+    }
+
+    public Map<String,Object> selectById(Long id,String tableName,List<String> tableCols)
+    {
+
+        return universalTableDao.selectById(id,tableName,tableCols);
+    }
+
+    public List<Map<String,Object>> list(String tableName,List<String> tableCols,Integer page,Integer size)
+    {
+        if (page != null && size != null){
+            page = (page - 1) * size;
+        }
+        return universalTableDao.list(tableName,tableCols,page,size);
+    }
+
+    public List<Map<String,Object>> selectByName(String tableName,List<String> tableCols,Integer page,Integer size,String name)
+    {
+        if (page != null && size != null){
+            page = (page - 1) * size;
+        }
+        return universalTableDao.selectByName(tableName,tableCols,page,size,name);
+    }
+
+    public List<Map<String,Object>> selectByNameWithParent(String tableName,List<String> tableCols,Integer page,Integer size,
+                                                           String name,Long parentRowId,Long tableId)
+    {
+        if (page != null && size != null){
+            page = (page - 1) * size;
+        }
+        return universalTableDao.selectByNameWithParent(tableName,tableCols,page,size,name,parentRowId,tableId);
+    }
+
+    public Integer getCountByName(String tableName,String name)
+    {
+        return universalTableDao.getCountByName(tableName,name);
+    }
+
+    public Long saveWithCols(String tableName,List<Map<String,Object>> cols,UniversalTableEntity universalTableEntity)
+    {
+        return universalTableDao.saveWithCols(tableName,cols,universalTableEntity);
+    }
+
+    public Integer updateWithCols(String tableName,List<Map<String,Object>> cols,Long id)
+    {
+        return universalTableDao.updateWithCols(tableName,cols,id);
+    }
+
+    public  Integer removeByIdsFromTableName(List<Long> ids,String tableName)
+    {
+        return universalTableDao.removeByIdsFromTableName(ids,tableName);
+    }
+
+    public List<Map<String,Object>> listAllItem(String tableName)
+    {
+        return universalTableDao.listAllItem(tableName);
+    }
+
+    public List<Map<String,Object>> listNotLeafItem(String tableName)
+    {
+        return universalTableDao.listNotLeafItem(tableName);
+    }
+
+    public List<Map<String,Object>> listLeafItem(String tableName,List<String> tableCols)
+    {
+        return universalTableDao.listLeafItem(tableName,tableCols);
+    }
+
+    public List<Map<String, Object>> listBySonIds(String tableName, List<String> tableCols, List<Long> ids, Integer page, Integer size){
+        if (page != null && size != null){
+            page = (page - 1) * size;
+        }
+        return universalTableDao.listBySonIds(tableName,tableCols,ids,page,size);
+    }
+
+    public boolean updateHbaseTableName(String tableName, Long id, String hbaseTableName){
+        return universalTableDao.updateHbaseTableName(tableName,id, hbaseTableName);
+    }
+
+    public String selectNameById(String tableName, Long id)
+    {
+        return universalTableDao.selectNameById(tableName,id);
+    }
+
+    public Integer getCount(String tableName)
+    {
+        return universalTableDao.getCount(tableName);
+    }
+
+    public Integer getCountByNameWithParent(String tableName, String name, Long parentRowId, Long tableId)
+    {
+        return universalTableDao.getCountByNameWithParent(tableName,name,parentRowId,tableId);
+    }
+
+    public List<Map<String,Object>> listItemWithLeafInfo(String tableName){
+        return universalTableDao.listItemWithLeafInfo(tableName);
+    }
+
+    public List<Map<String,Object>> listNotLeafItemInfo(String tableName, List<String> tableCols){
+        return universalTableDao.listNotLeafItemInfo(tableName,tableCols);
+    }
+
+    public List<Map<String,Object>>  listAllItemInfo(String tableName, List<String> tableCols){
+        return universalTableDao.listAllItemInfo(tableName,tableCols);
+    }
+
+    public List<Map<String, Object>> listBySonIdsNotLimit(String tableName, List<String> tableCols, List<Long> sonIds){
+        return universalTableDao.listBySonIdsNotLimit(tableName,tableCols,sonIds);
+    }
+
+}

+ 57 - 0
src/main/resources/mapper/levelManage/LevelDao.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="io.renren.modules.levelManage.dao.LevelDao">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="io.renren.modules.levelManage.entity.LevelEntity" id="levelMap">
+        <result property="id" column="id"/>
+        <result property="parentId" column="parent_id"/>
+        <result property="name" column="name"/>
+        <result property="hasHbasetable" column="has_hbasetable"/>
+        <result property="createDate" column="create_date"/>
+        <result property="uid" column="uid"/>
+        <result property="createTable" column="create_table"/>
+        <result property="enabled" column="enabled"/>
+        <result property="projectId" column="project_id"/>
+    </resultMap>
+
+
+    <select id="selectByName" resultMap="levelMap">
+        SELECT * FROM level WHERE
+         name like concat('%',#{name},'%')
+         limit #{page}, #{size};
+    </select>
+
+    <select id="getCountByName" resultType="INTEGER">
+        SELECT count(*) from level
+        WHERE name like concat('%',#{name},'%');
+    </select>
+
+    <select id="getSonLevel" resultMap="levelMap">
+        SELECT * FROM level where parent_id=#{id};
+    </select>
+
+    <select id="queryEnabledCount" resultType="INTEGER">
+        SELECT count(*) FROM level WHERE enabled=1;
+    </select>
+
+    <select id="getEnabledLevels" resultMap="levelMap">
+        SELECT * FROM level WHERE enabled=1;
+    </select>
+
+    <select id="queryEnabledCountWithParentId" resultType="INTEGER">
+        SELECT COUNT(*) FROM `level` WHERE enabled=1 AND parent_id=#{id};
+    </select>
+
+    <select id="getEnabledSon" resultMap="levelMap">
+        SELECT * FROM level where enabled=1 AND parent_id=#{id};
+    </select>
+
+    <select id="getEnabledLevelByProject" resultMap="levelMap">
+	    SELECT * FROM level where project_id in
+	    <foreach collection="ids" item="id" open="(" close=")" separator=",">
+        ${id}
+        </foreach>
+	</select>
+</mapper>

+ 29 - 0
src/main/resources/mapper/levelManage/LevelRelationDao.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="io.renren.modules.levelManage.dao.LevelRelationDao">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="io.renren.modules.levelManage.entity.LevelRelationEntity" id="levelRelationMap">
+        <result property="id" column="id"/>
+        <result property="parentTableId" column="parent_table_id"/>
+        <result property="parentRowId" column="parent_row_id"/>
+        <result property="sonTableId" column="son_table_id"/>
+        <result property="sonRowId" column="son_row_id"/>
+    </resultMap>
+
+    <select id="selectBySon" resultMap="levelRelationMap">
+        SELECT * from level_relation
+        where son_table_id=${tableId} and son_row_id=${id};
+    </select>
+
+    <select id="selectByParent" resultMap="levelRelationMap">
+        SELECT * FROM level_relation
+        where parent_table_id=${tableId} and parent_row_id=${id};
+    </select>
+    
+    <select id="selectByParentRowAndSonTable" resultMap="levelRelationMap">
+        SELECT * FROM level_relation
+        WHERE son_table_id=#{tableId} and parent_row_id=#{parentRowId}
+    </select>
+</mapper>

+ 58 - 0
src/main/resources/mapper/levelManage/LevelTableDao.xml

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="io.renren.modules.levelManage.dao.LevelTableDao">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="io.renren.modules.levelManage.entity.LevelTableEntity" id="levelTableMap">
+        <result property="id" column="id"/>
+        <result property="levelId" column="level_id"/>
+        <result property="name" column="name"/>
+        <result property="type" column="type"/>
+        <result property="createDate" column="create_date"/>
+        <result property="createUser" column="create_user"/>
+        <result property="remark" column="remark"/>
+        <result property="tableName" column="table_name"/>
+        <result property="isLeaf" column="is_leaf"/>
+    </resultMap>
+
+    <update id="createTable" parameterType="map">
+        CREATE TABLE ${tableName}
+        (
+            <foreach collection="cols" item="listItem" separator=",">
+                ${listItem.name} ${listItem.type} COMMENT #{listItem.comment}
+                <if test="listItem.name == 'id'">
+                     auto_increment PRIMARY KEY
+                </if>
+            </foreach>
+        );
+    </update>
+
+    <select id="listByLevelId" resultType="map">
+        select name,type,remark from level_table WHERE level_id=#{id};
+    </select>
+
+    <select id="listColsByLevelId" resultType="String">
+        select name,remark FROM level_table WHERE level_id=#{id};
+    </select>
+
+    <select id="listCommentByLevelId" resultType="String">
+        select remark FROM level_table WHERE level_id=#{id};
+    </select>
+
+    <select id="listTypeByLevelId" resultType="String">
+        SELECT type from level_table WHERE level_id=#{id};
+    </select>
+
+    <delete id="removeByIdsFromTableName" parameterType="List">
+        DELETE from ${tableName} where id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            ${id}
+        </foreach>
+        ;
+    </delete>
+
+    <select id="listBoolColsByLevelId" resultType="String">
+        SELECT name FROM level_table WHERE level_id=#{id} and type='bool'
+    </select>
+</mapper>

+ 152 - 0
src/main/resources/mapper/levelManage/ProjectAttributesDao.xml

@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="io.renren.modules.levelManage.dao.ProjectAttributesDao">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="io.renren.modules.levelManage.entity.ProjectAttributesEntity" id="projectAttributesMap">
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="type" column="type"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <select id="hasProject" resultType="INTEGER">
+        SELECT COUNT(*) FROM information_schema.`TABLES` WHERE table_name="project" AND table_schema=#{schema}
+    </select>
+
+    <update id="createTable" parameterType="map">
+        CREATE TABLE project
+        (
+        <foreach collection="cols" item="listItem" separator=",">
+            ${listItem.name} ${listItem.type} COMMENT #{listItem.comment}
+            <if test="listItem.name == 'id'">
+                auto_increment PRIMARY KEY
+            </if>
+        </foreach>
+        );
+    </update>
+
+    <select id="listAttribute" resultType="map">
+        select name,type,remark from project_attributes;;
+    </select>
+
+    <select id="countProject" resultType="INTEGER">
+        select count(*) from project;
+    </select>
+
+    <select id="listCols" resultType="String">
+        SELECT name from project_attributes;
+    </select>
+
+    <select id="list" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        project
+        limit #{page}, #{size};
+    </select>
+
+    <select id="listBoolCols" resultType="String">
+        SELECT name from project_attributes where type='bool'
+    </select>
+
+    <select id="selectById" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        project
+        WHERE id=#{id}
+    </select>
+
+    <insert id="saveWithCols" parameterType="MAP">
+        INSERT into project
+        <foreach collection="cols" item="col" separator="," close=")" open="(">
+            ${col.cols}
+        </foreach>
+        VALUES
+        <foreach collection="cols" item="col" separator="," open="(" close=")">
+            #{col.value}
+        </foreach>
+    </insert>
+
+    <select id="selectProjectNameById" resultType="String">
+        SELECT
+        name
+        from
+        project
+        where
+        id=#{id}
+    </select>
+
+    <update id="updateWithCols">
+        UPDATE project
+        SET
+        <foreach collection="cols" item="col" separator="," >
+            ${col.cols} = #{col.value}
+        </foreach>
+        WHERE
+        id = #{id}
+    </update>
+
+    <select id="selectByName" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        project
+        WHERE SUBSTR(name,5) like concat('%',#{name},'%')
+        limit #{page}, #{size};
+    </select>
+
+    <select id="getCountByName" resultType="INTEGER">
+        SELECT count(*)
+        from project
+        WHERE
+        SUBSTR(name,5) like concat('%',#{name},'%');
+    </select>
+
+    <delete id="removeProjectByIds" parameterType="List">
+        DELETE from project where id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            ${id}
+        </foreach>
+        ;
+    </delete>
+
+    <update id="dropProject">
+        DROP TABLE project;
+    </update>
+    <update id="truncateProjectAttribute">
+        truncate table project_attributes;
+    </update>
+
+    <select id="listProjectName" resultType="map">
+        SELECT id,name
+        FROM
+        project
+    </select>
+
+    <select id="countProjectLevel" resultType="String">
+        SELECT count(*)
+        FROM level
+        WHERE project_id=#{id}
+    </select>
+
+    <select id="selectRootLevel" resultType="Integer">
+        SELECT id FROM LEVEL WHERE parent_id=0 AND project_id=#{id}
+    </select>
+
+    <select id="listProjectByUid" resultType="map">
+        SELECT id,name
+        FROM
+        project
+        WHERE create_user=${uid}
+    </select>
+
+</mapper>

+ 183 - 0
src/main/resources/mapper/levelManage/UniversalTableDao.xml

@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="io.renren.modules.levelManage.dao.UniversalTableDao">
+
+    <!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="io.renren.modules.levelManage.entity.UniversalTableEntity" id="UniversalTableMap">
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="createDate" column="create_date"/>
+        <result property="createUser" column="create_user"/>
+    </resultMap>
+
+    <select id="selectById" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+        ${listItem}
+        </foreach>
+        FROM
+        ${tableName}
+        WHERE id=#{id}
+    </select>
+
+    <select id="list" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        ${tableName}
+        limit #{page}, #{size};
+    </select>
+
+    <select id="listBySonIds" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        ${tableName}
+        WHERE id in
+        <foreach collection="ids" item="id" separator="," open="(" close=")">
+            ${id}
+        </foreach>
+        limit #{page}, #{size};
+    </select>
+
+    <select id="listBySonIdsNotLimit" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        ${tableName}
+        WHERE id in
+        <foreach collection="ids" item="id" separator="," open="(" close=")">
+            ${id}
+        </foreach>
+    </select>
+
+    <select id="selectByName" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        ${tableName}
+        WHERE SUBSTR(name,5) like concat('%',#{name},'%')
+        limit #{page}, #{size};
+    </select>
+
+    <select id="getCountByName" resultType="INTEGER">
+        SELECT COUNT(*) FROM ${tableName}
+        WHERE
+        SUBSTR(name,5) like concat('%',#{name},'%');
+    </select>
+
+    <insert id="saveWithCols" parameterType="io.renren.modules.levelManage.entity.UniversalTableEntity" useGeneratedKeys="true" keyProperty="universalTableEntity.id">
+        INSERT into ${tableName}
+        <foreach collection="cols" item="col" separator="," close=")" open="(">
+            ${col.cols}
+        </foreach>
+        VALUES
+        <foreach collection="cols" item="col" separator="," open="(" close=")">
+            #{col.value}
+        </foreach>
+    </insert>
+
+    <update id="updateWithCols">
+        UPDATE ${tableName}
+        SET
+        <foreach collection="cols" item="col" separator="," >
+            ${col.cols} = #{col.value}
+        </foreach>
+        WHERE
+        id = #{id}
+    </update>
+
+    <delete id="removeByIdsFromTableName" parameterType="List">
+        DELETE from ${tableName} where id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            ${id}
+        </foreach>
+        ;
+    </delete>
+
+    <select id="listAllItem" resultType="map">
+        SELECT id, SUBSTR(name,5) as name
+        FROM ${tableName}
+    </select>
+
+    <select id="listNotLeafItem" resultType="map">
+        SELECT id, SUBSTR(name,5) as name
+        FROM ${tableName}
+        WHERE is_leaf!=1;
+    </select>
+
+    <select id="listNotLeafItemInfo" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        ${tableName}
+        WHERE is_leaf!=1;
+    </select>
+    <select id="listLeafItem" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        ${tableName}
+        WHERE is_leaf=1;
+    </select>
+
+    <update id="updateHbaseTableName" >
+        UPDATE ${tableName} set hbaseTableName=#{hbaseTableName} where id=#{id}
+    </update>
+
+    <select id="selectNameById" resultType="String">
+        SELECT name FROM ${tableName} where id=#{id}
+    </select>
+
+    <select id="getCount" resultType="INTEGER">
+        SELECT count(*) FROM  ${tableName};
+    </select>
+    
+    <select id="selectByNameWithParent" resultType="map">
+        SELECT * FROM ${tableName}
+        WHERE id IN
+            (SELECT son_row_id FROM level_relation
+             WHERE son_table_id=#{tableId}
+             AND parent_row_id=#{parentRowId}
+            )
+        AND SUBSTR(name,5) LIKE concat('%',#{name},'%')
+        limit #{page}, #{size};
+    </select>
+
+    <select id="getCountByNameWithParent" resultType="INTEGER">
+        SELECT count(*) FROM ${tableName}
+        WHERE id IN
+            (SELECT son_row_id FROM level_relation
+             WHERE son_table_id=#{tableId}
+             AND parent_row_id=#{parentRowId}
+            )
+        AND SUBSTR(name,5) LIKE concat('%',#{name},'%');
+    </select>
+
+    <select id="listItemWithLeafInfo" resultType="Map">
+        SELECT id, SUBSTR(name,5) as name,is_leaf
+        FROM ${tableName}
+    </select>
+
+    <select id="listAllItemInfo" resultType="map">
+        SELECT
+        <foreach collection="tableCols" item="listItem" separator="," >
+            ${listItem}
+        </foreach>
+        FROM
+        ${tableName}
+    </select>
+</mapper>