Browse Source

Merge branch 'small-tupu' of http://124.70.32.114:3100/jianzhenyu/Changsha_tupu into hanyuqing

small-tupu
hanyuqing 7 months ago
parent
commit
6d3a319ee0
  1. 8
      gyxtp/src/api/api/graph.js
  2. 109
      gyxtp/src/view/graphPageCopy.vue
  3. 3
      ruoyi-api/src/main/java/com/ruoyi/api/ElasticsearchUtils/impl/ElasticSearchUtilImpl.java
  4. 173
      ruoyi-api/src/main/java/com/ruoyi/api/controller/EsTestController.java
  5. 8
      ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java
  6. 73
      ruoyi-api/src/main/java/com/ruoyi/api/domain/ESDao.java
  7. 10
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java

8
gyxtp/src/api/api/graph.js

@ -109,3 +109,11 @@ export const getReInfoByNameAndType = (name,type) => {
method: 'get', method: 'get',
}); });
}; };
export const getheightLight = (param) => {
return request({
url: '/api/esQuery/'+param,
method: 'get',
});
};

109
gyxtp/src/view/graphPageCopy.vue

@ -225,7 +225,7 @@ import {demoData} from '@/assets/demo2.js'
import HeaderInfo from "@/components/UseAll/headerInfo.vue"; import HeaderInfo from "@/components/UseAll/headerInfo.vue";
import leftInfo from "@/components/UseAll/leftInfo.vue"; import leftInfo from "@/components/UseAll/leftInfo.vue";
import {getAllTitle, getDocInfo} from "@/api/api/doc"; 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 {Picture} from "@element-plus/icons-vue";
import {selectAticleByRelation} from '@/api/api/article' import {selectAticleByRelation} from '@/api/api/article'
@ -353,6 +353,7 @@ export default {
// graphData:[], // graphData:[],
nodes: [], nodes: [],
links: [], links: [],
heightLight:{},
width: 2000, width: 2000,
height: 1000, height: 1000,
@ -514,21 +515,28 @@ export default {
} }
}, },
getInfo2() { getInfo2() {
// 1. this.keywords
this.data = undefined; getheightLight(this.keywords).then((res)=>{
this.heightLight = {
// 2. "nodes": res.nodes.hits,
const params = this.keywords ? {nodename: this.keywords} : {}; "links":res.links.hits
}
// 3. API getDomainGraphTest({}).then((r) => {
getDomainGraphTest(params) this.zhengl(r.data);
.then((res) => { })
// 4. })
this.zhengl(res.data);
}) },
.catch((error) => { getNodeClass(id){
console.error("数据加载失败:", error); if (this.heightLight=={}){
}); return ""
}
if (id) {
this.heightLight.nodes
}
return ""
return "nodeclass"
}, },
async onLineClick(lineObject, linkObject, event) { async onLineClick(lineObject, linkObject, event) {
const from = linkObject.fromNode.data.docId const from = linkObject.fromNode.data.docId
@ -699,7 +707,8 @@ export default {
height: 150, height: 150,
color: color, color: color,
font: `normal ${fontSize} Arial`, font: `normal ${fontSize} Arial`,
fontColor: fontColor fontColor: fontColor,
styleClass:this.getNodeClass(node.id),
}); });
}); });
}); });
@ -791,7 +800,8 @@ export default {
height: 150, height: 150,
color: color, color: color,
font: `normal ${fontSize} Arial`, font: `normal ${fontSize} Arial`,
fontColor: fontColor fontColor: fontColor,
styleClass:"nodeclass",
}); });
}); });
} else { } else {
@ -873,7 +883,8 @@ export default {
height: 150, height: 150,
color: color, color: color,
font: `normal ${fontSize} Arial`, font: `normal ${fontSize} Arial`,
fontColor: fontColor fontColor: fontColor,
styleClass:"nodeclass",
}); });
currentLeftX -= 200; currentLeftX -= 200;
@ -940,7 +951,8 @@ export default {
height: 150, height: 150,
color: color, color: color,
font: `normal ${fontSize} Arial`, font: `normal ${fontSize} Arial`,
fontColor: fontColor fontColor: fontColor,
styleClass:"nodeclass",
}); });
currentRightX += 200; currentRightX += 200;
@ -960,8 +972,9 @@ export default {
line.num <= 10 ? 'rgb(0, 255, 0)' : // 绿 line.num <= 10 ? 'rgb(0, 255, 0)' : // 绿
line.num <= 15 ? 'rgb(255, 255, 0)' : // line.num <= 15 ? 'rgb(255, 255, 0)' : //
'rgb(178,246,255)', // line.num <= 2020 'rgb(178,246,255)', // line.num <= 2020
lineWidth:1, lineWidth:10,
lineShape: 1, lineShape: 1,
styleClass:"lineclass",
}) })
}); });
@ -980,6 +993,7 @@ export default {
} }
}); });
}, },
zhengl1(data) { zhengl1(data) {
const nodes = [] const nodes = []
const links = [] const links = []
@ -1430,22 +1444,23 @@ export default {
}) })
}, },
onNodeClick(nodeObject, $event) { onNodeClick(nodeObject, $event) {
const data = { console.log(nodeObject)
'id': nodeObject.data.docId, // const data = {
'docTitle': nodeObject.text, // 'id': nodeObject.data.docId,
} // 'docTitle': nodeObject.text,
getDocInfo(data).then((res) => { // }
localStorage.setItem("docUrl", res.data.docUrl) // getDocInfo(data).then((res) => {
this.$router.push({ // localStorage.setItem("docUrl", res.data.docUrl)
name: 'docInfo', // this.$router.push({
query: { // name: 'docInfo',
title: res.data.docTitle, // query: {
level: res.data.docLevel, // title: res.data.docTitle,
keyword: res.data.docTitle, // level: res.data.docLevel,
docId: res.data.id // keyword: res.data.docTitle,
} // docId: res.data.id
}) // }
}); // })
// });
} }
}, },
created() { created() {
@ -2055,4 +2070,24 @@ tr {
color: #FFFFFF !important; color: #FFFFFF !important;
font-size: 1vw; 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;
}
</style> </style>

3
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() request.add(new IndexRequest()
.index(index) .index(index)
.id(id.toString()) .id(id.toString())
// 在这停顿:出现无法取出泛型get到属性的问题 继续在这解决 2024年3月26日16:45:45
// √获取泛型属性问题已解决 2024年3月27日10:12:57
// .id(obj.getId().toString())
.source(objJson, XContentType.JSON)); .source(objJson, XContentType.JSON));
} }
} }

173
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.builders.Mappings;
import com.ruoyi.api.ElasticsearchUtils.impl.ElasticSearchUtilImpl; import com.ruoyi.api.ElasticsearchUtils.impl.ElasticSearchUtilImpl;
import com.ruoyi.api.domain.ESDao; 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.elasticsearch.search.SearchHits;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* --------------------------------------------------------------------------------------------------------------- <br/> * --------------------------------------------------------------------------------------------------------------- <br/>
@ -34,6 +41,12 @@ public class EsTestController {
RestClientConfig RestHighLevelClient; RestClientConfig RestHighLevelClient;
@Autowired @Autowired
ZhyDocApiMapper zhyDocApiMapper;
@Autowired
ZhyArticleMapper zhyArticleMapper;
@Autowired
private org.elasticsearch.client.RestHighLevelClient client; private org.elasticsearch.client.RestHighLevelClient client;
@Autowired @Autowired
@ -46,128 +59,82 @@ public class EsTestController {
public boolean deleteIndex() throws IOException { public boolean deleteIndex() throws IOException {
return elasticSearchUtil.deleteIndex("111"); return elasticSearchUtil.deleteIndex("111");
} }
@GetMapping("/estest2") @GetMapping("/esQuery2")
public SearchHits indexCreate2() throws Throwable { public SearchHits indexCreate2() throws Throwable {
//还差时间排序,和聚合搜索 //还差时间排序,和聚合搜索
SearchHits hits = new CustomQueryBuilder.Builder(client) SearchHits hits = new CustomQueryBuilder.Builder(client)
.buildAndExecute("111"); .buildAndExecute("111");
return hits; return hits;
} }
@GetMapping("/estest") @GetMapping("/esQuery/{param}")
public SearchHits indexCreate() throws Throwable { 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) { @GetMapping("/getHeightLight/{querypream}")
// for (SearchHit searchHit : hits) { public void getHeightLight(@PathVariable("querypream")String querypream) {
// Map<String, HighlightField> highlightFields = searchHit.getHighlightFields(); System.out.println(querypream);
// 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("/escreate")
public SearchHits aa() throws Throwable {
System.out.println("Lucene Version: " +
org.apache.lucene.util.Version.LATEST); @GetMapping("/esCreateDoc")
System.out.println("Loaded from: " + public SearchHits aa() throws Throwable {
org.apache.lucene.util.Version.class.getProtectionDomain().getCodeSource());
//创建文档 这里要注意,有一些不能一起使用,例如浮点型字段不能创建精确查找 //创建文档 这里要注意,有一些不能一起使用,例如浮点型字段不能创建精确查找
Mappings mappings = new ESCreateBuilder.Builder() Mappings mappings = new ESCreateBuilder.Builder()
.addField("paper_title",ESCreateBuilder.exactSearch) .addField("id")
// .addField("popularity",ESCreateBuilder.floatType) .addField("DBid")
.addField("id",ESCreateBuilder.floatType) .addField("type")
.addField("lineId",ESCreateBuilder.floatType)
.addField("keyWorld1")
.addField("keyWorld2")
.addField("paper_url")
.addField("abstracts") .addField("abstracts")
.addField("authors")
.addField("author")
.build(); .build();
System.out.println(mappings); elasticSearchUtil.createIndex("nodes",mappings);
////// //创建索引 elasticSearchUtil.createIndex("links",mappings);
boolean a = elasticSearchUtil.createIndex("111",mappings);
// System.out.println(mappings);
//
List<ESDao> bookList = new ArrayList<>(); List<ESDao> bookList = new ArrayList<>();
ESDao esDao = new ESDao(); List<ZhyDocApi> docList = zhyDocApiMapper.selectAllDoc1();
esDao.id = 1; for (int i=0;i<docList.size();i++){
esDao.authors = "菅振宇"; String abstracts = docList.get(i).getDocTitle();
esDao.lineId = 1; String id = String.valueOf(docList.get(i).getId());
esDao.paper_title = "论文名字测试11111";
esDao.paper_url = "adsf/sf/asd"; ESDao esDao = new ESDao();
esDao.keyWorld1 = "guanjiazi1"; esDao.id = id;
esDao.keyWorld2 = "guanjianzi2"; esDao.DBid = id;
esDao.abstracts = "关键测试部分的摘要娃哈哈大段的iiICv几AV艾师傅为天水电费气象水费海里的生物"; esDao.type = "node";
bookList.add(esDao); esDao.abstracts = abstracts;
bookList.add(esDao);
esDao = new ESDao(); }
esDao.id = 2; elasticSearchUtil.addDocBatch("nodes", bookList, ESDao.class, "id");
esDao.authors = "菅振宇";
esDao.lineId = 1;
esDao.paper_title = "论文名字测试22222222"; ZhyArticle zhyArticle = new ZhyArticle();
esDao.paper_url = "adsf/sf/asd"; List<ZhyArticle> lineList = zhyArticleMapper.selectZhyArticleList(zhyArticle);
esDao.keyWorld1 = "guanjiazi1"; for (int i=0;i<lineList.size();i++){
esDao.keyWorld2 = "guanjianzi2"; String abstracts = lineList.get(i).getName()+lineList.get(i).getKeywords()+lineList.get(i).getSummary();
esDao.abstracts = "ganraoondjdn天气和天气"; String id = String.valueOf(lineList.get(i).getId());
bookList.add(esDao);
ESDao esDao = new ESDao();
esDao = new ESDao(); esDao.id = id;
esDao.id = 3; esDao.DBid = id;
esDao.authors = "菅振宇"; esDao.type = "line";
esDao.lineId = 1; esDao.abstracts = abstracts;
esDao.paper_title = "论文名字测试3333333333"; bookList.add(esDao);
esDao.paper_url = "adsf/sf/asd"; }
esDao.keyWorld1 = "guanjiazi1"; elasticSearchUtil.addDocBatch("links", bookList, ESDao.class, "id");
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");
return null; return null;
} }
} }

8
ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java

@ -145,10 +145,10 @@ public class TestXiaoTuPuController extends BaseController {
neo4jUtil.excuteCypherSql(cypher); neo4jUtil.excuteCypherSql(cypher);
} }
@GetMapping("test7") // @GetMapping("test7")
public void test7() throws IOException { // public void test7() throws IOException {
pointService.buildPoint(); // pointService.buildPoint();
} // }
// 获取所有模型 // 获取所有模型
@GetMapping("getKeyWorlds") @GetMapping("getKeyWorlds")

73
ruoyi-api/src/main/java/com/ruoyi/api/domain/ESDao.java

@ -1,20 +1,12 @@
package com.ruoyi.api.domain; package com.ruoyi.api.domain;
public class ESDao { public class ESDao {
public Integer id; public String id;
public String paper_url; public String DBid; //图谱中线id
public Integer lineId; //图谱中线id public String type;
public String keyWorld1;
public String keyWorld2;
public String abstracts; //摘要 public String abstracts; //摘要
public String authors; public String getId() {
public String paper_title;
public Integer getId() {
return id; return id;
} }
@ -22,50 +14,31 @@ public class ESDao {
public String toString() { public String toString() {
return "ESDao{" + return "ESDao{" +
"id=" + id + "id=" + id +
", paper_url='" + paper_url + '\'' + ", DBid=" + DBid +
", lineId=" + lineId + ", type=" + type +
", keyWorld1='" + keyWorld1 + '\'' +
", keyWorld2='" + keyWorld2 + '\'' +
", abstracts='" + abstracts + '\'' + ", abstracts='" + abstracts + '\'' +
", authors='" + authors + '\'' +
", paper_title='" + paper_title + '\'' +
'}'; '}';
} }
public void setId(Integer id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public String getPaper_url() {
return paper_url;
}
public void setPaper_url(String paper_url) {
this.paper_url = paper_url;
}
public Integer getLineId() { public String getDBid() {
return lineId; return DBid;
} }
public void setLineId(Integer lineId) { public void setDBid(String DBid) {
this.lineId = lineId; this.DBid = DBid;
} }
public String getKeyWorld1() { public String getType() {
return keyWorld1; return type;
} }
public void setKeyWorld1(String keyWorld1) { public void setType(String type) {
this.keyWorld1 = keyWorld1; this.type = type;
}
public String getKeyWorld2() {
return keyWorld2;
}
public void setKeyWorld2(String keyWorld2) {
this.keyWorld2 = keyWorld2;
} }
public String getAbstracts() { public String getAbstracts() {
@ -75,20 +48,4 @@ public class ESDao {
public void setAbstracts(String abstracts) { public void setAbstracts(String abstracts) {
this.abstracts = abstracts; this.abstracts = abstracts;
} }
public String getAuthors() {
return authors;
}
public void setAuthors(String authors) {
this.authors = authors;
}
public String getPaper_title() {
return paper_title;
}
public void setPaper_title(String paper_title) {
this.paper_title = paper_title;
}
} }

10
ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java

@ -26,8 +26,8 @@ public class PointService {
@Autowired @Autowired
Neo4jUtil neo4jUtil; Neo4jUtil neo4jUtil;
public void buildPoint() throws IOException { public void buildPoint(String url) throws IOException {
List<Map<String, String>> dataList = getCsvLine(); List<Map<String, String>> dataList = getCsvLine(url);
Map<String,Integer> nameToId = new HashMap<>(); Map<String,Integer> nameToId = new HashMap<>();
for (Map<String, String> record : dataList) { for (Map<String, String> record : dataList) {
List<Map<String, String>> relationshipList = new ArrayList<>(); List<Map<String, String>> relationshipList = new ArrayList<>();
@ -265,8 +265,10 @@ public class PointService {
return result; return result;
} }
public List<Map<String, String>> getCsvLine() throws IOException { public List<Map<String, String>> getCsvLine(String url) throws IOException {
String csvFilePath = Paths.get("").toAbsolutePath() + "/test3.csv"; // String csvFilePath = Paths.get("").toAbsolutePath() + "/test3.csv";
String csvFilePath = url;
System.out.println("Reading CSV from: " + csvFilePath); System.out.println("Reading CSV from: " + csvFilePath);
File file = new File(csvFilePath); File file = new File(csvFilePath);

Loading…
Cancel
Save