From 6da6c1571438a9ae16e00e5bca8385cd7a511998 Mon Sep 17 00:00:00 2001 From: hanyuqing <1106611654@qq.com> Date: Tue, 16 Sep 2025 21:33:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E5=9B=BE=E8=B0=B1=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gyxtp/src/router/router.js | 2 +- .../src/main/java/com/ruoyi/api/ReadTextData.java | 66 ++ .../com/ruoyi/api/controller/DocApiController.java | 4 +- .../com/ruoyi/api/service/impl/BuildService.java | 193 +++++- .../java/com/ruoyi/common/constant/Constants.java | 3 + ruoyi-system/pom.xml | 6 +- .../ruoyi/system/service/impl/WordSplitter.java | 736 +++++++++++++++------ ruoyi-ui/src/api/system/article.js | 44 ++ ruoyi-ui/src/views/system/article/index.vue | 399 +++++++++++ ruoyi-ui/src/views/system/docmuban/index.vue | 4 +- ruoyi-ui/src/views/system/fileManage/index.vue | 76 +-- 11 files changed, 1281 insertions(+), 252 deletions(-) create mode 100644 ruoyi-api/src/main/java/com/ruoyi/api/ReadTextData.java create mode 100644 ruoyi-ui/src/api/system/article.js create mode 100644 ruoyi-ui/src/views/system/article/index.vue diff --git a/gyxtp/src/router/router.js b/gyxtp/src/router/router.js index ffa72c7..68350e6 100644 --- a/gyxtp/src/router/router.js +++ b/gyxtp/src/router/router.js @@ -22,7 +22,7 @@ const routes = [ meta: { title: '数据图谱', }, - component: () => import ("../view/graphPageCopy.vue") + component: () => import ("../view/graphPage.vue") }, { path: '/battlefield', diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/ReadTextData.java b/ruoyi-api/src/main/java/com/ruoyi/api/ReadTextData.java new file mode 100644 index 0000000..c7ba382 --- /dev/null +++ b/ruoyi-api/src/main/java/com/ruoyi/api/ReadTextData.java @@ -0,0 +1,66 @@ +package com.ruoyi.api; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.*; + +public class ReadTextData { + + // 定义一个类来存储每条记录 + static class Record { + String author; + String organization; + String title; + + @Override + public String toString() { + return "Record{" + + "author='" + author + '\'' + + ", organization='" + organization + '\'' + + ", title='" + title + '\'' + + '}'; + } + } + + public static void main(String[] args) { + // 替换为你的实际文件路径 + String filePath = "D:\\project\\gyx\\tupudata\\csv\\test.txt"; // Windows 路径示例 + // String filePath = "/Users/yourname/data.txt"; // Mac/Linux 路径示例 + + List records = new ArrayList<>(); + + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) { + + String line; + Record currentRecord = null; + int lineCount = 0; + + while ((line = reader.readLine()) != null) { + line = line.trim(); // 去除首尾空格 + if (line.isEmpty()) continue; // 跳过空行 + + lineCount++; + if (line.startsWith("作者:")) { + currentRecord = new Record(); + currentRecord.author = line.substring(3); // 去掉"作者:" + records.add(currentRecord); + } else if (line.startsWith("单位:") && currentRecord != null) { + currentRecord.organization = line.substring(3); // 去掉"单位:" + } else if (line.startsWith("题名:") && currentRecord != null) { + currentRecord.title = line.substring(3); // 去掉"题名:" + } + // 如果格式不匹配,可添加日志或报错 + } + + } catch (IOException e) { + System.err.println("读取文件时发生错误:" + e.getMessage()); + e.printStackTrace(); + } + + // 打印所有解析出的数据 + for (int i = 0; i < records.size(); i++) { + System.out.println("第" + (i+1) + "条: " + records.get(i)); + } + } +} \ No newline at end of file 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 a518806..3c80635 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 @@ -1891,8 +1891,8 @@ public void goPython(ZhyTaskInfo info, List> searchItems,Str // 解析 JSON 响应 ObjectMapper mapper = new ObjectMapper(); - Map objMap = mapper.readValue(payload, new TypeReference>() {}); - +// Map objMap = mapper.readValue(payload, new TypeReference>() {}); + Map objMap = gson.fromJson(payload, Map.class); // 检查响应状态 if ("500".equals(objMap.get("code"))) { info.setStatus(2); diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java index 9e13edb..8f4b6d4 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java @@ -1,5 +1,6 @@ package com.ruoyi.api.service.impl; +import com.ruoyi.api.ReadTextData; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.Neo4jUtil; import com.ruoyi.system.domain.ZhyArticle; @@ -14,10 +15,12 @@ import org.springframework.stereotype.Service; import java.io.*; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static com.ruoyi.common.constant.Constants.ARTICLE_DIR; import static com.ruoyi.common.constant.Constants.ARTICLE_PDF_DIR; @Service @@ -42,7 +45,7 @@ public class BuildService { // System.out.println(thesis.get("url")); // 1. 获取文件路径 String filePath = (String) thesis.get("url"); - String filePath1 = (String) thesis.get("url1"); + String filePath1 =ARTICLE_DIR; if (filePath == null || filePath.trim().isEmpty()) { // return AjaxResult.error("文件路径不能为空"); } @@ -193,8 +196,196 @@ public class BuildService { } + public void create1(Map thesis){ + // 1. 获取文件路径 + String filePath = (String) thesis.get("url"); + String filePath1 =ARTICLE_DIR; + if (filePath == null || filePath.trim().isEmpty()) { +// return AjaxResult.error("文件路径不能为空"); + } + File file = new File(filePath); + if (!file.exists()) { +// return AjaxResult.error("文件不存在: " + filePath); + } +// List> dataList = new ArrayList<>(); + List articles = new ArrayList<>(); + ZhyArticle zhyArticle = null; // 当前正在构建的记录 + + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) { + + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.isEmpty()) continue; // 跳过空行 + + if (line.startsWith("作者:")) { + // 遇到新的“作者”,说明上一条记录已结束,可以保存 + if (zhyArticle != null) { + articles.add(zhyArticle); + } + // 开始一条新记录 + zhyArticle = new ZhyArticle(); + zhyArticle.setAuthors(line.substring(3)); // 去掉"作者:" + } else if (line.startsWith("单位:")) { + if (zhyArticle != null) { + zhyArticle.setAgencies(line.substring(3)); // 去掉"单位:" + } + } else if (line.startsWith("题名:")) { + if (zhyArticle != null) { + zhyArticle.setName(line.substring(3)); // 去掉"题名:" + } + } + } + + // 文件读完,别忘了把最后一条记录加上 + if (zhyArticle != null) { + articles.add(zhyArticle); + } + + } catch (IOException e) { + System.err.println("读取文件时发生错误:" + e.getMessage()); + e.printStackTrace(); + } + ArrayList mainKeywordList = new ArrayList<>(); + String mainKeyword = ""; + mainKeywordList.add(mainKeyword); + // 3. 处理每一行数据(和你原来逻辑一致) + for (ZhyArticle article : articles) { +// 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 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.getName()); +// 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.getAuthors()); + article.setKeywords(data.getKeywords()); + article.setSummary(data.getSummary()); + article.setUrls(data.getUrls()); + 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); + + } + // 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() + "'}]->(b) " + + "RETURN r"; + neo4jUtil.excuteCypherSql(cql); + test1Mapper.updateGraphRelation(rel); + + } + } public void createRelation(String parentValue,String childValue,Map data,String local){ ZhyDoc doc1 = test1Mapper.selectDocByTitle(parentValue); ZhyDoc doc2 = test1Mapper.selectDocByTitle(childValue); diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index f5ad5f1..a9ee542 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -194,6 +194,9 @@ public static final String indexPathBattle = "D:\\project\\gyx\\tupudata\\battl */ public static final String ARTICLE_TXT_DIR = TUPUDATA_ROOT + "/article/txt"; + public static final String ARTICLE_DIR = TUPUDATA_ROOT + "/article"; + + /** * DOC 文档目录 */ diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index bd4a993..4c2837c 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -47,7 +47,11 @@ poi-ooxml 5.2.2 - + + org.apache.poi + poi-scratchpad + 5.2.2 + \ No newline at end of file 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 d461ed5..ba1781f 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 @@ -59,10 +59,6 @@ public class WordSplitter { List info = zhySetInfoMapper.selectZhySetInfoList(zs); String picSize = info.get(0).getContent(); - - - - try { // 创建文件输入流 FileInputStream fis = fileInputStream; @@ -190,12 +186,19 @@ public class WordSplitter { mm.put("title", title); mm.put("list", aa); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t =t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); System.out.println(outputFolder + "\\" + t + ".txt"); mm.put("docUrl", outputFolder + "\\" + t + ".txt"); list.add(mm); if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -203,6 +206,13 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); + currentSectionTitle =currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -213,7 +223,14 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t=t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); bl.add(bb); @@ -222,7 +239,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -230,6 +247,13 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); + currentSectionTitle =currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -244,7 +268,14 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t =t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); bl.add(bb); @@ -252,7 +283,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -260,6 +291,13 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); + currentSectionTitle =currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -270,7 +308,14 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t=t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); @@ -279,7 +324,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -287,6 +332,13 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&");; + currentSectionTitle =currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -297,7 +349,14 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t=t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); bl.add(bb); @@ -305,7 +364,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -313,6 +372,13 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&");; + currentSectionTitle =currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -323,7 +389,14 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t=t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); bl.add(bb); @@ -331,7 +404,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -339,6 +412,13 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&");; + currentSectionTitle =currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replace("\t", "") + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -388,7 +468,7 @@ public class WordSplitter { String type = String.valueOf(startsWithHeading1(currentSectionTitle,fileUploadDTO).get("type")); String title = String.valueOf(startsWithHeading1(currentSectionTitle,fileUploadDTO).get("title")); if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replaceAll(" ","_"); + currentSectionTitle = currentSectionTitle.replaceAll(" ",""); realTitle = title; realleve = type; String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; @@ -552,12 +632,18 @@ public class WordSplitter { mm.put("title", title); mm.put("list", aa); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); System.out.println(outputFolder + "\\" + t + ".txt"); mm.put("docUrl", outputFolder + "\\" + t + ".txt"); list.add(mm); if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -565,6 +651,12 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); + currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -575,7 +667,13 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); bl.add(bb); @@ -584,7 +682,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -592,6 +690,12 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); + currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -606,7 +710,13 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); bl.add(bb); @@ -614,7 +724,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -622,6 +732,12 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); + currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -632,7 +748,13 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); @@ -641,7 +763,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -649,6 +771,12 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&");; + currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -659,7 +787,13 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); bl.add(bb); @@ -667,7 +801,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -675,6 +809,12 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&");; + currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -685,7 +825,13 @@ public class WordSplitter { bb.put("type", type); bb.put("title", title); String t = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&"); - t = t.replaceAll(" ","_"); + t = t.replaceAll(" ",""); + t.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); bb.put("docUrl", outputFolder + "\\" + t + ".txt"); List bl = (List) aa.get("list"); bl.add(bb); @@ -693,7 +839,7 @@ public class WordSplitter { if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replace(" ","_"); + currentSectionTitle = currentSectionTitle.replace(" ",""); String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; saveSection(currentSection, outputFolder, currentSectionTitle, realleve, outputFilePath, realTitle,outputFolder,fileId,useImgs); currentSection = new XWPFDocument(); @@ -701,6 +847,12 @@ public class WordSplitter { } useImgs = new ArrayList<>(); currentSectionTitle = paragraph.getText().trim().replaceAll("[/\\\\:*?|]", "&");; + currentSectionTitle.replaceAll("[\"'\\u00A0]", "") // 引号和不间断空格 + .replaceAll("[\\u200B\\u200C\\u200D\\uFEFF]", "") // 零宽字符 + .replaceAll("[\\x00-\\x1F\\x7F]", "") // 控制字符 + .replaceAll("\\s+", "") // 多个空白合并为一个空格 + .trim() + .replaceAll("^\\.*$", ""); realTitle = title; realleve = type; } @@ -750,7 +902,7 @@ public class WordSplitter { String type = String.valueOf(startsWithHeadingOld(currentSectionTitle).get("type")); String title = String.valueOf(startsWithHeadingOld(currentSectionTitle).get("title")); if (!currentSectionTitle.isEmpty()) { - currentSectionTitle = currentSectionTitle.replaceAll(" ","_"); + currentSectionTitle = currentSectionTitle.replaceAll(" ",""); realTitle = title; realleve = type; String outputFilePath = outputFolder + "\\" + currentSectionTitle + ".txt"; @@ -774,10 +926,10 @@ public class WordSplitter { StringBuilder sb = new StringBuilder(); String all = ""; for(int i=0;i 0) { + patternBuilder.append("\\."); } + patternBuilder.append("\\d+"); } + // 关键:后面不能是数字或点,否则就是更深层级 + patternBuilder.append("(?=(?:[\\s\\p{Punct},。!?、\\s])|$)"); + Pattern pattern = Pattern.compile(patternBuilder.toString()); + Matcher matcher = pattern.matcher(text); - - if(result.equals("")){ - if (textResult.equals("")){ - System.out.println("是一级标题"); - // 在实际标题中查找这个字符第一次出现的位置 - int position = text.indexOf(lastChar); - - if (position == -1) { - // 如果没有找到,返回整个实际标题 - System.out.println("没有"); - info.put("title",text); - info.put("type",1); - info.put("content","标题"); - return info; - }else { - String content = text.substring(position + 1).trim(); - info.put("title",content); - info.put("type",1); - info.put("content","标题"); - return info; - } + if (matcher.find()) { + return text.substring(matcher.end()).trim(); + } + return null; + } + private static String matchChineseWithDunHaoFormat(String text, String temple) { + // 模板如 "一、" 表示格式:任意中文数字 + 顿号 + String regex = "^[一二三四五六七八九十百千]+、(?=[^\\s\\p{Punct},。!?、\\s]|$)"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + + if (matcher.find()) { + return text.substring(matcher.end()).trim(); + } + return null; + } + private static String matchChineseChapterFormat(String text, String temple) { + // 模板如 "第一章" 表示格式:第 + 中文数字 + 章/节/回 + String regex = "^第[一二三四五六七八九十百千0-9]+[章回节](?=[\\s\\p{Punct},。!?、\\s]|$)"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + + if (matcher.find()) { + return text.substring(matcher.end()).trim(); + } + return null; + } + private static String matchParenthesesChineseFormat(String text, String temple) { + // 模板如 "(一)" 表示格式:全角括号内中文数字 + String regex = "^([一二三四五六七八九十百千]+)(?=[\\s\\p{Punct},。!?、\\s]|$)"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + + if (matcher.find()) { + return text.substring(matcher.end()).trim(); + } + return null; + } + private static String matchNumberWithParenthesesFormat(String text, String temple) { + // 模板如 "1)" 表示格式:任意数字 + 全角右括号 + String regex = "^\\d+)(?=[\\s\\p{Punct},。!?、\\s]|$)"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + + if (matcher.find()) { + return text.substring(matcher.end()).trim(); + } + return null; + } - }else { - System.out.println("不是"); + public static Map getLevel(String text, String temple) { + Map info = new HashMap<>(); + if(!text.equals("")){ + char firstchar = temple.charAt(0); + char firsttext = text.charAt(0); + if(text.contains("。")){ + info.put("content","查看下一级"); + return info; } - } - else { - if(textResult.contains(result)){ - if (formatsMatch) { - System.out.println("判断: 数字格式匹配,可能是同级标题"); - int position = text.indexOf(lastChar); - String resTitle=""; - if(inputFormat.contains("[数字]")){ - resTitle = extractTitleOrReturnOriginal(text,temple); - } - if(inputFormat.contains("[中文数字]")){ - resTitle = extractContentAfterTemplate(text,temple); + if (firsttext != firstchar){ + boolean isChinese1 = Arrays.asList(CHINESE_DIGITS).contains(firsttext); + boolean isChinese2 = Arrays.asList(CHINESE_DIGITS).contains(firstchar); + if(!(isChinese1&&isChinese2)){ + boolean number1 = Character.isDigit(firsttext); + boolean number2 = Character.isDigit(firstchar); + if(!(number1&&number2)){ + info.put("content","查看下一级"); + return info; } - info.put("title",resTitle); - info.put("type",1); - info.put("content","标题"); - return info; -// if (position == -1) { -// // 如果没有找到,返回整个实际标题 -// System.out.println("没有"); -// info.put("title",text); -// info.put("type",1); -// info.put("content","标题"); -// return info; -// }else { -// String content = text.substring(position + 1).trim(); -// info.put("title",content); -// info.put("type",1); -// info.put("content","标题"); -// return info; -// } - } else { - System.out.println("判断: 数字格式不匹配,不是同级标题"); } - }else { - System.out.println("判断: 不是一级标题"); } } - info.put("content","查看下一级"); + // === 1. 空值处理 === + if (text == null || text.trim().isEmpty() || temple == null || temple.trim().isEmpty()) { + info.put("content", "查看下一级"); + return info; + } + text = text.trim(); + temple = temple.trim(); + + // === 2. 排除正文(含句号)=== + if (text.contains("。")) { + info.put("content", "查看下一级"); + return info; + } + // === 3. 模板转正则 === + String patternRegex = templateToRegex(temple); + if (patternRegex == null) { + info.put("content", "查看下一级"); + return info; + } + + // 添加前后边界和前瞻 + patternRegex = "^" + patternRegex; + Pattern pattern = Pattern.compile(patternRegex); + Matcher matcher = pattern.matcher(text); + + // === 4. 匹配并提取 === + if (matcher.find()) { + String extracted = text.substring(matcher.end()).trim(); + info.put("title", extracted); + info.put("content", "标题"); + return info; + } + + info.put("content", "查看下一级"); return info; + } + private static String templateToRegex(String temple) { + StringBuilder regex = new StringBuilder(); + int i = 0; + int n = temple.length(); + + while (i < n) { + char c = temple.charAt(i); + + if (isChineseNumeral(c)) { + // 处理连续中文数字 + int j = i; + while (j < n && isChineseNumeral(temple.charAt(j))) { + j++; + } + regex.append("[一二三四五六七八九十百千]+"); + i = j; + } else if (Character.isDigit(c)) { + // 处理阿拉伯数字 + int j = i; + while (j < n && Character.isDigit(temple.charAt(j))) { + j++; + } + regex.append("\\d+"); + i = j; + } else { + // 其他字符转义 + regex.append(Pattern.quote(String.valueOf(c))); + i++; + } + } + return regex.toString(); + } + // 判断是否为中文数字字符 + private static boolean isChineseNumeral(char c) { + return "一二三四五六七八九十百千".indexOf(c) != -1; } + + //专门处理 +// public static Map getLevel(String text,String temple){ +// System.out.println(temple); +// System.out.println(text); +// Map info = new HashMap(); +// //开始-校验判断 +// if (text == null || text.trim().isEmpty() || temple == null || temple.trim().isEmpty()) { +// info.put("content", "查看下一级"); +// return info; +// } +// text = text.trim(); +// temple = temple.trim(); +// if (text.contains("。")) { +// info.put("content", "查看下一级"); +// return info; +// } +// +// +// //根据模板类型选择匹配策略 +// String extractedTitle = null; +// +// // === 1. 数字点格式:1 / 1.1 / 1.12.1 / 22.3 === +// if (temple.matches("^\\d+(\\.\\d+)*$")) { +// extractedTitle = matchDotNumberFormat(text, temple); +// } +// // === 2. 中文章节:第一章 / 第十一节 / 第2章(可选)=== +// else if (temple.matches("^第[一二三四五六七八九十百千0-9]+[章回节]$")) { +// extractedTitle = matchChineseChapterFormat(text, temple); +// } +// // === 3. 中文编号 + 顿号:一、 / 十一、 / 二十、 === +// else if (temple.matches("^[一二三四五六七八九十百千]+、$")) { +// extractedTitle = matchChineseWithDunHaoFormat(text, temple); +// } +// // === 4. 括号中文:(一) / (十一) === +// else if (temple.matches("^([一二三四五六七八九十百千]+)$")) { +// extractedTitle = matchParenthesesChineseFormat(text, temple); +// } +// // === 5. 数字 + 括号:1) / 12) === +// else if (temple.matches("^\\d+)$")) { +// extractedTitle = matchNumberWithParenthesesFormat(text, temple); +// } +// // === 6. 其他不支持格式 === +// else { +// info.put("content", "查看下一级"); +// return info; +// } +// +// // 4. 判断是否匹配成功 +// if (extractedTitle != null) { +// info.put("title", extractedTitle.trim()); +// info.put("type",1); +// info.put("content", "标题"); +// return info; +// } +// +// info.put("content","查看下一级"); +// return info; +// +// + + + + + + + + + + + + + + + +//张晓萌写的垃圾屎山代码 +// //处理一级标题 +// String result = filterNumbers(temple); +// String inputFormat = extractNumberFormat(temple); +// //获取最后一个字 +// System.out.println(temple); +// System.out.println("--------------------"); +// char lastChar = temple.charAt(temple.length() - 1); +// System.out.println("过滤后模板标题: " + result); +// System.out.println("检测到的数字格式: " + inputFormat); +// +// //获取对应位置的字符串数量 +// int aa = temple.length()+2; +// String useTT = getFirstNChars(text, aa); +// String textResult = filterNumbers(useTT); +// +// // 比较数字格式 +// boolean formatsMatch = compareNumberFormats(temple, useTT); +// Map info = new HashMap(); +// System.out.println(text); +// if (text.length()==0){ +// info.put("content","查看下一级"); +// return info; +// } +// char firstchar = temple.charAt(0); +// char firsttext = text.charAt(0); +// if(text.contains("。")){ +// info.put("content","查看下一级"); +// return info; +// } +// if (firsttext != firstchar){ +// boolean isChinese1 = Arrays.asList(CHINESE_DIGITS).contains(firsttext); +// boolean isChinese2 = Arrays.asList(CHINESE_DIGITS).contains(firstchar); +// if(!(isChinese1&&isChinese2)){ +// boolean number1 = Character.isDigit(firsttext); +// boolean number2 = Character.isDigit(firstchar); +// if(!(number1&&number2)){ +// info.put("content","查看下一级"); +// return info; +// } +// } +// } +// +// +// +// +// if(result.equals("")){ +// if (textResult.equals("")){ +// System.out.println("是一级标题"); +// // 在实际标题中查找这个字符第一次出现的位置 +// int position = text.indexOf(lastChar); +// +// if (position == -1) { +// // 如果没有找到,返回整个实际标题 +// System.out.println("没有"); +// info.put("title",text); +// info.put("type",1); +// info.put("content","标题"); +// return info; +// }else { +// String content = text.substring(position + 1).trim(); +// info.put("title",content); +// info.put("type",1); +// info.put("content","标题"); +// return info; +// } +// +// +// }else { +// System.out.println("不是"); +// } +// } +// else { +// if(textResult.contains(result)){ +// if (formatsMatch) { +// System.out.println("判断: 数字格式匹配,可能是同级标题"); +// int position = text.indexOf(lastChar); +// String resTitle=""; +// if(inputFormat.contains("[数字]")){ +// resTitle = extractTitleOrReturnOriginal(text,temple); +// } +// if(inputFormat.contains("[中文数字]")){ +// resTitle = extractContentAfterTemplate(text,temple); +// } +// info.put("title",resTitle); +// info.put("type",1); +// info.put("content","标题"); +// return info; +//// if (position == -1) { +//// // 如果没有找到,返回整个实际标题 +//// System.out.println("没有"); +//// info.put("title",text); +//// info.put("type",1); +//// info.put("content","标题"); +//// return info; +//// }else { +//// String content = text.substring(position + 1).trim(); +//// info.put("title",content); +//// info.put("type",1); +//// info.put("content","标题"); +//// return info; +//// } +// } else { +// System.out.println("判断: 数字格式不匹配,不是同级标题"); +// } +// }else { +// System.out.println("判断: 不是一级标题"); +// } +// } +// +// info.put("content","查看下一级"); + + +// } private static final String CHINESE_NUMBERS = "零一二三四五六七八九十百千万亿"; private static final Pattern CHINESE_NUMBERS_PATTERN = Pattern.compile("[" + CHINESE_NUMBERS + "]+"); @@ -1834,7 +2204,7 @@ public class WordSplitter { //将四级标题存入数据库 //获取id,将分段数据进行存储 - String fileName = sectionTitle.replaceAll(" ", "_"); + String fileName = sectionTitle.replaceAll(" ", ""); System.out.println(fileName); fileName = fileName.replace("//","&"); @@ -1845,56 +2215,6 @@ public class WordSplitter { } - private void saveSectionBattle(XWPFDocument section, String folderPath, String sectionTitle, String level, String path, String title,String outputFolder,Integer fileId) throws IOException { - - StringBuilder sb = new StringBuilder(); - String all = ""; - - ZhyBattle battle = new ZhyBattle(); - battle.setBattleTitle(title); - battle.setBattleLevel(Long.valueOf(level)); - battle.setBattleUrl(path); - battle.setBattleFileId(Long.valueOf(fileId)); - battleList.add(battle); - - - for (XWPFParagraph paragraph : section.getParagraphs()) { - if (paragraph.getRuns().size() > 0) { - String aa = ""; - for (int a = 0; a < paragraph.getRuns().size(); a++) { - aa = aa + paragraph.getRuns().get(a); - } - - List charList = new ArrayList<>(); - for (int i = 0; i < aa.length(); i++) { - charList.add(aa.substring(i, i + 1)); - } - if (charList.size() > 0) { - if (charList.get(0).equals("表") || charList.get(0).equals("图") || (charList.get(0).equals("<") && charList.get(1).equals("d") && charList.get(2).equals("i"))) { - aa = "

" + aa + "

"; - } else { - aa = "

      " + aa + "

"; - } - } else { - aa = "

      " + aa + "

"; - } - - - all = all + aa; - } - } - - - //将四级标题存入数据库 - //获取id,将分段数据进行存储 - String fileName = sectionTitle.replaceAll(" ", "_"); - fileName = fileName.replace("//","&"); - String outputFilePath = outputFolder + "\\" + fileName + ".txt"; - sb.append(all).append(System.lineSeparator()); - writeToFile(sb.toString(), outputFilePath); - - - } private static void writeToFile(String content, String filePath) throws IOException { diff --git a/ruoyi-ui/src/api/system/article.js b/ruoyi-ui/src/api/system/article.js new file mode 100644 index 0000000..f73ba84 --- /dev/null +++ b/ruoyi-ui/src/api/system/article.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询文献管理列表 +export function listArticle(query) { + return request({ + url: '/system/article/list', + method: 'get', + params: query + }) +} + +// 查询文献管理详细 +export function getArticle(id) { + return request({ + url: '/system/article/' + id, + method: 'get' + }) +} + +// 新增文献管理 +export function addArticle(data) { + return request({ + url: '/system/article', + method: 'post', + data: data + }) +} + +// 修改文献管理 +export function updateArticle(data) { + return request({ + url: '/system/article', + method: 'put', + data: data + }) +} + +// 删除文献管理 +export function delArticle(id) { + return request({ + url: '/system/article/' + id, + method: 'delete' + }) +} diff --git a/ruoyi-ui/src/views/system/article/index.vue b/ruoyi-ui/src/views/system/article/index.vue new file mode 100644 index 0000000..d1839e7 --- /dev/null +++ b/ruoyi-ui/src/views/system/article/index.vue @@ -0,0 +1,399 @@ + + + diff --git a/ruoyi-ui/src/views/system/docmuban/index.vue b/ruoyi-ui/src/views/system/docmuban/index.vue index 7937f1b..eeb9a47 100644 --- a/ruoyi-ui/src/views/system/docmuban/index.vue +++ b/ruoyi-ui/src/views/system/docmuban/index.vue @@ -530,6 +530,7 @@ export default { }, //弹出添加zhyDoc弹窗按钮 addZhyDoc(type){ + this.handleAdd() this.form.type = type; if(this.form.type == "方向" || this.form.type == "作战" || this.form.type == "装备" || this.form.type == "环境"){ @@ -626,7 +627,7 @@ export default { if (this.form.id != null) { updateDocmuban(this.form).then(response => { this.$modal.msgSuccess("修改成功"); - this.addZhyDocmubanOpen = false; + this.updateZhyDocmubanOpen = false; this.getList(); }); } else { @@ -634,6 +635,7 @@ export default { this.$modal.msgSuccess("新增成功"); this.addZhyDocmubanOpen = false; this.getList(); + }); } } diff --git a/ruoyi-ui/src/views/system/fileManage/index.vue b/ruoyi-ui/src/views/system/fileManage/index.vue index a85cb4b..d5cc9e8 100644 --- a/ruoyi-ui/src/views/system/fileManage/index.vue +++ b/ruoyi-ui/src/views/system/fileManage/index.vue @@ -319,50 +319,50 @@ - - -
-
- - 删除 -
-
- - 点击上传视频 - -
- -
+ + + + + + + + + + + + + + + + + + + + + + + + + + - - -
- -
点击上传+拖拽上传
-
-
-
+ + + + + + + + + + + +