知识图谱融合+文件在线查看

main
王家东 7 months ago
parent 2aa921f1d4
commit 9515e658c0
  1. 40
      ant-design-vue-jeecg/src/views/seknowgroup/KnowledgeGraph.vue
  2. 2
      ant-design-vue-jeecg/src/views/seknowgroup/SeKnowGroupList.vue
  3. 14
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/course/controller/SeCourseController.java
  4. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/know/entity/SeKonw.java
  5. 4
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/know/mapper/SeKonwMapper.java
  6. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/know/service/ISeKonwService.java
  7. 27
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/know/service/impl/SeKonwServiceImpl.java
  8. 7
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/controller/SeKnowGroupController.java
  9. 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeList.java
  10. 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeName.java

@ -4,9 +4,10 @@
<script>
// import ForceGraph3D from '3d-force-graph'
/*import data from './dataJSON'*/
import { CSS2DRenderer, CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js'
import SpriteText from './spritetext.js'
import data from './dataJSON'
import { getAction } from '@api/manage'
export default {
name: 'ThreeDForceGraph',
props: {
@ -22,33 +23,34 @@ export default {
data() {
return {
Graph: {},
data: {
nodes: [
{ id: 'node1', label: '计算机' },
{ id: 'node2', label: 'java' },
{ id: 'node3', label: '前端' },
{ id: 'node4', label: '数据库' },
{ id: 'node5', label: 'mysql' }
],
edges: [
{ source: 'node1', target: 'node2', label: '' },
{ source: 'node1', target: 'node3', label: '' },
{ source: 'node1', target: 'node4', label: '' },
{ source: 'node4', target: 'node5', label: '' }
]
}
/*data: {}*/
data: {}
}
},
mounted() {
this.initGraph()
this.createData();
},
methods: {
createData(){
console.log(this.$route.query.id,'```')
getAction("/seknowgroup/seKnowGroup/createGroup", { id: this.$route.query.id }).then((res) => {
if (res.success) {
this.data = res.result;
console.log(this.data,'1345')
this.initGraph()
} else {
this.$message.warning(res.message)
}
})
},
initGraph() {
let dom = null
this.Graph = ForceGraph3D({
extraRenderers: [new CSS2DRenderer()]
})(document.getElementById('3d-graph'))
.graphData(JSON.parse(data))
.graphData(this.data)
// .nodeAutoColorBy('group')
.nodeThreeObject(node => {
const nodeEl = document.createElement('div')
@ -124,7 +126,7 @@ export default {
//
//@ts-ignore
Graph.graphData(graphData)
this.Graph.graphData(graphData)
})
dom = document.querySelector('canvas')
},

@ -178,7 +178,7 @@
},
methods: {
zsAtlsa(record) {
let routeData = this.$router.resolve({ path: '/atlas', query: { id: record.id } });
let routeData = this.$router.resolve({ path: '/atlas', query: { id: record.courseid } });
window.open(routeData.href, '_blank');
},

@ -725,12 +725,14 @@ public class SeCourseController extends JeecgController<SeCourse, ISeCourseServi
public void classtoknow(String id) {
SeCourse seCourse = seCourseService.getById(id);
SeKonw seKonw = new SeKonw();
seKonw.setId(id);
seKonw.setName(seCourse.getName());
seKonw.setCode("课程:"+seCourse.getCode());
//这里的数据自数据字典cck其中1代表的是课程表
seKonw.setKnowfrom("1");
seKonw.setFromid(id);
seKonw.setCourseid(id);
seKonw.setColor("rgba(58, 244, 142, 1)");
seKonwService.save(seKonw);
}
@ -750,12 +752,14 @@ public class SeCourseController extends JeecgController<SeCourse, ISeCourseServi
List<SeChapter> chapterList = seChapterMapper.selectList(queryWrapper);
for (int i=0;i<chapterList.size();i++){
SeKonw seKonw = new SeKonw();
seKonw.setId(chapterList.get(i).getId());
seKonw.setName(chapterList.get(i).getName());
//这里的数据自数据字典cck其中2代表的是章节表
seKonw.setKnowfrom("2");
seKonw.setInfo("来自课程:"+seCourse.getName());
seKonw.setFromid(chapterList.get(i).getId());
seKonw.setCourseid(id);
seKonw.setColor("rgba(58, 244, 142, 1)");
seKonwService.save(seKonw);
}
}
@ -792,7 +796,6 @@ public class SeCourseController extends JeecgController<SeCourse, ISeCourseServi
//这里的数据自数据字典cck其中1代表的是课程表
seKonwRelationshipMain.setPerFrom("1");
seKonwRelationshipMain.setPerName(seCourse.getName());
System.out.println(seCourse.getName());
seKonwRelationshipMain.setPerKowId(id);
seKonwRelationshipMain.setPerColor("rgba(254, 241, 0, 1)");
//这里的数据自数据字典cck其中2代表的是章节表
@ -800,6 +803,7 @@ public class SeCourseController extends JeecgController<SeCourse, ISeCourseServi
seKonwRelationshipMain.setNextName(chapterList.get(i).getName());
seKonwRelationshipMain.setNextKnowId(chapterList.get(i).getId());
seKonwRelationshipMain.setNextColor("rgba(10, 138, 244, 1)");
seKonwRelationshipMain.setCourseid(id);
seKonwRelationshipMainService.save(seKonwRelationshipMain);
}
}
@ -808,7 +812,6 @@ public class SeCourseController extends JeecgController<SeCourse, ISeCourseServi
//用于在创建前知识点和后知识点的过程中创建章-节这一层的知识点关系
public void cretzhangjie(String id){
//开始组装课程-章结构知识点关系
SeCourse seCourse = seCourseService.getById(id);
QueryWrapper<SeChapter> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("courseid", id).eq("pid","0");
@ -830,6 +833,7 @@ public class SeCourseController extends JeecgController<SeCourse, ISeCourseServi
seKonwRelationshipMain.setNextName(chapterListj.get(j).getName());
seKonwRelationshipMain.setNextKnowId(chapterListj.get(j).getId());
seKonwRelationshipMain.setNextColor("rgba(10, 138, 244, 1)");
seKonwRelationshipMain.setCourseid(id);
seKonwRelationshipMainService.save(seKonwRelationshipMain);
}
}
@ -864,9 +868,11 @@ public class SeCourseController extends JeecgController<SeCourse, ISeCourseServi
seKonwRelationshipMain.setPerKowId(knowcourseList.get(c).getUintid());
seKonwRelationshipMain.setPerColor("rgba(254, 241, 0, 1)");
seKonwRelationshipMain.setNextFrom("3");
seKonwRelationshipMain.setNextName(knowcourseList.get(c).getKnow());
seKonwRelationshipMain.setNextKnowId(knowcourseList.get(c).getKnowid());
SeKonw seKonw =seKonwService.getById(knowcourseList.get(c).getKnowid());
seKonwRelationshipMain.setNextName(seKonw.getName());
seKonwRelationshipMain.setNextKnowId(seKonw.getId());
seKonwRelationshipMain.setNextColor("rgba(10, 138, 244, 1)");
seKonwRelationshipMain.setCourseid(id);
seKonwRelationshipMainService.save(seKonwRelationshipMain);
}
}

@ -84,4 +84,6 @@ public class SeKonw implements Serializable {
private java.lang.String fromid;
@ApiModelProperty(value = "来源表ID")
private java.lang.String courseid;
@ApiModelProperty(value = "来源表ID")
private java.lang.String color;
}

@ -37,9 +37,9 @@ public interface SeKonwMapper extends BaseMapper<SeKonw> {
@Select("select wight from se_konw_relationship where id =#{relationId}")
String getrelaint(String relationId);
@Select("select id, name as label from se_konw where courseid =#{id}")
@Select("select id, name as label,courseid as classID,color from se_konw where courseid =#{id}")
List<NodeName> getallnodes(String id);
@Select("select per_kow_id as source,next_know_id as target from se_konw_relationship_main where courseid=#{id}")
@Select("select per_kow_id as source,next_know_id as target,courseid as classID from se_konw_relationship_main where courseid=#{id}")
List<NodeList> getalllikes(String id);
}

@ -29,7 +29,7 @@ public interface ISeKonwService extends IService<SeKonw> {
String getrelaint(String relationId);
List<NodeName> getallnodes(String id);
List<NodeName> getallnodes(List<NodeList> id);
List<NodeList> getalllikes(String id);

@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Description: 知识点表
@ -73,9 +74,31 @@ public class SeKonwServiceImpl extends ServiceImpl<SeKonwMapper, SeKonw> impleme
}
@Override
public List<NodeName> getallnodes(String id) {
public List<NodeName> getallnodes(List<NodeList> id) {
List<NodeName> nodeNameList = new ArrayList<>();
List<String> slist = new ArrayList<>();
if (!id.isEmpty()){
for (int i=0;i<id.size();i++){
String s1 =id.get(i).getTarget();
String s2 =id.get(i).getSource();
slist.add(s1);
slist.add(s2);
}}
List<String> distinctList = slist.stream().distinct().collect(Collectors.toList());
for (int i=0;i<distinctList.size();i++){
SeKonw seKonw = new SeKonw();
seKonw = seKonwService.getById(distinctList.get(i));
NodeName nodeName = new NodeName();
nodeName.setId(seKonw.getId());
nodeName.setClassID(seKonw.getCourseid());
nodeName.setColor(seKonw.getColor());
nodeName.setLabel(seKonw.getName());
nodeNameList.add(nodeName);
}
return seKonwMapper.getallnodes(id);
return nodeNameList;
}
@Override

@ -202,15 +202,16 @@ public class SeKnowGroupController extends JeecgController<SeKnowGroup, ISeKnowG
@GetMapping(value = "/createGroup")
public Result<?> createGroup(@RequestParam(name="id",required=true) String id) {
//开始获取并组装单个知识点
List<NodeName> nodes = seKonwService.getallnodes(id);
//开始组装知识点链接
List<NodeList> links = seKonwService.getalllikes(id);
//开始获取并组装单个知识点
List<NodeName> nodes = seKonwService.getallnodes(links);
//开始组装完整的只是节点
Exports exports = new Exports();
exports.setNodes(nodes);
exports.setLinks(links);
System.out.println(exports);
return Result.OK(exports);
}

@ -11,5 +11,6 @@ public class NodeList {
private String source;
private String target;
private String label;
private String classID;
}

@ -8,5 +8,6 @@ public class NodeName {
private String id;
private String label;
private String color;
private String classID;
}

Loading…
Cancel
Save