Browse Source

Merge branch 'small-tupu' of http://124.70.32.114:3100/jianzhenyu/Changsha_tupu into hanyuqing

hanyuqing
hanyuqing 6 months ago
parent
commit
ed4b61b776
  1. 11
      gyxtp/src/api/api/doc.js
  2. 8
      gyxtp/src/view/docInfo.vue
  3. 6
      gyxtp/src/view/graphPageNB927.vue
  4. 8
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyPointController.java
  5. 182
      ruoyi-api/src/main/java/com/ruoyi/api/controller/TestXiaoTuPuController.java
  6. 162
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/PointService.java
  7. 51
      ruoyi-ui/src/views/system/SysPoint/index.vue
  8. 13
      坦克.txt

11
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',

8
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)'
})
}

6
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)';

8
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<String> result = new ArrayList<>();
StringBuilder current = new StringBuilder();

182
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<List<Map<String, Object>>>(){}.getType();
@GetMapping("test10")
public void test10() throws IOException {
System.out.println(10);
List<ZhyArticle> 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<Map<String, String>> 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<String, String> 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(){

162
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<ZhyArticle> articles,String keyword,String type) throws IOException {
if (type.equals("CNKI")){
List<Map<String, String>> 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<String, String> 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<Map<String, String>> 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<String, String> 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<Map<String, String>> 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<String, String> 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<Map<String, String>> 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<String, String> 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<Map<String, String>> dataList) {
Map<String, Integer> nameToId = new HashMap<>();

51
ruoyi-ui/src/views/system/SysPoint/index.vue

@ -78,6 +78,10 @@
@click="handleImportRelation">导入文献
</el-button>
<el-button v-hasPermi="['system:SysPoint:add']" type="info" plain style="float: left" icon="el-icon-upload2" size="mini"
@click="handleImportRelation2">导入txt
</el-button>
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="warning"-->
@ -169,6 +173,25 @@
<el-button @click="upload1.open = false"> </el-button>
</div>
</el-dialog>
<el-dialog :title="upload2.title" :visible.sync="upload2.open" width="400px" append-to-body>
<el-upload ref="upload2" :limit="1" accept=".csv" :headers="upload2.headers" :action="upload2.url"
:disabled="upload2.isUploading" :on-progress="handleFileUploadProgressRelation2"
:on-success="handleFileSuccess2"
:auto-upload="false" drag>
<i class="el-icon-upload"></i>
<div class="el-upload__text"> txt 文件拖到此处 <em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span style="color: #999;">仅允许导入 .txt 格式文件逗号分隔文本</span>
<br/>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileFormR2"> </el-button>
<el-button @click="upload2.open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
@ -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() {

13
坦克.txt

@ -0,0 +1,13 @@
题名: 文献名字1
作者: 王刚;陈慧敏;娃哈哈
中文刊名: 我不需要
单位: [1]实验室1;[2]单位22
摘要: 摘要我不需要
题名: 文献名字2
作者: 李强;康师傅
中文刊名: 我不需要22
学位授予单位: [1]实验室2,
摘要: 摘要我不需要2
关键词: [ss]关键词55;[dddd]关键词3
Loading…
Cancel
Save