|
|
|
@ -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); |
|
|
|
|