|
|
|
@ -1,10 +1,14 @@ |
|
|
|
package com.main.woka.Web.Controller; |
|
|
|
|
|
|
|
import com.main.woka.Common.core.AjaxResult; |
|
|
|
import com.main.woka.Common.util.Neo4jUtil; |
|
|
|
import com.main.woka.Web.Dao.KcInfo; |
|
|
|
import com.main.woka.Web.Dao.KcInfoRelation; |
|
|
|
import com.main.woka.Web.Dao.KcTwImg; |
|
|
|
import com.main.woka.Web.Mapper.KcFileMapper; |
|
|
|
import com.main.woka.Web.Mapper.KcInfoRelationMapper; |
|
|
|
import com.main.woka.Web.Mapper.TwImgMapper; |
|
|
|
import org.neo4j.driver.v1.StatementResult; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
@ -28,6 +32,13 @@ public class KcInfoController extends BaseController { |
|
|
|
TwImgMapper twImgMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
KcInfoRelationMapper kcInfoRelationMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
Neo4jUtil neo4jUtil; |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/getDocList") |
|
|
|
public AjaxResult getDocList(@RequestBody KcInfo kcInfo) { |
|
|
|
|
|
|
|
@ -152,6 +163,13 @@ public class KcInfoController extends BaseController { |
|
|
|
System.out.println(id); |
|
|
|
AjaxResult ajax = new AjaxResult(); |
|
|
|
KcInfo aa = kcFileMapper.selectById(id); |
|
|
|
//获取和上级关系
|
|
|
|
|
|
|
|
KcInfoRelation r = new KcInfoRelation(); |
|
|
|
r.setSourceId(aa.getParentId()); |
|
|
|
r.setTargetId(aa.getId()); |
|
|
|
String relation = kcInfoRelationMapper.selectKcRelationshipList(r).get(0).getRelation(); |
|
|
|
aa.setRelation(relation); |
|
|
|
|
|
|
|
//判断这个实体是什么类型
|
|
|
|
if (aa.getType() == 1) { |
|
|
|
@ -282,4 +300,717 @@ public class KcInfoController extends BaseController { |
|
|
|
} |
|
|
|
return result.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改信息以及层级
|
|
|
|
@PostMapping(value = "/editInfoGraph") |
|
|
|
public AjaxResult editInfoGraph(@RequestBody KcInfo kcInfo) throws IOException { |
|
|
|
//判断这个info是什么
|
|
|
|
|
|
|
|
//图文
|
|
|
|
if (kcInfo.getType() == 1) { |
|
|
|
Long id = kcInfo.getId(); |
|
|
|
|
|
|
|
String name = kcInfo.getName(); |
|
|
|
String contentInfo = kcInfo.getContentInfo(); |
|
|
|
String imgs = kcInfo.getImgs(); |
|
|
|
String[] imgList = imgs.split(","); |
|
|
|
|
|
|
|
KcInfo aa = kcFileMapper.selectById(id); |
|
|
|
int d = twImgMapper.deleteImgs(id); |
|
|
|
List<KcTwImg> list = new ArrayList<>(); |
|
|
|
if (imgList.length != 0) { |
|
|
|
for (int a = 0; a < imgList.length; a++) { |
|
|
|
KcTwImg twimg = new KcTwImg(); |
|
|
|
twimg.setTwId(id); |
|
|
|
twimg.setImgUrl(imgList[a]); |
|
|
|
list.add(twimg); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if(!imgs.equals("")){ |
|
|
|
KcTwImg twimg = new KcTwImg(); |
|
|
|
twimg.setTwId(id); |
|
|
|
twimg.setImgUrl(imgs); |
|
|
|
list.add(twimg); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
twImgMapper.insertTwImg(list); |
|
|
|
|
|
|
|
if (aa.getTwUrl() == null || aa.getTwUrl().isEmpty() || contentInfo == null) { |
|
|
|
return AjaxResult.error("File path or content is missing"); |
|
|
|
} |
|
|
|
Path currentPath = Paths.get(aa.getTwUrl()); |
|
|
|
String aurl = aa.getTwUrl(); |
|
|
|
String[] urls = aurl.split("\\\\"); |
|
|
|
aurl = urls[urls.length - 1]; |
|
|
|
Path newPath = currentPath.getParent().resolve(aurl); |
|
|
|
// Rename the file
|
|
|
|
Files.move(currentPath, newPath, StandardCopyOption.REPLACE_EXISTING); |
|
|
|
// Update the file with new content
|
|
|
|
Files.write(newPath, contentInfo.getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KcInfo info = new KcInfo(); |
|
|
|
info.setLevel(kcInfo.getLevel()); |
|
|
|
info.setId(id); |
|
|
|
info.setName(name); |
|
|
|
info.setTwUrl(String.valueOf(newPath)); |
|
|
|
info.setTwType(kcInfo.getTwType()); |
|
|
|
|
|
|
|
String cql = "match (r{docId:'" + id + "'}) SET r.name = '" + name + "'"; |
|
|
|
|
|
|
|
StatementResult result1 = neo4jUtil.excuteCypherSql(cql); |
|
|
|
//判断层级是不是修改
|
|
|
|
Long oldLevel = aa.getLevel(); |
|
|
|
|
|
|
|
|
|
|
|
if (oldLevel!=kcInfo.getLevel()) { |
|
|
|
//查询下级
|
|
|
|
Long jj = kcInfo.getLevel() - oldLevel; |
|
|
|
String newLevel = "leve" + kcInfo.getLevel(); |
|
|
|
List<KcInfo> list1 = kcFileMapper.getOneHeader(kcInfo.getId()); |
|
|
|
String cqlLevel = "match (r{docId:'" + kcInfo.getId() + "'}) SET r.leve = '" + newLevel + "'"; |
|
|
|
StatementResult resultLevel = neo4jUtil.excuteCypherSql(cqlLevel); |
|
|
|
|
|
|
|
if (list1.size() != 0) { |
|
|
|
for (int j = 0; j < list1.size(); j++) { |
|
|
|
String newl = ""; |
|
|
|
if (list1.get(j).getLevel() == 1) { |
|
|
|
newl = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 2) { |
|
|
|
newl = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 3) { |
|
|
|
newl = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 4) { |
|
|
|
newl = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 5) { |
|
|
|
newl = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 6) { |
|
|
|
newl = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 7) { |
|
|
|
newl = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel1 = "match (r{docId:'" + list1.get(j).getId() + "'}) SET r.leve = '" + newl + "'"; |
|
|
|
StatementResult resultLevel1 = neo4jUtil.excuteCypherSql(cqlLevel1); |
|
|
|
list1.get(j).setLevel(list1.get(j).getLevel() + jj); |
|
|
|
int a = kcFileMapper.updateDocById(list1.get(j)); |
|
|
|
|
|
|
|
List<KcInfo> list2 = kcFileMapper.getOneHeader(list1.get(j).getId()); |
|
|
|
if (list2.size() != 0) { |
|
|
|
for (int j1 = 0; j1 < list2.size(); j1++) { |
|
|
|
String newl1 = ""; |
|
|
|
if (list2.get(j1).getLevel() == 1) { |
|
|
|
newl1 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 2) { |
|
|
|
newl1 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 3) { |
|
|
|
newl1 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 4) { |
|
|
|
newl1 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 5) { |
|
|
|
newl1 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 6) { |
|
|
|
newl1 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 7) { |
|
|
|
newl1 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel2 = "match (r{docId:'" + list2.get(j1).getId() + "'}) SET r.leve = '" + newl1 + "'"; |
|
|
|
StatementResult resultLevel2 = neo4jUtil.excuteCypherSql(cqlLevel2); |
|
|
|
list2.get(j1).setLevel(list2.get(j1).getLevel() + jj); |
|
|
|
int a2 = kcFileMapper.updateDocById(list2.get(j1)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list3 = kcFileMapper.getOneHeader(list2.get(j1).getId()); |
|
|
|
if (list3.size() != 0) { |
|
|
|
for (int j2 = 0; j2 < list3.size(); j2++) { |
|
|
|
String newl2 = ""; |
|
|
|
if (list3.get(j2).getLevel() == 1) { |
|
|
|
newl2 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 2) { |
|
|
|
newl2 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 3) { |
|
|
|
newl2 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 4) { |
|
|
|
newl2 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 5) { |
|
|
|
newl2 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 6) { |
|
|
|
newl2 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 7) { |
|
|
|
newl2 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel3 = "match (r{docId:'" + list3.get(j2).getId() + "'}) SET r.leve = '" + newl2 + "'"; |
|
|
|
StatementResult resultLevel3 = neo4jUtil.excuteCypherSql(cqlLevel3); |
|
|
|
list3.get(j2).setLevel(list3.get(j2).getLevel() + jj); |
|
|
|
int a3 = kcFileMapper.updateDocById(list3.get(j2)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list4 = kcFileMapper.getOneHeader(list3.get(j2).getId()); |
|
|
|
if (list4.size() != 0) { |
|
|
|
for (int j3 = 0; j3 < list4.size(); j3++) { |
|
|
|
String newl3 = ""; |
|
|
|
if (list4.get(j3).getLevel() == 1) { |
|
|
|
newl3 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 2) { |
|
|
|
newl3 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 3) { |
|
|
|
newl3 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 4) { |
|
|
|
newl3 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 5) { |
|
|
|
newl3 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 6) { |
|
|
|
newl3 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 7) { |
|
|
|
newl3 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel4 = "match (r{docId:'" + list4.get(j3).getId() + "'}) SET r.leve = '" + newl3 + "'"; |
|
|
|
StatementResult resultLevel4 = neo4jUtil.excuteCypherSql(cqlLevel4); |
|
|
|
list4.get(j3).setLevel(list4.get(j3).getLevel() + jj); |
|
|
|
int a4 = kcFileMapper.updateDocById(list4.get(j3)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list5 = kcFileMapper.getOneHeader(list4.get(j3).getId()); |
|
|
|
if (list5.size() != 0) { |
|
|
|
for (int j4 = 0; j4 < list5.size(); j4++) { |
|
|
|
String newl4 = ""; |
|
|
|
if (list5.get(j4).getLevel() == 1) { |
|
|
|
newl4 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 2) { |
|
|
|
newl4 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 3) { |
|
|
|
newl4 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 4) { |
|
|
|
newl4 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 5) { |
|
|
|
newl4 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 6) { |
|
|
|
newl4 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 7) { |
|
|
|
newl4 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel5 = "match (r{docId:'" + list5.get(j4).getId() + "'}) SET r.leve = '" + newl4 + "'"; |
|
|
|
StatementResult resultLevel5 = neo4jUtil.excuteCypherSql(cqlLevel5); |
|
|
|
list5.get(j4).setLevel(list5.get(j4).getLevel() + jj); |
|
|
|
int a5 = kcFileMapper.updateDocById(list5.get(j4)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list6 = kcFileMapper.getOneHeader(list5.get(j4).getId()); |
|
|
|
if (list6.size() != 0) { |
|
|
|
for (int j5 = 0; j5 < list6.size(); j5++) { |
|
|
|
String newl5 = ""; |
|
|
|
if (list6.get(j5).getLevel() == 1) { |
|
|
|
newl5 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 2) { |
|
|
|
newl5 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 3) { |
|
|
|
newl5 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 4) { |
|
|
|
newl5 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 5) { |
|
|
|
newl5 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 6) { |
|
|
|
newl5 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 7) { |
|
|
|
newl5 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel6 = "match (r{docId:'" + list6.get(j5).getId() + "'}) SET r.leve = '" + newl5 + "'"; |
|
|
|
StatementResult resultLevel6 = neo4jUtil.excuteCypherSql(cqlLevel6); |
|
|
|
list6.get(j5).setLevel(list6.get(j5).getLevel() + jj); |
|
|
|
int a6 = kcFileMapper.updateDocById(list6.get(j5)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list7 = kcFileMapper.getOneHeader(list6.get(j5).getId()); |
|
|
|
if (list7.size() != 0) { |
|
|
|
for (int j6 = 0; j6 < list7.size(); j6++) { |
|
|
|
String newl6 = ""; |
|
|
|
if (list7.get(j6).getLevel() == 1) { |
|
|
|
newl6 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 2) { |
|
|
|
newl6 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 3) { |
|
|
|
newl6 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 4) { |
|
|
|
newl6 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 5) { |
|
|
|
newl6 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 6) { |
|
|
|
newl6 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 7) { |
|
|
|
newl6 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel7 = "match (r{docId:'" + list7.get(j6).getId() + "'}) SET r.leve = '" + newl6 + "'"; |
|
|
|
StatementResult resultLevel7 = neo4jUtil.excuteCypherSql(cqlLevel7); |
|
|
|
list7.get(j6).setLevel(list7.get(j6).getLevel() + jj); |
|
|
|
int a7 = kcFileMapper.updateDocById(list7.get(j6)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (aa.getParentId() != kcInfo.getParentId()) { |
|
|
|
|
|
|
|
//修改上级
|
|
|
|
//修改relation
|
|
|
|
KcInfo zp = kcFileMapper.selectDocByIdId(kcInfo.getParentId()); |
|
|
|
KcInfoRelation r = new KcInfoRelation(); |
|
|
|
r.setSourceId(aa.getParentId()); |
|
|
|
r.setTargetId(id); |
|
|
|
List<KcInfoRelation> aa1 = kcInfoRelationMapper.selectKcRelationshipList(r); |
|
|
|
KcInfoRelation qq = aa1.get(0); |
|
|
|
qq.setSourceId(kcInfo.getParentId()); |
|
|
|
qq.setSourceName(zp.getName()); |
|
|
|
qq.setRelation(kcInfo.getRelation()); |
|
|
|
int g = kcInfoRelationMapper.updateKcRelationship(qq); |
|
|
|
|
|
|
|
//删除过去的这个关系
|
|
|
|
String cqrD = "MATCH (n:Doc{docId:'" + aa.getParentId() + "'})-[r]-(n2:Doc{docId:'" + id + "'}) DELETE r"; |
|
|
|
StatementResult resultD = neo4jUtil.excuteCypherSql(cqrD); |
|
|
|
|
|
|
|
if (kcInfo.getRelation() != null && !kcInfo.getRelation().equals("")) { |
|
|
|
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + kcInfo.getParentId() + "' AND b.docId = '" + kcInfo.getId() + "'CREATE (a)-[r:"+kcInfo.getRelation()+"{ name: '"+kcInfo.getRelation()+"'}] -> (b) RETURN r"; |
|
|
|
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC); |
|
|
|
} else { |
|
|
|
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + kcInfo.getParentId() + "' AND b.docId = '" + kcInfo.getId() + "'CREATE (a)-[r:"+"属于"+"{ name: '属于'}] -> (b) RETURN r"; |
|
|
|
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
KcInfo zp = kcFileMapper.selectDocByIdId(kcInfo.getParentId()); |
|
|
|
KcInfoRelation r = new KcInfoRelation(); |
|
|
|
r.setSourceId(aa.getParentId()); |
|
|
|
r.setTargetId(id); |
|
|
|
List<KcInfoRelation> aa1 = kcInfoRelationMapper.selectKcRelationshipList(r); |
|
|
|
KcInfoRelation qq = aa1.get(0); |
|
|
|
if(!qq.getRelation().equals(kcInfo.getRelation())){ |
|
|
|
System.out.println("--------ppppppppppppppppppp"); |
|
|
|
qq.setSourceId(kcInfo.getParentId()); |
|
|
|
qq.setTargetId(kcInfo.getId()); |
|
|
|
qq.setRelation(kcInfo.getRelation()); |
|
|
|
int g = kcInfoRelationMapper.updateKcRelationship(qq); |
|
|
|
|
|
|
|
|
|
|
|
//删除过去的这个关系
|
|
|
|
String cqrD = "MATCH (n:Doc{docId:'" + kcInfo.getParentId() + "'})-[r]-(n2:Doc{docId:'" + kcInfo.getId() + "'}) DELETE r"; |
|
|
|
StatementResult resultD = neo4jUtil.excuteCypherSql(cqrD); |
|
|
|
|
|
|
|
if (kcInfo.getRelation() != null && !kcInfo.getRelation().equals("")) { |
|
|
|
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + kcInfo.getParentId() + "' AND b.docId = '" + kcInfo.getId() + "'CREATE (a)-[r:"+kcInfo.getRelation()+"{ name: '"+kcInfo.getRelation()+"'}] -> (b) RETURN r"; |
|
|
|
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC); |
|
|
|
} else { |
|
|
|
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + kcInfo.getParentId() + "' AND b.docId = '" + kcInfo.getId() + "'CREATE (a)-[r:"+"属于"+"{ name: '属于'}] -> (b) RETURN r"; |
|
|
|
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int a = kcFileMapper.updateDocById(info); |
|
|
|
if (a > 0) { |
|
|
|
return AjaxResult.success(); |
|
|
|
} else { |
|
|
|
return AjaxResult.error(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//图文
|
|
|
|
if (kcInfo.getType() == 2) { |
|
|
|
System.out.println("jjjjj===="); |
|
|
|
System.out.println(kcInfo.getSpUrl()); |
|
|
|
System.out.println(kcInfo); |
|
|
|
Long id = kcInfo.getId(); |
|
|
|
String name = kcInfo.getName(); |
|
|
|
String spUrl = kcInfo.getSpUrl(); |
|
|
|
KcInfo aa = kcFileMapper.selectById(id); |
|
|
|
aa.setSpUrl(spUrl); |
|
|
|
aa.setName(name); |
|
|
|
aa.setSpType(kcInfo.getSpType()); |
|
|
|
|
|
|
|
|
|
|
|
KcInfo info = new KcInfo(); |
|
|
|
info.setLevel(kcInfo.getLevel()); |
|
|
|
info.setId(id); |
|
|
|
info.setName(name); |
|
|
|
|
|
|
|
String cql = "match (r{docId:'" + id + "'}) SET r.name = '" + name + "'"; |
|
|
|
|
|
|
|
StatementResult result1 = neo4jUtil.excuteCypherSql(cql); |
|
|
|
//判断层级是不是修改
|
|
|
|
Long oldLevel = aa.getLevel(); |
|
|
|
if (oldLevel!=kcInfo.getLevel()) { |
|
|
|
//查询下级
|
|
|
|
Long jj = kcInfo.getLevel() - oldLevel; |
|
|
|
String newLevel = "leve" + kcInfo.getLevel(); |
|
|
|
List<KcInfo> list1 = kcFileMapper.getOneHeader(kcInfo.getId()); |
|
|
|
String cqlLevel = "match (r{docId:'" + kcInfo.getId() + "'}) SET r.leve = '" + newLevel + "'"; |
|
|
|
StatementResult resultLevel = neo4jUtil.excuteCypherSql(cqlLevel); |
|
|
|
|
|
|
|
if (list1.size() != 0) { |
|
|
|
for (int j = 0; j < list1.size(); j++) { |
|
|
|
String newl = ""; |
|
|
|
if (list1.get(j).getLevel() == 1) { |
|
|
|
newl = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 2) { |
|
|
|
newl = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 3) { |
|
|
|
newl = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 4) { |
|
|
|
newl = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 5) { |
|
|
|
newl = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 6) { |
|
|
|
newl = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list1.get(j).getLevel() == 7) { |
|
|
|
newl = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel1 = "match (r{docId:'" + list1.get(j).getId() + "'}) SET r.leve = '" + newl + "'"; |
|
|
|
StatementResult resultLevel1 = neo4jUtil.excuteCypherSql(cqlLevel1); |
|
|
|
list1.get(j).setLevel(list1.get(j).getLevel() + jj); |
|
|
|
int a = kcFileMapper.updateDocById(list1.get(j)); |
|
|
|
|
|
|
|
List<KcInfo> list2 = kcFileMapper.getOneHeader(list1.get(j).getId()); |
|
|
|
if (list2.size() != 0) { |
|
|
|
for (int j1 = 0; j1 < list2.size(); j1++) { |
|
|
|
String newl1 = ""; |
|
|
|
if (list2.get(j1).getLevel() == 1) { |
|
|
|
newl1 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 2) { |
|
|
|
newl1 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 3) { |
|
|
|
newl1 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 4) { |
|
|
|
newl1 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 5) { |
|
|
|
newl1 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 6) { |
|
|
|
newl1 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list2.get(j1).getLevel() == 7) { |
|
|
|
newl1 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel2 = "match (r{docId:'" + list2.get(j1).getId() + "'}) SET r.leve = '" + newl1 + "'"; |
|
|
|
StatementResult resultLevel2 = neo4jUtil.excuteCypherSql(cqlLevel2); |
|
|
|
list2.get(j1).setLevel(list2.get(j1).getLevel() + jj); |
|
|
|
int a2 = kcFileMapper.updateDocById(list2.get(j1)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list3 = kcFileMapper.getOneHeader(list2.get(j1).getId()); |
|
|
|
if (list3.size() != 0) { |
|
|
|
for (int j2 = 0; j2 < list3.size(); j2++) { |
|
|
|
String newl2 = ""; |
|
|
|
if (list3.get(j2).getLevel() == 1) { |
|
|
|
newl2 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 2) { |
|
|
|
newl2 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 3) { |
|
|
|
newl2 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 4) { |
|
|
|
newl2 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 5) { |
|
|
|
newl2 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 6) { |
|
|
|
newl2 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list3.get(j2).getLevel() == 7) { |
|
|
|
newl2 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel3 = "match (r{docId:'" + list3.get(j2).getId() + "'}) SET r.leve = '" + newl2 + "'"; |
|
|
|
StatementResult resultLevel3 = neo4jUtil.excuteCypherSql(cqlLevel3); |
|
|
|
list3.get(j2).setLevel(list3.get(j2).getLevel() + jj); |
|
|
|
int a3 = kcFileMapper.updateDocById(list3.get(j2)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list4 = kcFileMapper.getOneHeader(list3.get(j2).getId()); |
|
|
|
if (list4.size() != 0) { |
|
|
|
for (int j3 = 0; j3 < list4.size(); j3++) { |
|
|
|
String newl3 = ""; |
|
|
|
if (list4.get(j3).getLevel() == 1) { |
|
|
|
newl3 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 2) { |
|
|
|
newl3 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 3) { |
|
|
|
newl3 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 4) { |
|
|
|
newl3 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 5) { |
|
|
|
newl3 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 6) { |
|
|
|
newl3 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list4.get(j3).getLevel() == 7) { |
|
|
|
newl3 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel4 = "match (r{docId:'" + list4.get(j3).getId() + "'}) SET r.leve = '" + newl3 + "'"; |
|
|
|
StatementResult resultLevel4 = neo4jUtil.excuteCypherSql(cqlLevel4); |
|
|
|
list4.get(j3).setLevel(list4.get(j3).getLevel() + jj); |
|
|
|
int a4 = kcFileMapper.updateDocById(list4.get(j3)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list5 = kcFileMapper.getOneHeader(list4.get(j3).getId()); |
|
|
|
if (list5.size() != 0) { |
|
|
|
for (int j4 = 0; j4 < list5.size(); j4++) { |
|
|
|
String newl4 = ""; |
|
|
|
if (list5.get(j4).getLevel() == 1) { |
|
|
|
newl4 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 2) { |
|
|
|
newl4 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 3) { |
|
|
|
newl4 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 4) { |
|
|
|
newl4 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 5) { |
|
|
|
newl4 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 6) { |
|
|
|
newl4 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list5.get(j4).getLevel() == 7) { |
|
|
|
newl4 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel5 = "match (r{docId:'" + list5.get(j4).getId() + "'}) SET r.leve = '" + newl4 + "'"; |
|
|
|
StatementResult resultLevel5 = neo4jUtil.excuteCypherSql(cqlLevel5); |
|
|
|
list5.get(j4).setLevel(list5.get(j4).getLevel() + jj); |
|
|
|
int a5 = kcFileMapper.updateDocById(list5.get(j4)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list6 = kcFileMapper.getOneHeader(list5.get(j4).getId()); |
|
|
|
if (list6.size() != 0) { |
|
|
|
for (int j5 = 0; j5 < list6.size(); j5++) { |
|
|
|
String newl5 = ""; |
|
|
|
if (list6.get(j5).getLevel() == 1) { |
|
|
|
newl5 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 2) { |
|
|
|
newl5 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 3) { |
|
|
|
newl5 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 4) { |
|
|
|
newl5 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 5) { |
|
|
|
newl5 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 6) { |
|
|
|
newl5 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list6.get(j5).getLevel() == 7) { |
|
|
|
newl5 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel6 = "match (r{docId:'" + list6.get(j5).getId() + "'}) SET r.leve = '" + newl5 + "'"; |
|
|
|
StatementResult resultLevel6 = neo4jUtil.excuteCypherSql(cqlLevel6); |
|
|
|
list6.get(j5).setLevel(list6.get(j5).getLevel() + jj); |
|
|
|
int a6 = kcFileMapper.updateDocById(list6.get(j5)); |
|
|
|
|
|
|
|
|
|
|
|
List<KcInfo> list7 = kcFileMapper.getOneHeader(list6.get(j5).getId()); |
|
|
|
if (list7.size() != 0) { |
|
|
|
for (int j6 = 0; j6 < list7.size(); j6++) { |
|
|
|
String newl6 = ""; |
|
|
|
if (list7.get(j6).getLevel() == 1) { |
|
|
|
newl6 = "leve" + (1 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 2) { |
|
|
|
newl6 = "leve" + (2 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 3) { |
|
|
|
newl6 = "leve" + (3 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 4) { |
|
|
|
newl6 = "leve" + (4 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 5) { |
|
|
|
newl6 = "leve" + (5 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 6) { |
|
|
|
newl6 = "leve" + (6 + jj); |
|
|
|
} |
|
|
|
if (list7.get(j6).getLevel() == 7) { |
|
|
|
newl6 = "leve" + (7 + jj); |
|
|
|
} |
|
|
|
String cqlLevel7 = "match (r{docId:'" + list7.get(j6).getId() + "'}) SET r.docLeve = '" + newl6 + "'"; |
|
|
|
StatementResult resultLevel7 = neo4jUtil.excuteCypherSql(cqlLevel7); |
|
|
|
list7.get(j6).setLevel(list7.get(j6).getLevel() + jj); |
|
|
|
int a7 = kcFileMapper.updateDocById(list7.get(j6)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (aa.getParentId() != kcInfo.getParentId()) { |
|
|
|
|
|
|
|
//修改上级
|
|
|
|
//修改relation
|
|
|
|
KcInfo zp = kcFileMapper.selectDocByIdId(kcInfo.getParentId()); |
|
|
|
KcInfoRelation r = new KcInfoRelation(); |
|
|
|
r.setSourceId(aa.getParentId()); |
|
|
|
r.setTargetId(id); |
|
|
|
List<KcInfoRelation> aa1 = kcInfoRelationMapper.selectKcRelationshipList(r); |
|
|
|
KcInfoRelation qq = aa1.get(0); |
|
|
|
qq.setSourceId(kcInfo.getParentId()); |
|
|
|
qq.setSourceName(zp.getName()); |
|
|
|
qq.setRelation(kcInfo.getRelation()); |
|
|
|
int g = kcInfoRelationMapper.updateKcRelationship(qq); |
|
|
|
|
|
|
|
//删除过去的这个关系
|
|
|
|
String cqrD = "MATCH (n:Doc{docId:'" + aa.getParentId() + "'})-[r]-(n2:Doc{docId:'" + id + "'}) DELETE r"; |
|
|
|
StatementResult resultD = neo4jUtil.excuteCypherSql(cqrD); |
|
|
|
|
|
|
|
if (kcInfo.getRelation() != null && !kcInfo.getRelation().equals("")) { |
|
|
|
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + kcInfo.getParentId() + "' AND b.docId = '" + kcInfo.getId() + "'CREATE (a)-[r:"+kcInfo.getRelation()+"{ name: '"+kcInfo.getRelation()+"'}] -> (b) RETURN r"; |
|
|
|
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC); |
|
|
|
} else { |
|
|
|
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + kcInfo.getParentId() + "' AND b.docId = '" + kcInfo.getId() + "'CREATE (a)-[r:"+"属于"+"{ name: '属于'}] -> (b) RETURN r"; |
|
|
|
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
KcInfo zp = kcFileMapper.selectDocByIdId(kcInfo.getParentId()); |
|
|
|
KcInfoRelation r = new KcInfoRelation(); |
|
|
|
r.setSourceId(aa.getParentId()); |
|
|
|
r.setTargetId(id); |
|
|
|
List<KcInfoRelation> aa1 = kcInfoRelationMapper.selectKcRelationshipList(r); |
|
|
|
KcInfoRelation qq = aa1.get(0); |
|
|
|
if(!qq.getRelation().equals(kcInfo.getRelation())){ |
|
|
|
System.out.println("--------ppppppppppppppppppp"); |
|
|
|
qq.setSourceId(kcInfo.getParentId()); |
|
|
|
qq.setTargetId(kcInfo.getId()); |
|
|
|
qq.setRelation(kcInfo.getRelation()); |
|
|
|
int g = kcInfoRelationMapper.updateKcRelationship(qq); |
|
|
|
|
|
|
|
|
|
|
|
//删除过去的这个关系
|
|
|
|
String cqrD = "MATCH (n:Doc{docId:'" + kcInfo.getParentId() + "'})-[r]-(n2:Doc{docId:'" + kcInfo.getId() + "'}) DELETE r"; |
|
|
|
StatementResult resultD = neo4jUtil.excuteCypherSql(cqrD); |
|
|
|
if (kcInfo.getRelation() != null && !kcInfo.getRelation().equals("")) { |
|
|
|
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + kcInfo.getParentId() + "' AND b.docId = '" + kcInfo.getId() + "'CREATE (a)-[r:"+kcInfo.getRelation()+"{ name: '"+kcInfo.getRelation()+"'}] -> (b) RETURN r"; |
|
|
|
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC); |
|
|
|
} else { |
|
|
|
String cqrC = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + kcInfo.getParentId() + "' AND b.docId = '" + kcInfo.getId() + "'CREATE (a)-[r:"+"属于"+"{ name: '属于'}] -> (b) RETURN r"; |
|
|
|
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int a = kcFileMapper.updateDocById(info); |
|
|
|
if (a > 0) { |
|
|
|
return AjaxResult.success(); |
|
|
|
} else { |
|
|
|
return AjaxResult.error(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.error(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|