diff --git a/gyxtp/src/api/api/graph.js b/gyxtp/src/api/api/graph.js index 387ce0d..bba813d 100644 --- a/gyxtp/src/api/api/graph.js +++ b/gyxtp/src/api/api/graph.js @@ -109,3 +109,11 @@ export const getReInfoByNameAndType = (name,type) => { method: 'get', }); }; + +export const getheightLight = (param) => { + return request({ + url: '/api/esQuery/'+param, + method: 'get', + }); +}; + diff --git a/gyxtp/src/view/graphPageCopy.vue b/gyxtp/src/view/graphPageCopy.vue index 1edd266..bb3780f 100644 --- a/gyxtp/src/view/graphPageCopy.vue +++ b/gyxtp/src/view/graphPageCopy.vue @@ -225,7 +225,7 @@ import {demoData} from '@/assets/demo2.js' import HeaderInfo from "@/components/UseAll/headerInfo.vue"; import leftInfo from "@/components/UseAll/leftInfo.vue"; import {getAllTitle, getDocInfo} from "@/api/api/doc"; -import {getDomainGraphTest} from "@/api/api/graph"; +import {getDomainGraphTest, getheightLight} from "@/api/api/graph"; import {Picture} from "@element-plus/icons-vue"; import {selectAticleByRelation} from '@/api/api/article' @@ -353,6 +353,7 @@ export default { // graphData:[], nodes: [], links: [], + heightLight:{}, width: 2000, height: 1000, @@ -514,21 +515,28 @@ export default { } }, getInfo2() { - // 1. 清空当前数据 - this.data = undefined; - - // 2. 准备查询参数(有关键词时用关键词查询,否则查询全部) - const params = this.keywords ? {nodename: this.keywords} : {}; - - // 3. 调用API获取数据 - getDomainGraphTest(params) - .then((res) => { - // 4. 处理并渲染新数据 - this.zhengl(res.data); - }) - .catch((error) => { - console.error("数据加载失败:", error); - }); + this.keywords + getheightLight(this.keywords).then((res)=>{ + this.heightLight = { + "nodes": res.nodes.hits, + "links":res.links.hits + } + getDomainGraphTest({}).then((r) => { + this.zhengl(r.data); + }) + }) + + }, + getNodeClass(id){ + if (this.heightLight=={}){ + return "" + } + + if (id) { + this.heightLight.nodes + } + return "" + return "nodeclass" }, async onLineClick(lineObject, linkObject, event) { const from = linkObject.fromNode.data.docId @@ -699,7 +707,8 @@ export default { height: 150, color: color, font: `normal ${fontSize} Arial`, - fontColor: fontColor + fontColor: fontColor, + styleClass:this.getNodeClass(node.id), }); }); }); @@ -791,7 +800,8 @@ export default { height: 150, color: color, font: `normal ${fontSize} Arial`, - fontColor: fontColor + fontColor: fontColor, + styleClass:"nodeclass", }); }); } else { @@ -873,7 +883,8 @@ export default { height: 150, color: color, font: `normal ${fontSize} Arial`, - fontColor: fontColor + fontColor: fontColor, + styleClass:"nodeclass", }); currentLeftX -= 200; @@ -940,7 +951,8 @@ export default { height: 150, color: color, font: `normal ${fontSize} Arial`, - fontColor: fontColor + fontColor: fontColor, + styleClass:"nodeclass", }); currentRightX += 200; @@ -960,8 +972,9 @@ export default { line.num <= 10 ? 'rgb(0, 255, 0)' : // 绿色 line.num <= 15 ? 'rgb(255, 255, 0)' : // 黄色 'rgb(178,246,255)', // 红色(包含line.num <= 20和超过20的情况) - lineWidth:1, + lineWidth:10, lineShape: 1, + styleClass:"lineclass", }) }); @@ -980,6 +993,7 @@ export default { } }); }, + zhengl1(data) { const nodes = [] const links = [] @@ -1430,22 +1444,23 @@ export default { }) }, onNodeClick(nodeObject, $event) { - const data = { - 'id': nodeObject.data.docId, - 'docTitle': nodeObject.text, - } - getDocInfo(data).then((res) => { - localStorage.setItem("docUrl", res.data.docUrl) - this.$router.push({ - name: 'docInfo', - query: { - title: res.data.docTitle, - level: res.data.docLevel, - keyword: res.data.docTitle, - docId: res.data.id - } - }) - }); + console.log(nodeObject) + // const data = { + // 'id': nodeObject.data.docId, + // 'docTitle': nodeObject.text, + // } + // getDocInfo(data).then((res) => { + // localStorage.setItem("docUrl", res.data.docUrl) + // this.$router.push({ + // name: 'docInfo', + // query: { + // title: res.data.docTitle, + // level: res.data.docLevel, + // keyword: res.data.docTitle, + // docId: res.data.id + // } + // }) + // }); } }, created() { @@ -2055,4 +2070,24 @@ tr { color: #FFFFFF !important; font-size: 1vw; } + +.lineclass{ + filter: drop-shadow(0 0 10px white) !important; /* 添加白色光晕 */ +} +.nodeclass { + /* 白色 3px 边框 */ + stroke: white !important; + stroke-width: 3 !important; + stroke-opacity: 1 !important; + + /* 多层光晕:内层青色,外层白色 */ + filter: + drop-shadow(0 0 20px rgba(0, 255, 255, 1)) /* 内层青色光晕 */ + drop-shadow(0 0 20px rgba(0, 255, 255, 1)) /* 内层青色光晕 */ + drop-shadow(0 0 20px rgba(0, 255, 255, 1)) /* 内层青色光晕 */ + drop-shadow(0 0 50px rgba(255, 255, 255, 1)); /* 外层白色光晕 */ + + /* 确保边框在填充之上 */ + paint-order: stroke fill !important; +} \ No newline at end of file diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/ElasticsearchUtils/impl/ElasticSearchUtilImpl.java b/ruoyi-api/src/main/java/com/ruoyi/api/ElasticsearchUtils/impl/ElasticSearchUtilImpl.java index 8aafbe4..b49b7fe 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/ElasticsearchUtils/impl/ElasticSearchUtilImpl.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/ElasticsearchUtils/impl/ElasticSearchUtilImpl.java @@ -547,9 +547,6 @@ public class ElasticSearchUtilImpl implements ElasticSearchUtil { request.add(new IndexRequest() .index(index) .id(id.toString()) - // 在这停顿:出现无法取出泛型get到属性的问题 继续在这解决 2024年3月26日16:45:45 - // √获取泛型属性问题已解决 2024年3月27日10:12:57 - // .id(obj.getId().toString()) .source(objJson, XContentType.JSON)); } } diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/controller/EsTestController.java b/ruoyi-api/src/main/java/com/ruoyi/api/controller/EsTestController.java index fec4319..73925be 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/controller/EsTestController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/controller/EsTestController.java @@ -6,15 +6,22 @@ import com.ruoyi.api.ElasticsearchUtils.builders.ESCreateBuilder; import com.ruoyi.api.ElasticsearchUtils.builders.Mappings; import com.ruoyi.api.ElasticsearchUtils.impl.ElasticSearchUtilImpl; import com.ruoyi.api.domain.ESDao; +import com.ruoyi.api.domain.ZhyDocApi; +import com.ruoyi.api.mapper.ZhyDocApiMapper; +import com.ruoyi.system.domain.ZhyArticle; +import com.ruoyi.system.mapper.ZhyArticleMapper; import org.elasticsearch.search.SearchHits; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * ---------------------------------------------------------------------------------------------------------------
@@ -34,6 +41,12 @@ public class EsTestController { RestClientConfig RestHighLevelClient; @Autowired + ZhyDocApiMapper zhyDocApiMapper; + + @Autowired + ZhyArticleMapper zhyArticleMapper; + + @Autowired private org.elasticsearch.client.RestHighLevelClient client; @Autowired @@ -46,128 +59,82 @@ public class EsTestController { public boolean deleteIndex() throws IOException { return elasticSearchUtil.deleteIndex("111"); } - @GetMapping("/estest2") + @GetMapping("/esQuery2") public SearchHits indexCreate2() throws Throwable { //还差时间排序,和聚合搜索 SearchHits hits = new CustomQueryBuilder.Builder(client) .buildAndExecute("111"); return hits; } - @GetMapping("/estest") - public SearchHits indexCreate() throws Throwable { + @GetMapping("/esQuery/{param}") + public Map indexCreate(@PathVariable("param")String param) throws Throwable { //还差时间排序,和聚合搜索 + SearchHits nodes = new CustomQueryBuilder.Builder(client) + .withFuzzyMatch("abstracts",param) + .buildAndExecute("nodes"); + SearchHits links = new CustomQueryBuilder.Builder(client) + .withFuzzyMatch("abstracts",param) + .buildAndExecute("links"); + Map map = new HashMap(); + map.put("nodes",nodes); + map.put("links",links); + return map; + } - SearchHits hits = new CustomQueryBuilder.Builder(client) - .withFuzzyMatch("abstracts","天气") - .buildAndExecute("111"); -// if (hits.getHits().length> 0) { -// for (SearchHit searchHit : hits) { -// Map highlightFields = searchHit.getHighlightFields(); -// T item = JSON.parseObject(searchHit.getSourceAsString(), clazz); -// Field[] fields = clazz.getDeclaredFields(); -// for (Field field : fields) { -// field.setAccessible(true); -// if (highlightFields.containsKey(field.getName())) { -// try { -// field.set(item, highlightFields.get(field.getName()).fragments()[0].toString()); -// } catch (IllegalAccessException e) { -// e.printStackTrace(); -// } -// } -// } -// list.add(item); -// } - return hits; + + + + @GetMapping("/getHeightLight/{querypream}") + public void getHeightLight(@PathVariable("querypream")String querypream) { + System.out.println(querypream); } - @GetMapping("/escreate") - public SearchHits aa() throws Throwable { - System.out.println("Lucene Version: " + - org.apache.lucene.util.Version.LATEST); - System.out.println("Loaded from: " + - org.apache.lucene.util.Version.class.getProtectionDomain().getCodeSource()); + + @GetMapping("/esCreateDoc") + public SearchHits aa() throws Throwable { //创建文档 这里要注意,有一些不能一起使用,例如浮点型字段不能创建精确查找 Mappings mappings = new ESCreateBuilder.Builder() - .addField("paper_title",ESCreateBuilder.exactSearch) -// .addField("popularity",ESCreateBuilder.floatType) - .addField("id",ESCreateBuilder.floatType) - .addField("lineId",ESCreateBuilder.floatType) - .addField("keyWorld1") - .addField("keyWorld2") - .addField("paper_url") + .addField("id") + .addField("DBid") + .addField("type") .addField("abstracts") - .addField("authors") - .addField("author") .build(); - System.out.println(mappings); -////// //创建索引 + elasticSearchUtil.createIndex("nodes",mappings); + elasticSearchUtil.createIndex("links",mappings); - boolean a = elasticSearchUtil.createIndex("111",mappings); -// System.out.println(mappings); -// List bookList = new ArrayList<>(); - ESDao esDao = new ESDao(); - esDao.id = 1; - esDao.authors = "菅振宇"; - esDao.lineId = 1; - esDao.paper_title = "论文名字测试11111"; - esDao.paper_url = "adsf/sf/asd"; - esDao.keyWorld1 = "guanjiazi1"; - esDao.keyWorld2 = "guanjianzi2"; - esDao.abstracts = "关键测试部分的摘要娃哈哈大段的iiICv几AV艾师傅为天水电费气象水费海里的生物"; - bookList.add(esDao); - - esDao = new ESDao(); - esDao.id = 2; - esDao.authors = "菅振宇"; - esDao.lineId = 1; - esDao.paper_title = "论文名字测试22222222"; - esDao.paper_url = "adsf/sf/asd"; - esDao.keyWorld1 = "guanjiazi1"; - esDao.keyWorld2 = "guanjianzi2"; - esDao.abstracts = "ganraoondjdn天气和天气"; - bookList.add(esDao); - - esDao = new ESDao(); - esDao.id = 3; - esDao.authors = "菅振宇"; - esDao.lineId = 1; - esDao.paper_title = "论文名字测试3333333333"; - esDao.paper_url = "adsf/sf/asd"; - esDao.keyWorld1 = "guanjiazi1"; - esDao.keyWorld2 = "guanjianzi2"; - esDao.abstracts = "天空和气体"; - bookList.add(esDao); - - esDao = new ESDao(); - esDao.id = 4; - esDao.authors = "菅振宇"; - esDao.lineId = 1; - esDao.paper_title = "论文名字测试44444444"; - esDao.paper_url = "adsf/sf/asd"; - esDao.keyWorld1 = "guanjiazi1"; - esDao.keyWorld2 = "guanjianzi2"; - esDao.abstracts = "天阿斯蒂芬阿萨德覅水电费几点睡觉覅"; - bookList.add(esDao); - - esDao = new ESDao(); - esDao.id = 5; - esDao.authors = "菅振宇"; - esDao.lineId = 1; - esDao.paper_title = "论文名字测试44444444"; - esDao.paper_url = "adsf/sf/asd"; - esDao.keyWorld1 = "guanjiazi1"; - esDao.keyWorld2 = "guanjianzi2"; - esDao.abstracts = "nononono没有田也灭有七"; - bookList.add(esDao); - -// System.out.println(bookList); -// //向索引中增加记录,强烈建议使用第二种将文档的id和记录的id相关联,这在更新或删除的时候非常方便 -// elasticSearchUtil.addDocBatch("book5", bookList); - elasticSearchUtil.addDocBatch("111", bookList, ESDao.class, "id"); + List docList = zhyDocApiMapper.selectAllDoc1(); + for (int i=0;i lineList = zhyArticleMapper.selectZhyArticleList(zhyArticle); + for (int i=0;i> dataList = getCsvLine(); + public void buildPoint(String url) throws IOException { + List> dataList = getCsvLine(url); Map nameToId = new HashMap<>(); for (Map record : dataList) { List> relationshipList = new ArrayList<>(); @@ -265,8 +265,10 @@ public class PointService { return result; } - public List> getCsvLine() throws IOException { - String csvFilePath = Paths.get("").toAbsolutePath() + "/test3.csv"; + public List> getCsvLine(String url) throws IOException { +// String csvFilePath = Paths.get("").toAbsolutePath() + "/test3.csv"; + String csvFilePath = url; + System.out.println("Reading CSV from: " + csvFilePath); File file = new File(csvFilePath);