逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录

最近闲来无事 开发了一套知识图谱系统 特地再次跟大家分享软件开发过程

技术

技术挺简单的 就是按照下面开发的
Java后端:SpringBoot JPA mysql neo4j图数据库
前端:echarts vue.js elementUI

功能

逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第1张图片

写好以后运行图

逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第2张图片
逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第3张图片
逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第4张图片
逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第5张图片
逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第6张图片
逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第7张图片
具体实现代码如下:

package org.qust.controller.admin;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.qust.common.Result;
import org.qust.common.StatusCode;
import org.qust.entity.BaseInfo;
import org.qust.entity.TechnologyInfo;
import org.qust.entity.TitleType;
import org.qust.entity.neo4j.EchartsData;
import org.qust.entity.neo4j.EchartsLinks;
import org.qust.entity.neo4j.Thesis;
import org.qust.entity.neo4j.Topic;
import org.qust.service.BaseInfoService;
import org.qust.service.TechnologyInfoService;
import org.qust.service.TitleTypeService;
import org.qust.service.neo4j.ThesisService;
import org.qust.service.neo4j.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Description:知识图谱维护-Neo4j
 * User:lock
 * Date:2020-04-28
 * Time:00:50
 */
@RestController
@RequestMapping("/kgraph")
public class KGraphController {
    @Autowired
    private BaseInfoService baseInfoService;
    @Autowired
    private ThesisService thesisService;
    @Autowired
    private TitleTypeService titleTypeService;
    @Autowired
    private TopicService topicService;
    @Autowired
    private TechnologyInfoService technologyInfoService;

    // 生成所有的知识图谱
    @RequiresRoles("user")
    @RequestMapping(method = RequestMethod.GET,value = "/geneAll")
    public Result geneAll(){

        for (BaseInfo baseInfo : baseInfoService.findAll()) {
            thesisService.add(new Thesis(baseInfo.getSno(),baseInfo.getSname(),baseInfo.getTitle()));
        }
        for (TitleType titleType : titleTypeService.findAll()) {
            List<TechnologyInfo> technologyInfoList = technologyInfoService.findByTechnology(titleType.getType());
            Topic topic = new Topic();
            topic.setName(titleType.getType());
            if(technologyInfoList.size()>0){
                List<Thesis> thesesList = new ArrayList<>();
                for (TechnologyInfo technologyInfo : technologyInfoList) {
                    thesesList.add(thesisService.findBySno(technologyInfo.getSno()));
                }
                topic.setTheses(thesesList);
            }
            topicService.add(topic);
        }
        return new Result(true, StatusCode.OK,"已全部加载到Neo4j数据库!");
    }

    // 查找全部
    @RequiresRoles("user")
    @RequestMapping(method = RequestMethod.GET,value = "/getAll")
    public Result getAll(){
        return new Result(true, StatusCode.OK,"查找成功!",modifyJson(topicService.findAll()));
    }

    // 根据名称模糊查询
    @RequiresRoles("user")
    @RequestMapping(method = RequestMethod.GET,value = "/getAll/{name}")
    public Result getByNameLike(@PathVariable String name){
        return new Result(true, StatusCode.OK,"查找成功!",modifyJson(topicService.findByNameLike("*"+name+"*")));
    }

    // 清空知识图谱
    @RequiresRoles("user")
    @RequestMapping(method = RequestMethod.DELETE,value = "/delete")
    public Result deleteAll(){
        thesisService.deleteAll();
        topicService.deleteAll();
        return new Result(true, StatusCode.OK,"Neo4j 数据已经全部清空!");
    }

    // 修改为Echarts接受的格式类型
    @RequiresRoles("user")
    public Map<String,Object> modifyJson(Iterable<Topic> topics){
        Map<String,Object> map = new HashMap<>();
        List<EchartsData> data = new ArrayList<>();
        List<EchartsLinks> links = new ArrayList<>();
        List<String> thesisTitle = new ArrayList<>();
        // 处理为Echarts需要的格式
        for (Topic topic : topics) {
            Map<String,Object> topicDes = new HashMap<>();
            topicDes.put("title",topic.getName());
            data.add(new EchartsData(topic.getName(),topicDes,40,0));
            List<Thesis> theses = topic.getTheses();
            if(theses!=null){
                for (Thesis  t: theses) {
                    if(!thesisTitle.contains(t.getTitle())){
                        thesisTitle.add(t.getTitle());
                        data.add(new EchartsData(t.getTitle(),t,40,1));
                    }
                    links.add(new EchartsLinks(t.getTitle(),topic.getName(),"属于","属于"));
                }
            }
        }
        map.put("data",data);
        map.put("links",links);
        return map;
    }
}

逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第8张图片
具体实现代码如下:

package org.qust.controller.admin;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.qust.common.Result;
import org.qust.common.StatusCode;
import org.qust.entity.TitleType;
import org.qust.entity.TypeAndNum;
import org.qust.service.BaseInfoService;
import org.qust.service.TechnologyInfoService;
import org.qust.service.TitleTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Description:charts数据生成
 * User:lock
 * Date:2020-05-07
 * Time:08:52
 */
@RestController
@RequestMapping("/charts")
public class ChartsController {

    @Autowired
    private TechnologyInfoService technologyInfoService;
    @Autowired
    private TitleTypeService titleTypeService;
    @Autowired
    private BaseInfoService baseInfoService;

    // 得到 dataSetCharts 数据
    @RequiresRoles("user")
    @RequestMapping(value = "/geneDataSetCharts", method = RequestMethod.GET)
    public Result geneDataSetCharts(){
//        ['product', '2012', '2013', '2014', '2015', '2016', '2017'],
//        ['Matcha Latte', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
//        ['Milk Tea', 86.5, 92.1, 85.7, 83.1, 73.4, 55.1],
//        ['Cheese Cocoa', 24.1, 67.2, 79.5, 86.4, 65.2, 82.5],
//        ['Walnut Brownie', 55.2, 67.1, 69.2, 72.4, 53.9, 39.1]
        List<String> product = new ArrayList<>();
        List<String> allSemester = technologyInfoService.findAllSemester();
        product.add("product");
        product.addAll(allSemester);
        List<List<String>> res = new ArrayList<>();
        res.add(product);
        for (TitleType titleType : titleTypeService.findAll()) {
            List<String> type = new ArrayList<>();
            type.add(titleType.getType());
            for (String semester : allSemester) {
                int size = technologyInfoService.findByTechnologyAndSemester(titleType.getType(), semester).size();
                type.add(String.valueOf(size));
            }
            res.add(type);
        }
        return new Result(true, StatusCode.OK,"查询成功!",res);
    }

    // 得到 barCharts 数据
    @RequiresRoles("user")
    @RequestMapping(value = "/getBarChartRace", method = RequestMethod.GET)
    public Result getBarChartRace(){
        Map<String,Object> map1 = new HashMap<>();
        List<String> allSemester = technologyInfoService.findAllSemester();
        List<String> years = new ArrayList<>();
        List<List<String>> jdData = new ArrayList<>();
        List<List<Integer>> data = new ArrayList<>();
        for (String semester : allSemester) {
            years.add(semester);
            List<String> jdData_item = new ArrayList<>();
            List<Integer> data_item = new ArrayList<>();
            for (TypeAndNum typeAndNum : technologyInfoService.findTypeAndNumBySemester(semester)) {
                jdData_item.add(typeAndNum.getType());
                data_item.add(typeAndNum.getNum());
            }
            jdData.add(jdData_item);
            data.add(data_item);
        }
        map1.put("years",years);
        map1.put("jdData",jdData);
        map1.put("data",data);
        return new Result(true, StatusCode.OK,"查询成功!",map1);
    }

    // 得到 全部类别 数据
    @RequiresRoles("user")
    @RequestMapping(value = "/getAllTypes", method = RequestMethod.GET)
    public Result getAllTypes(){
        return new Result(true, StatusCode.OK,"查询成功!",titleTypeService.findAll());
    }

    // 得到 getOrderByOrigin 数据
    @RequiresRoles("user")
    @RequestMapping(value = "/getOrderByOrigin", method = RequestMethod.GET)
    public Result getOrderByOrigin(){
        Map<String, Object> resMap = new HashMap<>();
        List<String> title = new ArrayList<>();
        List<Map<String, Object>> data = new ArrayList<>();
        for (TypeAndNum typeAndNum : baseInfoService.orderByOrigin()) {
            title.add(typeAndNum.getType());
            Map<String, Object> map = new HashMap<>();
            map.put("value",typeAndNum.getNum());
            map.put("name",typeAndNum.getType());
            data.add(map);
        }
        resMap.put("title", title);
        resMap.put("data", data);
        return new Result(true, StatusCode.OK,"查询成功!",resMap);
    }

    // 得到 getOrderByType 数据
    @RequiresRoles("user")
    @RequestMapping(value = "/getOrderByType", method = RequestMethod.GET)
    public Result getOrderByType(){
        Map<String, Object> resMap = new HashMap<>();
        List<String> title = new ArrayList<>();
        List<Map<String, Object>> data = new ArrayList<>();
        for (TypeAndNum typeAndNum : baseInfoService.orderByType()) {
            title.add(typeAndNum.getType());
            Map<String, Object> map = new HashMap<>();
            map.put("value",typeAndNum.getNum());
            map.put("name",typeAndNum.getType());
            data.add(map);
        }
        resMap.put("title", title);
        resMap.put("data", data);
        return new Result(true, StatusCode.OK,"查询成功!",resMap);
    }


    @RequiresRoles("user")
    @RequestMapping(value = "/getOrderByTeacher", method = RequestMethod.GET)
    public Result getOrderByTeacher(){
        Map<String, Object> resMap = new HashMap<>();
        List<String> title = new ArrayList<>();
        List<Map<String, Object>> data = new ArrayList<>();
        for (TypeAndNum typeAndNum : baseInfoService.orderByTeacher()) {
            title.add(typeAndNum.getType());
            Map<String, Object> map = new HashMap<>();
            map.put("value",typeAndNum.getNum());
            map.put("name",typeAndNum.getType());
            data.add(map);
        }
        resMap.put("title", title);
        resMap.put("data", data);
        return new Result(true, StatusCode.OK,"查询成功!",resMap);
    }
}

逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第9张图片
逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第10张图片
逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第11张图片
逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第12张图片
具体实现代码如下:

package org.qust.controller.admin;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.qust.common.Result;
import org.qust.common.StatusCode;
import org.qust.entity.BaseInfo;
import org.qust.entity.WordCloud;
import org.qust.service.BaseInfoService;
import org.qust.service.WordCloudService;
import org.qust.service.WordUtilService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Description:词汇云维护
 * User:lock
 * Date:2020-04-28
 * Time:00:37
 */
@RestController
@RequestMapping("/wordCloud")
public class WordCloudController {

    @Autowired
    private BaseInfoService baseInfoService;
    @Autowired
    private WordUtilService wordUtilService;
    @Autowired
    private WordCloudService wordCloudService;
    // 获得标签云信息
    @RequiresRoles("user")
    @RequestMapping(value = "/geneWordCloud",method = RequestMethod.GET)
    public Result geneWordCloud(){
        // 先全部删除
        wordCloudService.deleteAll();
        List<String> words = new ArrayList<>();
        for (BaseInfo baseInfo : baseInfoService.findAll()) {
            words.addAll(wordUtilService.segment(baseInfo.getTitle()));
        }
        List<Map.Entry<String, Integer>> freWords = this.getFreWords(words);
        for(int i=0; i<150; i++){
            Map.Entry<String, Integer> freWord = freWords.get(i);
            WordCloud wordCloud = new WordCloud(freWord.getKey(), freWord.getValue());
            wordCloudService.add(wordCloud);
        }
        return new Result(true, StatusCode.OK,"生成标签云信息成功!");
    }
    // 获得标签云信息
    @RequiresRoles("user")
    @RequestMapping(value = "/getWordCloud",method = RequestMethod.GET)
    public Result getWordCloud(){
        List<Map<String,Object>> words = new ArrayList<>();
        for (WordCloud wordCloud : wordCloudService.findAll()) {
            Map<String,Object> map = new HashMap<>();
            map.put("name", wordCloud.getName());
            map.put("value",wordCloud.getValue());
            words.add(map);
        }
        return new Result(true, StatusCode.OK,"获取标签云信息成功!",words);
    }
    // 统计关键词词频
    public List<Map.Entry<String, Integer>> getFreWords(List<String> words){
        Map<String, Integer> map = new HashMap<>();
        for (String word : words) {
            if(map.containsKey(word)){
                int num = map.get(word);
                map.put(word, ++num);
            }else{
                map.put(word, 1);
            }
        }
        List<Map.Entry<String,Integer>> list = new ArrayList<Map.Entry<String,Integer>>(map.entrySet());
        list.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
        return list;
    }

}

数据库表设计

逆天版SpringBoot毕业论文知识图谱及可视化系统 软件开发实录_第13张图片

运行视频

我录制好了 如果大家想学习的话可以跟我交流,毕竟源码对外免费开放,可以跟大家一起进步,未来可期!

炸天版SpringBoot知识图谱-毕业论文可视化 毕业设计可视化

你可能感兴趣的:(2020计算机源代码,JavaEE组件篇,SpringBoot项目)