Browse Source

小图谱跳转

small-tupu
hanyuqing 7 months ago
parent
commit
bda9ccfbcc
  1. 49
      gyxtp/src/view/graphPageCopy.vue
  2. 117
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java
  3. 2
      ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java
  4. 3
      ruoyi-api/src/main/java/com/ruoyi/api/controller/EsTestController.java
  5. 40
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java
  6. 88
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/GraphServiceImpl.java
  7. 4
      ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
  8. 2
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/Test1Mapper.java
  9. 70
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZhyFileManageServiceImpl.java
  10. 6
      ruoyi-system/src/main/resources/mapper/system/Test1Mapper.xml
  11. 2
      ruoyi-ui/src/utils/request.js

49
gyxtp/src/view/graphPageCopy.vue

@ -541,19 +541,15 @@ export default {
if (nodes.length === 0&&nodes1.length === 0) {
return "";
}
console.log(name)
// id
const targetId = String(name).trim();
console.log(targetId)
// nodes id targetId
let found = nodes.some(node => {
const nodeId = node.sourceAsMap.abstracts
return nodeId === targetId;
});
let found2 = nodes1.some(node => {
console.log("2222222")
const nodeId = node.docTitle
return nodeId === targetId;
});
@ -563,18 +559,23 @@ export default {
// 'nodeclass' ''
return found ? 'nodeclass' : '';
},
getLinesClass(id) {
getLinesClass(mergedDbIds) {
console.log("44444444444444")
const lines = this.heightLight.links;
if (lines == undefined){
return ""
}
// id
const targetId = Number(String(id).trim());
// const targetId = Number(String(id).trim());
// console.log(targetId)
const list=Array.from(mergedDbIds)
const numberArray = list.map(item => parseInt(item, 10));
const found = lines.some(line => {
const data= line.sourceAsMap.data
const array=JSON.parse(data)
console.log(array)
if(array.length>0){
return array.includes(targetId);
return numberArray.includes(array[0]);
}else {
console.log("没有")
return false
@ -1013,7 +1014,7 @@ export default {
lineList.forEach(line => {
let style=""
let num=1
if(this.getLinesClass(line.DbId)!=""){
if(this.getLinesClass(line.mergedDbIds)!=""){
style=this.getLinesClass(line.DbId)
num=10
}
@ -1057,22 +1058,22 @@ export default {
},
onNodeClick(nodeObject, $event) {
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
// }
// })
// });
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() {

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

@ -70,8 +70,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import static com.ruoyi.common.constant.Constants.ARTICLE_PDF_DIR;
import static com.ruoyi.common.constant.Constants.FILE_MANAGER_DIR;
import static com.ruoyi.common.constant.Constants.*;
@RestController
@RequestMapping("/system/fileManage")
@ -268,7 +267,7 @@ public class ZhyFileManageController extends BaseController {
return isDefinitelyUtf8 ? "UTF-8" : "GBK";
}
@PostMapping("/insertRelationByFile")
public AjaxResult insertRelationByFile(MultipartFile file) throws IOException {
public AjaxResult insertRelationByFile(MultipartFile file) throws Throwable {
// 1. 校验文件是否为空
if (file.isEmpty()) {
return AjaxResult.error("上传的文件为空");
@ -344,15 +343,9 @@ public class ZhyFileManageController extends BaseController {
}
}
// 4. 打印验证结果
System.out.println("共读取到 " + dataList.size() + " 条数据:");
for (int i = 0; i < dataList.size(); i++) {
Map<String, String> data = dataList.get(i);
// System.out.println("第" + (i + 1) + "行: " +
// "main_keyword=" + data.get("main_keyword") + " | " +
// "sub_keyword=" + data.get("sub_keyword") + " | " +
// "title=" + data.get("title") + " | " +
// "url=" + data.get("url"));
String title1=data.get("main_keyword");
System.out.println(title1);
@ -375,6 +368,20 @@ public class ZhyFileManageController extends BaseController {
neo4jUtil.excuteCypherSql(updateCql);
}
}
// List<ESDao> esDaos=new ArrayList<>();
// for (int j=0;j<list.size();j++){
// String abstracts = list.get(j).getDocTitle();
// String id = String.valueOf(list.get(j).getId());
//
// ESDao esDao = new ESDao();
// esDao.id = id;
// esDao.DBid = id;
// esDao.type = "node";
// esDao.abstracts = abstracts;
// esDao.data = null;
// esDaos.add(esDao);
// }
// esService.insertDocsById("nodes",esDaos);
ZhyArticle article=new ZhyArticle();
article.setName(data.get("title"));
@ -395,8 +402,10 @@ public class ZhyFileManageController extends BaseController {
zhyArticleMapper.insertZhyArticle(article);
System.out.println("sssssssssssss");
System.out.println(article.getId());
test1Mapper.updateParentId(list);
for(int a=0;a<list.size();a++){
test1Mapper.deleteTxtById(list.get(a).getId());
}
test1Mapper.insertDocList(list);
ZhyDocRelation zz = new ZhyDocRelation();
zz.setRelationship(relation);
zz.setSource(doc1.getId());
@ -406,21 +415,38 @@ public class ZhyFileManageController extends BaseController {
zz.setCreateTime(new Date());
zz.setArticleId(article.getId());
zhyDocRelationMapper.insertZhyRelationship(zz);
List<String> ids = new ArrayList<>();
ids.add(String.valueOf(zz.getId()));
ESDao esDao = new ESDao();
esDao.id = article.getId().toString();
esDao.DBid = article.getId().toString();
esDao.type = "line";
esDao.abstracts = article.getName()+article.getKeywords()+article.getSummary();
esDao.data = ids.toString();
esService.insertDocById("links",esDao);
}
}
//获取所有关系
List<ZhyDocRelation> listR = zhyDocRelationMapper.getAllRelation();
// List<String> ids = new ArrayList<>();
//创建
for(int i=0;i<listR.size();i++){
// ids.add(String.valueOf(listR.get(i).getId()));
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())+"', DbId: '"+String.valueOf(listR.get(i).getId())+"' }] -> (b) RETURN r";
neo4jUtil.excuteCypherSql(cql);
test1Mapper.updateGraphRelation(listR.get(i));
}
// for (ZhyDocRelation rel : listR) {
// ZhyArticle article=zhyArticleMapper.selectZhyArticleById(rel.getArticleId());
// ESDao esDao = new ESDao();
// esDao.id = article.getId().toString();
// esDao.DBid = article.getId().toString();
// esDao.type = "line";
// esDao.abstracts = article.getName()+article.getKeywords()+article.getSummary();
// esDao.data = ids.toString();
// esService.insertDocById("links",esDao);
// }
return AjaxResult.success().put("msg", "成功");
}
@ -531,6 +557,8 @@ public class ZhyFileManageController extends BaseController {
public AjaxResult reset() throws Throwable {
String url = saveFileWithStructure1();
List<ZhyDoc> nodeList=new ArrayList<>();
try {
// String[] strs1 = {
// "南海方向",
@ -1038,7 +1066,10 @@ public class ZhyFileManageController extends BaseController {
zhyFileManageService.wordSplitterOld(null , url +"\\wordSplitter", 0,list);
// zhyFileManageService.createIndex(url + "\\wordSplitter", "D:\\project\\gyx\\tupudata\\fileManager\\index");
test1Mapper.updateParentId(list);
for(int a=0;a<list.size();a++){
test1Mapper.deleteTxtById(list.get(a).getId());
}
test1Mapper.insertDocList(list);
@ -1190,11 +1221,10 @@ public class ZhyFileManageController extends BaseController {
elasticSearchUtil.createIndex("nodes",mappings);
elasticSearchUtil.createIndex("links",mappings);
}catch (Exception e){
System.out.println(e);
}
List<ESDao> esDaos=new ArrayList<>();
List<ESDao> esDaos1=new ArrayList<>();
for (int i=0;i<list.size();i++){
String abstracts = list.get(i).getDocTitle();
String id = String.valueOf(list.get(i).getId());
@ -1237,11 +1267,14 @@ public class ZhyFileManageController extends BaseController {
neo4jUtil.excuteCypherSql(cql);
test1Mapper.updateGraphRelation(listR.get(i));
}
}catch (Exception e){
System.out.println(e);
}
return AjaxResult.success().put("msg", "成功");
}
//一键删除方法
@GetMapping("/deletAllInfo")
public AjaxResult deletAllInfo() {
public AjaxResult deletAllInfo() throws IOException {
AjaxResult aj = new AjaxResult();
@ -1262,8 +1295,19 @@ public class ZhyFileManageController extends BaseController {
System.out.println(cql);
StatementResult result = neo4jUtil.excuteCypherSql(cql);
if (elasticSearchUtil.indexExists("nodes")) {
elasticSearchUtil.deleteIndex("nodes");
System.out.println("索引nodes已删除");
} else {
System.out.println("索引nodes不存在,跳过删除");
}
if (elasticSearchUtil.indexExists("links")) {
elasticSearchUtil.deleteIndex("links");
System.out.println("索引links已删除");
} else {
System.out.println("索引links不存在,跳过删除");
}
System.out.println(TUPUDATA_ROOT);
//删除指定文件夹
File directory = new File(FILE_MANAGER_DIR);
boolean result111 = deleteDirectory(directory);
@ -2368,6 +2412,17 @@ public class ZhyFileManageController extends BaseController {
zhyDoc.setDocLevel(docLevelNew);
zhyDoc.setProdectName(prodectName);
test1Mapper.updateDocById(zhyDoc);
ESDao esDao = new ESDao();
esDao.id = id.toString();
esDao.DBid = id.toString();
esDao.type = "node";
esDao.abstracts = name1;
esDao.data = null;
System.out.println("ssssss");
System.out.println(esDao);
esService.deleteDocById("nodes",id.toString());
esService.insertDocById("nodes",esDao);
// luceneUtil.deleteIndexByUrl(String.valueOf(id));
// luceneUtil.createSingleIndex1(String.valueOf(newPath), id);
@ -2651,10 +2706,10 @@ public class ZhyFileManageController extends BaseController {
String cqrD = "MATCH (n:Doc{docId:'" + oldpp + "'})-[r]-(n2:Doc{docId:'" + id + "'}) DELETE r";
StatementResult resultD = neo4jUtil.excuteCypherSql(cqrD);
if (relation1 != null && !relation1.equals("")) {
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + parentInd + "' AND b.docId = '" + id + "' CREATE (a)-[r:" + relation1 + " { name: '" + relation1+ "' }] -> (b) RETURN r";
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + parentInd + "' AND b.docId = '" + id + "' CREATE (a)-[r:" + relation1 + " { name: '" + relation1+"', DbId: '' }] -> (b) RETURN r";
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC);
} else {
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + parentInd + "' AND b.docId = '" + id + "' CREATE (a)-[r:" + relation + " { name: '" + relation+ "' }] -> (b) RETURN r";
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + parentInd + "' AND b.docId = '" + id + "' CREATE (a)-[r:" + relation + " { name: '" + relation+ "', DbId: '' }] -> (b) RETURN r";
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC);
}
@ -2815,7 +2870,16 @@ public class ZhyFileManageController extends BaseController {
zhyDoc.setCreateBy(String.valueOf(getUserId()));
zhyDoc.setGroupId(groupId);
test1Mapper.insertDoc(zhyDoc);
luceneUtil.createSingleIndex2(zhyDoc.getDocUrl(), zhyDoc.getId(), zhyDoc.getDocTitle());
ESDao esDao = new ESDao();
esDao.id = zhyDoc.getId().toString();
esDao.DBid = zhyDoc.getId().toString();
esDao.type = "node";
esDao.abstracts = txtName;
esDao.data = null;
System.out.println("ssssss");
System.out.println(esDao);
esService.insertDocById("nodes",esDao);
// luceneUtil.createSingleIndex2(zhyDoc.getDocUrl(), zhyDoc.getId(), zhyDoc.getDocTitle());
//创建完索引
//创建图谱
String cql = "create (doc: Doc{";
@ -2926,7 +2990,7 @@ public class ZhyFileManageController extends BaseController {
//创建图谱
String cqr = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + zz.getSource() + "' AND b.docId = '" + zz.getTarget() + "' CREATE (a)-[r:" + zz.getRelationship() + " { name: '" + zz.getRelationship() + "' }] -> (b) RETURN r";
String cqr = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + zz.getSource() + "' AND b.docId = '" + zz.getTarget() + "' CREATE (a)-[r:" + zz.getRelationship() + " { name: '" + zz.getRelationship() + "', DbId: '' }] -> (b) RETURN r";
neo4jUtil.excuteCypherSql(cqr);
zz.setIsgraph(1l);
@ -2964,7 +3028,8 @@ public class ZhyFileManageController extends BaseController {
String url = requestBody.get("url");
System.out.println(id + url);
test1Mapper.deleteTxtById(id);
luceneUtil.deleteIndexByUrl(String.valueOf(id));
esService.deleteDocById("nodes",id.toString());
// luceneUtil.deleteIndexByUrl(String.valueOf(id));
//删除指定的实体
String cql = "MATCH (n:Doc{docId:'" + id + "'}) DETACH delete n";
System.out.println(cql);

2
ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java

@ -1358,7 +1358,7 @@ public class DocApiController extends BaseController {
zhyTaskService.updateZhyTask(task);
}
@PostMapping("/buildOne")
public void buildOne(HttpServletRequest request,@RequestBody Map data) {
public void buildOne(HttpServletRequest request,@RequestBody Map data) throws IOException {
Map thesis =new HashMap<>();
buildService.create(thesis);
if (!data.get("l1").equals("")){

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

@ -100,7 +100,8 @@ public class EsTestController {
public SearchHits indexCreate2() throws Throwable {
//还差时间排序,和聚合搜索
SearchHits hits = new CustomQueryBuilder.Builder(client)
.buildAndExecute("111");
.withFuzzyMatch("abstracts","气象")
.buildAndExecute("links");
return hits;
}
@GetMapping("/esQuery/{param}")

40
ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java

@ -1,6 +1,7 @@
package com.ruoyi.api.service.impl;
import com.ruoyi.api.ReadTextData;
import com.ruoyi.api.domain.ESDao;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.Neo4jUtil;
import com.ruoyi.system.domain.ZhyArticle;
@ -33,11 +34,13 @@ public class BuildService {
Test1Mapper test1Mapper;
@Autowired
Neo4jUtil neo4jUtil;
@Autowired
ESService esService;
// @Autowired
// Map<String,String> thesis
public void create(Map<String,String> thesis){
public void create(Map<String,String> thesis) throws IOException {
// Map thesis =new HashMap<>();
// thesis.put("url","D:\\\\project\\\\gyx\\\\tupudata\\\\thesis\\\\thesis_results_20250819_102943.csv");
// System.out.println("11");
@ -103,7 +106,7 @@ public class BuildService {
} catch (IOException e) {
e.printStackTrace();
}
List<ZhyDocRelation> allRelation=new ArrayList<>();
// 3. 处理每一行数据(和你原来逻辑一致)
for (Map<String, String> data : dataList) {
System.out.println("44444444444444");
@ -174,6 +177,7 @@ public class BuildService {
}
if(!flag){
createRelation(parentValue, childValue,data,filePath1);
}
}else{
//插入关系
@ -189,7 +193,20 @@ public class BuildService {
}
//
}
// List<String> ids = new ArrayList<>();
// for (ZhyDocRelation rel : allRelation) {
// ids.add(String.valueOf(rel.getId()));
// }
// for (ZhyDocRelation rel : allRelation) {
// ZhyArticle article=zhyArticleMapper.selectZhyArticleById(rel.getArticleId());
// ESDao esDao = new ESDao();
// esDao.id = article.getId().toString();
// esDao.DBid = article.getId().toString();
// esDao.type = "line";
// esDao.abstracts = article.getName()+article.getKeywords()+article.getSummary();
// esDao.data = ids.toString();
// esService.insertDocById("links",esDao);
// }
// return AjaxResult.success().put("msg", "文件处理完成,共导入 " + dataList.size() + " 条数据");
@ -389,7 +406,7 @@ public class BuildService {
}
}
public void createRelation(String parentValue,String childValue,Map<String, String> data,String local){
public void createRelation(String parentValue,String childValue,Map<String, String> data,String local) throws IOException {
ZhyDoc doc1 = test1Mapper.selectDocByTitle(parentValue);
ZhyDoc doc2 = test1Mapper.selectDocByTitle(childValue);
if (doc1 != null && doc2 != null) {
@ -432,6 +449,16 @@ public class BuildService {
zz.setArticleId(article.getId());
System.out.println(zz);
zhyDocRelationMapper.insertZhyRelationship(zz);
List<String> ids = new ArrayList<>();
ids.add(String.valueOf(zz.getId()));
ESDao esDao = new ESDao();
esDao.id = article.getId().toString();
esDao.DBid = article.getId().toString();
esDao.type = "line";
esDao.abstracts = article.getName()+article.getKeywords()+article.getSummary();
esDao.data = ids.toString();
esService.insertDocById("links",esDao);
}
// 4. 批量创建 Neo4j 关系
@ -439,12 +466,13 @@ public class BuildService {
for (ZhyDocRelation rel : listR) {
String cql = "MATCH (a:Doc),(b:Doc) " +
"WHERE a.docId = '" + rel.getSource() + "' AND b.docId = '" + rel.getTarget() + "' " +
"CREATE (a)-[r:" + rel.getRelationship() + " {name: '" + rel.getRelationship() + "'}]->(b) " +
"CREATE (a)-[r:" + rel.getRelationship() + " {name: '" + rel.getRelationship() +"', DbId: '"+rel.getId()+ "'}]->(b) " +
"RETURN r";
neo4jUtil.excuteCypherSql(cql);
test1Mapper.updateGraphRelation(rel);
}
}
private static String[] parseCsvLine(String line) {
List<String> result = new ArrayList<>();

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

@ -477,7 +477,29 @@ public class GraphServiceImpl implements GraphService {
aa.put("relate",graphRelation.get(b).get("name"));
graphRelationNew.add(aa);
}
// === 开始去重合并 ===
// // === 开始去重合并 ===
// Map<String, HashMap<String, Object>> mergedMap = new LinkedHashMap<>();
//
// for (HashMap<String, Object> link : graphRelationNew) {
// String source = String.valueOf(link.get("source"));
// String target = String.valueOf(link.get("target"));
// String key = source + "->" + target; // 有向图
//
// if (mergedMap.containsKey(key)) {
// HashMap<String, Object> existing = mergedMap.get(key);
// existing.put("num", (int) existing.get("num") + 1);
// } else {
// HashMap<String, Object> newLink = new HashMap<>(link);
// newLink.put("num", 1);
// mergedMap.put(key, newLink);
// }
// }
//
//// 写回
// nr.put("links", new ArrayList<>(mergedMap.values()));
// nr.put("links", graphRelationNew);
// === 开始去重合并,并收集 DbId 数组 ===
Map<String, HashMap<String, Object>> mergedMap = new LinkedHashMap<>();
for (HashMap<String, Object> link : graphRelationNew) {
@ -485,20 +507,34 @@ public class GraphServiceImpl implements GraphService {
String target = String.valueOf(link.get("target"));
String key = source + "->" + target; // 有向图
// 获取当前关系的 DbId
Object currentDbId = link.get("DbId"); // 确保 DbId 是唯一标识之一
if (mergedMap.containsKey(key)) {
// 已存在,添加 DbId 到 mergedDbIds 数组
HashMap<String, Object> existing = mergedMap.get(key);
@SuppressWarnings("unchecked")
List<Object> mergedDbIds = (List<Object>) existing.get("mergedDbIds");
if (mergedDbIds == null) {
mergedDbIds = new ArrayList<>();
existing.put("mergedDbIds", mergedDbIds);
}
mergedDbIds.add(currentDbId);
// 更新计数
existing.put("num", (int) existing.get("num") + 1);
} else {
// 第一次出现,创建新条目
HashMap<String, Object> newLink = new HashMap<>(link);
newLink.put("num", 1);
List<Object> mergedDbIds = new ArrayList<>();
mergedDbIds.add(currentDbId);
newLink.put("mergedDbIds", mergedDbIds); // 添加 DbId 数组
newLink.put("num", 1); // 初始化数量
mergedMap.put(key, newLink);
}
}
// 写回
// 写回结果
nr.put("links", new ArrayList<>(mergedMap.values()));
// nr.put("links", graphRelationNew);
}
else {
String nodecql = String.format("MATCH (n:Doc) %s RETURN distinct(n) limit %s",
@ -612,6 +648,27 @@ public class GraphServiceImpl implements GraphService {
}
// === 开始去重合并 ===
// Map<String, HashMap<String, Object>> mergedMap = new LinkedHashMap<>();
//
// for (HashMap<String, Object> link : graphRelationNew) {
// String source = String.valueOf(link.get("source"));
// String target = String.valueOf(link.get("target"));
// String key = source + "->" + target; // 有向图
//
// if (mergedMap.containsKey(key)) {
// HashMap<String, Object> existing = mergedMap.get(key);
// existing.put("num", (int) existing.get("num") + 1);
// } else {
// HashMap<String, Object> newLink = new HashMap<>(link);
// newLink.put("num", 1);
// mergedMap.put(key, newLink);
// }
// }
//
//// 写回
// nr.put("links", new ArrayList<>(mergedMap.values()));
// nr.put("links", graphRelationNew);
// === 开始去重合并,并收集 DbId 数组 ===
Map<String, HashMap<String, Object>> mergedMap = new LinkedHashMap<>();
for (HashMap<String, Object> link : graphRelationNew) {
@ -619,19 +676,34 @@ public class GraphServiceImpl implements GraphService {
String target = String.valueOf(link.get("target"));
String key = source + "->" + target; // 有向图
// 获取当前关系的 DbId
Object currentDbId = link.get("DbId"); // 确保 DbId 是唯一标识之一
if (mergedMap.containsKey(key)) {
// 已存在,添加 DbId 到 mergedDbIds 数组
HashMap<String, Object> existing = mergedMap.get(key);
@SuppressWarnings("unchecked")
List<Object> mergedDbIds = (List<Object>) existing.get("mergedDbIds");
if (mergedDbIds == null) {
mergedDbIds = new ArrayList<>();
existing.put("mergedDbIds", mergedDbIds);
}
mergedDbIds.add(currentDbId);
// 更新计数
existing.put("num", (int) existing.get("num") + 1);
} else {
// 第一次出现,创建新条目
HashMap<String, Object> newLink = new HashMap<>(link);
newLink.put("num", 1);
List<Object> mergedDbIds = new ArrayList<>();
mergedDbIds.add(currentDbId);
newLink.put("mergedDbIds", mergedDbIds); // 添加 DbId 数组
newLink.put("num", 1); // 初始化数量
mergedMap.put(key, newLink);
}
}
// 写回
// 写回结果
nr.put("links", new ArrayList<>(mergedMap.values()));
// nr.put("links", graphRelationNew);
}
} catch (Exception e) {
e.printStackTrace();

4
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 outPath = "D:\\project\\gyx\\tupudata\\fileOut\\";
public static final String TUPUDATA_ROOT = "C:/D/project/gyx/tupudata";
public static String TUPUDATA_ROOT = "D:/project/gyx/tupudata";
/**
* 文章 PDF 存储目录
@ -206,7 +206,7 @@ public static final String indexPathBattle = "D:\\project\\gyx\\tupudata\\battl
* 文件管理索引目录
*/
public static final String FILE_MANAGER_INDEX_DIR = TUPUDATA_ROOT + "/fileManager/index";
public static final String FILE_MANAGER_DIR = TUPUDATA_ROOT + "/fileManager";
public static String FILE_MANAGER_DIR = TUPUDATA_ROOT + "/fileManager";
/**
* 对战管理索引目录battleManager

2
ruoyi-system/src/main/java/com/ruoyi/system/mapper/Test1Mapper.java

@ -42,7 +42,7 @@ public interface Test1Mapper {
List<ZhyDoc> selectDocByIds(@Param("ids")List<Long> ids);
int updateDocById(ZhyDoc zhyDoc);
int updateParentId(List<ZhyDoc> list);
int updateParentId(ZhyDoc zhyDoc);
int updateParentId1(@Param("docTitle") String docTitle,@Param("docLevel") Long docLevel,@Param("docParentId") Long docParentId);
int updateParentId2(@Param("docTitle") String docTitle, @Param("docLevel") Long docLevel, @Param("docParentId") Long docParentId, @Param("groupId")Long groupId);

70
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZhyFileManageServiceImpl.java

@ -81,44 +81,44 @@ public class ZhyFileManageServiceImpl {
public String createIndex(String wordUrl,String indexUrl){
System.out.println("@@@@@@@@@@@@@@@@@@@@@");
try {
luceneUtil.createIndex(wordUrl,indexUrl);
return "a";
} catch (Exception e) {
System.out.println("##############");
e.printStackTrace();
}
return "b";
}
public String createIndexAdd(String wordUrl,String indexUrl){
try {
luceneUtil.createIndexAdd(wordUrl);
return "a";
} catch (Exception e) {
e.printStackTrace();
}
return "b";
}
// public String createIndex(String wordUrl,String indexUrl){
// System.out.println("@@@@@@@@@@@@@@@@@@@@@");
// try {
// luceneUtil.createIndex(wordUrl,indexUrl);
// return "a";
// } catch (Exception e) {
// System.out.println("##############");
// e.printStackTrace();
// }
// return "b";
// }
public String createIndexBattle(String wordUrl,String indexUrl){
try {
luceneUtil.createIndexBattle(wordUrl,indexUrl);
return "a";
} catch (Exception e) {
e.printStackTrace();
}
return "b";
}
// public String createIndexAdd(String wordUrl,String indexUrl){
// try {
// luceneUtil.createIndexAdd(wordUrl);
// return "a";
// } catch (Exception e) {
// e.printStackTrace();
// }
// return "b";
// }
//
//
//
//
//
//
// public String createIndexBattle(String wordUrl,String indexUrl){
// try {
// luceneUtil.createIndexBattle(wordUrl,indexUrl);
// return "a";
// } catch (Exception e) {
// e.printStackTrace();
// }
// return "b";
// }
public String getRelationShip(Integer fileId){

6
ruoyi-system/src/main/resources/mapper/system/Test1Mapper.xml

@ -102,11 +102,9 @@ select * from zhy_doc where isgraph = 0 and file_id = #{fileId}
</insert>
<update id="updateParentId" >
<foreach collection="list" item="item" index="index" separator=";">
update zhy_doc
set doc_parent_id = #{item.docParentId}
where doc_title = #{item.docTitle} and doc_level = #{item.docLevel}
</foreach>
set doc_parent_id = #{docParentId}
where doc_title = #{docTitle} and doc_level = #{docLevel}
</update>

2
ruoyi-ui/src/utils/request.js

@ -19,7 +19,7 @@ const service = axios.create({
// baseURL: "http://127.0.0.1:10031",
// 超时
timeout: 10000
timeout: 60000
})
// request拦截器

Loading…
Cancel
Save