diff --git a/gyxtp/src/api/api/article.js b/gyxtp/src/api/api/article.js index 957f674..b9b208b 100644 --- a/gyxtp/src/api/api/article.js +++ b/gyxtp/src/api/api/article.js @@ -13,7 +13,12 @@ export const getArticleInfo = (id) => { method: 'get', }); }; - +export const getArticleInfo1 = (name) => { + return request({ + url: '/api/article/getArticleInfo1/'+name, + method: 'get', + }); +}; export const updateArticle = (params) => { return request({ diff --git a/gyxtp/src/api/api/graph.js b/gyxtp/src/api/api/graph.js index bba813d..9439114 100644 --- a/gyxtp/src/api/api/graph.js +++ b/gyxtp/src/api/api/graph.js @@ -89,12 +89,6 @@ export const getKeyWorlds = () => { }); }; -export const getDocInfoBylinkIds = (param) => { - return request({ - url: '/api/test/getDocInfoBylinkIds/'+param, - method: 'get', - }); -}; export const getPointInfoByUUID = (param) => { return request({ @@ -109,6 +103,19 @@ export const getReInfoByNameAndType = (name,type) => { method: 'get', }); }; +export const getDocInfoBylinkIds = (param) => { + return request({ + url: '/api/test/getDocInfoBylinkIds/'+param, + method: 'get', + }); +}; + +export const selectPointResById = (id) => { + return request({ + url: '/api/test/selectPointResById/'+id, + method: 'get', + }); +}; export const getheightLight = (param) => { return request({ @@ -117,3 +124,4 @@ export const getheightLight = (param) => { }); }; + diff --git a/gyxtp/src/router/router.js b/gyxtp/src/router/router.js index 5ce14f6..ffa72c7 100644 --- a/gyxtp/src/router/router.js +++ b/gyxtp/src/router/router.js @@ -117,6 +117,15 @@ const routes = [ // component: () => import ("../views/graphPageNoJson.vue") }, { + path: '/pointArticleInfo', + name: 'pointArticleInfo', + meta: { + title: '文章界面', + }, + component: () => import('../view/pointArticleInfo.vue'), + // component: () => import ("../views/graphPageNoJson.vue") + }, + { path: '/small', component: () => import('@/view/small.vue'), }, diff --git a/gyxtp/src/view/pointArticleInfo.vue b/gyxtp/src/view/pointArticleInfo.vue new file mode 100644 index 0000000..19ba17c --- /dev/null +++ b/gyxtp/src/view/pointArticleInfo.vue @@ -0,0 +1,1950 @@ + + + + + + + diff --git a/gyxtp/src/view/pointInfo.vue b/gyxtp/src/view/pointInfo.vue index 2112d60..a9711b3 100644 --- a/gyxtp/src/view/pointInfo.vue +++ b/gyxtp/src/view/pointInfo.vue @@ -45,12 +45,12 @@ v-for="(item) in tableData" :key="item" > -
+
-
{{ Object.keys(item)[0] }}
+
{{ Object.keys(item)[0] }}
@@ -145,7 +145,15 @@ export default { }; }, methods: { - + goArticle(row){ + console.log(row[0].id) + this.$router.push({ + path: '/pointArticleInfo', + query: { + id: row[0].id + } + }) + }, }, mounted() { const id = this.$route.params.id @@ -1116,5 +1124,8 @@ margin-top: 0.2vw; .el-tree-node__expand-icon { font-size: 1.2vw !important; } +.articleName:hover{ + color:rgb(7, 118, 255); +} diff --git a/gyxtp/src/view/small.vue b/gyxtp/src/view/small.vue index 32855dc..45789c3 100644 --- a/gyxtp/src/view/small.vue +++ b/gyxtp/src/view/small.vue @@ -353,7 +353,7 @@ export default { goArticle(row){ console.log(row.id) this.$router.push({ - path: '/articleInfo', + path: '/pointArticleInfo', query: { id: row.id } 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 fc10957..a518806 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 @@ -12,6 +12,7 @@ import com.ruoyi.api.domain.*; import com.ruoyi.api.mapper.ZhyDocApiMapper; import com.ruoyi.api.service.impl.BuildService; import com.ruoyi.api.service.impl.PdfUtil; +import com.ruoyi.api.service.impl.PointService; import com.ruoyi.api.util.ReushToken; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -56,6 +57,8 @@ public class DocApiController extends BaseController { @Autowired BuildService staticBuildService; @Autowired + PointService pointService; + @Autowired static PythonService pythonService; @Autowired LuceneUtil luceneUtil; @@ -1668,9 +1671,6 @@ public class DocApiController extends BaseController { taskInfo.setGroupId(0l); taskInfo.setStatus(0); zhyTaskInfoService.insertZhyTaskInfo(taskInfo); - -// goPython(doc1.getDocTitle(),doc2.getDocTitle(),group0SearchItems); - } } for(int i=0;i> searchItems,Str map1.put("msg","正在构建'"+info.getName1()+"'图谱"); webSocketService.sendToUser(userId,gson.toJson(map1)); } + if(info.getName2()!=null){ + staticBuildService.create(objMap); + }else{ + String filePath = (String) objMap.get("url"); + pointService.buildPoint(filePath); + } - staticBuildService.create(objMap); } else if ("none".equals(functionName)) { System.out.println("Python 返回:没有数据"); } else { 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 986aa5c..8b820ed 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 @@ -19,6 +19,8 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static com.ruoyi.common.constant.Constants.ARTICLE_PDF_DIR; + @RestController @RequestMapping("/api/test") public class TestXiaoTuPuController extends BaseController { @@ -210,6 +212,18 @@ public class TestXiaoTuPuController extends BaseController { List a = zhyPointMapper.selectPointRelationshipByRids(LinkIds); return a; } + @GetMapping("selectPointResById/{id}") + public Map selectPointResById(@PathVariable("id")Integer id) throws IOException { + Map map = zhyPointMapper.selectPointResById(id); + System.out.println("2222222222"); + System.out.println(map); + Object title = map.get("title"); + if (title != null) { + String localUrl = ARTICLE_PDF_DIR+"/"+title.toString()+".pdf"; + map.put("localUrl", localUrl); + } + return map; + } @GetMapping("getPointInfoByUUID/{id}") public List selectPointByUUID(@PathVariable("id")Integer id) { List a = zhyPointMapper.selectPointByUUID(id); diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/controller/ZhyArticleController.java b/ruoyi-api/src/main/java/com/ruoyi/api/controller/ZhyArticleController.java index 7139c88..d41cb20 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/controller/ZhyArticleController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/controller/ZhyArticleController.java @@ -126,6 +126,13 @@ public class ZhyArticleController extends BaseController return article; } + @GetMapping("/getArticleInfo1/{name}") + public ZhyArticle getArticleInfo1(@PathVariable("name") String name) + { + ZhyArticle article=zhyArticleService.selectZhyArticleByName(name); + return article; + } + @GetMapping("/selectAticleByRelation") diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ZhyPointMapper.java b/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ZhyPointMapper.java index a6f87bd..0128c53 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ZhyPointMapper.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ZhyPointMapper.java @@ -14,7 +14,7 @@ public interface ZhyPointMapper { List selectPointResByNeo4jId(@Param("neo4jId") Integer neo4jId); - + Map selectPointResById(@Param("id") Integer id); List selectPointByType1(@Param("type1") String type1); List selectPointRelationshipByRids(@Param("ids") List ids); List selectPointRelationshipByName(@Param("author") String author,@Param("keyword") String keyword,@Param("agency") String agency,@Param("title") String title); 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 c7f7d5c..e07976a 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 @@ -27,7 +27,10 @@ public class PointService { Neo4jUtil neo4jUtil; public void buildPoint(String url) throws IOException { +// String url="D:\\project\\gyx\\tupudata\\thesis\\thesis_results_20250914_201832.csv"; List> dataList = getCsvLine(url); + System.out.println("2222222222222222222222"); + System.out.println(dataList); Map nameToId = new HashMap<>(); for (Map record : dataList) { List> relationshipList = new ArrayList<>(); @@ -87,6 +90,7 @@ public class PointService { relType = "相关作者"; } else if (authorStr != null && !authorStr.trim().isEmpty() && agencyStr != null && !agencyStr.trim().isEmpty()) { + System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaa"); start = authorStr; end = agencyStr; relType = "相关机构"; @@ -208,7 +212,7 @@ public class PointService { List keywords = new ArrayList<>(); // 1. 解析 keywords(字段名可根据 CSV 调整) - String keywordStr = record.get("searchword1"); + String keywordStr = record.get("main_keyword"); if (keywordStr != null && !keywordStr.trim().isEmpty()) { String[] keywordArray = keywordStr.split(";"); // 中文分号分隔 for (String kw : keywordArray) { @@ -276,33 +280,59 @@ public class PointService { throw new FileNotFoundException("CSV file not found: " + csvFilePath); } + // 2. 读取 CSV 文件(使用 GBK 编码) List> dataList = new ArrayList<>(); + String[] headers = null; - // 定义 CSV 格式 - CSVFormat format = CSVFormat.DEFAULT - .withFirstRecordAsHeader() - .withIgnoreSurroundingSpaces(true) - .withTrim() - .withQuote('"') - .withEscape('\\') - .withIgnoreEmptyLines(true); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"))) { + String line; + int lineNumber = 0; - try (FileInputStream fis = new FileInputStream(file); - InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8); // ✅ 指定 GBK 编码 - CSVParser csvParser = new CSVParser(isr, format)) { + while ((line = reader.readLine()) != null) { + lineNumber++; - for (CSVRecord record : csvParser) { + // 去除 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 (String header : csvParser.getHeaderNames()) { - rowMap.put(header, record.get(header)); + for (int i = 0; i < headers.length && i < row.length; i++) { + String key = headers[i].trim(); + String value = row[i]; + + if (Arrays.asList("main_keyword", "sub_keyword", "title", "authors", "keywords", "abstract", "url", "urls").contains(key)) { + rowMap.put(key, value); + } } dataList.add(rowMap); } } catch (IOException e) { - System.err.println("Error reading CSV file: " + e.getMessage()); - throw e; + e.printStackTrace(); } + for (Map data : dataList) { + String mainKeyword = data.get("main_keyword"); + Pattern pattern = Pattern.compile("'([^']*)'"); + Matcher matcher = pattern.matcher(mainKeyword); + while (matcher.find()) { + data.put("main_keyword", matcher.group(1)); + } + } return dataList; } private static String[] parseCsvLine(String line) { diff --git a/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml b/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml index 0e17c68..8aa1acf 100644 --- a/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml +++ b/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml @@ -18,6 +18,9 @@ + - + insert into zhy_article