Browse Source

图谱新增节点以及修改节点

zxm
zhangxiaomeng 1 year ago
parent
commit
25c4a213b1
  1. 13
      kcui/src/api/kcInfo.js
  2. 2
      kcui/src/view/DhInfo.vue
  3. 445
      kcui/src/view/Graph.vue
  4. 2
      kcui/src/view/JsInfo.vue
  5. 3
      kcui/src/view/SpInfo.vue
  6. 2
      kcui/src/view/TWInfo.vue
  7. 731
      src/main/java/com/main/woka/Web/Controller/KcInfoController.java
  8. 4
      src/main/java/com/main/woka/Web/Controller/KcTlFileController.java
  9. 11
      src/main/java/com/main/woka/Web/Dao/KcInfo.java
  10. 1
      src/main/resources/Mapper/KcFileMapper.xml
  11. 10
      src/main/resources/Mapper/KcInfoRelationMapper.xml

13
kcui/src/api/kcInfo.js

@ -71,3 +71,16 @@ export function getInfo(params) {
}
})
}
export function editInfoGraph(data) {
return request({
url: '/kcDoc/editInfoGraph',
method: 'post',
data:data,
headers: {
'Authorization': 'Bearer '+ getToken() // 将 token 放在请求头中
}
})
}

2
kcui/src/view/DhInfo.vue

@ -195,7 +195,7 @@ export default {
{id: 2, name: "动画显示", info: "DhInfo"},
{id: 3, name: "计算模块", info: "JsInfo"},
{id: 4, name: "知识图谱", info: "Graph"},
{id: 4, name: "帮助文档", info: "Help"}
{id: 5, name: "帮助文档", info: "Help"}
],
page: "动画显示",
typeList: ["全部", "起降", "飞行", "通信载荷使用", "探测载荷使用", "攻击载荷使用"],

445
kcui/src/view/Graph.vue

@ -24,7 +24,8 @@
<img src="../assets/img/twCircle.png"
style="width: 0.9vw;height:0.9vw;object-fit: contain;float: right;margin-top: 7%;">
<div style="width: 55%;text-align: center;">
{{ item.name }}</div>
{{ item.name }}
</div>
<img src="../assets/img/jiantouchoose.png"
style="width: 0.9vw;height:0.9vw;object-fit: contain;float: right;margin-top: 7%;">
<img src="../assets/img/muluchoose.png"
@ -39,14 +40,17 @@
<div style="color: white; margin:1vw 2vw 0vw 2vw;width: 100%;">
<div style="width: 100%;display: flex;flex-direction: row;justify-content: space-around;">
<div style="width: 4vw;">关键字</div>
<input style="background-color: transparent; border: none; border-bottom: 1px solid white; color: white; outline: none;" placeholder="请输入关键字" v-model="keywords"/>
<div @click="getInfo1" style="width: 3vw;height: 1.5vw;background-color: #001c3a;text-align: center;border-radius:1vw;line-height: 1.5vw;">
查询
</div>
<div style="width: 4vw;">关键字</div>
<input
style="background-color: transparent; border: none; border-bottom: 1px solid white; color: white; outline: none;"
placeholder="请输入关键字" v-model="keywords"/>
<div @click="getInfo1"
style="width: 3vw;height: 1.5vw;background-color: #001c3a;text-align: center;border-radius:1vw;line-height: 1.5vw;">
查询
</div>
<div style="margin-left: 1vw;" v-if="userType==1">
<el-button type="primary" plain icon="el-icon-upload2" size="mini" @click="openFileInput" >导入</el-button>
<el-button type="primary" plain icon="el-icon-upload2" size="mini" @click="openFileInput">导入</el-button>
<input
ref="fileInput"
type="file"
@ -83,6 +87,11 @@
:value="item.value">
</el-option>
</el-select>
<div @click="getInfo1"
style="width: 3vw;height: 1.5vw;background-color: #001c3a;text-align: center;border-radius:1vw;line-height: 1.5vw;">
生成报告
</div>
</div>
</div>
</div>
@ -96,11 +105,36 @@
</div>
</div>
</div>
<!-- 弹窗 -->
<!-- 操作弹窗 -->
<el-dialog
title="添加分支内容"
title="操作分支内容"
:visible.sync="isModalVisible"
append-to-body
top="10vh"
custom-class="custom-dialog"
>
<el-form label-width="90px">
<el-form-item label="节点名称">
<el-input v-model="nodeInfo.name" readonly></el-input>
</el-form-item>
<el-form-item label="节点层级">
<el-input v-model="nodeInfo.leve" readonly></el-input>
</el-form-item>
<el-form-item label="操作">
<el-button type="primary" @click="openAdd()">新增下级</el-button>
<el-button type="warning" @click="openEdit()">修改</el-button>
<el-button type="danger">删除</el-button>
</el-form-item>
</el-form>
</el-dialog>
<!-- 新增分支弹窗 -->
<el-dialog
title="添加分支内容"
:visible.sync="isModalVisible1"
append-to-body
top="4vh"
custom-class="custom-dialog"
>
@ -120,7 +154,7 @@
<el-input v-model="newBranchContent"></el-input>
</el-form-item>
<el-form-item style="position: relative ;" label="节点内容" v-if="this.typeValue=='tw'">
<Editor v-model="newBranchValue" style="height: 10vw;"></Editor>
<Editor v-model="newBranchValue" style="height: 10vw;"></Editor>
</el-form-item>
<el-form-item label="上传视频" prop="spUrl" v-if="this.typeValue=='sp'">
@ -140,7 +174,8 @@
<div v-if="!videoFlag && showVideoPath" style="display: flex; flex-wrap: wrap; gap: 10px;">
<div v-for="(url, index) in showVideoPath.split(',')" :key="url"
style="position: relative; flex: 1 1 calc(33.333% - 20px); min-width: 200px; margin-bottom: 10px;">
<video :src="`${videoUpload.url2}${url}`" style="width:90%; height: auto;border-radius: 0.5vw;" class="avatar video-avatar" controls>
<video :src="`${videoUpload.url2}${url}`" style="width:90%; height: auto;border-radius: 0.5vw;"
class="avatar video-avatar" controls>
您的浏览器不支持视频播放
</video>
<img
@ -153,7 +188,9 @@
</div>
<el-progress :stroke-width="10" class="progressType" v-if="videoFlag"
type="circle" :percentage="videoUploadPercent" style="margin-top:30px;"></el-progress>
<el-button style="z-index: 999;" class="video-btn" slot="trigger" size="small" type="primary">点击上传视频</el-button>
<el-button style="z-index: 999;" class="video-btn" slot="trigger" size="small" type="primary">
点击上传视频
</el-button>
</el-upload>
</el-form-item>
@ -174,6 +211,108 @@
</span>
</el-dialog>
<!-- 修改分支弹窗 -->
<el-dialog
title="修改分支内容"
:visible.sync="isModalVisible2"
append-to-body
top="2vw"
style="height: 70vw;"
custom-class="custom-dialog"
>
<el-form label-width="90px">
<el-form-item label="fileId">
<el-input v-model="editFileId"></el-input>
</el-form-item>
<el-form-item label="类型">
<el-select v-model="editType" placeholder="请选择类型">
<el-option label="图文" value="tw"></el-option>
<el-option label="视频" value="sp"></el-option>
<el-option label="动画" value="dh"></el-option>
<el-option label="计算模块" value="js"></el-option>
</el-select>
</el-form-item>
<el-form-item label="节点名称">
<el-input v-model="editName"></el-input>
</el-form-item>
<el-form-item style="position: relative ;" label="节点内容" v-if="this.editType=='tw'">
<Editor v-model="this.editContent" style="height: 8vw;"></Editor>
</el-form-item>
<el-form-item style="position: relative;margin-top: 5vw;" label="相关图片" v-if="this.editType=='tw'">
<el-upload
action="http://127.0.0.1:10031/fileUpdate/upload"
list-type="picture-card"
:on-remove="handleRemove"
:file-list="fileList"
:multiple="true"
:limit="9"
:on-exceed="handleExceed"
:before-upload="beforeUpload"
:on-success="handleSuccess"
:on-error="handleError">
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
<el-form-item label="上传视频" prop="spUrl" v-if="this.editType=='sp'">
<el-upload
class="avatar-uploader el-upload--text"
multiple
:headers="videoUpload.headers"
:action="videoUpload.url"
:file-list="videoFileList"
:show-file-list="false"
accept=".mp4"
:on-success="handleVideoSuccess"
:before-upload="beforeUploadVideo"
:on-progress="uploadVideoProcess"
:on-remove="handleVideoRemove"
>
<div v-if="!videoFlag && showVideoPath" style="display: flex; flex-wrap: wrap; gap: 10px;">
<div style="position: relative; flex: 1 1 calc(33.333% - 20px); min-width: 200px; margin-bottom: 10px;">
<video :src="showVideoPath" style="width:90%; height: auto;border-radius: 0.5vw;"
class="avatar video-avatar" controls>
您的浏览器不支持视频播放
</video>
<img
src="../assets/img/delete.png"
@click.stop="handleVideoRemove(videoFileList[0])"
style="width: 35px; height: 35px;position: absolute; top: 5px; left: 5px; cursor: pointer; z-index: 999;"
alt="删除"
/>
</div>
</div>
<el-progress :stroke-width="10" class="progressType" v-if="videoFlag"
type="circle" :percentage="videoUploadPercent" style="margin-top:30px;"></el-progress>
<el-button style="z-index: 999;" class="video-btn" slot="trigger" size="small" type="primary">
点击上传视频
</el-button>
</el-upload>
</el-form-item>
<el-form-item label="父级节点ID" >
<el-input v-model="editParentId" disabled></el-input>
</el-form-item>
<el-form-item label="关系">
<el-input v-model="editRelation"
@input="editRelation = $event.target.value.replace(/[^a-zA-Z\u4e00-\u9fa5]/g, '')"></el-input>
</el-form-item>
<el-form-item label="层级">
<el-input-number v-model="editLeve" controls-position="right" :min="1"></el-input-number>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="closeModal1"> </el-button>
<el-button type="primary" @click="editSubmit"> </el-button>
</span>
</el-dialog>
</div>
</div>
</div>
@ -186,7 +325,7 @@
<script>
import headInfo from '@/components/Head.vue';
import Foot from "@/components/Foot.vue";
import {getDocList, getInfo, getTwInfo} from "@/api/kcInfo";
import {editInfoGraph, getDocList, getInfo, getTwInfo} from "@/api/kcInfo";
import {getgraphInfo, test} from "@/api/login";
import VisGraph from '@/assets/js/graphvis.min.20241008.js'
import LayoutFactory from '@/assets/js/graphvis.layout.min.js'
@ -197,7 +336,7 @@ import {getToken} from "@/utils/auth";
export default {
// eslint-disable-next-line vue/multi-word-component-names
name: 'TWInfo',
name: 'Graph',
components: {Editor, Foot, headInfo},
data() {
return {
@ -209,7 +348,7 @@ export default {
{id: 2, name: "动画显示", info: "DhInfo"},
{id: 3, name: "计算模块", info: "JsInfo"},
{id: 4, name: "知识图谱", info: "Graph"},
{id: 4, name: "帮助文档", info: "Help"}
{id: 5, name: "帮助文档", info: "Help"}
],
page: "知识图谱",
typeList: ["海洋大气", "海洋文学", "海洋地理", "复杂水声", "复杂电磁"],
@ -232,6 +371,7 @@ export default {
config,
visGraph: null, // VisGraph
isModalVisible: false,
isModalVisible1: false,
newBranchContent: '',
selectedNode: null,
@ -307,16 +447,34 @@ export default {
//
headers: {Authorization: "Bearer " + getToken()},
//
url: "http://127.0.0.1:10031/fileUpdate/upload",
url: "http://127.0.0.1:10031/fileUpdate/upload",
url2: "http://127.0.0.1:10031",
},
videoFlag: false, //
videoUploadPercent: "", //
isShowUploadVideo: false, //
videoFileList:[],
videoFileList: [],
showVideoPath: "",
uploadUrl: "",//
form:{},
form: {},
nodeInfo: {},
//
isModalVisible2:false,
fileList:[],
isUpload: 0,
editName:"",
editType:0,
editLeve:0,
editParentId:0,
editFileId:0,
editContent:0,
editRelation:"",
}
},
@ -419,12 +577,9 @@ export default {
getTwInfo(data).then((res) => {
console.log(res.data)
})
},
goBook() {
this.$router.push({name: 'Book', query: {id: '1'}})
},
onCreated(editor) {
this.editor = Object.seal(editor) // Object.seal()
},
@ -497,7 +652,7 @@ export default {
node: {
...this.config.node,
ondblClick: (event, node) => {
if(this.userType==1){
if (this.userType == 1) {
this.showPopup(node);
}
@ -506,33 +661,237 @@ export default {
};
this.visGraph = new VisGraph(document.getElementById('graph-panel'), configWithEvents);
},
// eslint-disable-next-line no-unused-vars
async showPopup(node) {
this.selectedNode = node;
this.newBranchParentId = node.properties.docId;
this.newBranchLevel = parseInt(node.properties.leve) + 1;
this.isModalVisible = true; //
this.nodeInfo = node.properties;
},
async openAdd() {
this.selectedNode = this.nodeInfo;
this.newBranchParentId = this.nodeInfo.docId;
this.newBranchLevel = parseInt(this.nodeInfo.leve) + 1;
try {
const response = await this.getFileIdByDocId({docId: node.properties.docId});
const response = await this.getFileIdByDocId({docId: this.nodeInfo.docId});
this.newBranchFileId = response.fileId;
this.isModalVisible1 = true;
} catch (error) {
console.error('Failed to fetch file ID:', error);
alert('无法获取文件ID,请稍后再试。');
return;
}
},
async openEdit() {
this.isModalVisible2 = true;
var data = {
'id': this.nodeInfo.docId,
}
getInfo(data).then((res) => {
console.log(res.data.data)
if(res.data.data.type==1){
this.editType = "tw";
}
if(res.data.data.type==2){
this.editType = "sp";
}
if(res.data.data.type==3){
this.editType = "dh";
}
if(res.data.data.type==4){
this.editType = "js";
}
this.isModalVisible = true; //
this.editName = res.data.data.name;
this.editLeve = res.data.data.contentInfo;
this.editParentId = res.data.data.parentId;
this.editFileId = res.data.data.fileId;
this.editRelation = res.data.data.relation;
if(this.editType=='tw'){
this.editContent = res.data.data.contentInfo;
var imgs = res.data.data.imgList;
console.log(imgs)
this.fileList = [];
for (let j = 0; j < imgs.length; j++) {
var ii = {
uuid: imgs[j].imgId,
url: imgs[j].imgUrl
}
this.fileList.push(ii)
}
}
if(this.editType=='sp'){
console.log(res.data.data.spUrl)
this.videoFileList = [];
this.showVideoPath = "";
if (res.data.data.spUrl != null) {
this.videoFileList.push({url: res.data.data.spUrl, name: res.data.data.name});
this.showVideoPath = res.data.data.spUrl;
}
}
});
},
async editSubmit() {
console.log("kjkjkkkjjkkjkj")
console.log(this.editType)
if (this.editType == 'tw') {
const content = this.editName.trim();
const value = this.editContent.trim();
const fileId = this.editFileId.trim();
const relation = this.editRelation.trim();
if (content) {
var urlStr = "";
for (let f = 0; f < this.fileList.length; f++) {
if (f == 0) {
if (this.fileList[f].response != null) {
urlStr = this.fileList[f].response.data.url
} else {
urlStr = this.fileList[f].url
}
} else {
if (this.fileList[f].response != null) {
urlStr = urlStr + "," + this.fileList[f].response.data.url
} else {
urlStr = urlStr + "," + this.fileList[f].url
}
}
}
//
const data = {
id:this.nodeInfo.docId,
fileId: fileId,
name: content,
contentInfo: value,
relation: relation,
parentId: this.editParentId,
level: this.editLeve,
type: 1,
imgs: urlStr,
};
try {
editInfoGraph(data).then((res)=>{
console.log(res);
})
//
this.visGraph.drawData(this.graphData);
this.reLayout();
this.closeModal(); //
this.isModalVisible = false;
} catch (error) {
console.error('Failed to add new branch:', error);
alert('Failed to add new branch. Please try again.');
}
}
}
if (this.editType == 'sp') {
const content = this.editName.trim();
const relation = this.editRelation.trim();
console.log(this.videoFileList[0].url);
if (content) {
//
const data = {
id:this.nodeInfo.docId,
type: 2,
name: content,
relation: relation,
parentId: this.editParentId,
level: this.editLeve,
spUrl: this.videoFileList[0].url
};
try {
editInfoGraph(data).then((res)=>{
console.log(res);
})
//
this.visGraph.drawData(this.graphData);
this.reLayout();
this.closeModal(); //
} catch (error) {
console.error('Failed to add new branch:', error);
alert('Failed to add new branch. Please try again.');
}
}
}
},
//
//
//
handleRemove(file, fileList) {
console.log('File removed:', file);
console.log('Current fileList:', fileList);
},
//
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 9 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
//
beforeUpload(file) {
const isJPGorPNG = file.type === 'image/jpeg' || file.type === 'image/png';
const isLt2M = file.size / 1024 / 1024 < 10; // 2MB
if (!isJPGorPNG) {
this.$message.error('上传图片只能是 JPG/PNG 格式!');
}
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 2MB!');
}
return isJPGorPNG && isLt2M;
},
//
handleSuccess(response, file, fileList) {
console.log('Upload success:', response);
// fileList
console.log(fileList)
this.fileList = fileList;
this.isUpload = 1;
},
//
// eslint-disable-next-line no-unused-vars
handleError(err, file, fileList) {
console.log('Upload error:', err);
this.$message.error('上传失败,请重试!');
},
getFileIdByDocId(data) {
return getFileIdByDocId(data);
},
closeModal() {
this.isModalVisible = false;
this.isModalVisible1 = false;
this.newBranchContent = '';
this.selectedNode = null;
},
closeModal1() {
this.isModalVisible2 = false;
this.editContent = '';
this.selectedNode = null;
},
async addNewBranch() {
if(this.typeValue=='tw'){
if (this.typeValue == 'tw') {
const content = this.newBranchContent.trim();
const value = this.newBranchValue.trim();
const fileId = this.newBranchFileId.trim();
@ -547,7 +906,7 @@ export default {
relation: relation,
parentId: this.newBranchParentId,
level: this.newBranchLevel,
nodeType:'tw'
nodeType: 'tw'
};
try {
@ -573,6 +932,7 @@ export default {
this.visGraph.drawData(this.graphData);
this.reLayout();
this.closeModal(); //
this.isModalVisible = false;
} catch (error) {
console.error('Failed to add new branch:', error);
alert('Failed to add new branch. Please try again.');
@ -581,20 +941,20 @@ export default {
}
if(this.typeValue=='sp'){
if (this.typeValue == 'sp') {
console.log(this.videoFileList[0].url)
const content = this.newBranchContent.trim();
const relation = this.newBranchRelation.trim();
if (this.selectedNode && content ) {
if (this.selectedNode && content) {
//
const data = {
nodeType:this.typeValue,
nodeType: this.typeValue,
txtName: content,
relation: relation,
parentId: this.newBranchParentId,
level: this.newBranchLevel,
spUrl:this.videoFileList[0].url
spUrl: this.videoFileList[0].url
};
try {
@ -789,7 +1149,7 @@ export default {
this.$message.warning('该视频已存在于列表中');
return;
}
this.videoFileList.push({ url: videoUrl, name: file.name });
this.videoFileList.push({url: videoUrl, name: file.name});
this.showVideoPath = this.videoFileList.map(f => f.url).join(',');
this.updateCourseUrl();
this.$message.success('视频上传成功');
@ -825,6 +1185,7 @@ export default {
var that = this;
//
this.config.node.onClick = function (event, node) {
@ -835,12 +1196,12 @@ export default {
getInfo(data).then((res) => {
var type = res.data.data.type;
if(type==1){
if (type == 1) {
that.$router.push({path: '/TwInfoXq', query: {id: res.data.data.id, level: res.data.data.level, type: "tw"}})
console.log("查看文章详情")
}
if(type==2){
that.$router.push({path: '/SpInfoXq', query: {id: res.data.data.id,type: "sp"}})
if (type == 2) {
that.$router.push({path: '/SpInfoXq', query: {id: res.data.data.id, type: "sp"}})
}
});
};
@ -866,6 +1227,7 @@ export default {
margin-top: 5%;
color: #7cdeff;
}
.leftBox2 {
width: 100%;
height: 90%;
@ -992,7 +1354,8 @@ export default {
flex-direction: row;
color: #ffffff;
}
.custom-dialog{
.custom-dialog {
margin-top: 0vh !important;
}
</style>

2
kcui/src/view/JsInfo.vue

@ -196,7 +196,7 @@ export default {
{id: 2, name: "动画显示", info: "DhInfo"},
{id: 3, name: "计算模块", info: "JsInfo"},
{id: 4, name: "知识图谱", info: "Graph"},
{id: 4, name: "帮助文档", info: "Help"}
{id: 5, name: "帮助文档", info: "Help"}
],
page: "计算模块",
typeList: ["全部", "起降", "飞行", "通信载荷使用", "探测载荷使用", "攻击载荷使用"],

3
kcui/src/view/SpInfo.vue

@ -236,7 +236,7 @@ export default {
{id: 2, name: "动画显示", info: "DhInfo"},
{id: 3, name: "计算模块", info: "JsInfo"},
{id: 4, name: "知识图谱", info: "Graph"},
{id: 4, name: "帮助文档", info: "Help"}
{id: 5, name: "帮助文档", info: "Help"}
],
page: "视频资源",
typeList: ["全部", "起降", "飞行", "通信载荷使用", "探测载荷使用", "攻击载荷使用"],
@ -615,6 +615,7 @@ export default {
text-align: center;
color: #ffffff;
font-size: 0.9vw;
margin-top: 1%;
}
.pageList {

2
kcui/src/view/TWInfo.vue

@ -221,7 +221,7 @@ export default {
{id: 2, name: "动画显示", info: "DhInfo"},
{id: 3, name: "计算模块", info: "JsInfo"},
{id: 4, name: "知识图谱", info: "Graph"},
{id: 4, name: "帮助文档", info: "Help"}
{id: 5, name: "帮助文档", info: "Help"}
],
page: "图文认知",
typeList: ["全部", "海洋大气", "海洋文学", "海洋地理", "复杂水声", "复杂电磁"],

731
src/main/java/com/main/woka/Web/Controller/KcInfoController.java

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

4
src/main/java/com/main/woka/Web/Controller/KcTlFileController.java

@ -243,7 +243,7 @@ public class KcTlFileController extends BaseController {
//创建图谱
String cqr = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + zz.getSourceId() + "' AND b.docId = '" + zz.getTargetId() + "'CREATE (a)-[r:" + zz.getRelation() + "] -> (b) RETURN r";
String cqr = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + zz.getSourceId() + "' AND b.docId = '" + zz.getTargetId() + "'CREATE (a)-[r:"+relation+"{ name: '"+relation+"'}] -> (b) RETURN r";
StatementResult result2 = neo4jUtil.excuteCypherSql(cqr);
zz.setIsGraph(1l);
@ -363,7 +363,7 @@ public class KcTlFileController extends BaseController {
kcInfoRelationMapper.insertKcRelationship(zz);
//创建图谱
String cqr = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + zz.getSourceId() + "' AND b.docId = '" + zz.getTargetId() + "'CREATE (a)-[r:" + zz.getRelation() + "] -> (b) RETURN r";
String cqr = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '" + zz.getSourceId() + "' AND b.docId = '" + zz.getTargetId() + "'CREATE (a)-[r:"+relation+"{ name: '"+relation+"'}] -> (b) RETURN r";
StatementResult result2 = neo4jUtil.excuteCypherSql(cqr);
zz.setIsGraph(1l);

11
src/main/java/com/main/woka/Web/Dao/KcInfo.java

@ -43,6 +43,17 @@ public class KcInfo {
//与上级关系
private String relation;
public String getRelation() {
return relation;
}
public void setRelation(String relation) {
this.relation = relation;
}
private String contentInfo;//文章内容

1
src/main/resources/Mapper/KcFileMapper.xml

@ -120,6 +120,7 @@
update kc_info
<set>
<if test="name != null and name != ''">name = #{name},</if>
<if test="type != null ">type = #{type},</if>
<if test="twUrl != null and twUrl != ''">tw_url = #{twUrl},</if>
<if test="spUrl != null and spUrl != ''">sp_url = #{spUrl},</if>
<if test="jsInfo != null and jsInfo != ''">js_info = #{jsInfo},</if>

10
src/main/resources/Mapper/KcInfoRelationMapper.xml

@ -61,11 +61,11 @@
<include refid="selectKcRelationshipVo"/>
<where>
<if test="relation != null and relation != ''"> and relation = #{relation}</if>
<if test="sourceId != null "> and sourceId = #{sourceId}</if>
<if test="targetId != null "> and targetId = #{targetId}</if>
<if test="sourceName != null and sourceName != ''"> and sourceName = #{sourceName}</if>
<if test="targetName != null and targetName != ''"> and targetName = #{targetName}</if>
<if test="isGraph != null "> and isGraph = #{isGraph}</if>
<if test="sourceId != null "> and source_id = #{sourceId}</if>
<if test="targetId != null "> and target_id = #{targetId}</if>
<if test="sourceName != null and sourceName != ''"> and source_name = #{sourceName}</if>
<if test="targetName != null and targetName != ''"> and target_name = #{targetName}</if>
<if test="isGraph != null "> and is_graph = #{isGraph}</if>
</where>
</select>

Loading…
Cancel
Save