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. 105
      gyxtp/src/view/graphPageCopy.vue
  3. 3
      ruoyi-api/src/main/java/com/ruoyi/api/ElasticsearchUtils/impl/ElasticSearchUtilImpl.java
  4. 161
      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',
});
};
export const getheightLight = (param) => {
return request({
url: '/api/esQuery/'+param,
method: 'get',
});
};

105
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;
this.keywords
getheightLight(this.keywords).then((res)=>{
this.heightLight = {
"nodes": res.nodes.hits,
"links":res.links.hits
}
getDomainGraphTest({}).then((r) => {
this.zhengl(r.data);
})
})
// 2.
const params = this.keywords ? {nodename: this.keywords} : {};
},
getNodeClass(id){
if (this.heightLight=={}){
return ""
}
// 3. API
getDomainGraphTest(params)
.then((res) => {
// 4.
this.zhengl(res.data);
})
.catch((error) => {
console.error("数据加载失败:", error);
});
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 <= 2020
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;
}
</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()
.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));
}
}

161
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;
/**
* --------------------------------------------------------------------------------------------------------------- <br/>
@ -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<String, HighlightField> 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<ESDao> bookList = new ArrayList<>();
List<ZhyDocApi> docList = zhyDocApiMapper.selectAllDoc1();
for (int i=0;i<docList.size();i++){
String abstracts = docList.get(i).getDocTitle();
String id = String.valueOf(docList.get(i).getId());
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艾师傅为天水电费气象水费海里的生物";
esDao.id = id;
esDao.DBid = id;
esDao.type = "node";
esDao.abstracts = abstracts;
bookList.add(esDao);
}
elasticSearchUtil.addDocBatch("nodes", bookList, ESDao.class, "id");
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);
ZhyArticle zhyArticle = new ZhyArticle();
List<ZhyArticle> lineList = zhyArticleMapper.selectZhyArticleList(zhyArticle);
for (int i=0;i<lineList.size();i++){
String abstracts = lineList.get(i).getName()+lineList.get(i).getKeywords()+lineList.get(i).getSummary();
String id = String.valueOf(lineList.get(i).getId());
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没有田也灭有七";
ESDao esDao = new ESDao();
esDao.id = id;
esDao.DBid = id;
esDao.type = "line";
esDao.abstracts = abstracts;
bookList.add(esDao);
// System.out.println(bookList);
// //向索引中增加记录,强烈建议使用第二种将文档的id和记录的id相关联,这在更新或删除的时候非常方便
// elasticSearchUtil.addDocBatch("book5", bookList);
elasticSearchUtil.addDocBatch("111", bookList, ESDao.class, "id");
}
elasticSearchUtil.addDocBatch("links", bookList, ESDao.class, "id");
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);
}
@GetMapping("test7")
public void test7() throws IOException {
pointService.buildPoint();
}
// @GetMapping("test7")
// public void test7() throws IOException {
// pointService.buildPoint();
// }
// 获取所有模型
@GetMapping("getKeyWorlds")

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

@ -1,20 +1,12 @@
package com.ruoyi.api.domain;
public class ESDao {
public Integer id;
public String paper_url;
public Integer lineId; //图谱中线id
public String keyWorld1;
public String keyWorld2;
public String id;
public String DBid; //图谱中线id
public String type;
public String abstracts; //摘要
public String authors;
public String paper_title;
public Integer getId() {
public String getId() {
return id;
}
@ -22,50 +14,31 @@ public class ESDao {
public String toString() {
return "ESDao{" +
"id=" + id +
", paper_url='" + paper_url + '\'' +
", lineId=" + lineId +
", keyWorld1='" + keyWorld1 + '\'' +
", keyWorld2='" + keyWorld2 + '\'' +
", DBid=" + DBid +
", type=" + type +
", abstracts='" + abstracts + '\'' +
", authors='" + authors + '\'' +
", paper_title='" + paper_title + '\'' +
'}';
}
public void setId(Integer id) {
public void setId(String 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() {
return lineId;
public String getDBid() {
return DBid;
}
public void setLineId(Integer lineId) {
this.lineId = lineId;
public void setDBid(String DBid) {
this.DBid = DBid;
}
public String getKeyWorld1() {
return keyWorld1;
public String getType() {
return type;
}
public void setKeyWorld1(String keyWorld1) {
this.keyWorld1 = keyWorld1;
}
public String getKeyWorld2() {
return keyWorld2;
}
public void setKeyWorld2(String keyWorld2) {
this.keyWorld2 = keyWorld2;
public void setType(String type) {
this.type = type;
}
public String getAbstracts() {
@ -75,20 +48,4 @@ public class ESDao {
public void setAbstracts(String 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
Neo4jUtil neo4jUtil;
public void buildPoint() throws IOException {
List<Map<String, String>> dataList = getCsvLine();
public void buildPoint(String url) throws IOException {
List<Map<String, String>> dataList = getCsvLine(url);
Map<String,Integer> nameToId = new HashMap<>();
for (Map<String, String> record : dataList) {
List<Map<String, String>> relationshipList = new ArrayList<>();
@ -265,8 +265,10 @@ public class PointService {
return result;
}
public List<Map<String, String>> getCsvLine() throws IOException {
String csvFilePath = Paths.get("").toAbsolutePath() + "/test3.csv";
public List<Map<String, String>> 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);

Loading…
Cancel
Save