diff --git a/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java b/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java index beaa1a2..c6bdbc3 100644 --- a/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java +++ b/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java @@ -21,7 +21,7 @@ public class KnowVO implements Serializable { private String label; /** - * 信息 + * color */ private String color; diff --git a/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java index 8744014..dbe1575 100644 --- a/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java @@ -113,7 +113,7 @@ public class knowServiceImpl implements KnowService { Node node1 = (Node) element.get("p"); Long group = (Long) element.get("d"); - knowVO.setColor(colorChoose.get(group)); +// knowVO.setColor(colorChoose.get(group)); Long id1 = node1.id(); String name1 = node1.get("name").asString(); @@ -168,8 +168,8 @@ public class knowServiceImpl implements KnowService { knowVO = new KnowVO(); Node node1 = (Node) element.get("p"); - Long group = (Long) element.get("d"); - knowVO.setColor(colorChoose.get(group)); +// Long group = (Long) element.get("d"); +// knowVO.setColor(colorChoose.get(group)); Long id1 = node1.id(); String name1 = node1.get("name").asString(); @@ -225,7 +225,7 @@ public class knowServiceImpl implements KnowService { Node node1 = (Node) element.get("p"); Long group = (Long) element.get("d"); - knowVO.setColor(colorChoose.get(group)); +// knowVO.setColor(colorChoose.get(group)); Long id1 = node1.id(); String name1 = node1.get("name").asString(); @@ -748,7 +748,10 @@ public class knowServiceImpl implements KnowService { @Override public BaseResponse getAllKnowByCourseId(String id) { Collection> all = - neo4jClient.query("match(n:Know)-[r:contain*0..4]->(p:Know) where n.courseId = '" + id + "' return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all(); + neo4jClient.query("match(n:Know)-[r:contain*0..]->(p:Know) where n.courseId = '" + id + "' return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all(); + Collection> all2 = + neo4jClient.query("match(n:Know)-[r*]->(p:Know) where n.courseId = '" + id + "' return r as `r`").fetch().all(); + Map colorChoose = new HashMap<>(); String color[] = new String[10]; @@ -758,6 +761,7 @@ public class knowServiceImpl implements KnowService { } Iterator> iterator = all.iterator(); + Iterator> iterator2 = all2.iterator(); Set knowList = new HashSet<>(); Set linksList = new HashSet<>(); KnowVO knowVO; @@ -768,9 +772,8 @@ public class knowServiceImpl implements KnowService { Map element = iterator.next(); knowVO = new KnowVO(); Node node1 = (Node) element.get("p"); - Long group = (Long) element.get("d"); -// knowVO.setColor(colorChoose.get(group)); + knowVO.setColor(colorChoose.get(group)); if (node1 != null) { Long id1 = node1.id(); String name1 = node1.get("name").asString(); @@ -778,9 +781,29 @@ public class knowServiceImpl implements KnowService { knowVO.setLabel(name1); knowList.add(knowVO); knowVO.setColor(colorChoose.get(group)); + } + node2 = (List) element.get("r"); + if (!node2.isEmpty()) { + for (int i = 0; i < node2.size(); i++) { + InternalRelationship e = (InternalRelationship) node2.get(i); + links = new Links(); + links.setId(e.id()); + links.setSource(e.startNodeId()); + links.setTarget(e.endNodeId()); + if ("contain".equals(e.type())) { + links.setLabel("包含"); + } else if ("order".equals(e.type())) { + links.setLabel("顺序"); + } + linksList.add(links); + } } + + } + while (iterator2.hasNext()) { + Map element = iterator2.next(); node2 = (List) element.get("r"); if (!node2.isEmpty()) { for (int i = 0; i < node2.size(); i++) { diff --git a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java index b120f8a..f4b993d 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java @@ -168,7 +168,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl