|
|
|
@ -314,10 +314,10 @@ public class Neo4jServiceImpl implements Neo4jService {
|
|
|
|
|
// 组织节点
|
|
|
|
|
Map<String, String> sourceNodeMap = new HashMap<>();
|
|
|
|
|
sourceNodeMap.put("name", record.get("sourceName").asString());
|
|
|
|
|
setNodeIdAndColor(nodes, labelColorMap, sourceLabels, sourceId, sourceNodeMap);
|
|
|
|
|
setNodeIdAndColor(nodes, labelColorMap, sourceLabels, sourceId, sourceNodeMap, graphReqVO);
|
|
|
|
|
Map<String, String> targetNodeMap = new HashMap<>();
|
|
|
|
|
targetNodeMap.put("name", record.get("targetName").asString());
|
|
|
|
|
setNodeIdAndColor(nodes, labelColorMap, targetLabels, targetId, targetNodeMap);
|
|
|
|
|
setNodeIdAndColor(nodes, labelColorMap, targetLabels, targetId, targetNodeMap, graphReqVO);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("查询失败", e);
|
|
|
|
@ -349,11 +349,15 @@ public class Neo4jServiceImpl implements Neo4jService {
|
|
|
|
|
return R.ok(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setNodeIdAndColor(List<Map<String, String>> nodes, List<Map<String, String>> labelColorMap, List<String> labels, long id, Map<String, String> nodeMap) {
|
|
|
|
|
private void setNodeIdAndColor(List<Map<String, String>> nodes, List<Map<String, String>> labelColorMap, List<String> labels, long id, Map<String, String> nodeMap, GraphReqVO graphReqVO) {
|
|
|
|
|
nodeMap.put("id", String.valueOf(id));
|
|
|
|
|
for (Map<String, String> labelColor : labelColorMap) {
|
|
|
|
|
if (labels.contains(labelColor.get("name"))) {
|
|
|
|
|
nodeMap.put("color", labelColor.get("color"));
|
|
|
|
|
if (graphReqVO.getNodeLabels().isEmpty() && graphReqVO.getRelTypes().isEmpty() && StringUtils.isEmpty(graphReqVO.getQueryStr())) {
|
|
|
|
|
nodeMap.put("color", labelColor.get("lightColor"));
|
|
|
|
|
} else {
|
|
|
|
|
nodeMap.put("color", labelColor.get("color"));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -403,8 +407,9 @@ public class Neo4jServiceImpl implements Neo4jService {
|
|
|
|
|
List<Map<String, Object>> nodeLabelsList = nodeLabels.stream().map(label -> {
|
|
|
|
|
Map<String, Object> nodeLabelMap = new HashMap<>();
|
|
|
|
|
Map<String, String> itemStyle = new HashMap<>();
|
|
|
|
|
itemStyle.put("color", Neo4jUtils.getRandomColorPair()[0]);
|
|
|
|
|
itemStyle.put("lightColor", Neo4jUtils.getRandomColorPair()[1]);
|
|
|
|
|
String[] colors = Neo4jUtils.getRandomColorPair();
|
|
|
|
|
itemStyle.put("color", colors[0]);
|
|
|
|
|
itemStyle.put("lightColor", colors[1]);
|
|
|
|
|
nodeLabelMap.put("name", label);
|
|
|
|
|
nodeLabelMap.put("itemStyle", itemStyle);
|
|
|
|
|
return nodeLabelMap;
|
|
|
|
|