diff --git a/gyxtp/package-lock.json b/gyxtp/package-lock.json index 24f2bf7..cf0fd4c 100644 --- a/gyxtp/package-lock.json +++ b/gyxtp/package-lock.json @@ -15,7 +15,7 @@ "@vueuse/core": "^10.1.0", "axios": "^1.7.7", "core-js": "^3.8.3", - "echarts": "^5.5.1", + "echarts": "^5.3.3", "echarts-wordcloud": "^2.0.0", "element-plus": "^2.8.8", "fabric": "^6.4.3", @@ -6538,18 +6538,18 @@ } }, "node_modules/echarts": { - "version": "5.5.1", - "resolved": "https://registry.npmmirror.com/echarts/-/echarts-5.5.1.tgz", - "integrity": "sha512-Fce8upazaAXUVUVsjgV6mBnGuqgO+JNDlcgF79Dksy4+wgGpQB2lmYoO4TSweFg/mZITdpGHomw/cNBJZj1icA==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.3.tgz", + "integrity": "sha512-BRw2serInRwO5SIwRviZ6Xgm5Lb7irgz+sLiFMmy/HOaf4SQ+7oYqxKzRHAKp4xHQ05AuHw1xvoQWJjDQq/FGw==", "dependencies": { "tslib": "2.3.0", - "zrender": "5.6.0" + "zrender": "5.3.2" } }, "node_modules/echarts-wordcloud": { - "version": "2.1.0", - "resolved": "https://registry.npmmirror.com/echarts-wordcloud/-/echarts-wordcloud-2.1.0.tgz", - "integrity": "sha512-Kt1JmbcROgb+3IMI48KZECK2AP5lG6bSsOEs+AsuwaWJxQom31RTNd6NFYI01E/YaI1PFZeueaupjlmzSQasjQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/echarts-wordcloud/-/echarts-wordcloud-2.0.0.tgz", + "integrity": "sha512-K7l6pTklqdW7ZWzT/1CS0KhBSINr/cd7c5N1fVMzZMwLQHEwT7x+nivK7g5hkVh7WNcAv4Dn6/ZS5zMKRozC1g==", "peerDependencies": { "echarts": "^5.0.1" } @@ -15875,9 +15875,9 @@ "dev": true }, "node_modules/zrender": { - "version": "5.6.0", - "resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.6.0.tgz", - "integrity": "sha512-uzgraf4njmmHAbEUxMJ8Oxg+P3fT04O+9p7gY+wJRVxo8Ge+KmYv0WJev945EH4wFuc4OY2NLXz46FZrWS9xJg==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.3.2.tgz", + "integrity": "sha512-8IiYdfwHj2rx0UeIGZGGU4WEVSDEdeVCaIg/fomejg1Xu6OifAL1GVzIPHg2D+MyUkbNgPWji90t0a8IDk+39w==", "dependencies": { "tslib": "2.3.0" } @@ -20497,18 +20497,18 @@ "dev": true }, "echarts": { - "version": "5.5.1", - "resolved": "https://registry.npmmirror.com/echarts/-/echarts-5.5.1.tgz", - "integrity": "sha512-Fce8upazaAXUVUVsjgV6mBnGuqgO+JNDlcgF79Dksy4+wgGpQB2lmYoO4TSweFg/mZITdpGHomw/cNBJZj1icA==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.3.tgz", + "integrity": "sha512-BRw2serInRwO5SIwRviZ6Xgm5Lb7irgz+sLiFMmy/HOaf4SQ+7oYqxKzRHAKp4xHQ05AuHw1xvoQWJjDQq/FGw==", "requires": { "tslib": "2.3.0", - "zrender": "5.6.0" + "zrender": "5.3.2" } }, "echarts-wordcloud": { - "version": "2.1.0", - "resolved": "https://registry.npmmirror.com/echarts-wordcloud/-/echarts-wordcloud-2.1.0.tgz", - "integrity": "sha512-Kt1JmbcROgb+3IMI48KZECK2AP5lG6bSsOEs+AsuwaWJxQom31RTNd6NFYI01E/YaI1PFZeueaupjlmzSQasjQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/echarts-wordcloud/-/echarts-wordcloud-2.0.0.tgz", + "integrity": "sha512-K7l6pTklqdW7ZWzT/1CS0KhBSINr/cd7c5N1fVMzZMwLQHEwT7x+nivK7g5hkVh7WNcAv4Dn6/ZS5zMKRozC1g==", "requires": {} }, "ee-first": { @@ -27478,9 +27478,9 @@ } }, "zrender": { - "version": "5.6.0", - "resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.6.0.tgz", - "integrity": "sha512-uzgraf4njmmHAbEUxMJ8Oxg+P3fT04O+9p7gY+wJRVxo8Ge+KmYv0WJev945EH4wFuc4OY2NLXz46FZrWS9xJg==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.3.2.tgz", + "integrity": "sha512-8IiYdfwHj2rx0UeIGZGGU4WEVSDEdeVCaIg/fomejg1Xu6OifAL1GVzIPHg2D+MyUkbNgPWji90t0a8IDk+39w==", "requires": { "tslib": "2.3.0" } diff --git a/gyxtp/package.json b/gyxtp/package.json index d10f9d9..a58086b 100644 --- a/gyxtp/package.json +++ b/gyxtp/package.json @@ -12,7 +12,7 @@ "@vueuse/core": "^10.1.0", "axios": "^1.7.7", "core-js": "^3.8.3", - "echarts": "^5.5.1", + "echarts": "^5.3.3", "echarts-wordcloud": "^2.0.0", "element-plus": "^2.8.8", "fabric": "^6.4.3", diff --git a/gyxtp/src/view/docInfo.vue b/gyxtp/src/view/docInfo.vue index 14105f7..fb31469 100644 --- a/gyxtp/src/view/docInfo.vue +++ b/gyxtp/src/view/docInfo.vue @@ -51,11 +51,11 @@
-
+
知识内容
-
+
关系图谱
@@ -63,7 +63,7 @@ -
+
图片视频
@@ -71,11 +71,11 @@
-
+
知识内容
-
+
关系图谱
@@ -83,20 +83,20 @@ -
+
图片视频
-
-
+
+
知识内容
-
+
关系图谱
@@ -104,20 +104,20 @@ -
+
图片视频
-
-
+
+
知识内容
-
+
关系图谱
@@ -125,7 +125,7 @@ -
+
图片视频
@@ -233,67 +233,71 @@ @@ -654,8 +658,9 @@ export default { }, onNodeClick(nodeObject, $event) { - var url = localStorage.getItem("docUrl"); + var url = localStorage.getItem("docUrl"); + console.log(url) localStorage.setItem("oldDocUrl", url) localStorage.setItem("oldLevel", this.$route.query.level); localStorage.setItem("olddocId", this.$route.query.docId) @@ -664,7 +669,12 @@ export default { 'id': nodeObject.data.docId, 'docTitle': nodeObject.text, } + if (data.docTitle=="联合作战气象海洋影响评估与决策支撑体系"){ + return + } + getDocInfo(data).then((res) => { + localStorage.setItem("docUrl", res.data.docUrl); this.$router.replace({ query: { @@ -929,7 +939,7 @@ export default { }, width: 320, height: 320, - color: '#1955ff', + color: '#ffd602', fontColor: '#000000', className: 'testNode' }) @@ -946,7 +956,7 @@ export default { docId: nodeList[a].docId, width: 300, height: 300, - color: '#ffd119' + color: 'rgb(64, 158, 255)' }) } if (nodeList[a].docLeve == "leve2") { @@ -961,7 +971,7 @@ export default { docId: nodeList[a].docId, width: 260, height: 260, - color: '#9b72a6' + color: '#ff8c00' }) } if (nodeList[a].docLeve == "leve3") { @@ -976,7 +986,7 @@ export default { docId: nodeList[a].docId, width: 220, height: 220, - color: '#b7f49e' + color:'#67c23a' }) } if (nodeList[a].docLeve == "leve4") { @@ -991,7 +1001,7 @@ export default { docId: nodeList[a].docId, width: 180, height: 180, - color: 'rgba(255,156,41,0.96)' + color: 'rgb(248,143,248)' }) } if (nodeList[a].docLeve == "leve5") { @@ -1006,7 +1016,7 @@ export default { docId: nodeList[a].docId, width: 140, height: 140, - color: 'rgba(30,255,0,0.73)' + color: 'rgb(65,154,255)' }) } if (nodeList[a].docLeve == "leve6") { @@ -1021,7 +1031,7 @@ export default { docId: nodeList[a].docId, width: 110, height: 110, - color: '#00e4ff' + color: 'rgb(0,228,255)' }) } @@ -1033,7 +1043,7 @@ export default { from: lineList[b].sourceid, to: lineList[b].targetid, text: lineList[b].name, - color: '#000000', + color: '#fff', uuid: lineList[b].uuid, lineWidth: 2 }) diff --git a/gyxtp/src/view/graphPageCopy0926.vue b/gyxtp/src/view/graphPageCopy0926.vue index 3625b85..e738ba1 100644 --- a/gyxtp/src/view/graphPageCopy0926.vue +++ b/gyxtp/src/view/graphPageCopy0926.vue @@ -349,9 +349,8 @@ export default { defaultNodeShape: 0, defaultNodeWidth: 40, defaultNodeHeight: 40, - toolBarDirection: 'h', - toolBarPositionH: 'center', - toolBarPositionV: 'bottom', + toolBarDirection: 'v', + toolBarPositionH: 'right', defaultLineShape: 1, defaultJunctionPoint: 'border', // lineUseTextPath: true, @@ -463,6 +462,9 @@ export default { 'id': nodeObject.data.docId, 'docTitle': nodeObject.text, } + if (data.docTitle=="联合作战气象海洋影响评估与决策支撑体系"){ + return + } getDocInfo(data).then((res) => { localStorage.setItem("docUrl", res.data.docUrl) this.$router.push({ @@ -1642,6 +1644,11 @@ tr { font-weight: 600; color:white; } +.el-table .success-row:hover > .el-table__cell { + background-color: red !important; + color: white !important; + font-weight: 600; +} .el-table .cell{ width:400px; } diff --git a/gyxtp/src/view/graphPageNB927.vue b/gyxtp/src/view/graphPageNB927.vue new file mode 100644 index 0000000..c56f037 --- /dev/null +++ b/gyxtp/src/view/graphPageNB927.vue @@ -0,0 +1,1583 @@ + + + + + + diff --git a/gyxtp/src/view/small.vue b/gyxtp/src/view/small.vue index ac58e35..fe20d1f 100644 --- a/gyxtp/src/view/small.vue +++ b/gyxtp/src/view/small.vue @@ -12,6 +12,7 @@
+
@@ -26,6 +27,7 @@ +
+

固定区域词云图

+
+
@@ -113,16 +119,21 @@ + +
+
@@ -1126,4 +1244,33 @@ tr { .el-tree--highlight-current { background: no-repeat; } + + +.container h3 { + margin: 0 0 10px 0; + font-size: 16px; + color: white; + text-align: center; +} + + +.container { + position: fixed; + bottom: 20px; + left:100px; + width: 400px; /* 增大宽度 */ + height: 300px; /* 增大高度 */ + background-color: transparent; + border: 1px solid #ddd; + border-radius: 12px; + box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); + padding: 12px; + z-index: 9999; +} + +.chart-container { + width: 100%; + height: calc(100% - 42px); /* 调整标题高度 */ + position: relative; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java index 8260ab6..6c551f8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java @@ -275,6 +275,258 @@ public class ZhyFileManageController extends BaseController { // 默认 fallback return isDefinitelyUtf8 ? "UTF-8" : "GBK"; } +// @PostMapping("/insertRelationByFile") +// public AjaxResult insertRelationByFile(MultipartFile file) throws Throwable { +// // 1. 校验文件是否为空 +// if (file.isEmpty()) { +// return AjaxResult.error("上传的文件为空"); +// } +// String filePath1 =ARTICLE_DIR; +// // 2. 读取 CSV 文件(使用 GBK 编码) +// List> dataList = new ArrayList<>(); +// String[] headers = null; +// +// InputStream inputStream = null; +// BufferedReader reader = null; +// try { +// inputStream = file.getInputStream(); +// +// // 🔍 第一步:探测编码 +// String encoding = detectCsvEncoding(inputStream); +// System.out.println("自动检测到编码: " + encoding); +// +// // 重新打开流(因为探测时已读取部分数据) +// inputStream.close(); +// inputStream = file.getInputStream(); +// +// reader = new BufferedReader(new InputStreamReader(inputStream, encoding)); +// +// String line; +// int lineNumber = 0; +// +// while ((line = reader.readLine()) != null) { +// lineNumber++; +// +// // 去除 BOM(如果存在) +// if (lineNumber == 1 && line.startsWith("\uFEFF")) { +// line = line.substring(1); +// } +// +// // ✅ 替换 split(",") 为能处理引号内逗号的解析方法 +// String[] row = parseCsvLine(line); +// for (int i = 0; i < row.length; i++) { +// row[i] = row[i].trim(); // 去空格 +// } +// +// if (lineNumber == 1) { +// // 第一行是表头 +// headers = row; +// continue; // 跳过第一行,不加入数据 +// } +// +// // 将每一行转为 Map +// Map rowMap = new HashMap<>(); +// for (int i = 0; i < headers.length && i < row.length; i++) { +// String key = headers[i].trim(); +// // 只保留你需要的字段 +// if (Arrays.asList("ck", "main_keyword", "sub_keyword", "title", "authors", "keywords", "abstract", "url", "urls").contains(key)) { +// rowMap.put(key, row[i]); +// } +// } +// dataList.add(rowMap); +// } +// +// } catch (IOException e) { +// return AjaxResult.error("读取文件时发生错误:" + e.getMessage()); +// } finally { +// try { +// if (reader != null) reader.close(); +// if (inputStream != null) inputStream.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// List allRelation=new ArrayList<>(); +// // 3. 处理每一行数据(和你原来逻辑一致) +// for (Map data : dataList) { +// System.out.println("44444444444444"); +// System.out.println(data); +// String mainKeyword = data.get("main_keyword"); +// Pattern pattern = Pattern.compile("'([^']*)'"); +// Matcher matcher = pattern.matcher(mainKeyword); +// +// ArrayList mainKeywordList = new ArrayList<>(); +// while (matcher.find()) { +// mainKeywordList.add(matcher.group(1)); // 提取引号内的内容 +// } +// +//// System.out.println(mainKeywordList); +// Map mapLevel=new HashMap(); +// for (int i=0;i relations=zhyDocRelationMapper.selectZhyRelationshipArticle(relation); +//// System.out.println(relations); +// if(relations.size()>0){ +// boolean flag=false; +// for (int p=0;p data,String local) throws IOException { + ZhyDoc doc1 = test1Mapper.selectDocByTitle(parentValue); + ZhyDoc doc2 = test1Mapper.selectDocByTitle(childValue); + if (doc1 != null && doc2 != null) { + List allDocs = test1Mapper.selectAllDoc1(); + for (ZhyDoc doc : allDocs) { + if (doc.getDocTitle().equals(childValue)) { + doc.setDocParentId(doc1.getId()); + String updateCql = "MATCH (doc:Doc {docId: '" + doc.getId() + "'}) " + + "SET doc.docParentId = '" + doc1.getId() + "' " + + "RETURN doc"; + neo4jUtil.excuteCypherSql(updateCql); + } + } + // 插入文章 + ZhyArticle article = new ZhyArticle(); + article.setName(data.get("title")); +// article.setOpenUrl(data.get("urls")); + File file = new File(ARTICLE_PDF_DIR, article.getName()+".pdf"); + System.out.println("文件路径: " + file.getAbsolutePath()); + article.setLocalUrl(file.getAbsolutePath()); + article.setAuthors(data.get("authors")); + article.setKeywords(data.get("keywords")); + article.setSummary(data.get("abstract")); + article.setUrls(data.get("urls")); + article.setSourceId(doc1.getId()); + article.setSourceName(doc1.getDocTitle()); + article.setTargetId(doc2.getId()); + article.setTagertName(doc2.getDocTitle()); + + zhyArticleMapper.insertZhyArticle(article); + + // 插入关系 + ZhyDocRelation zz = new ZhyDocRelation(); + zz.setRelationship("相关"); // 你可能需要从 CSV 中读取关系类型,或固定值 + zz.setSource(doc1.getId()); + zz.setTarget(doc2.getId()); + zz.setSourceName(doc1.getDocTitle()); + zz.setTargetName(doc2.getDocTitle()); + zz.setCreateTime(new Date()); + zz.setArticleId(article.getId()); + System.out.println(zz); + zhyDocRelationMapper.insertZhyRelationship(zz); + List ids = new ArrayList<>(); + ids.add(String.valueOf(zz.getId())); + ESDao esDao = new ESDao(); + esDao.id = article.getId().toString(); + esDao.DBid = article.getId().toString(); + esDao.type = "line"; + if(article.getLocalUrl()!=null){ + System.out.println("333333"); + try { + String txt=article.getLocalUrl().replace("pdf", "txt"); + List content = extractContentUntilSecondPage(txt); + if (content != null) { + // 打印结果 + for (String line : content) { + System.out.println(line); + } + String result = String.join("", content); + esDao.abstracts = result; + } else { + System.out.println("未找到相关内容或文件不存在。"); + esDao.abstracts = article.getName()+article.getKeywords()+article.getSummary(); + } + } catch (IOException e) { + e.printStackTrace(); + esDao.abstracts = article.getName()+article.getKeywords()+article.getSummary(); + } + }else{ + esDao.abstracts = article.getName()+article.getKeywords()+article.getSummary(); + } + esDao.data = ids.toString(); + esService.insertDocById("links",esDao); + + + } + // 4. 批量创建 Neo4j 关系 + List listR = zhyDocRelationMapper.getAllRelation(); + for (ZhyDocRelation rel : listR) { + String cql = "MATCH (a:Doc),(b:Doc) " + + "WHERE a.docId = '" + rel.getSource() + "' AND b.docId = '" + rel.getTarget() + "' " + + "CREATE (a)-[r:" + rel.getRelationship() + " {name: '" + rel.getRelationship() +"', DbId: '"+rel.getId()+ "'}]->(b) " + + "RETURN r"; + + neo4jUtil.excuteCypherSql(cql); + test1Mapper.updateGraphRelation(rel); + } + + } @PostMapping("/insertRelationByFile") public AjaxResult insertRelationByFile(MultipartFile file) throws Throwable { // 1. 校验文件是否为空 @@ -357,6 +609,14 @@ public class ZhyFileManageController extends BaseController { Map data = dataList.get(i); String title1=data.get("main_keyword"); + String mainKeyword = data.get("main_keyword"); + Pattern pattern = Pattern.compile("'([^']*)'"); + Matcher matcher = pattern.matcher(mainKeyword); + + ArrayList mainKeywordList = new ArrayList<>(); + while (matcher.find()) { + mainKeywordList.add(matcher.group(1)); // 提取引号内的内容 + } System.out.println(title1); String title2=data.get("sub_keyword"); System.out.println(title2); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyRelationshipController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyRelationshipController.java index 25453a4..61da64b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyRelationshipController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyRelationshipController.java @@ -167,6 +167,7 @@ public class ZhyRelationshipController extends BaseController } zhyRelationship.setTargetName(dd2.getDocTitle()); zhyRelationship.setIsgraph(1l); + zhyRelationship.setRelationship("相关"); zhyRelationshipMapper.insertZhyRelationship(zhyRelationship); String cqr = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+zhyRelationship.getSource()+"' AND b.docId = '"+zhyRelationship.getTarget()+"'CREATE (a)-[r:"+zhyRelationship.getRelationship()+"{ name: '"+zhyRelationship.getRelationship()+ "', DbId: '"+zhyRelationship.getId()+"' }] -> (b) RETURN r"; neo4jUtil.excuteCypherSql(cqr); @@ -219,6 +220,7 @@ public class ZhyRelationshipController extends BaseController ZhyDoc dd2 = test1Mapper.selectDocById(vv); zhyRelationship.setTargetName(dd2.getDocTitle()); zhyRelationship.setIsgraph(1l); + zhyRelationship.setRelationship("相关"); zhyRelationshipMapper.insertZhyRelationship(zhyRelationship); String cqr = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+zhyRelationship.getSource()+"' AND b.docId = '"+zhyRelationship.getTarget()+"'CREATE (a)-[r:"+zhyRelationship.getRelationship()+"{ name: '"+zhyRelationship.getRelationship()+ "', DbId: '"+zhyRelationship.getId()+"' }] -> (b) RETURN r"; neo4jUtil.excuteCypherSql(cqr); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/FolderUploadController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/FolderUploadController.java index 4685a13..2e5c56e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/FolderUploadController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/FolderUploadController.java @@ -107,39 +107,88 @@ public class FolderUploadController { // List> dataList = new ArrayList<>(); List articles = new ArrayList<>(); - ZhyArticle zhyArticle = null; // 当前正在构建的记录 + System.out.println("有"); try (BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) { String line; + ZhyArticle zhyArticle = null; + String currentField = null; // 当前字段:"authors", "agencies", "summary" + while ((line = reader.readLine()) != null) { line = line.trim(); - if (line.isEmpty()) continue; // 跳过空行 + if (line.isEmpty()) continue; + + // ✅ 步骤1:检查前8个字符内是否有冒号(: 或 :) + int sepIndex = -1; + char separator = '\0'; + String prefix = line.substring(0, Math.min(8, line.length())); // 前最多8个字符 + + if (prefix.contains(":")) { + sepIndex = prefix.indexOf(":"); + separator = ':'; + } else if (prefix.contains(":")) { + sepIndex = prefix.indexOf(":"); + separator = ':'; + } - if (line.startsWith("题名:")) { - if (zhyArticle != null) { - articles.add(zhyArticle); - } - // 开始一条新记录 - zhyArticle = new ZhyArticle(); - zhyArticle.setName(line.substring(3)); - }else if (line.startsWith("作者:")) { - if (zhyArticle != null) { - zhyArticle.setAuthors(line.substring(3)); // 去掉"单位:" + // 判断是否是“字段行”(前8字符内有冒号) + if (sepIndex != -1) { + String fieldKey = line.substring(0, sepIndex).trim(); + String value = line.substring(sepIndex + (separator == ':' ? 1 : 1)).trim(); + + // ✅ 只处理你关心的四个字段 + if ("题名".equals(fieldKey)) { + if (zhyArticle != null) { + articles.add(zhyArticle); + } + zhyArticle = new ZhyArticle(); + zhyArticle.setName(value); + currentField = null; + } else if ("作者".equals(fieldKey)) { + if (zhyArticle != null) { + zhyArticle.setAuthors(value); + currentField = "authors"; + } + } else if ("单位".equals(fieldKey)) { + if (zhyArticle != null) { + zhyArticle.setAgencies(value); + currentField = "agencies"; + } + } else if ("摘要".equals(fieldKey)) { + if (zhyArticle != null) { + zhyArticle.setSummary(value); + currentField = "summary"; + } } - } else if (line.startsWith("单位:")) { - if (zhyArticle != null) { - zhyArticle.setAgencies(line.substring(3)); // 去掉"单位:" + // ✅ 如果字段不在白名单内(如“中文刊名”),则: + // - 不处理 + // - 不追加 + // - 重置 currentField(防止后续行追加到错误字段) + else { + currentField = null; // 关键:断开与之前字段的联系 } - } else if (line.startsWith("摘要:")) { - if (zhyArticle != null) { - zhyArticle.setSummary(line.substring(3)); // 去掉"题名:" + } + // ✅ 普通行:不是字段行,追加到 currentField + else { + if (zhyArticle != null && currentField != null) { + if ("authors".equals(currentField)) { + String existing = zhyArticle.getAuthors(); + zhyArticle.setAuthors((existing != null ? existing : "") + "\n" + line); + } else if ("agencies".equals(currentField)) { + String existing = zhyArticle.getAgencies(); + zhyArticle.setAgencies((existing != null ? existing : "") + "\n" + line); + } else if ("summary".equals(currentField)) { + String existing = zhyArticle.getSummary(); + zhyArticle.setSummary((existing != null ? existing : "") + "\n" + line); + } } + // 如果 currentField == null,说明前面是未知字段,跳过 } } - // 文件读完,别忘了把最后一条记录加上 + // 添加最后一条记录 if (zhyArticle != null) { articles.add(zhyArticle); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java b/ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java index f681518..8e7feb8 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java @@ -1754,6 +1754,7 @@ public class DocApiController extends BaseController { taskInfo.setName2(doc2.getDocTitle()); taskInfo.setGroupId(1l); taskInfo.setStatus(0); + zhyTaskInfoService.insertZhyTaskInfo(taskInfo); } } for(int i=0;i ids = new ArrayList<>(); -// for (ZhyDocRelation rel : allRelation) { -// ids.add(String.valueOf(rel.getId())); -// } -// for (ZhyDocRelation rel : allRelation) { -// ZhyArticle article=zhyArticleMapper.selectZhyArticleById(rel.getArticleId()); -// ESDao esDao = new ESDao(); -// esDao.id = article.getId().toString(); -// esDao.DBid = article.getId().toString(); -// esDao.type = "line"; -// esDao.abstracts = article.getName()+article.getKeywords()+article.getSummary(); -// esDao.data = ids.toString(); -// -// } - - -// return AjaxResult.success().put("msg", "文件处理完成,共导入 " + dataList.size() + " 条数据"); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WordSplitter.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WordSplitter.java index ba1781f..b87916c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WordSplitter.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WordSplitter.java @@ -2268,7 +2268,7 @@ public class WordSplitter { zz.setDocLevel(1l); ZhyDoc zhy = test1Mapper.selectDoc(zz); zhy.setDocParentId(0l); - zhy.setGroupId(Long.valueOf(i)); + zhy.setGroupId(0l); updateList.add(zhy); @@ -2287,7 +2287,7 @@ public class WordSplitter { aa.setDocUrl(String.valueOf(ll.get(a).get("docUrl"))); aa.setDocParentId(TopId); aa.setCreateTime(new Date()); - aa.setGroupId(Long.valueOf(i)); + aa.setGroupId(0l); updateList.add(aa); } else { int aaaaa = 0; @@ -2318,7 +2318,7 @@ public class WordSplitter { newDoc.setCreateTime(new Date()); newDoc.setDocParentId(zhy1.getId()); System.out.println(newDoc); - newDoc.setGroupId(Long.valueOf(i)); + newDoc.setGroupId(0l); updateList.add(newDoc); aaaaa = 1; break; @@ -2334,7 +2334,7 @@ public class WordSplitter { aa.setDocUrl(String.valueOf(ll.get(a).get("docUrl"))); aa.setDocParentId(TopId); aa.setCreateTime(new Date()); - aa.setGroupId(Long.valueOf(i)); + aa.setGroupId(0l); System.out.println(aa); updateList.add(aa); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZhyFileManageServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZhyFileManageServiceImpl.java index 3de1cb3..4042a6e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZhyFileManageServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZhyFileManageServiceImpl.java @@ -136,7 +136,7 @@ public class ZhyFileManageServiceImpl { String name1 = name; String name2 = source; ZhyDocRelation zz1 = new ZhyDocRelation(); - zz1.setRelationship("属于"); + zz1.setRelationship("包含"); zz1.setSource(Long.valueOf(fileId)); zz1.setTarget(OneId); zz1.setSourceName(name1); @@ -151,7 +151,7 @@ public class ZhyFileManageServiceImpl { String target = list1.get(i).getDocTitle(); // String aa = relationUtil.analyzeRelationship(source,target); - String aa = "属于"; + String aa = "包含"; // System.out.println(aa); //获取两个的Id Long TwoId = list1.get(i).getId(); @@ -175,7 +175,7 @@ public class ZhyFileManageServiceImpl { String source = list2.get(a1).getDocTitle(); String target = list1.get(i).getDocTitle(); // String aa = relationUtil.analyzeRelationship(source,target); - String aa = "属于"; + String aa = "包含"; System.out.println(aa); //获取两个的Id Long TwoId = list1.get(i).getId(); @@ -199,7 +199,7 @@ public class ZhyFileManageServiceImpl { for(int i=0;i