|
|
|
@ -3,12 +3,9 @@ package com.supervision.service.impl;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.lang.Snowflake;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.supervision.dao.*;
|
|
|
|
|
import com.supervision.domain.*;
|
|
|
|
|
import com.supervision.enums.TagEnum;
|
|
|
|
@ -362,30 +359,7 @@ public class GraphNebulaServiceImpl implements GraphNebulaService {
|
|
|
|
|
for (TreeNodeVO nodeVO : firstNodeList) {
|
|
|
|
|
recursionBuildTree(nodeVO, treeNodeMap, graphVO.getEdges());
|
|
|
|
|
}
|
|
|
|
|
// 为所有节点分配新的唯一ID(前端需要ID字段为唯一ID)
|
|
|
|
|
Snowflake snowflake = IdUtil.getSnowflake(1);
|
|
|
|
|
// 先转JSON,再转回去.为了避免出现对象复用的情况,导致ID不能分配为唯一ID
|
|
|
|
|
String jsonStr = JSONUtil.toJsonStr(firstNodeList);
|
|
|
|
|
List<TreeNodeVO> newTreeNodeList = JSONUtil.toList(jsonStr, TreeNodeVO.class);
|
|
|
|
|
|
|
|
|
|
recursionGenerateSingleId(newTreeNodeList, snowflake);
|
|
|
|
|
return newTreeNodeList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 为属性结构构建新的唯一ID,把原先的ID迁移到GraphId
|
|
|
|
|
*/
|
|
|
|
|
private void recursionGenerateSingleId(List<TreeNodeVO> firstNodeList, Snowflake snowflake) {
|
|
|
|
|
for (TreeNodeVO treeNodeVO : firstNodeList) {
|
|
|
|
|
if (StrUtil.isBlank(treeNodeVO.getGraphId())) {
|
|
|
|
|
treeNodeVO.setGraphId(treeNodeVO.getId());
|
|
|
|
|
}
|
|
|
|
|
String nextId = snowflake.nextIdStr() + "-id";
|
|
|
|
|
treeNodeVO.setId(nextId);
|
|
|
|
|
if (CollUtil.isNotEmpty(treeNodeVO.getChildren())) {
|
|
|
|
|
recursionGenerateSingleId(treeNodeVO.getChildren(), snowflake);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return firstNodeList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void recursionBuildTree(TreeNodeVO preNode, Map<String, TreeNodeVO> treeNodeMap, List<EdgeVO> edgeList) {
|
|
|
|
|