diff --git a/gyxtp/src/api/api/doc.js b/gyxtp/src/api/api/doc.js index 2dfe090..0c070ed 100644 --- a/gyxtp/src/api/api/doc.js +++ b/gyxtp/src/api/api/doc.js @@ -161,7 +161,16 @@ export const getDocInfo = (params) => { } }); }; - +export const getDocInfoNB = (params) => { + return request({ + url: '/api/doc/getDocInfoNB', + method: 'post', + data: params, + headers:{ + 'token':localStorage.getItem('token') + } + }); +}; export const getXgInfo = (params) => { return request({ url: '/api/doc/getXgInfo', diff --git a/gyxtp/src/view/docInfo.vue b/gyxtp/src/view/docInfo.vue index eabfae4..b4b24e6 100644 --- a/gyxtp/src/view/docInfo.vue +++ b/gyxtp/src/view/docInfo.vue @@ -1015,8 +1015,8 @@ export default { label: 5, }, docId: nodeList[a].docId, - width: 140, - height: 140, + width: 180, + height: 180, color: 'rgb(65,154,255)' }) } @@ -1030,8 +1030,8 @@ export default { label: 6, }, docId: nodeList[a].docId, - width: 110, - height: 110, + width: 180, + height: 180, color: 'rgb(0,228,255)' }) } diff --git a/gyxtp/src/view/graphPageNB927.vue b/gyxtp/src/view/graphPageNB927.vue index 9bec701..9cab065 100644 --- a/gyxtp/src/view/graphPageNB927.vue +++ b/gyxtp/src/view/graphPageNB927.vue @@ -744,7 +744,7 @@ export default { } // 配置参数 - const baseRadius = 1200; // 每层之间的半径差 + const baseRadius = 1500; // 每层之间的半径差 const centerX = 0, centerY = 0; // 遍历每一层进行布局 @@ -882,10 +882,10 @@ export default { color = 'rgb(248,143,248)'; break; case "5": - color = 'rgb(65,154,255)'; + color = 'rgb(0,228,255)'; break; case "6": - color = 'rgb(0,228,255)'; + color = 'rgba(255, 255, 255, 0.6)'; break; default: color = 'rgba(255, 255, 255, 0.6)'; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyPointController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyPointController.java index cb9d302..d2c6a09 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyPointController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyPointController.java @@ -145,6 +145,14 @@ public class ZhyPointController extends BaseController return AjaxResult.success(); } + @PostMapping("/insertPoint2") + public AjaxResult insert2(MultipartFile file) throws Throwable { + + System.out.println("!1111"); +// pointService.buildPoint(); + return AjaxResult.success(); + } + private String[] parseCsvLine(String line) { List result = new ArrayList<>(); StringBuilder current = new StringBuilder(); diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java b/ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java index c146e24..8e4e85c 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java @@ -7,12 +7,17 @@ import com.ruoyi.api.mapper.ZhyPointMapper; import com.ruoyi.api.service.impl.PointService; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.utils.Neo4jUtil; +import com.ruoyi.system.domain.ZhyArticle; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.io.BufferedReader; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStreamReader; import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -36,6 +41,183 @@ public class TestXiaoTuPuController extends BaseController { private static final Gson gson = new GsonBuilder().create(); private static final Type LIST_MAP_TYPE = new TypeToken>>(){}.getType(); + @GetMapping("test10") + public void test10() throws IOException { + System.out.println(10); + List articles = new ArrayList<>(); + + System.out.println("有"); + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(new FileInputStream("坦克.txt"), 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; + + // ✅ 步骤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 = ':'; + } + + // 判断是否是“字段行”(前8字符内有冒号) + if (sepIndex != -1) { + String fieldKey = line.substring(0, sepIndex).trim(); + String value = line.substring(sepIndex + (separator == ':' ? 1 : 1)).trim(); + System.out.println(fieldKey); + System.out.println(value); + + + // ✅ 只处理你关心的四个字段 + 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.setAgencies(value); + currentField = "agencies"; + } + } else if ("摘要".equals(fieldKey)) { + if (zhyArticle != null) { + zhyArticle.setSummary(value); + currentField = "summary"; + } + } else if ("关键词".equals(fieldKey)) { + if (zhyArticle != null) { + zhyArticle.setKeywords(value); + currentField = "keywords"; + } + } + // ✅ 如果字段不在白名单内(如“中文刊名”),则: + // - 不处理 + // - 不追加 + // - 重置 currentField(防止后续行追加到错误字段) + else { + currentField = null; // 关键:断开与之前字段的联系 + } + } + // ✅ 普通行:不是字段行,追加到 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); + } + + } catch (IOException e) { + System.err.println("读取文件时发生错误:" + e.getMessage()); + e.printStackTrace(); + } + + System.out.println(articles); + pointService.buildPoint(articles,"坦克","维普"); +// +// +// List> dataList = new ArrayList<>(); +// for (int i = 0; i < articles.size(); i++) { +// +// String authorsstr = articles.get(i).getAuthors(); +// +// if (authorsstr != null && !authorsstr.isEmpty()) { +// // 判断字符串长度大于0,且最后一个字符是 '等' +// if (authorsstr.charAt(authorsstr.length() - 1) == '等') { +// authorsstr = authorsstr.substring(0, authorsstr.length() - 1); // 去掉最后一个字符 +// } +// } +// +// // 按中文分号或英文逗号分割作者 +// String[] authors = authorsstr.split("[;,;,]"); +// String[] agencies = articles.get(i).getAgencies().split(","); +// if (agencies.length>1){ +// for (int j = 0; j < authors.length; j++) { +// authors[j] = authors[j]+generateSequence(agencies.length); +// } +// } +// Map map = new HashMap<>(); +// map.put("main_keyword","坦克"); +// map.put("title",articles.get(i).getName()); +// map.put("authors",formatAuthorsWithAgencies(authors,agencies)); +// map.put("urls",""); +// if (articles.get(i).getKeywords()==null){ +// map.put("keywords",""); +// }else{ +// map.put("keywords",articles.get(i).getKeywords().replace(",", ";")); +// } +// dataList.add(map); +// } +// System.out.println(dataList); + + } + public static String generateSequence(int n) { + if (n <= 0) return ""; + StringBuilder sb = new StringBuilder(); + for (int i = 1; i <= n; i++) { + sb.append(i); + if (i < n) { + sb.append(","); + } + } + return sb.toString(); + } + public static String formatAuthorsWithAgencies(String[] authors, String[] agencies) { + // 处理作者:去除空值或空字符串,并用中文逗号连接 + String authorPart = Arrays.stream(authors) + .map(String::trim) + .filter(s -> !s.isEmpty()) + .collect(Collectors.joining(",")); + + // 处理机构:去除空值或空字符串,并用中文分号连接 + String agencyPart = Arrays.stream(agencies) + .map(String::trim) + .filter(s -> !s.isEmpty()) + .collect(Collectors.joining(";")); + + // 拼接最终结果 + if (!agencyPart.isEmpty()) { + return authorPart + "(" + agencyPart + ")"; + } else { + return authorPart; + } + } @GetMapping("test1") public void test1(){ diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java index 3e81170..62a21db 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java @@ -2,6 +2,7 @@ package com.ruoyi.api.service.impl; import com.ruoyi.api.mapper.ZhyPointMapper; import com.ruoyi.common.utils.Neo4jUtil; +import com.ruoyi.system.domain.ZhyArticle; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; @@ -39,6 +40,167 @@ public class PointService { build_DO(dataList); } + public void buildPoint(List articles,String keyword,String type) throws IOException { + + if (type.equals("CNKI")){ + List> dataList = new ArrayList<>(); + for (int i = 0; i < articles.size(); i++) { + if (articles.get(i).getAuthors()==null || articles.get(i).getAgencies()==null){ + continue; + } + // 按中文分号或英文逗号分割作者 + String[] authors = articles.get(i).getAuthors().split("[;,;,]"); + String[] agencies = articles.get(i).getAgencies().split(","); + if (agencies.length>1){ + for (int j = 0; j < authors.length; j++) { + authors[j] = authors[j]+generateSequence(agencies.length); + } + } + Map map = new HashMap<>(); + map.put("main_keyword",keyword); + map.put("title",articles.get(i).getName()); + map.put("authors",formatAuthorsWithAgencies(authors,agencies)); + map.put("urls",""); + if (articles.get(i).getKeywords()==null){ + map.put("keywords",""); + }else{ + map.put("keywords",articles.get(i).getKeywords().replace(";;", ";")); + } + dataList.add(map); + } + build_DO(dataList); + } + if (type.equals("万方")){ + List> dataList = new ArrayList<>(); + for (int i = 0; i < articles.size(); i++) { + if (articles.get(i).getAuthors()==null || articles.get(i).getAgencies()==null){ + continue; + } + String authorsstr = articles.get(i).getAuthors(); + if (authorsstr != null && !authorsstr.isEmpty()) { + // 判断字符串长度大于0,且最后一个字符是 '等' + if (authorsstr.charAt(authorsstr.length() - 1) == '等') { + authorsstr = authorsstr.substring(0, authorsstr.length() - 1); // 去掉最后一个字符 + } + } + // 按中文分号或英文逗号分割作者 + String[] authors = authorsstr.split("[;,;,]"); + String[] agencies = articles.get(i).getAgencies().split(","); + if (agencies.length>1){ + for (int j = 0; j < authors.length; j++) { + authors[j] = authors[j]+generateSequence(agencies.length); + } + } + Map map = new HashMap<>(); + map.put("main_keyword","坦克"); + map.put("title",articles.get(i).getName()); + map.put("authors",formatAuthorsWithAgencies(authors,agencies)); + map.put("urls",""); + if (articles.get(i).getKeywords()==null){ + map.put("keywords",""); + }else{ + map.put("keywords",articles.get(i).getKeywords().replace(",", ";")); + } + dataList.add(map); + } + build_DO(dataList); + } + if (type.equals("维普")){ + List> dataList = new ArrayList<>(); + for (int i = 0; i < articles.size(); i++) { + if (articles.get(i).getAuthors()==null || articles.get(i).getAgencies()==null){ + continue; + } + String agenciesstr = articles.get(i).getAgencies(); + agenciesstr = agenciesstr.replaceAll("\\[.*?\\]", ""); + // 按中文分号或英文逗号分割作者 + String[] authors = articles.get(i).getAuthors().split(";"); + String[] agencies = agenciesstr.split(";"); + + if (agencies.length>1){ + for (int j = 0; j < authors.length; j++) { + authors[j] = authors[j]+generateSequence(agencies.length); + } + } + Map map = new HashMap<>(); + map.put("main_keyword","坦克"); + map.put("title",articles.get(i).getName()); + map.put("authors",formatAuthorsWithAgencies(authors,agencies)); + map.put("urls",""); + if (articles.get(i).getKeywords()==null){ + map.put("keywords",""); + }else{ + String keywrods = articles.get(i).getKeywords(); + keywrods = keywrods.replaceAll("\\[.*?\\]", ""); + map.put("keywords",keywrods.replace(";", ";")); + } + dataList.add(map); + } + build_DO(dataList); + } + if (type.equals("军事")){ + List> dataList = new ArrayList<>(); + for (int i = 0; i < articles.size(); i++) { + if (articles.get(i).getAuthors()==null || articles.get(i).getAgencies()==null){ + continue; + } + String authorsstr = articles.get(i).getAuthors(); + + // 按中文分号或英文逗号分割作者 + String[] authors = authorsstr.split(";"); + String[] agencies = articles.get(i).getAgencies().split(";"); + if (agencies.length>1){ + for (int j = 0; j < authors.length; j++) { + authors[j] = authors[j]+generateSequence(agencies.length); + } + } + Map map = new HashMap<>(); + map.put("main_keyword","坦克"); + map.put("title",articles.get(i).getName()); + map.put("authors",formatAuthorsWithAgencies(authors,agencies)); + map.put("urls",""); + if (articles.get(i).getKeywords()==null){ + map.put("keywords",""); + }else{ + map.put("keywords",articles.get(i).getKeywords().replace(";", ";")); + } + dataList.add(map); + } + build_DO(dataList); + } + + } + public static String generateSequence(int n) { + if (n <= 0) return ""; + StringBuilder sb = new StringBuilder(); + for (int i = 1; i <= n; i++) { + sb.append(i); + if (i < n) { + sb.append(","); + } + } + return sb.toString(); + } + public static String formatAuthorsWithAgencies(String[] authors, String[] agencies) { + // 处理作者:去除空值或空字符串,并用中文逗号连接 + String authorPart = Arrays.stream(authors) + .map(String::trim) + .filter(s -> !s.isEmpty()) + .collect(Collectors.joining(",")); + + // 处理机构:去除空值或空字符串,并用中文分号连接 + String agencyPart = Arrays.stream(agencies) + .map(String::trim) + .filter(s -> !s.isEmpty()) + .collect(Collectors.joining(";")); + + // 拼接最终结果 + if (!agencyPart.isEmpty()) { + return authorPart + "(" + agencyPart + ")"; + } else { + return authorPart; + } + } public void build_DO(List> dataList) { Map nameToId = new HashMap<>(); diff --git a/ruoyi-ui/src/views/system/SysPoint/index.vue b/ruoyi-ui/src/views/system/SysPoint/index.vue index a58d291..71ad86b 100644 --- a/ruoyi-ui/src/views/system/SysPoint/index.vue +++ b/ruoyi-ui/src/views/system/SysPoint/index.vue @@ -78,6 +78,10 @@ @click="handleImportRelation">导入文献 + 导入txt + + @@ -169,6 +173,25 @@ 取 消 + + + + +
将 txt 文件拖到此处,或 点击上传
+
+ 仅允许导入 .txt 格式文件(逗号分隔文本) +
+
+
+ + +
@@ -188,6 +211,15 @@ export default { updateSupport: 0, url: "http://"+process.env.VUE_APP_IP+"/system/SysPoint/insertPoint" }, + upload2: { + tip: "准备上传文件", + open: false, + title: "", + oprnIno: false, + isUploading: false, + updateSupport: 0, + url: "http://"+process.env.VUE_APP_IP+"/system/SysPoint/insertPoint2" + }, typeOptions: [ { label: '作者', value: 'author' }, { label: '机构', value: 'agency' }, @@ -237,18 +269,37 @@ export default { this.$message.success('导入补充文件成功'); this.getList() }, + handleFileSuccess2(response, file, fileList) { + this.upload2.open = false; + this.upload2.isUploading = false; + this.$refs.upload2.clearFiles(); + this.$message.success('导入补充文件成功'); + this.getList() + }, handleFileUploadProgressRelation(event, file, fileList) { this.upload1.isUploading = true; this.upload1.oprnIno = true; }, + handleFileUploadProgressRelation2(event, file, fileList) { + this.upload2.isUploading = true; + this.upload2.oprnIno = true; + + }, submitFileFormR() { this.$refs.upload1.submit(); }, + submitFileFormR2() { + this.$refs.upload2.submit(); + }, handleImportRelation() { this.upload1.title = "导入文献"; this.upload1.open = true; }, + handleImportRelation2() { + this.upload2.title = "导入文献"; + this.upload2.open = true; + }, deletAllInfo(){ this.$modal.confirm('是否确认删除全部的数据项?').then(function() { diff --git a/坦克.txt b/坦克.txt new file mode 100644 index 0000000..f4167a5 --- /dev/null +++ b/坦克.txt @@ -0,0 +1,13 @@ +题名: 文献名字1 +作者: 王刚;陈慧敏;娃哈哈 +中文刊名: 我不需要 +单位: [1]实验室1;[2]单位22 +摘要: 摘要我不需要 + + +题名: 文献名字2 +作者: 李强;康师傅 +中文刊名: 我不需要22 +学位授予单位: [1]实验室2, +摘要: 摘要我不需要2 +关键词: [ss]关键词55;[dddd]关键词3 \ No newline at end of file