Browse Source

导入文件夹

hanyuqing
hanyuqing 5 months ago
parent
commit
25db854022
  1. 55
      gyxtp/src/components/UseAll/leftInfo.vue
  2. 8
      gyxtp/src/router/router.js
  3. 127
      gyxtp/src/view/docInfo.vue
  4. 128
      gyxtp/src/view/graphPageCopy0926.vue
  5. 7
      gyxtp/src/view/graphPageNB927.vue
  6. 4
      gyxtp/src/view/pointInfo.vue
  7. 13
      gyxtp/vue.config.js
  8. 17
      ruoyi-admin/pom.xml
  9. 827
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java
  10. 15
      ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java
  11. 10
      ruoyi-api/src/main/java/com/ruoyi/api/domain/ZhyDocApi.java
  12. 4
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java
  13. 12
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/GraphServiceImpl.java
  14. 3
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
  15. 4
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZhyFileManageServiceImpl.java
  16. 1
      ruoyi-ui/src/main.js
  17. 2
      ruoyi-ui/src/utils/request.js
  18. 4
      ruoyi-ui/src/views/system/fileManage/index.vue
  19. 108
      ruoyi-ui/src/views/system/fileManage/indexNB.vue

55
gyxtp/src/components/UseAll/leftInfo.vue

@ -10,12 +10,12 @@
<div style="font-size:0.8vw;color: #ffffff;">知识概览</div>
</div>
</div>
<!-- <div class="menuInfo" @click="goIndex">-->
<!-- <div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">-->
<!-- <img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu2.png">-->
<!-- <div style="font-size:0.8vw;color: #0776ff;">知识检索</div>-->
<!-- </div>-->
<!-- </div>-->
<div class="menuInfo" @click="goIndex">
<div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">
<img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu2.png">
<div style="font-size:0.8vw;color: #0776ff;">知识检索</div>
</div>
</div>
<!-- <div class="menuInfo" @click="goCreate">-->
<!-- <div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">-->
<!-- <img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu2.png">-->
@ -37,13 +37,13 @@
<div style="font-size:0.8vw;color: #0776ff;">知识概览</div>
</div>
</div>
<!-- <div class="menuInfo" @click="goIndex">-->
<!-- <img style="width: 100%;height: 100%;" src="../../assets/img2/menuXuan.png">-->
<!-- <div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">-->
<!-- <img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu22.png">-->
<!-- <div style="font-size:0.8vw;color: #ffffff;">知识检索</div>-->
<!-- </div>-->
<!-- </div>-->
<div class="menuInfo" @click="goIndex">
<img style="width: 100%;height: 100%;" src="../../assets/img2/menuXuan.png">
<div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">
<img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu22.png">
<div style="font-size:0.8vw;color: #ffffff;">知识检索</div>
</div>
</div>
<!-- <div class="menuInfo" @click="goCreate">-->
<!-- <div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">-->
<!-- <img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu2.png">-->
@ -64,20 +64,6 @@
<div style="font-size:0.8vw;color: #0776ff;">知识概览</div>
</div>
</div>
<!-- <div class="menuInfo" @click="goIndex">-->
<!-- <div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">-->
<!-- <img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu2.png">-->
<!-- <div style="font-size:0.8vw;color: #0776ff;">知识检索</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="menuInfo" @click="goCreate">-->
<!-- <img style="width: 100%;height: 100%;" src="../../assets/img2/menuXuan.png">-->
<!-- <div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">-->
<!-- <img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu22.png">-->
<!-- <div style="font-size:0.8vw;color: #ffffff;">自动构建</div>-->
<!-- </div>-->
<!-- </div>-->
<div class="menuInfo" @click="goSmall">
<div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">
<img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu2.png">
@ -92,12 +78,12 @@
<div style="font-size:0.8vw;color: #0776ff;">知识概览</div>
</div>
</div>
<!-- <div class="menuInfo" @click="goIndex">-->
<!-- <div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">-->
<!-- <img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu2.png">-->
<!-- <div style="font-size:0.8vw;color: #0776ff;">知识检索</div>-->
<!-- </div>-->
<!-- </div>-->
<div class="menuInfo" @click="goIndex">
<div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">
<img style="width: 72%;object-fit: contain;" src="../../assets/img2/menu2.png">
<div style="font-size:0.8vw;color: #0776ff;">知识检索</div>
</div>
</div>
<!-- <div class="menuInfo" @click="goCreate">-->
<!-- <img style="width: 100%;height: 100%;" src="../../assets/img2/menuXuan.png">-->
@ -106,6 +92,7 @@
<!-- <div style="font-size:0.8vw;color: #ffffff;">自动构建</div>-->
<!-- </div>-->
<!-- </div>-->
<div class="menuInfo" @click="goSmall">
<img style="width: 100%;height: 100%;" src="../../assets/img2/menuXuan.png">
<div style="width: 80%;position: absolute;left: 1vw;top: 0.5vw;">
@ -145,7 +132,7 @@ export default {
this.$router.push('/graphPage');
},
goIndex() {
this.$router.push('/index');
this.$router.push('/graphPageNB');
},
goCreate() {

8
gyxtp/src/router/router.js

@ -25,6 +25,14 @@ const routes = [
component: () => import ("../view/graphPageCopy0926.vue")
},
{
path: '/graphPageNB',
name: 'graphPageNB',
meta: {
title: '数据图谱',
},
component: () => import ("../view/graphPageNB927.vue")
},
{
path: '/battlefield',
name: 'battlefield',
meta: {

127
gyxtp/src/view/docInfo.vue

@ -179,11 +179,18 @@
</div>
<div class="yuanInfo" v-if="!docShow && chooseInfo==1">
<div class="zhengwen">
<div class="tInfo">
<div class="tcontent">知识内容:</div>
</div>
</div>
<div ref="content" v-html="htmlContent" class="docx-content"></div>
<div class="yuanwen" v-html="contentInfo.content"></div>
</div>
<div class="videoInfo" v-if="chooseInfo==2 && haveImg==true">
@ -338,10 +345,12 @@
</div>
</div>
</div>
</template>
<script>
import mammoth from 'mammoth';
import Video1 from "../components/Video1";
import {
getDocInfo,
@ -360,7 +369,7 @@ import RelationGraph from 'relation-graph-vue3';
import HeaderInfo from '../components/UseAll/headerInfo'
import leftInfo from "../components/UseAll/leftInfo";
import {ElMessage} from 'element-plus'
import { mathmlToLatex } from 'mammoth-math';
const graphOptions = {
debug: true,
backgrounImageNoRepeat: true,
@ -409,6 +418,7 @@ export default {
},
data() {
return {
htmlContent:"",
videoUrls: [], //
isWorkVisible1look: false,
lookUrl: "",
@ -495,6 +505,82 @@ export default {
};
},
methods: {
async loadDocx(url) {
try {
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const arrayBuffer = await response.arrayBuffer();
// 使 mammoth-math mathmlToLatex
const result = await mammoth.convertToHtml(
{ arrayBuffer },
{
mathConverter: mathmlToLatex
}
);
//
let htmlContent = result.value.replace(
/&lt;img\s+src=["']([^"']+)["'][^&]*&gt;/gi,
(match, src) => `<img src="${src}" style="max-width:100%">`
);
this.htmlContent = htmlContent;
this.loading = false;
this.renderMath();
this.$nextTick(() => {
this.renderMath();
});
} catch (err) {
console.error('加载或解析失败:', err);
this.error = `无法加载文档: ${err.message}`;
this.loading = false;
}
},
// loadDocx(url) {
// // url = "http://localhost/dev-api/api/docxFile/ .docx_20251029_173422/wordSplitter/CHCMCL.docx";
//
// this.loading = true;
// this.error = '';
// this.htmlContent = '';
//
// // 使 fetch .docx
// fetch(url)
// .then(response => {
// if (!response.ok) {
// throw new Error(`HTTP ${response.status}: ${response.statusText}`);
// }
// return response.arrayBuffer();
// })
// .then(arrayBuffer => {
// return mammoth.convertToHtml({ arrayBuffer });
// })
// .then(result => {
// let htmlContent = result.value;
//
// // 🔥 &lt;img src="..."&gt; <img>
// htmlContent = htmlContent.replace(
// /&lt;img\s+src=["']([^"']+)["']([^&]*)&gt;/gi,
// (match, src, rest) => {
// // src
// return `<img src="${src}"${rest} style="max-width: 100%;">`;
// }
// );
//
// this.htmlContent = htmlContent; // <img>
//
// console.log(' HTML:', htmlContent);
// console.log(':', result.messages);
//
// this.loading = false;
// })
// .catch(err => {
// console.error(':', err);
// this.error = `: ${err.message}`;
// this.loading = false;
// });
// },
openImgBig(url) {
console.log("jdksajdlkjsajals")
this.isWorkVisible1look = true;
@ -785,6 +871,7 @@ export default {
var data = {
id: res.data.id
}
this.loadDocx("http://localhost/dev-api/api/docxFile/"+res.data.url)
addDocCount(data).then((res) => {
console.log(res);
})
@ -1092,6 +1179,36 @@ export default {
localStorage.clear();
this.$router.push('/');
},
async renderMath() {
try {
// startup
const { MathJax } = await import('mathjax-full/js/components/startup.js');
//
window.MathJax = MathJax;
MathJax.config = {
loader: { load: ['input/tex', 'output/chtml'] },
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\\[', '\\]']]
}
};
// promise
await MathJax.startup.promise;
console.log('✅ MathJax 初始化完成');
// typesetPromise
const target = this.$refs.content;
if (target && typeof window.MathJax.typesetPromise === 'function') {
await window.MathJax.typesetPromise([target]);
console.log('✅ 公式渲染成功!');
}
} catch (err) {
console.error('❌ MathJax 初始化失败', err);
}
},
goSearch() {
this.$router.push({name: 'docList', query: {word: this.searchWord}});
},
@ -1107,7 +1224,13 @@ export default {
}
var url = localStorage.getItem("docUrl");
this.getDoc(this.title, this.level, this.searchWord, url);
this.getXg(this.title, this.level, url);
this.renderMath()
},
};

128
gyxtp/src/view/graphPageCopy0926.vue

@ -983,57 +983,91 @@ export default {
})
},
onNodeClick(nodeObject, $event) {
console.log('Clicked node:', nodeObject.id);
console.log(nodeObject.id)
const graphInstance = this.$refs.graphRef.getInstance();
//
const allLines = graphInstance.getLines();
allLines.forEach(line => {
line.lineWidth = 1;
});
//
const startNode = graphInstance.getNodeById(nodeObject.id);
if (!startNode) return;
//
const highlightLines = new Set();
// BFS
const queue = [startNode];
const visited = new Set([startNode.id]); //
while (queue.length > 0) {
const currentNode = queue.shift();
//
const outEdges = graphInstance.getLinesByNode(currentNode).filter(line => line.from === currentNode.id);
for (const edge of outEdges) {
highlightLines.add(edge);
const childNodeId = edge.to;
if (!visited.has(childNodeId)) {
const childNode = graphInstance.getNodeById(childNodeId);
if (childNode) {
visited.add(childNodeId);
queue.push(childNode);
}
let node = graphInstance.getNodeById(nodeObject.id)
let relinks = graphInstance.getLinesByNode(node);
// let links = graphInstance.getLinks();
//
// for (let i=0;i<links.length;i++){
// graphInstance.getLinks()[i].lineWidth = 1
// }
if (this.lastNodeL.id == node.id) {
console.log("ss11111111")
for (let i = 0; i < relinks.length; i++) {
console.log(graphInstance.getLinesByNode(node)[i].lineWidth)
if (graphInstance.getLinesByNode(node)[i].lineWidth == 10) {
graphInstance.getLinesByNode(node)[i].lineWidth = 1
} else {
graphInstance.getLinesByNode(node)[i].lineWidth = 10
}
}
return
}
//
highlightLines.forEach(line => {
line.lineWidth = 10;
});
// UI
this.lastNodeL = startNode;
//
// graphInstance.refresh && graphInstance.refresh();
}
if (this.lastNodeL != "") {
let a = graphInstance.getLinesByNode(this.lastNodeL);
for (let i = 0; i < a.length; i++) {
graphInstance.getLinesByNode(this.lastNodeL)[i].lineWidth = 1
}
}
for (let i = 0; i < relinks.length; i++) {
graphInstance.getLinesByNode(node)[i].lineWidth = 10
}
this.lastNodeL = node
},
// console.log('Clicked node:', nodeObject.id);
// const graphInstance = this.$refs.graphRef.getInstance();
//
// //
// const allLines = graphInstance.getLines();
// allLines.forEach(line => {
// line.lineWidth = 1;
// });
//
// //
// const startNode = graphInstance.getNodeById(nodeObject.id);
// if (!startNode) return;
//
// //
// const highlightLines = new Set();
//
// // BFS
// const queue = [startNode];
// const visited = new Set([startNode.id]); //
//
// while (queue.length > 0) {
// const currentNode = queue.shift();
//
// //
// const outEdges = graphInstance.getLinesByNode(currentNode).filter(line => line.from === currentNode.id);
//
// for (const edge of outEdges) {
// highlightLines.add(edge);
//
// const childNodeId = edge.to;
// if (!visited.has(childNodeId)) {
// const childNode = graphInstance.getNodeById(childNodeId);
// if (childNode) {
// visited.add(childNodeId);
// queue.push(childNode);
// }
// }
// }
// }
//
// //
// highlightLines.forEach(line => {
// line.lineWidth = 10;
// });
//
// // UI
// this.lastNodeL = startNode;
//
// //
// // graphInstance.refresh && graphInstance.refresh();
// }
},
created() {
var that = this;

7
gyxtp/src/view/graphPageNB927.vue

@ -2,7 +2,7 @@
<div class="about">
<HeaderInfo style="height: 5.65vw;float: left;"></HeaderInfo>
<leftInfo @show="isZhe" style="width: 5vw;position: absolute;top: 5.35vw;position: absolute;z-index:100;"
:leftNum="0" :zhedie="zhedie" v-if="zhedie == 0"></leftInfo>
:leftNum="1" :zhedie="zhedie" v-if="zhedie == 0"></leftInfo>
<div v-if="zhedie == 0" @click="this.zhedie = 1"
style="position: absolute;height: 3vw;width: 3vw;font-size: 2vw;border-radius: 0 50% 50% 0;z-index: 1000;bottom:45%;left:5vw;cursor: pointer">
<img src="../assets/img2/close3.png" style="width: 60%;object-fit: contain;">
@ -318,7 +318,7 @@ export default {
isShowCodePanel: false,
isShowNodeMenuPanel: false,
nodeMenuPanelPosition: { x: 0, y: 0 },
currentGroup:0,
currentGroup:-1,
direction: "rtl",
// visGraph
visGraph: null,
@ -485,7 +485,8 @@ export default {
},
async getFile(){
await getFile().then(async res=>{
this.fileList=res.data;
// fileName
this.fileList = res.data.filter(file => file.fileName !== "联合作战气象海洋影响评估与决策支撑体系.docx");
if(this.fileList.length>0){
console.log("22222222")
this.selectedFileId=this.fileList[0].id

4
gyxtp/src/view/pointInfo.vue

@ -5,7 +5,7 @@
<div class="docInfo" >
<div class="bodyDiv" style=" margin-top: 9.65vw;;
overflow: auto;
/*overflow: auto;*/
height: 80vw;">
<div class="headerDoc">
<div style="margin-left: 1vw;">
@ -46,7 +46,7 @@
v-for="(item) in tableData"
:key="item"
>
<div style="color: #373737;cursor: pointer">
<div style="color: #373737;cursor: pointer;padding: 10px">
<div>
<div style="height: 1.5vw;margin-bottom: 7px;">
<img src="../assets/img2/book2.png"

13
gyxtp/vue.config.js

@ -1,5 +1,14 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave:false,
})
lintOnSave: false,
configureWebpack: {
resolve: {
fallback: {
path: require.resolve('path-browserify'),
util: require.resolve('util/'),
},
},
},
})

17
ruoyi-admin/pom.xml

@ -17,6 +17,23 @@
<dependencies>
<!-- <dependency>-->
<!-- <groupId>org.apache.poi</groupId>-->
<!-- <artifactId>poi-ooxml</artifactId>-->
<!-- <version>5.0.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.poi</groupId>-->
<!-- <artifactId>poi-scratchpad</artifactId>-->
<!-- <version>5.0.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.jsoup</groupId>-->
<!-- <artifactId>jsoup</artifactId>-->
<!-- <version>1.13.1</version>-->
<!-- </dependency>-->
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>

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

@ -31,6 +31,7 @@ import com.ruoyi.system.service.IZhyArticleService;
import com.ruoyi.system.service.impl.LuceneUtil;
import com.ruoyi.system.service.impl.ZhyFileManageServiceImpl;
import lombok.Data;
import lombok.var;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
@ -78,7 +79,15 @@ import java.util.regex.Pattern;
import java.util.stream.Stream;
import static com.ruoyi.common.constant.Constants.*;
import org.apache.poi.xwpf.usermodel.*;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;
import java.io.ByteArrayInputStream;
import java.nio.file.Files;
import java.nio.file.Path;
@RestController
@RequestMapping("/system/fileManage")
public class ZhyFileManageController extends BaseController {
@ -286,6 +295,7 @@ public class ZhyFileManageController extends BaseController {
List<Map<String, String>> dataList = new ArrayList<>();
String[] headers = null;
InputStream inputStream = null;
BufferedReader reader = null;
try {
@ -2613,6 +2623,166 @@ public class ZhyFileManageController extends BaseController {
}
}
private void generateDocxFromHtml(String htmlContent, Path outputPath) throws Exception {
// 1. 创建空的 .docx 文档
XWPFDocument document = new XWPFDocument();
// 2. 解析 HTML
Document doc = Jsoup.parse(htmlContent);
org.jsoup.nodes.Element body = doc.body();
// 3. 遍历 HTML 元素
for (Node node : body.childNodes()) {
processNode(node, document);
}
// 4. 保存到文件(覆盖原路径)
try (var out = Files.newOutputStream(outputPath)) {
document.write(out);
}
document.close();
}
private void processNode(Node node, XWPFDocument document) {
if (node instanceof TextNode) {
// 普通文本
String text = ((TextNode) node).text().trim();
if (!text.isEmpty()) {
XWPFParagraph p = document.createParagraph();
XWPFRun run = p.createRun();
run.setText(text);
}
} else if (node instanceof Element) {
Element elem = (Element) node;
String tagName = elem.tagName().toLowerCase();
XWPFParagraph p = document.createParagraph();
XWPFRun run = p.createRun();
//
switch (tagName) {
case "p":
// 段落
for (Node child : elem.childNodes()) {
if (child instanceof TextNode) {
run.setText(((TextNode) child).text());
} else if (child instanceof Element) {
processInlineElement((Element) child, run);
}
}
break;
case "h1":
case "h2":
case "h3":
run.setText(elem.text());
p.setStyle(tagName.toUpperCase()); // 可选:设置样式
break;
case "strong":
case "b":
run.setText(elem.text());
run.setBold(true);
break;
case "em":
case "i":
run.setText(elem.text());
run.setItalic(true);
break;
case "u":
run.setText(elem.text());
run.setUnderline(UnderlinePatterns.SINGLE);
break;
case "br":
run.setText("\n");
break;
case "img":
String src = elem.outerHtml();
if (src != null && !src.trim().isEmpty()) {
// 方案1:显示为 "[图片] 链接地址"
XWPFParagraph liP = document.createParagraph();
liP.setIndentFromLeft(400);
XWPFRun liRun = liP.createRun();
liRun.setText(src);
}
break;
case "ul":
for (Element li : elem.select("li")) {
XWPFParagraph liP = document.createParagraph();
liP.setIndentFromLeft(400);
XWPFRun liRun = liP.createRun();
liRun.setText("• " + li.text());
}
break;
case "ol":
int num = 1;
for (Element li : elem.select("li")) {
XWPFParagraph liP = document.createParagraph();
liP.setIndentFromLeft(400);
XWPFRun liRun = liP.createRun();
liRun.setText((num++) + ". " + li.text());
}
break;
default:
run.setText(elem.text());
break;
}
}
}
// 处理内联标签(如 <b>、<i> 在段落内)
private void processInlineElement(Element elem, XWPFRun run) {
String tagName = elem.tagName().toLowerCase();
boolean bold = run.isBold();
boolean italic = run.isItalic();
UnderlinePatterns underline = run.getUnderline();
System.out.println(tagName);
switch (tagName) {
case "strong":
case "b":
run.setBold(true);
run.setText(elem.text());
run.setBold(bold); // 恢复状态(实际中建议拆分 run)
break;
case "em":
case "i":
run.setItalic(true);
run.setText(elem.text());
run.setItalic(italic);
break;
case "u":
run.setUnderline(UnderlinePatterns.SINGLE);
run.setText(elem.text());
break;
case "img":
String src = elem.outerHtml();
if (src != null && !src.trim().isEmpty()) {
run.setText(src);
}
break;
default:
run.setText(elem.text());
break;
}
}
// 从 src 提取图片字节(支持 data:image/base64)
private byte[] getImageBytesFromSrc(String src) {
if (src.startsWith("data:image")) {
String base64Data = src.substring(src.indexOf(",") + 1);
return java.util.Base64.getDecoder().decode(base64Data);
}
// 可扩展:从 URL 或服务器路径加载
return null;
}
@PostMapping("/updateTxt")
public AjaxResult updateTxt(@RequestBody Map<String, String> requestBody) {
String filePath = requestBody.get("url");
@ -2622,15 +2792,7 @@ public class ZhyFileManageController extends BaseController {
String videoUrl = requestBody.get("videoUrl");
String imgs = requestBody.get("imgs");
String prodectName = requestBody.get("prodectName");
Long groupId = Long.valueOf(requestBody.get("groupId"));
// Long parentInd = Long.valueOf(requestBody.get("parentInd"));
// ZhyDoc docParent=test1Mapper.selectDocByIdId(parentInd);
// Long groupId=0l;
// if(docParent!=null){
// groupId=docParent.getGroupId();
// }
System.out.println("ddddddddddddd");
System.out.println(groupId);
Long parentInd = Long.valueOf(requestBody.get("parentInd"));
Long docLevelNew = Long.valueOf(requestBody.get("docLevel"));
String relation1 = requestBody.get("realtion");
if(relation1 == null ||relation1.equals("")){
@ -2644,14 +2806,43 @@ public class ZhyFileManageController extends BaseController {
String aurl = filePath;
String[] urls = aurl.split("\\\\");
aurl = urls[urls.length - 1];
aurl = aurl.replace(".txt",".docx");
Path newPath = currentPath.getParent().resolve(aurl);
try {
// Rename the file
Files.move(currentPath, newPath, StandardCopyOption.REPLACE_EXISTING);
// Update the file with new content
Files.write(newPath, content.getBytes(StandardCharsets.UTF_8));
generateDocxFromHtml(content, newPath);
// // Rename the file
// Files.move(currentPath, newPath, StandardCopyOption.REPLACE_EXISTING);
//
// // Update the file with new content
// Files.write(newPath, content.getBytes(StandardCharsets.UTF_8));
ZhyDoc zhyDoc = new ZhyDoc();
ZhyDoc oldZhyDoc = test1Mapper.selectDocByIdId(id);
@ -2660,32 +2851,38 @@ public class ZhyFileManageController extends BaseController {
zhyDoc.setDocUrl(String.valueOf(newPath));
zhyDoc.setDocVideo(videoUrl);
zhyDoc.setDocImgs(imgs);
// zhyDoc.setDocParentId(parentInd);
zhyDoc.setGroupId(groupId);
zhyDoc.setDocParentId(parentInd);
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);
String cql = "match (r{docId:'" + id + "'}) SET r.docTitle = '" + name1 + "'";
neo4jUtil.excuteCypherSql(cql);
String cql1 = "match (r{docId:'" + id + "'}) SET r.groupId = '" + groupId + "'";
StatementResult result1 = neo4jUtil.excuteCypherSql(cql);
neo4jUtil.excuteCypherSql(cql1);
//判断这个文章的层级是不是变化了
Long oldLevel = oldZhyDoc.getDocLevel();
@ -2694,290 +2891,287 @@ public class ZhyFileManageController extends BaseController {
//查询下级
Long jj = docLevelNew - oldLevel;
String newLevel = "leve" + docLevelNew;
// List<ZhyDoc> list1 = test1Mapper.getOneHeader(oldZhyDoc.getId());
List<ZhyDoc> list1 = test1Mapper.getOneHeader(oldZhyDoc.getId());
String cqlLevel = "match (r{docId:'" + oldZhyDoc.getId() + "'}) SET r.docLeve = '" + newLevel + "'";
neo4jUtil.excuteCypherSql(cqlLevel);
// if (list1.size() != 0) {
// for (int j = 0; j < list1.size(); j++) {
// String newl = "";
// if (list1.get(j).getDocLevel() == 1) {
// newl = "leve" + (1 + jj);
// }
// if (list1.get(j).getDocLevel() == 2) {
// newl = "leve" + (2 + jj);
// }
// if (list1.get(j).getDocLevel() == 3) {
// newl = "leve" + (3 + jj);
// }
// if (list1.get(j).getDocLevel() == 4) {
// newl = "leve" + (4 + jj);
// }
// if (list1.get(j).getDocLevel() == 5) {
// newl = "leve" + (5 + jj);
// }
// if (list1.get(j).getDocLevel() == 6) {
// newl = "leve" + (6 + jj);
// }
// if (list1.get(j).getDocLevel() == 7) {
// newl = "leve" + (7 + jj);
// }
// String cqlLevel1 = "match (r{docId:'" + list1.get(j).getId() + "'}) SET r.docLeve = '" + newl + "'";
// neo4jUtil.excuteCypherSql(cqlLevel1);
// list1.get(j).setDocLevel(list1.get(j).getDocLevel() + jj);
// int a = test1Mapper.updateDocById(list1.get(j));
//
// List<ZhyDoc> list2 = test1Mapper.getOneHeader(list1.get(j).getId());
// if (list2.size() != 0) {
// for (int j1 = 0; j1 < list2.size(); j1++) {
// String newl1 = "";
// if (list2.get(j1).getDocLevel() == 1) {
// newl1 = "leve" + (1 + jj);
// }
// if (list2.get(j1).getDocLevel() == 2) {
// newl1 = "leve" + (2 + jj);
// }
// if (list2.get(j1).getDocLevel() == 3) {
// newl1 = "leve" + (3 + jj);
// }
// if (list2.get(j1).getDocLevel() == 4) {
// newl1 = "leve" + (4 + jj);
// }
// if (list2.get(j1).getDocLevel() == 5) {
// newl1 = "leve" + (5 + jj);
// }
// if (list2.get(j1).getDocLevel() == 6) {
// newl1 = "leve" + (6 + jj);
// }
// if (list2.get(j1).getDocLevel() == 7) {
// newl1 = "leve" + (7 + jj);
// }
// String cqlLevel2 = "match (r{docId:'" + list2.get(j1).getId() + "'}) SET r.docLeve = '" + newl1 + "'";
// StatementResult resultLevel2 = neo4jUtil.excuteCypherSql(cqlLevel2);
// list2.get(j1).setDocLevel(list2.get(j1).getDocLevel() + jj);
// int a2 = test1Mapper.updateDocById(list2.get(j1));
//
//
// List<ZhyDoc> list3 = test1Mapper.getOneHeader(list2.get(j1).getId());
// if (list3.size() != 0) {
// for (int j2 = 0; j2 < list3.size(); j2++) {
// String newl2 = "";
// if (list3.get(j2).getDocLevel() == 1) {
// newl2 = "leve" + (1 + jj);
// }
// if (list3.get(j2).getDocLevel() == 2) {
// newl2 = "leve" + (2 + jj);
// }
// if (list3.get(j2).getDocLevel() == 3) {
// newl2 = "leve" + (3 + jj);
// }
// if (list3.get(j2).getDocLevel() == 4) {
// newl2 = "leve" + (4 + jj);
// }
// if (list3.get(j2).getDocLevel() == 5) {
// newl2 = "leve" + (5 + jj);
// }
// if (list3.get(j2).getDocLevel() == 6) {
// newl2 = "leve" + (6 + jj);
// }
// if (list3.get(j2).getDocLevel() == 7) {
// newl2 = "leve" + (7 + jj);
// }
// String cqlLevel3 = "match (r{docId:'" + list3.get(j2).getId() + "'}) SET r.docLeve = '" + newl2 + "'";
// StatementResult resultLevel3 = neo4jUtil.excuteCypherSql(cqlLevel3);
// list3.get(j2).setDocLevel(list3.get(j2).getDocLevel() + jj);
// int a3 = test1Mapper.updateDocById(list3.get(j2));
//
//
// List<ZhyDoc> list4 = test1Mapper.getOneHeader(list3.get(j2).getId());
// if (list4.size() != 0) {
// for (int j3 = 0; j3 < list4.size(); j3++) {
// String newl3 = "";
// if (list4.get(j3).getDocLevel() == 1) {
// newl3 = "leve" + (1 + jj);
// }
// if (list4.get(j3).getDocLevel() == 2) {
// newl3 = "leve" + (2 + jj);
// }
// if (list4.get(j3).getDocLevel() == 3) {
// newl3 = "leve" + (3 + jj);
// }
// if (list4.get(j3).getDocLevel() == 4) {
// newl3 = "leve" + (4 + jj);
// }
// if (list4.get(j3).getDocLevel() == 5) {
// newl3 = "leve" + (5 + jj);
// }
// if (list4.get(j3).getDocLevel() == 6) {
// newl3 = "leve" + (6 + jj);
// }
// if (list4.get(j3).getDocLevel() == 7) {
// newl3 = "leve" + (7 + jj);
// }
// String cqlLevel4 = "match (r{docId:'" + list4.get(j3).getId() + "'}) SET r.docLeve = '" + newl3 + "'";
// StatementResult resultLevel4 = neo4jUtil.excuteCypherSql(cqlLevel4);
// list4.get(j3).setDocLevel(list4.get(j3).getDocLevel() + jj);
// int a4 = test1Mapper.updateDocById(list4.get(j3));
//
//
// List<ZhyDoc> list5 = test1Mapper.getOneHeader(list4.get(j3).getId());
// if (list5.size() != 0) {
// for (int j4 = 0; j4 < list5.size(); j4++) {
// String newl4 = "";
// if (list5.get(j4).getDocLevel() == 1) {
// newl4 = "leve" + (1 + jj);
// }
// if (list5.get(j4).getDocLevel() == 2) {
// newl4 = "leve" + (2 + jj);
// }
// if (list5.get(j4).getDocLevel() == 3) {
// newl4 = "leve" + (3 + jj);
// }
// if (list5.get(j4).getDocLevel() == 4) {
// newl4 = "leve" + (4 + jj);
// }
// if (list5.get(j4).getDocLevel() == 5) {
// newl4 = "leve" + (5 + jj);
// }
// if (list5.get(j4).getDocLevel() == 6) {
// newl4 = "leve" + (6 + jj);
// }
// if (list5.get(j4).getDocLevel() == 7) {
// newl4 = "leve" + (7 + jj);
// }
// String cqlLevel5 = "match (r{docId:'" + list5.get(j4).getId() + "'}) SET r.docLeve = '" + newl4 + "'";
// StatementResult resultLevel5 = neo4jUtil.excuteCypherSql(cqlLevel5);
// list5.get(j4).setDocLevel(list5.get(j4).getDocLevel() + jj);
// int a5 = test1Mapper.updateDocById(list5.get(j4));
//
//
// List<ZhyDoc> list6 = test1Mapper.getOneHeader(list5.get(j4).getId());
// if (list6.size() != 0) {
// for (int j5 = 0; j5 < list6.size(); j5++) {
// String newl5 = "";
// if (list6.get(j5).getDocLevel() == 1) {
// newl5 = "leve" + (1 + jj);
// }
// if (list6.get(j5).getDocLevel() == 2) {
// newl5 = "leve" + (2 + jj);
// }
// if (list6.get(j5).getDocLevel() == 3) {
// newl5 = "leve" + (3 + jj);
// }
// if (list6.get(j5).getDocLevel() == 4) {
// newl5 = "leve" + (4 + jj);
// }
// if (list6.get(j5).getDocLevel() == 5) {
// newl5 = "leve" + (5 + jj);
// }
// if (list6.get(j5).getDocLevel() == 6) {
// newl5 = "leve" + (6 + jj);
// }
// if (list6.get(j5).getDocLevel() == 7) {
// newl5 = "leve" + (7 + jj);
// }
// String cqlLevel6 = "match (r{docId:'" + list6.get(j5).getId() + "'}) SET r.docLeve = '" + newl5 + "'";
// StatementResult resultLevel6 = neo4jUtil.excuteCypherSql(cqlLevel6);
// list6.get(j5).setDocLevel(list6.get(j5).getDocLevel() + jj);
// int a6 = test1Mapper.updateDocById(list6.get(j5));
//
//
// List<ZhyDoc> list7 = test1Mapper.getOneHeader(list6.get(j5).getId());
// if (list7.size() != 0) {
// for (int j6 = 0; j6 < list7.size(); j6++) {
// String newl6 = "";
// if (list7.get(j6).getDocLevel() == 1) {
// newl6 = "leve" + (1 + jj);
// }
// if (list7.get(j6).getDocLevel() == 2) {
// newl6 = "leve" + (2 + jj);
// }
// if (list7.get(j6).getDocLevel() == 3) {
// newl6 = "leve" + (3 + jj);
// }
// if (list7.get(j6).getDocLevel() == 4) {
// newl6 = "leve" + (4 + jj);
// }
// if (list7.get(j6).getDocLevel() == 5) {
// newl6 = "leve" + (5 + jj);
// }
// if (list7.get(j6).getDocLevel() == 6) {
// newl6 = "leve" + (6 + jj);
// }
// if (list7.get(j6).getDocLevel() == 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).setDocLevel(list7.get(j6).getDocLevel() + jj);
// int a7 = test1Mapper.updateDocById(list7.get(j6));
// }
// }
// }
// }
// }
// }
// }
// }
//
// }
// }
//
// }
// }
// }
// }
}
if (list1.size() != 0) {
for (int j = 0; j < list1.size(); j++) {
String newl = "";
if (list1.get(j).getDocLevel() == 1) {
newl = "leve" + (1 + jj);
}
if (list1.get(j).getDocLevel() == 2) {
newl = "leve" + (2 + jj);
}
if (list1.get(j).getDocLevel() == 3) {
newl = "leve" + (3 + jj);
}
if (list1.get(j).getDocLevel() == 4) {
newl = "leve" + (4 + jj);
}
if (list1.get(j).getDocLevel() == 5) {
newl = "leve" + (5 + jj);
}
if (list1.get(j).getDocLevel() == 6) {
newl = "leve" + (6 + jj);
}
if (list1.get(j).getDocLevel() == 7) {
newl = "leve" + (7 + jj);
}
String cqlLevel1 = "match (r{docId:'" + list1.get(j).getId() + "'}) SET r.docLeve = '" + newl + "'";
neo4jUtil.excuteCypherSql(cqlLevel1);
list1.get(j).setDocLevel(list1.get(j).getDocLevel() + jj);
int a = test1Mapper.updateDocById(list1.get(j));
List<ZhyDoc> list2 = test1Mapper.getOneHeader(list1.get(j).getId());
if (list2.size() != 0) {
for (int j1 = 0; j1 < list2.size(); j1++) {
String newl1 = "";
if (list2.get(j1).getDocLevel() == 1) {
newl1 = "leve" + (1 + jj);
}
if (list2.get(j1).getDocLevel() == 2) {
newl1 = "leve" + (2 + jj);
}
if (list2.get(j1).getDocLevel() == 3) {
newl1 = "leve" + (3 + jj);
}
if (list2.get(j1).getDocLevel() == 4) {
newl1 = "leve" + (4 + jj);
}
if (list2.get(j1).getDocLevel() == 5) {
newl1 = "leve" + (5 + jj);
}
if (list2.get(j1).getDocLevel() == 6) {
newl1 = "leve" + (6 + jj);
}
if (list2.get(j1).getDocLevel() == 7) {
newl1 = "leve" + (7 + jj);
}
String cqlLevel2 = "match (r{docId:'" + list2.get(j1).getId() + "'}) SET r.docLeve = '" + newl1 + "'";
StatementResult resultLevel2 = neo4jUtil.excuteCypherSql(cqlLevel2);
list2.get(j1).setDocLevel(list2.get(j1).getDocLevel() + jj);
int a2 = test1Mapper.updateDocById(list2.get(j1));
List<ZhyDoc> list3 = test1Mapper.getOneHeader(list2.get(j1).getId());
if (list3.size() != 0) {
for (int j2 = 0; j2 < list3.size(); j2++) {
String newl2 = "";
if (list3.get(j2).getDocLevel() == 1) {
newl2 = "leve" + (1 + jj);
}
if (list3.get(j2).getDocLevel() == 2) {
newl2 = "leve" + (2 + jj);
}
if (list3.get(j2).getDocLevel() == 3) {
newl2 = "leve" + (3 + jj);
}
if (list3.get(j2).getDocLevel() == 4) {
newl2 = "leve" + (4 + jj);
}
if (list3.get(j2).getDocLevel() == 5) {
newl2 = "leve" + (5 + jj);
}
if (list3.get(j2).getDocLevel() == 6) {
newl2 = "leve" + (6 + jj);
}
if (list3.get(j2).getDocLevel() == 7) {
newl2 = "leve" + (7 + jj);
}
String cqlLevel3 = "match (r{docId:'" + list3.get(j2).getId() + "'}) SET r.docLeve = '" + newl2 + "'";
StatementResult resultLevel3 = neo4jUtil.excuteCypherSql(cqlLevel3);
list3.get(j2).setDocLevel(list3.get(j2).getDocLevel() + jj);
int a3 = test1Mapper.updateDocById(list3.get(j2));
List<ZhyDoc> list4 = test1Mapper.getOneHeader(list3.get(j2).getId());
if (list4.size() != 0) {
for (int j3 = 0; j3 < list4.size(); j3++) {
String newl3 = "";
if (list4.get(j3).getDocLevel() == 1) {
newl3 = "leve" + (1 + jj);
}
if (list4.get(j3).getDocLevel() == 2) {
newl3 = "leve" + (2 + jj);
}
if (list4.get(j3).getDocLevel() == 3) {
newl3 = "leve" + (3 + jj);
}
if (list4.get(j3).getDocLevel() == 4) {
newl3 = "leve" + (4 + jj);
}
if (list4.get(j3).getDocLevel() == 5) {
newl3 = "leve" + (5 + jj);
}
if (list4.get(j3).getDocLevel() == 6) {
newl3 = "leve" + (6 + jj);
}
if (list4.get(j3).getDocLevel() == 7) {
newl3 = "leve" + (7 + jj);
}
String cqlLevel4 = "match (r{docId:'" + list4.get(j3).getId() + "'}) SET r.docLeve = '" + newl3 + "'";
StatementResult resultLevel4 = neo4jUtil.excuteCypherSql(cqlLevel4);
list4.get(j3).setDocLevel(list4.get(j3).getDocLevel() + jj);
int a4 = test1Mapper.updateDocById(list4.get(j3));
List<ZhyDoc> list5 = test1Mapper.getOneHeader(list4.get(j3).getId());
if (list5.size() != 0) {
for (int j4 = 0; j4 < list5.size(); j4++) {
String newl4 = "";
if (list5.get(j4).getDocLevel() == 1) {
newl4 = "leve" + (1 + jj);
}
if (list5.get(j4).getDocLevel() == 2) {
newl4 = "leve" + (2 + jj);
}
if (list5.get(j4).getDocLevel() == 3) {
newl4 = "leve" + (3 + jj);
}
if (list5.get(j4).getDocLevel() == 4) {
newl4 = "leve" + (4 + jj);
}
if (list5.get(j4).getDocLevel() == 5) {
newl4 = "leve" + (5 + jj);
}
if (list5.get(j4).getDocLevel() == 6) {
newl4 = "leve" + (6 + jj);
}
if (list5.get(j4).getDocLevel() == 7) {
newl4 = "leve" + (7 + jj);
}
String cqlLevel5 = "match (r{docId:'" + list5.get(j4).getId() + "'}) SET r.docLeve = '" + newl4 + "'";
StatementResult resultLevel5 = neo4jUtil.excuteCypherSql(cqlLevel5);
list5.get(j4).setDocLevel(list5.get(j4).getDocLevel() + jj);
int a5 = test1Mapper.updateDocById(list5.get(j4));
List<ZhyDoc> list6 = test1Mapper.getOneHeader(list5.get(j4).getId());
if (list6.size() != 0) {
for (int j5 = 0; j5 < list6.size(); j5++) {
String newl5 = "";
if (list6.get(j5).getDocLevel() == 1) {
newl5 = "leve" + (1 + jj);
}
if (list6.get(j5).getDocLevel() == 2) {
newl5 = "leve" + (2 + jj);
}
if (list6.get(j5).getDocLevel() == 3) {
newl5 = "leve" + (3 + jj);
}
if (list6.get(j5).getDocLevel() == 4) {
newl5 = "leve" + (4 + jj);
}
if (list6.get(j5).getDocLevel() == 5) {
newl5 = "leve" + (5 + jj);
}
if (list6.get(j5).getDocLevel() == 6) {
newl5 = "leve" + (6 + jj);
}
if (list6.get(j5).getDocLevel() == 7) {
newl5 = "leve" + (7 + jj);
}
String cqlLevel6 = "match (r{docId:'" + list6.get(j5).getId() + "'}) SET r.docLeve = '" + newl5 + "'";
StatementResult resultLevel6 = neo4jUtil.excuteCypherSql(cqlLevel6);
list6.get(j5).setDocLevel(list6.get(j5).getDocLevel() + jj);
int a6 = test1Mapper.updateDocById(list6.get(j5));
List<ZhyDoc> list7 = test1Mapper.getOneHeader(list6.get(j5).getId());
if (list7.size() != 0) {
for (int j6 = 0; j6 < list7.size(); j6++) {
String newl6 = "";
if (list7.get(j6).getDocLevel() == 1) {
newl6 = "leve" + (1 + jj);
}
if (list7.get(j6).getDocLevel() == 2) {
newl6 = "leve" + (2 + jj);
}
if (list7.get(j6).getDocLevel() == 3) {
newl6 = "leve" + (3 + jj);
}
if (list7.get(j6).getDocLevel() == 4) {
newl6 = "leve" + (4 + jj);
}
if (list7.get(j6).getDocLevel() == 5) {
newl6 = "leve" + (5 + jj);
}
if (list7.get(j6).getDocLevel() == 6) {
newl6 = "leve" + (6 + jj);
}
if (list7.get(j6).getDocLevel() == 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).setDocLevel(list7.get(j6).getDocLevel() + jj);
int a7 = test1Mapper.updateDocById(list7.get(j6));
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
ZhyFileManage fileManage=test1Mapper.getFileByName(name+".docx");
//判断这个知识点的上级是否进行修改
// Long oldpp = oldZhyDoc.getDocParentId();
// if (oldpp != parentInd) {
//
// //修改上级
// //修改relation
// ZhyDoc zp = test1Mapper.selectDocByIdId(parentInd);
// ZhyDocRelation r = new ZhyDocRelation();
// if(oldpp==0){
// oldpp=fileManage.getId().longValue();
// }
// r.setSource(oldpp);
// r.setTarget(id);
// List<ZhyDocRelation> aa = zhyDocRelationMapper.selectZhyRelationshipList(r);
// ZhyDocRelation qq = aa.get(0);
// if(parentInd==0){
// qq.setSourceName(name);
// parentInd=fileManage.getId().longValue();
//
// }else{
// qq.setSourceName(zp.getDocTitle());
// }
//
// qq.setSource(parentInd);
// qq.setRelationship(relation1);
// int g = zhyDocRelationMapper.updateZhyRelationship(qq);
//
// //删除过去的这个关系
// 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+"', 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+ "', DbId: '' }] -> (b) RETURN r";
// StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC);
// }
//
// }
Long oldpp = oldZhyDoc.getDocParentId();
if (oldpp != parentInd) {
//修改上级
//修改relation
ZhyDoc zp = test1Mapper.selectDocByIdId(parentInd);
ZhyDocRelation r = new ZhyDocRelation();
if(oldpp==0){
oldpp=fileManage.getId().longValue();
}
r.setSource(oldpp);
r.setTarget(id);
List<ZhyDocRelation> aa = zhyDocRelationMapper.selectZhyRelationshipList(r);
ZhyDocRelation qq = aa.get(0);
if(parentInd==0){
qq.setSourceName(name);
parentInd=fileManage.getId().longValue();
// int g = zhyDocRelationMapper.updateZhyRelationship(qq);
}else{
qq.setSourceName(zp.getDocTitle());
}
qq.setSource(parentInd);
qq.setRelationship(relation1);
int g = zhyDocRelationMapper.updateZhyRelationship(qq);
//删除过去的这个关系
String cqrD = "MATCH (n:Local{docId:'" + oldpp + "'})-[r]-(n2:Local{docId:'" + id + "'}) DELETE r";
StatementResult resultD = neo4jUtil.excuteCypherSql(cqrD);
if (relation1 != null && !relation1.equals("")) {
String cqrC = "MATCH (a:Local),(b:Local) WHERE a.docId = '" + parentInd + "' AND b.docId = '" + id + "' CREATE (a)-[r:" + relation1 + " { name: '" + relation1+ "' }] -> (b) RETURN r";
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC);
} else {
String cqrC = "MATCH (a:Local),(b:Local) WHERE a.docId = '" + parentInd + "' AND b.docId = '" + id + "' CREATE (a)-[r:" + relation + " { name: '" + relation+ "' }] -> (b) RETURN r";
StatementResult resultC = neo4jUtil.excuteCypherSql(cqrC);
}
}
// int g = zhyDocRelationMapper.updateZhyRelationship(qq);
return AjaxResult.success("File renamed and updated successfully");
} catch (IOException e) {
e.printStackTrace();
return AjaxResult.error("Error renaming or updating the file: " + e.getMessage());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@PostMapping("/updateTxt1")
@ -3438,18 +3632,18 @@ public class ZhyFileManageController extends BaseController {
zhyFileManage.setCreateBy(getUserId());
zhyFileManageService.insertFile(zhyFileManage);
fileId=zhyFileManage.getId();
String sql="create (doc: Doc{docId:'"+zhyFileManage.getId()+"',docTitle:'"+name+"',docLeve:'leve0',fileId:'"+zhyFileManage.getId()+"'})";
String sql="create (doc: Local{docId:'"+zhyFileManage.getId()+"',docTitle:'"+name+"',docLeve:'leve0',fileId:'"+zhyFileManage.getId()+"'})";
neo4jUtil.excuteCypherSql(sql);
}
}
String txtName = requestBody.get("txtName");
String TxtValue = requestBody.get("TxtValue");
String docParentId=requestBody.get("docParentId");
String relation1 = requestBody.get("relation");
if(relation1.equals("")){
relation1=relation;
}
Long groupId = Long.valueOf(requestBody.get("groupId"));
Long groupId = -1l;
Long docLevel = Long.valueOf(requestBody.get("docLevel"));
ZhyFileManage zhyFileManage = test1Mapper.getFileById(fileId);
@ -3470,17 +3664,10 @@ public class ZhyFileManageController extends BaseController {
zhyDoc.setCreateTime(new Date());
zhyDoc.setCreateBy(String.valueOf(getUserId()));
zhyDoc.setGroupId(groupId);
zhyDoc.setDocParentId(Long.valueOf(docParentId));
test1Mapper.insertDoc(zhyDoc);
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);
String cql = "create (doc: Doc{";
String cql = "create (doc: Local{";
List<Map> listNew = new ArrayList<>();
if (zhyDoc.getId() != null) {
@ -3556,7 +3743,6 @@ public class ZhyFileManageController extends BaseController {
if(zhyDoc.getDocLevel()==1){
//创建关系
ZhyDocRelation zz = new ZhyDocRelation();
zz.setRelationship(relation1);
zz.setSource(fileId.longValue());
@ -3569,7 +3755,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() + "', DbId: '' }] -> (b) RETURN r";
String cqr = "MATCH (a:Local),(b:Local) 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);
@ -3641,6 +3827,15 @@ public class ZhyFileManageController extends BaseController {
zhyDoc.setCreateBy(String.valueOf(getUserId()));
zhyDoc.setGroupId(groupId);
test1Mapper.insertDoc(zhyDoc);
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());
//创建完索引
//创建图谱
@ -3790,7 +3985,7 @@ public class ZhyFileManageController extends BaseController {
esService.deleteDocById("nodes",id.toString());
// luceneUtil.deleteIndexByUrl(String.valueOf(id));
//删除指定的实体
String cql = "MATCH (n:Doc{docId:'" + id + "'}) DETACH delete n";
String cql = "MATCH (n:Local{docId:'" + id + "'}) DETACH delete n";
System.out.println(cql);
StatementResult result1 = neo4jUtil.excuteCypherSql(cql);

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

@ -46,6 +46,7 @@ import java.io.IOException;
import java.util.stream.Collectors;
import com.ruoyi.api.util.PythonApiClient;
import static com.ruoyi.common.constant.Constants.FILE_MANAGER_DIR;
@RestController
@ -335,6 +336,12 @@ public class DocApiController extends BaseController {
}
}
// public static void main(String[] args) {
// String a = "D:\\tupudata\\fileManager\\高影响战场天气过程分析与预报 .docx_20251029_173422\\wordSplitter\\(二)红外云图(IR).txt";
// a=a.replace(FILE_MANAGER_DIR+"\\","");
// a=a.replace("txt","docx");
// System.out.println(a);
// }
//获取文件内容
@PostMapping("/getDocInfo")
@ -343,6 +350,13 @@ public class DocApiController extends BaseController {
zhyDocApi.setDocTitle("");
//先去查询
ZhyDocApi zz = zhyDocApiMapper.selectDoc(zhyDocApi);
if(zz.getDocUrl()!=null){
String url=zz.getDocUrl();
System.out.println(url);
url=url.replace("D:\\tupudata\\fileManager\\","");
url=url.replace("txt","docx");
zz.setUrl(url);
}
if (zz != null) {
// Long pId = zz.getDocParentId();
// if (pId != 0) {
@ -1977,6 +1991,7 @@ public class DocApiController extends BaseController {
} catch (Exception e) {
// 其他潜在异常,如 sendPython 抛出的异常
System.err.println("调用 Python 时发生异常: " + e.getMessage());
e.printStackTrace(); // 打印完整的异常堆栈信息
retryCount++;
if (retryCount > maxRetries) break;
Thread.sleep(2 * 60 * 1000);

10
ruoyi-api/src/main/java/com/ruoyi/api/domain/ZhyDocApi.java

@ -17,6 +17,8 @@ public class ZhyDocApi extends BaseEntity {
private Long docLevel;
private Long docParentId;
private String docUrl;
private String url;
private String prodectName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ -57,6 +59,14 @@ public class ZhyDocApi extends BaseEntity {
private Long openDowload;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Long getOpenDowload() {
return openDowload;
}

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

@ -112,6 +112,10 @@ public class BuildService {
System.out.println("44444444444444");
System.out.println(data);
String mainKeyword = data.get("main_keyword");
System.out.println(mainKeyword+"aaa");
if(mainKeyword==null){
continue;
}
Pattern pattern = Pattern.compile("'([^']*)'");
Matcher matcher = pattern.matcher(mainKeyword);

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

@ -760,7 +760,7 @@ public class GraphServiceImpl implements GraphService {
if (hasNodename || hasRelation) {
// 场景1: 有 nodename 或 关系 -> 查带边的子图
String nodeSql = String.format(
"MATCH (n:Doc)<-[r]->(m:Doc) %s RETURN n, m, r LIMIT %d",
"MATCH (n:Local)<-[r]->(m:Local) %s RETURN n, m, r LIMIT %d",
whereClause, query.getPageSize()
);
System.out.println("Executing Cypher: " + nodeSql);
@ -786,7 +786,7 @@ public class GraphServiceImpl implements GraphService {
nr.put("links", newLinks);
} else {
// 没有关联节点,只查节点本身
String nodeOnlySql = String.format("MATCH (n:Doc) %s RETURN n LIMIT %d", whereClause, query.getPageSize());
String nodeOnlySql = String.format("MATCH (n:Local) %s RETURN n LIMIT %d", whereClause, query.getPageSize());
List<HashMap<String, Object>> soloNodes = neo4jUtil.getGraphNode(nodeOnlySql);
List<HashMap<String, Object>> formattedNodes = convertSoloNodes(soloNodes);
nr.put("nodes", formattedNodes);
@ -797,10 +797,10 @@ public class GraphServiceImpl implements GraphService {
String nodeSql;
if (hasFileId) {
String escapedFileId = query.getFileId().replace("'", "\\'");
nodeSql = String.format("MATCH (n:Doc) WHERE n.fileId = '%s' RETURN distinct(n) LIMIT %d",
nodeSql = String.format("MATCH (n:Local) WHERE n.fileId = '%s' RETURN distinct(n) LIMIT %d",
escapedFileId, query.getPageSize());
} else {
nodeSql = String.format("MATCH (n:Doc) RETURN distinct(n) LIMIT %d", query.getPageSize());
nodeSql = String.format("MATCH (n:Local) RETURN distinct(n) LIMIT %d", query.getPageSize());
}
List<HashMap<String, Object>> graphNode = neo4jUtil.getGraphNode(nodeSql);
@ -812,9 +812,9 @@ public class GraphServiceImpl implements GraphService {
if (hasFileId) {
String escapedFileId = query.getFileId().replace("'", "\\'");
relSql = String.format(
"MATCH (n:Doc)<-[r]->(m:Doc) WHERE n.fileId = '%s' RETURN distinct r", escapedFileId);
"MATCH (n:Local)<-[r]->(m:Local) WHERE n.fileId = '%s' RETURN distinct r", escapedFileId);
} else {
relSql = "MATCH (n:Doc)<-[r]->(m:Doc) RETURN distinct r";
relSql = "MATCH (n:Local)<-[r]->(m:Local) RETURN distinct r";
}
List<HashMap<String, Object>> graphRel = neo4jUtil.getGraphRelationShip(relSql);

3
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java

@ -16,6 +16,7 @@ import com.ruoyi.common.constant.Constants;
import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
import static com.ruoyi.common.constant.Constants.ARTICLE_PDF_DIR;
import static com.ruoyi.common.constant.Constants.FILE_MANAGER_DIR;
/**
* 通用配置
@ -37,6 +38,8 @@ public class ResourcesConfig implements WebMvcConfigurer
// 添加新的映射
registry.addResourceHandler("/api/pdfFile/**")
.addResourceLocations("file:"+ARTICLE_PDF_DIR+ "/");
registry.addResourceHandler("/api/docxFile/**")
.addResourceLocations("file:"+FILE_MANAGER_DIR+ "/");
registry.addResourceHandler("/upload/**")
.addResourceLocations("file:"+"D:/tupudata/upload/");

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

@ -780,7 +780,7 @@ public class ZhyFileManageServiceImpl {
for(int bb=0;bb<list2.size();bb++){
String docId = "";
String cql = "create (doc: Doc{";
String cql = "create (doc: Local{";
for(int a=0;a<list2.get(bb).size();a++){
if(list2.get(bb).get(a).get("key").equals("docId")){
docId = String.valueOf(list2.get(bb).get(a).get("value"));
@ -837,7 +837,7 @@ public class ZhyFileManageServiceImpl {
//创建
for(int i=0;i<listR.size();i++){
String cql = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+listR.get(i).getSource() +"' AND " + "b.docId = '"+listR.get(i).getTarget()+"'";
String cql = "MATCH (a:Local),(b:Local) WHERE a.docId = '"+listR.get(i).getSource() +"' AND " + "b.docId = '"+listR.get(i).getTarget()+"'";
cql = cql + " CREATE (a)-[r:"+String.valueOf(listR.get(i).getRelationship())+"{ name: '"+String.valueOf(listR.get(i).getRelationship())+"'}] -> (b) RETURN r";
StatementResult result = neo4jUtil.excuteCypherSql(cql);
int bb = test1Mapper.updateGraphRelation(listR.get(i));

1
ruoyi-ui/src/main.js

@ -40,6 +40,7 @@ import DictData from '@/components/DictData'
//全局引入echarts
import * as echarts from 'echarts';
import axios from 'axios'
Vue.prototype.$axios = axios;
// 全局方法挂载

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

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

4
ruoyi-ui/src/views/system/fileManage/index.vue

@ -35,8 +35,8 @@
<el-button v-hasPermi="['system:tupupoint:insert']" type="primary" plain style="float: left;margin-left: 2vw" icon="el-icon-plus" size="mini"
@click="openAddTxt()">新增
</el-button>
<!-- <el-button v-hasPermi="['system:tupupoint:export']" type="success" plain style="float: left" icon="el-icon-refresh" size="mini" @click="reset">重置数据-->
<!-- </el-button>-->
<el-button v-hasPermi="['system:tupupoint:export']" type="success" plain style="float: left" icon="el-icon-refresh" size="mini" @click="reset">重置数据
</el-button>
<el-button v-hasPermi="['system:tupupoint:export']" type="info" plain style="float: left" icon="el-icon-upload2" size="mini" @click="handleImport">导入
</el-button>
<el-button v-hasPermi="['system:tupupoint:export']" type="info" plain style="float: left" icon="el-icon-upload2" size="mini"

108
ruoyi-ui/src/views/system/fileManage/indexNB.vue

@ -15,26 +15,11 @@
<el-button type="primary" plain style="float: left;margin-left: 2vw" icon="el-icon-plus" size="mini"
@click="openAddTxt(0)">新增
</el-button>
<el-button type="success" plain style="float: left" icon="el-icon-refresh" size="mini" @click="reset">重置数据
</el-button>
<el-button type="info" plain style="float: left" icon="el-icon-upload2" size="mini" @click="handleImport">导入
</el-button>
<el-button type="info" plain style="float: left" icon="el-icon-upload2" size="mini"
@click="handleImportRelation">导入文献
</el-button>
<el-button type="primary" style="float: left" plain icon="el-icon-download" size="mini" @click="exportAllContent">
导出
<el-button type="info" plain style="float: left" icon="el-icon-upload2" size="mini" @click="handleImport">导入
</el-button>
<el-button type="warning" plain style="float: left" size="mini" @click="exportList">
导出表格
</el-button>
<el-button type="danger" plain style="float: left" size="mini" @click="deletAllInfo">
一键清除
</el-button>
<!-- <el-button type="danger" plain style="float: left" size="mini" @click="opendeletOly=true">-->
<!-- 删除指定实体-->
<!-- </el-button>-->
@ -414,6 +399,7 @@
</div>
</template>
<script>
import mammoth from 'mammoth';
import {getToken} from "@/utils/auth";
import {addTemplate, listTemplate, delTemplate} from "@/api/system/titleTemplate"
import {
@ -428,15 +414,25 @@ import {
getFileListNew1, updateOpenDown, getAllFieldList, downInfoFile, getAllTxtListP, insertNode, reset
} from "@/api/system/file";
import Editor from '@/components/Editor/index.vue'
import {addTxt1, deletAllInfoNew, deleteDocTitleOnly, getFileById,deletAllByFileId} from "../../../api/system/file";
import {
addTxt1,
deletAllInfoNew,
deleteDocTitleOnly,
getFileById,
deletAllByFileId,
updateTxt, deleteTxt
} from "../../../api/system/file";
import {updateTemplate} from "../../../api/system/titleTemplate";
import { mathmlToLatex } from 'mammoth-math';
export default {
components: {
Editor
},
data() {
return {
htmlContent:"",
templeteTitle:"创建新模板",
//
templateDialog: {
@ -704,6 +700,40 @@ export default {
}
},
methods: {
async loadDocx(url) {
try {
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const arrayBuffer = await response.arrayBuffer();
// 使 mammoth-math mathmlToLatex
const result = await mammoth.convertToHtml(
{ arrayBuffer },
{
mathConverter: mathmlToLatex
}
);
//
let htmlContent = result.value.replace(
/&lt;img\s+src=["']([^"']+)["'][^&]*&gt;/gi,
(match, src) => `<img src="${src}" style="max-width:100%">`
);
this.htmlContent = htmlContent;
this.TxtValue = this.htmlContent
this.loading = false;
this.$nextTick(() => {
this.renderMath();
});
} catch (err) {
console.error('加载或解析失败:', err);
this.error = `无法加载文档: ${err.message}`;
this.loading = false;
}
},
handleCancle() {
this.templateEditor.visible = false;
this.templateEditor.form.level1 = ""
@ -1243,7 +1273,7 @@ export default {
url: row.docUrl
}
this.$modal.confirm('是否确认删除"' + row.docTitle + '"的数据项?').then(function () {
return deleteTxt1(data);
return deleteTxt(data);
}).then(() => {
this.getFileListInfo()
this.$modal.msgSuccess("删除成功");
@ -1269,7 +1299,7 @@ export default {
docLevel: this.level,
relation: this.relaTion,
}
addTxt1(data).then((res) => {
addTxtC(data).then((res) => {
if (res.code == 200) {
this.$message.success("新增成功")
this.addTxt = false
@ -1344,7 +1374,7 @@ export default {
docLevel: this.level1
}
console.log(data);
updateTxt1(data).then((res) => {
updateTxt(data).then((res) => {
this.editTxt = false
if (res.code == 200) {
this.$message.success("修改成功")
@ -1363,6 +1393,12 @@ export default {
})
},
async editDoc(row) {
let url22=row.docUrl
url22=url22.replace("D:\\tupudata\\fileManager\\","")
url22=url22.replace(".txt",".docx")
url22="http://localhost/dev-api/api/docxFile/"+url22
console.log(row);
this.txtId = row.id;
this.fileId = row.fileId;
@ -1414,9 +1450,11 @@ export default {
}
})
getTxt(row.docUrl).then((res) => {
this.editTxt = true
this.TxtValue = res
this.loadDocx(url22)
// this.TxtValue = res
})
},
async changeLevel(row) {
@ -1543,6 +1581,29 @@ export default {
this.loading = false;
}
},
async renderMath() {
try {
const { MathJax } = await import('mathjax-full/js/components/startup.js');
window.MathJax = MathJax;
MathJax.config = {
loader: { load: ['input/tex', 'output/chtml'] },
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\\[', '\\]']]
}
};
await MathJax.startup.promise;
if (typeof window.MathJax.typesetPromise === 'function') {
await window.MathJax.typesetPromise([this.$el]);
console.log('✅ 公式渲染成功');
}
} catch (err) {
console.error('❌ MathJax 渲染失败', err);
}
},
},
mounted() {
this.getFileListInfo()
@ -1553,6 +1614,9 @@ export default {
socket.onmessage = function (event) {
that.upload.tip = event.data
}
this.renderMath()
},
}
</script>

Loading…
Cancel
Save