Browse Source

Merge branch 'small-tupu' of http://124.70.32.114:3100/jianzhenyu/Changsha_tupu into hanyuqing

small-tupu
hanyuqing 6 months ago
parent
commit
bd62767a06
  1. 81
      gyxtp/src/view/small.vue
  2. 22
      ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java

81
gyxtp/src/view/small.vue

@ -538,14 +538,19 @@ export default {
let nodes = []; let nodes = [];
let links = []; let links = [];
// Step 0: nodeId -> node.type
const nodeTypeMap = {};
res.nodes.forEach(node => {
nodeTypeMap[node.id] = node.type;
});
// Step 1: totalNum data.num // Step 1: totalNum data.num
const totalNumMap = {}; // { nodeId: totalNum } const totalNumMap = {}; // { nodeId: totalNum }
console.log(res.links)
res.links.forEach(link => { res.links.forEach(link => {
const from = link.from; const from = link.from;
const to = link.to; const to = link.to;
const num = link.num || 0; // const num = link.num || 0; //
console.log(num)
// from to num // from to num
totalNumMap[from] = (totalNumMap[from] || 0) + num; totalNumMap[from] = (totalNumMap[from] || 0) + num;
@ -559,20 +564,62 @@ export default {
} }
}); });
// Step 2: totalNum
// Step 3: from to author agency
for (let i = 0; i < res.links.length; i++) {
const link = res.links[i];
const fromNodeId = link.from;
const toNodeId = link.to;
// from to
const fromType = nodeTypeMap[fromNodeId];
const toType = nodeTypeMap[toNodeId];
//
const forbiddenTypes = ['author', 'agency'];
// from to author agency
if (forbiddenTypes.includes(fromType) && forbiddenTypes.includes(toType)) {
continue;
}
//
const t_line = {
from: fromNodeId,
to: toNodeId,
text: link.text,
data: {
uuids: link.uuids,
num: link.num
}
};
links.push(t_line);
}
//
const connectedNodeIds = new Set();
links.forEach(link => {
connectedNodeIds.add(link.from);
connectedNodeIds.add(link.to);
});
for (let i = 0; i < res.nodes.length; i++) { for (let i = 0; i < res.nodes.length; i++) {
const node = res.nodes[i]; const node = res.nodes[i];
// // text if (!connectedNodeIds.has(node.id)) {
// if (node.type === "keyword" && node.text !== this.getpoinName) { continue; //
// continue; }
// } // text
if (node.type === "keyword" && node.text !== this.getpoinName) {
continue;
}
// num // num
const totalNum = totalNumMap[node.id]; const totalNum = totalNumMap[node.id];
// totalNum // totalNum
const baseSize = 150; // const baseSize = 120; //
const sizePerNum = 40; // num const sizePerNum = 40; // num
const maxSize = 300; // const maxSize = 300; //
@ -582,6 +629,7 @@ export default {
const t_data = { const t_data = {
id: node.id, id: node.id,
type:node.type,
text: node.text, text: node.text,
width: width, width: width,
height: height, height: height,
@ -593,23 +641,6 @@ export default {
nodes.push(t_data); nodes.push(t_data);
} }
// Step 3:
for (let i = 0; i < res.links.length; i++) {
const link = res.links[i];
const t_line = {
from: link.from,
to: link.to,
text: link.text,
data: {
uuids: link.uuids,
num: link.num
}
};
links.push(t_line);
}
var data = { var data = {
nodes:nodes, nodes:nodes,
links:links links:links

22
ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java

@ -99,17 +99,19 @@ public class TestXiaoTuPuController extends BaseController {
} }
Integer uuid = Integer.valueOf(String.valueOf(list.get(0).get("uuid"))); Integer uuid = Integer.valueOf(String.valueOf(list.get(0).get("uuid")));
String cypher = "MATCH (center:TestNode)\n" + // String cypher = "MATCH (center:TestNode)\n" +
"WHERE id(center) = " + uuid + "\n" + // "WHERE id(center) = " + uuid + "\n" +
"MATCH path = (center)-[r]-(other:TestNode)\n" + // 直接匹配一条关系 // "MATCH path = (center)-[r]-(other:TestNode)\n" + // 直接匹配一条关系
"WITH r, center AS n, other AS m\n" + // "WITH r, center AS n, other AS m\n" +
"RETURN DISTINCT n, m, r";
// String cypher ="MATCH (center:TestNode)\n" +
// "WHERE id(center) = "+uuid+"\n" +
// "MATCH path = (center)-[*1..2]-(other:TestNode)\n" +
// "UNWIND relationships(path) AS r\n" +
// "WITH r, startNode(r) AS n, endNode(r) AS m\n" +
// "RETURN DISTINCT n, m, r"; // "RETURN DISTINCT n, m, r";
//
String cypher ="MATCH (center:TestNode)\n" +
"WHERE id(center) = "+uuid+"\n" +
"MATCH path = (center)-[*1..2]-(other:TestNode)\n" +
"UNWIND relationships(path) AS r\n" +
"WITH r, startNode(r) AS n, endNode(r) AS m\n" +
"RETURN DISTINCT n, m, r";
HashMap<String, Object> graphNode = neo4jUtil.getGraphNodeAndShip(cypher); HashMap<String, Object> graphNode = neo4jUtil.getGraphNodeAndShip(cypher);

Loading…
Cancel
Save