From 32ecb38bc7d0f56f0b15ca0f99a49ddeb7d11b72 Mon Sep 17 00:00:00 2001 From: jzy <928294064@qq.com> Date: Sun, 26 Oct 2025 15:33:36 +0800 Subject: [PATCH] yangshi --- gyxtp/src/view/pointInfo.vue | 22 ++++++++++++++- .../web/controller/system/ZhyPointController.java | 2 +- .../com/ruoyi/api/service/impl/PointService.java | 31 ++++++++++++++++++++-- .../main/resources/mapper/api/ZhyPointMapper.xml | 4 +-- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/gyxtp/src/view/pointInfo.vue b/gyxtp/src/view/pointInfo.vue index cac5532..135b404 100644 --- a/gyxtp/src/view/pointInfo.vue +++ b/gyxtp/src/view/pointInfo.vue @@ -51,10 +51,18 @@
{{ Object.keys(item)[0] }}
- + + +
+ 出处: +
+ {{c.source}}; +
+
+
中心词:
{{c.keyword}}; @@ -77,6 +85,12 @@
+ 出处: +
+ {{c.source}}; +
+
+
中心词:
{{c.keyword}}; @@ -98,6 +112,12 @@
+ 出处: +
+ {{c.source}}; +
+
+
作者:
{{c.author}}; 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 d2c6a09..11504d0 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 @@ -122,7 +122,7 @@ public class ZhyPointController extends BaseController 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)) { + if (Arrays.asList("ck", "main_keyword", "sub_keyword", "title", "authors", "keywords", "abstract", "url", "urls","source").contains(key)) { rowMap.put(key, row[i]); } } 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 62a21db..0d8597b 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 @@ -61,6 +61,7 @@ public class PointService { map.put("title",articles.get(i).getName()); map.put("authors",formatAuthorsWithAgencies(authors,agencies)); map.put("urls",""); +// map.put("source",articles.get(i).getSourceName()); if (articles.get(i).getKeywords()==null){ map.put("keywords",""); }else{ @@ -212,9 +213,11 @@ public class PointService { List agencies = new ArrayList<>(new LinkedHashSet<>(parsed.get("agency"))); List keywords = new ArrayList<>(new LinkedHashSet<>(parsed.get("keyword"))); String title = record.get("title"); + String source = record.get("source"); String urls = record.get("urls"); String guanjianzi = record.get("keywords"); + // 用于存储每个三元组对应的关系 ID Map> tripletToIds = new HashMap<>(); @@ -247,6 +250,8 @@ public class PointService { params.put("title", title); params.put("url", urls); params.put("guanjianzi", guanjianzi); + params.put("source", source); + params.put("source_data", getYear(source)); zhyPointMapper.insertPointReship(params); Integer insertedId = Integer.valueOf(String.valueOf(params.get("id"))); rel.relationshipId = insertedId; @@ -254,6 +259,7 @@ public class PointService { // 添加到 tripletToIds tripletToIds.computeIfAbsent(tripletKey, k -> new ArrayList<>()).add(insertedId); } catch (Exception e) { + System.out.println(e.getMessage()); System.out.println("并发导致重复数据"); } } @@ -286,12 +292,15 @@ public class PointService { params.put("title", title); params.put("url", urls); params.put("guanjianzi", guanjianzi); + params.put("source", source); + params.put("source_data", getYear(source)); zhyPointMapper.insertPointReship(params); Integer insertedId = Integer.valueOf(String.valueOf(params.get("id"))); rel.relationshipId = insertedId; tripletToIds.computeIfAbsent(tripletKey, k -> new ArrayList<>()).add(insertedId); } catch (Exception e) { + System.out.println(e.getMessage()); System.out.println("并发导致重复数据"); } } @@ -324,12 +333,14 @@ public class PointService { params.put("title", title); params.put("url", urls); params.put("guanjianzi", guanjianzi); + params.put("source", source); + params.put("source_data", getYear(source)); zhyPointMapper.insertPointReship(params); Integer insertedId = Integer.valueOf(String.valueOf(params.get("id"))); rel.relationshipId = insertedId; - tripletToIds.computeIfAbsent(tripletKey, k -> new ArrayList<>()).add(insertedId); } catch (Exception e) { + System.out.println(e.getMessage()); System.out.println("并发导致重复数据"); } } @@ -371,6 +382,22 @@ public class PointService { } } + public Integer getYear(String source){ + // 定义匹配4位连续数字的正则表达式 + Pattern pattern = Pattern.compile("\\d{4}"); + Matcher matcher = pattern.matcher(source); + + String year = null; + if (matcher.find()) { + year = matcher.group(); // 提取第一个匹配的4位数字 + } + // 输出结果 + if (year != null) { + return Integer.valueOf(year); + } else { + return null; + } + } /** * 生成两个列表的笛卡尔积,并标记关系类型 */ @@ -559,7 +586,7 @@ public class PointService { String key = headers[i].trim(); String value = row[i]; - if (Arrays.asList("main_keyword", "sub_keyword", "title", "authors", "keywords", "abstract", "url", "urls").contains(key)) { + if (Arrays.asList("main_keyword", "sub_keyword", "title", "authors", "keywords", "abstract", "url", "urls","source").contains(key)) { rowMap.put(key, value); } } diff --git a/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml b/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml index 1ce46d2..c4e2120 100644 --- a/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml +++ b/ruoyi-api/src/main/resources/mapper/api/ZhyPointMapper.xml @@ -59,9 +59,9 @@ INSERT INTO zhy_point_relationship - (author, keyword, agency, relationship_id, title, url,keywords) + (author, keyword, agency, relationship_id, title, url,keywords,source,source_data) VALUES - (#{p.author}, #{p.keyword}, #{p.agency}, #{p.relationship_id}, #{p.title}, #{p.url}, #{p.guanjianzi}) + (#{p.author}, #{p.keyword}, #{p.agency}, #{p.relationship_id}, #{p.title}, #{p.url}, #{p.guanjianzi},#{p.source},#{p.source_data}) INSERT INTO zhy_point_relationship_group