Browse Source

yangshi

small-tupu
菅振宇 7 months ago
parent
commit
7583e05629
  1. 54
      gyxtp/src/view/graphPageCopy.vue
  2. 4
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java
  3. 31
      ruoyi-api/src/main/java/com/ruoyi/api/controller/EsTestController.java
  4. 6
      ruoyi-api/src/main/java/com/ruoyi/api/domain/ESDao.java
  5. 8
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/GraphServiceImpl.java
  6. 2
      ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

54
gyxtp/src/view/graphPageCopy.vue

@ -520,7 +520,8 @@ export default {
getheightLight(this.keywords).then((res)=>{ getheightLight(this.keywords).then((res)=>{
this.heightLight = { this.heightLight = {
"nodes": res.nodes.hits, "nodes": res.nodes.hits,
"links":res.links.hits "links":res.links.hits,
"nodes1":res.nodes1
} }
console.log(this.heightLight) console.log(this.heightLight)
getDomainGraphTest({}).then((r) => { getDomainGraphTest({}).then((r) => {
@ -530,43 +531,50 @@ export default {
}, },
getNodeClass(name) { getNodeClass(name) {
console.log(name)
// this.heightLight.nodes // this.heightLight.nodes
const nodes = this.heightLight.nodes; const nodes = this.heightLight.nodes;
if (!Array.isArray(nodes) || nodes.length === 0) { const nodes1 = this.heightLight.nodes1;
if (!Array.isArray(nodes) || nodes.length === 0||!Array.isArray(nodes1) || nodes1.length === 0) {
return ""; return "";
} }
// id // id
const targetId = String(name).trim(); const targetId = String(name).trim();
// nodes id targetId // nodes id targetId
const found = nodes.some(node => { let found = nodes.some(node => {
const nodeId = node.sourceAsMap.abstracts const nodeId = node.sourceAsMap.abstracts
return nodeId === targetId; return nodeId === targetId;
}); });
found = nodes1.some(node => {
console.log("2222222")
const nodeId = node.docTitle
return nodeId === targetId;
});
// 'nodeclass' '' // 'nodeclass' ''
return found ? 'nodeclass' : ''; return found ? 'nodeclass' : '';
}, },
getLinesClass(from) { getLinesClass(id) {
const lines = this.heightLight.links; const lines = this.heightLight.links;
console.log(this.heightLight)
if (lines == undefined){ if (lines == undefined){
return return ""
} }
// id // id
const targetId = String(from).trim(); const targetId = Number(String(id).trim());
const found = lines.some(line => { const found = lines.some(line => {
const data = line.sourceAsMap.data const data= line.sourceAsMap.data
return data.some(item => { const array=JSON.parse(data)
const source = item.source; if(array.length>0){
console.log(source) return array.includes(targetId);
console.log(targetId) }else {
return source === targetId; console.log("没有")
}); return false
}
}); });
// 'nodeclass' '' // 'nodeclass' ''
return found ? 'lineclass' : ''; return found ? 'lineclass' : '';
}, },
@ -993,8 +1001,16 @@ export default {
} }
}); });
}); });
console.log(lineList)
// 线 // 线
lineList.forEach(line => { lineList.forEach(line => {
let style=""
let num=1
if(this.getLinesClass(line.DbId)!=""){
style=this.getLinesClass(line.DbId)
num=10
}
console.log(line) console.log(line)
links.push({ links.push({
from: line.source, from: line.source,
@ -1005,9 +1021,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:num,
lineShape: 1, lineShape: 1,
styleClass:this.getLinesClass(line.source), styleClass:style,
}) })
}); });

4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java

@ -407,7 +407,7 @@ public class ZhyFileManageController extends BaseController {
for(int i=0;i<listR.size();i++){ for(int i=0;i<listR.size();i++){
String cql = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+listR.get(i).getSource() +"' AND " + "b.docId = '"+listR.get(i).getTarget()+"'"; String cql = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+listR.get(i).getSource() +"' AND " + "b.docId = '"+listR.get(i).getTarget()+"'";
cql = cql + " CREATE (a)-[r:"+String.valueOf(listR.get(i).getRelationship())+"{ name: '"+String.valueOf(listR.get(i).getRelationship())+"'}] -> (b) RETURN r"; cql = cql + " CREATE (a)-[r:"+String.valueOf(listR.get(i).getRelationship())+"{ name: '"+String.valueOf(listR.get(i).getRelationship())+"', DbId: '"+String.valueOf(listR.get(i).getId())+"' }] -> (b) RETURN r";
neo4jUtil.excuteCypherSql(cql); neo4jUtil.excuteCypherSql(cql);
test1Mapper.updateGraphRelation(listR.get(i)); test1Mapper.updateGraphRelation(listR.get(i));
} }
@ -1193,7 +1193,7 @@ public class ZhyFileManageController extends BaseController {
for(int i=0;i<listR.size();i++){ for(int i=0;i<listR.size();i++){
String cql = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+listR.get(i).getSource() +"' AND " + "b.docId = '"+listR.get(i).getTarget()+"'"; String cql = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+listR.get(i).getSource() +"' AND " + "b.docId = '"+listR.get(i).getTarget()+"'";
cql = cql + " CREATE (a)-[r:"+String.valueOf(listR.get(i).getRelationship())+"{ name: '"+String.valueOf(listR.get(i).getRelationship())+"'}] -> (b) RETURN r"; cql = cql + " CREATE (a)-[r:"+String.valueOf(listR.get(i).getRelationship())+"{ name: '"+String.valueOf(listR.get(i).getRelationship())+"', DbId: '"+String.valueOf(listR.get(i).getId())+"' }] -> (b) RETURN r";
neo4jUtil.excuteCypherSql(cql); neo4jUtil.excuteCypherSql(cql);
test1Mapper.updateGraphRelation(listR.get(i)); test1Mapper.updateGraphRelation(listR.get(i));
} }

31
ruoyi-api/src/main/java/com/ruoyi/api/controller/EsTestController.java

@ -9,9 +9,11 @@ import com.ruoyi.api.domain.ESDao;
import com.ruoyi.api.domain.ZhyDocApi; import com.ruoyi.api.domain.ZhyDocApi;
import com.ruoyi.api.mapper.ZhyDocApiMapper; import com.ruoyi.api.mapper.ZhyDocApiMapper;
import com.ruoyi.system.domain.ZhyArticle; import com.ruoyi.system.domain.ZhyArticle;
import com.ruoyi.system.domain.ZhyDoc;
import com.ruoyi.system.domain.ZhyDocRelation; import com.ruoyi.system.domain.ZhyDocRelation;
import com.ruoyi.system.mapper.ZhyArticleMapper; import com.ruoyi.system.mapper.ZhyArticleMapper;
import com.ruoyi.system.mapper.ZhyDocRelationMapper; import com.ruoyi.system.mapper.ZhyDocRelationMapper;
import org.elasticsearch.search.SearchHit;
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;
@ -81,8 +83,19 @@ public class EsTestController {
.withFuzzyMatch("abstracts",param) .withFuzzyMatch("abstracts",param)
.buildAndExecute("links"); .buildAndExecute("links");
Map map = new HashMap(); Map map = new HashMap();
map.put("nodes",nodes);
map.put("links",links); map.put("links",links);
List<ZhyDocApi> nodes1=new ArrayList<>();
for(int i=0;i<links.getHits().length;i++){
SearchHit a=links.getHits()[i];
String dbid =(String) a.getSourceAsMap().get("DBid");
ZhyArticle article=zhyArticleMapper.selectZhyArticleById(Long.valueOf(dbid));
ZhyDocApi docSource=zhyDocApiMapper.selectDocByIdId(article.getSourceId());
ZhyDocApi docTarget=zhyDocApiMapper.selectDocByIdId(article.getTargetId());
nodes1.add(docSource);
nodes1.add(docTarget);
}
map.put("nodes",nodes);
map.put("nodes1",nodes1);
return map; return map;
} }
@ -105,6 +118,7 @@ public class EsTestController {
.addField("DBid") .addField("DBid")
.addField("type") .addField("type")
.addField("abstracts") .addField("abstracts")
.addField("data")
.build(); .build();
elasticSearchUtil.createIndex("nodes",mappings); elasticSearchUtil.createIndex("nodes",mappings);
elasticSearchUtil.createIndex("links",mappings); elasticSearchUtil.createIndex("links",mappings);
@ -126,25 +140,30 @@ public class EsTestController {
} }
elasticSearchUtil.addDocBatch("nodes", bookList, ESDao.class, "id"); elasticSearchUtil.addDocBatch("nodes", bookList, ESDao.class, "id");
List<ESDao> bookList2 = new ArrayList<>();
ZhyArticle zhyArticle = new ZhyArticle(); ZhyArticle zhyArticle = new ZhyArticle();
List<ZhyArticle> lineList = zhyArticleMapper.selectZhyArticleList(zhyArticle); List<ZhyArticle> lineList = zhyArticleMapper.selectZhyArticleList(zhyArticle);
for (int i=0;i<lineList.size();i++){ for (int i=0;i<lineList.size();i++){
String abstracts = lineList.get(i).getName()+lineList.get(i).getKeywords()+lineList.get(i).getSummary(); String abstracts = lineList.get(i).getName()+lineList.get(i).getKeywords()+lineList.get(i).getSummary();
System.out.println(abstracts);
String id = String.valueOf(lineList.get(i).getId()); String id = String.valueOf(lineList.get(i).getId());
ZhyDocRelation zhyDocRelation = new ZhyDocRelation(); ZhyDocRelation zhyDocRelation = new ZhyDocRelation();
zhyDocRelation.setArticleId(lineList.get(i).getId()); zhyDocRelation.setArticleId(lineList.get(i).getId());
List<Map> a = zhyDocRelationMapper.selectZhyRelationshipArticle(zhyDocRelation); List<Map> a = zhyDocRelationMapper.selectZhyRelationshipArticle(zhyDocRelation);
List<String> ids = new ArrayList<>();
for (int j = 0;j<a.size();j++){
ids.add(String.valueOf(a.get(j).get("id")));
}
ESDao esDao = new ESDao(); ESDao esDao = new ESDao();
esDao.id = id; esDao.id = id;
esDao.DBid = id; esDao.DBid = id;
esDao.type = "line"; esDao.type = "line";
esDao.abstracts = abstracts; esDao.abstracts = abstracts;
esDao.data = a; esDao.data = ids.toString();
bookList.add(esDao); bookList2.add(esDao);
System.out.println(bookList2);
} }
elasticSearchUtil.addDocBatch("links", bookList, ESDao.class, "id"); elasticSearchUtil.addDocBatch("links", bookList2, ESDao.class, "id");
return null; return null;
} }
} }

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

@ -8,13 +8,13 @@ public class ESDao {
public String DBid; //图谱中线id public String DBid; //图谱中线id
public String type; public String type;
public String abstracts; //摘要 public String abstracts; //摘要
public List<Map> data; public String data;
public String getId() { public String getId() {
return id; return id;
} }
public List<Map> getData() { public String getData() {
return data; return data;
} }
@ -29,7 +29,7 @@ public class ESDao {
'}'; '}';
} }
public void setData(List<Map> data) { public void setData(String data) {
this.data = data; this.data = data;
} }

8
ruoyi-api/src/main/java/com/ruoyi/api/service/impl/GraphServiceImpl.java

@ -604,8 +604,10 @@ public class GraphServiceImpl implements GraphService {
} }
aa.put("source",graphRelation.get(b).get("sourceid")); aa.put("source",graphRelation.get(b).get("sourceid"));
aa.put("target",graphRelation.get(b).get("targetid")); aa.put("target",graphRelation.get(b).get("targetid"));
aa.put("DbId",graphRelation.get(b).get("DbId"));
aa.put("uuid",graphRelation.get(b).get("uuid"));
aa.put("relate",graphRelation.get(b).get("name")); aa.put("relate",graphRelation.get(b).get("name"));
System.out.println(aa);
graphRelationNew.add(aa); graphRelationNew.add(aa);
} }
@ -745,6 +747,7 @@ public class GraphServiceImpl implements GraphService {
List<HashMap<String, Object>> graphRel = neo4jUtil.getGraphRelationShip(relSql); List<HashMap<String, Object>> graphRel = neo4jUtil.getGraphRelationShip(relSql);
List<HashMap<String, Object>> links = buildLinksFromRelOnly(graphRel, newNodes); List<HashMap<String, Object>> links = buildLinksFromRelOnly(graphRel, newNodes);
System.out.println(links);
nr.put("links", links); nr.put("links", links);
} }
@ -868,7 +871,7 @@ public class GraphServiceImpl implements GraphService {
for (HashMap<String, Object> node : nodes) { for (HashMap<String, Object> node : nodes) {
nodeIndex.put(String.valueOf(node.get("id")), node); nodeIndex.put(String.valueOf(node.get("id")), node);
} }
System.out.println(relations);
Map<String, HashMap<String, Object>> mergedMap = new LinkedHashMap<>(); Map<String, HashMap<String, Object>> mergedMap = new LinkedHashMap<>();
for (HashMap<String, Object> rel : relations) { for (HashMap<String, Object> rel : relations) {
@ -884,6 +887,7 @@ public class GraphServiceImpl implements GraphService {
link.put("target", targetId); link.put("target", targetId);
link.put("relate", rel.get("name")); link.put("relate", rel.get("name"));
link.put("id",rel.get("uuid")); link.put("id",rel.get("uuid"));
link.put("DbId",rel.get("DbId"));
HashMap<String, Object> srcNode = nodeIndex.get(sourceId); HashMap<String, Object> srcNode = nodeIndex.get(sourceId);
HashMap<String, Object> tgtNode = nodeIndex.get(targetId); HashMap<String, Object> tgtNode = nodeIndex.get(targetId);

2
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@ -182,7 +182,7 @@ public static final String indexPathBattle = "D:\\project\\gyx\\tupudata\\battl
// public static final String indexPathBattle = "C:\\tupudata\\battleManager\\index"; // public static final String indexPathBattle = "C:\\tupudata\\battleManager\\index";
public static final String outPath = "D:\\project\\gyx\\tupudata\\fileOut\\"; public static final String outPath = "D:\\project\\gyx\\tupudata\\fileOut\\";
public static final String TUPUDATA_ROOT = "D:/project/gyx/tupudata"; public static final String TUPUDATA_ROOT = "C:/D/project/gyx/tupudata";
/** /**
* 文章 PDF 存储目录 * 文章 PDF 存储目录

Loading…
Cancel
Save