diff --git a/gyxtp/src/api/api/graph.js b/gyxtp/src/api/api/graph.js index 2de05bb..5fa011a 100644 --- a/gyxtp/src/api/api/graph.js +++ b/gyxtp/src/api/api/graph.js @@ -127,5 +127,10 @@ export const getheightLight = (param) => { method: 'get', }); }; - +export const getKeywordsByKeyword = (param) => { + return request({ + url: '/api/test/getKeywordsByKeyword/'+param, + method: 'get', + }); +}; diff --git a/gyxtp/src/view/small.vue b/gyxtp/src/view/small.vue index fe20d1f..e9e753f 100644 --- a/gyxtp/src/view/small.vue +++ b/gyxtp/src/view/small.vue @@ -141,7 +141,14 @@ import { demoData } from '@/assets/demo2.js' import HeaderInfo from "@/components/UseAll/headerInfo.vue"; import leftInfo from "@/components/UseAll/leftInfo.vue"; import {getAllTitle, getDocInfo, getTitleBySamll} from "@/api/api/doc"; -import {getDocInfoBylinkIds, getDomainGraphTest, getKeyWorlds, getpoinAll, getpoinByName} from "@/api/api/graph"; +import { + getDocInfoBylinkIds, + getDomainGraphTest, + getKeywordsByKeyword, + getKeyWorlds, + getpoinAll, + getpoinByName +} from "@/api/api/graph"; import { Picture } from "@element-plus/icons-vue"; import { selectAticleByRelation } from '@/api/api/article' @@ -156,43 +163,6 @@ export default { return { chart: null, words: [ - - { name: '部署', value: 2 }, - { name: '运维', value: 2 }, - { name: '安全', value: 2 }, - { name: '测试', value: 2 }, - { name: '调试', value: 2 }, - { name: '日志', value: 2 }, - { name: '监控', value: 2 }, - { name: '性能', value: 2 }, - { name: '优化', value: 2 }, - { name: '缓存', value: 2 }, - { name: '架构', value: 3 }, - { name: '设计', value: 2 }, - { name: '需求', value: 2 }, - { name: '文档', value: 1 }, - { name: '会议', value: 1 }, - { name: '沟通', value: 1 }, - { name: '协作', value: 1 }, - - { name: '脚本', value: 1 }, - { name: '自动化', value: 2 }, - { name: 'CI/CD', value: 2 }, - { name: '容器', value: 2 }, - { name: 'Docker', value: 2 }, - { name: 'Kubernetes', value: 2 }, - { name: '微服务', value: 3 }, - { name: 'API', value: 3 }, - { name: 'JSON', value: 1 }, - { name: 'HTTP', value: 2 }, - { name: '协议', value: 1 }, - { name: '加密', value: 1 }, - { name: '权限', value: 2 }, - { name: '登录', value: 2 }, - { name: '注册', value: 1 }, - { name: '用户', value: 2 }, - { name: '功能', value: 2 }, - { name: '模块', value: 1 } ], getpoinName :"模糊综合评价方法", // testoptions: { @@ -460,6 +430,10 @@ export default { ], backgroundColor: 'rgba(255, 255, 255, 0.21)' } + + getKeywordsByKeyword(this.getpoinName).then(res=>{ + this.words = res + }) this.chart.setOption(option) }, randomColor() { @@ -633,6 +607,7 @@ export default { text: node.text, width: width, height: height, + totalNum:totalNum, color: this.getColor(node.type), fontColor: '#fff', styleClass:node.type=="keyword"?"nodeClassL1":"nodeClass" @@ -646,6 +621,7 @@ export default { links:links } + this.initChart() this.$refs.graphRef.setJsonData(data); }) } diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java b/ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java index e4132b4..c146e24 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java @@ -16,6 +16,7 @@ import java.lang.reflect.Type; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import static com.ruoyi.common.constant.Constants.ARTICLE_PDF_DIR; @@ -238,6 +239,45 @@ public class TestXiaoTuPuController extends BaseController { return a; } + @GetMapping("getKeywordsByKeyword/{keyName}") + public List> getKeywordsByKeyword(@PathVariable("keyName") String keyName) { + List records = zhyPointMapper.getKeywordsByKeyword(keyName); + + Map keywordCount = new HashMap<>(); + + for (Map record : records) { + Object keywordObj = record.get("keywords"); + if (keywordObj == null) continue; + + String keywordsStr = keywordObj.toString().trim(); + if (keywordsStr.isEmpty()) continue; + + // 使用中文分号“;”拆分 + String[] keywords = keywordsStr.split(";"); + + for (String keyword : keywords) { + keyword = keyword.trim(); + if (!keyword.isEmpty()) { + keywordCount.put(keyword, keywordCount.getOrDefault(keyword, 0) + 1); + } + } + } + + // 转换为 List 并排序:按 value 降序,取前 30 + List> result = keywordCount.entrySet().stream() + .sorted(Map.Entry.comparingByValue().reversed()) // 按 value 降序 + .limit(30) // 只取前 30 + .map(entry -> { + Map item = new HashMap<>(); + item.put("name", entry.getKey()); + item.put("value", entry.getValue()); + return item; + }) + .collect(Collectors.toList()); + + return result; + } + diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ZhyPointMapper.java b/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ZhyPointMapper.java index cd41ca8..97185dc 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ZhyPointMapper.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ZhyPointMapper.java @@ -12,12 +12,12 @@ public interface ZhyPointMapper { List selectPointByUUID(@Param("uuid") Integer uuid); - + List getKeywordsByKeyword(@Param("keyName") String keyName); List selectPointResByNeo4jId(@Param("neo4jId") Integer neo4jId); Map selectPointResById(@Param("id") Integer id); List selectPointByType1(@Param("type1") String type1); List selectPointRelationshipByRids(@Param("ids") List ids); List selectPointRelationshipByName(@Param("author") String author,@Param("keyword") String keyword,@Param("agency") String agency,@Param("title") String title); int insertPoint(@Param("name") String name,@Param("uuid") Integer uuid,@Param("type1") String type1); - int insertPointReship(@Param("author") String author,@Param("keyword") String keyword,@Param("agency") String agency,@Param("relationship_id") Integer relationship_id,@Param("title") String title,@Param("url") String url); + int insertPointReship(@Param("author") String author,@Param("keyword") String keyword,@Param("agency") String agency,@Param("relationship_id") Integer relationship_id,@Param("title") String title,@Param("url") String url,@Param("guanjianzi") String guanjianzi); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java index 670b2de..3990ee5 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java @@ -41,6 +41,7 @@ public class PointService { List keywords = new ArrayList<>(new LinkedHashSet<>(parsed.get("keyword"))); String title = record.get("title"); String urls = record.get("urls"); + String guanjianzi = record.get("keywords"); relationshipList.addAll(cartesianProduct(authors, keywords, "author", "keyword")); @@ -116,7 +117,7 @@ public class PointService { int reshipId = createReletionship(startNodeId,endNodeId,relType,data); try { - zhyPointMapper.insertPointReship(authorStr,keywordStr,agencyStr,reshipId,title,urls); + zhyPointMapper.insertPointReship(authorStr,keywordStr,agencyStr,reshipId,title,urls,guanjianzi); }catch (Exception e){ System.out.println("并发导致重复数据"); } @@ -139,6 +140,7 @@ public class PointService { List keywords = new ArrayList<>(new LinkedHashSet<>(parsed.get("keyword"))); String title = record.get("title"); String urls = record.get("urls"); + String guanjianzi = record.get("keywords"); relationshipList.addAll(cartesianProduct(authors, keywords, "author", "keyword")); @@ -188,7 +190,6 @@ public class PointService { relType = "相关作者"; } else if (authorStr != null && !authorStr.trim().isEmpty() && agencyStr != null && !agencyStr.trim().isEmpty()) { - System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaa"); start = authorStr; end = agencyStr; relType = "相关机构"; @@ -214,7 +215,7 @@ public class PointService { int reshipId = createReletionship(startNodeId,endNodeId,relType,data); try { - zhyPointMapper.insertPointReship(authorStr,keywordStr,agencyStr,reshipId,title,urls); + zhyPointMapper.insertPointReship(authorStr,keywordStr,agencyStr,reshipId,title,urls,guanjianzi); }catch (Exception e){ System.out.println("并发导致重复数据"); } diff --git a/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml b/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml index d0736ed..a70b723 100644 --- a/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml +++ b/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml @@ -59,10 +59,13 @@ INSERT INTO zhy_point_relationship - (author, keyword, agency, relationship_id, title, url) + (author, keyword, agency, relationship_id, title, url,keywords) VALUES - (#{author}, #{keyword}, #{agency}, #{relationship_id}, #{title}, #{url}) + (#{author}, #{keyword}, #{agency}, #{relationship_id}, #{title}, #{url},#{guanjianzi}) +