Browse Source

导入文件夹

small-tupu
hanyuqing 6 months ago
parent
commit
bd8506c91f
  1. 174
      ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java
  2. 10
      ruoyi-system/src/main/java/com/ruoyi/system/domain/ZhyTask.java
  3. 7
      ruoyi-system/src/main/resources/mapper/system/ZhyTaskMapper.xml
  4. 30
      ruoyi-ui/src/views/system/create/index.vue

174
ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java

@ -1324,7 +1324,15 @@ public class DocApiController extends BaseController {
System.out.println(userId);
List<Long> selected = new ArrayList<>();
Object selectedObj = data.get("selected");
Object urlObj = data.get("url");
Map urlMap=new HashMap<>();
if (urlObj instanceof Map) {
urlMap = (Map<?, ?>) urlObj;
// 现在可以使用 map
System.out.println("Key set: " + urlMap.keySet());
} else {
System.out.println("对象不是 Map 类型");
}
if (selectedObj instanceof List) {
for (Object id : (List<?>) selectedObj) {
if (id instanceof Integer) {
@ -1350,6 +1358,7 @@ public class DocApiController extends BaseController {
task.setUserCommand(jsonString);
task.setType(1);
task.setStatus(0);
task.setUrl(gson.toJson(urlObj));
zhyTaskService.insertZhyTask(task);
for (int i=0;i<selected.size();i++){
System.out.println(selected.get(i));
@ -1368,7 +1377,7 @@ public class DocApiController extends BaseController {
map1.put("msg","正在抓取'"+info.getName1()+"'数据");
webSocketService.sendToUser(userId,gson.toJson(map1));
goPython(info,searchItems,userId);
goPython(info,searchItems,userId,urlMap);
}
boolean allStatusOne = true; // 假设所有状态都是1
@ -1388,63 +1397,6 @@ public class DocApiController extends BaseController {
webSocketService.sendToUser(userId,gson.toJson(map1));
}
}
@PostMapping("/buildOne")
public void buildOne(HttpServletRequest request,@RequestBody Map data) throws IOException {
Map thesis =new HashMap<>();
buildService.create(thesis);
if (!data.get("l1").equals("")){
Long l1 = Long.valueOf(String.valueOf(data.get("l1")));
ZhyDoc doc=test1Mapper.selectDocByIdId(l1);
data.put("l1",doc.getDocTitle());
}else {
Integer l1=null;
}
if (!data.get("l2").equals("")){
Long l2 = Long.valueOf(String.valueOf(data.get("l2")));
ZhyDoc doc=test1Mapper.selectDocByIdId(l2);
data.put("l2",doc.getDocTitle());
}else{
Integer l2=null;
}
if (!data.get("l3").equals("")){
Long l3 = Long.valueOf(String.valueOf(data.get("l3")));
ZhyDoc doc=test1Mapper.selectDocByIdId(l3);
data.put("l3",doc.getDocTitle());
}else {
Integer l3=null;
}
if (!data.get("l4").equals("")){
Long l4 = Long.valueOf(String.valueOf(data.get("l4")));
ZhyDoc doc=test1Mapper.selectDocByIdId(l4);
data.put("l4",doc.getDocTitle());
}else {
Integer l4=null;
}
if (!data.get("l5").equals("")){
Long l5 = Long.valueOf(String.valueOf(data.get("l5")));
ZhyDoc doc=test1Mapper.selectDocByIdId(l5);
data.put("l5",doc.getDocTitle());
}else {
Integer l5=null;
}
if (!data.get("l6").equals("")){
Long l6 = Long.valueOf(String.valueOf(data.get("l6")));
ZhyDoc doc=test1Mapper.selectDocByIdId(l6);
data.put("l6",doc.getDocTitle());
}else {
Integer l6=null;
}
Websocket.start();
Gson gson = new Gson();
String json = gson.toJson(data);
Websocket.sendMessage(json);
}
@GetMapping("/proceed/{taskId}/{userId}")
public void proceed(HttpServletRequest request,@PathVariable("taskId")Long taskId,@PathVariable("userId")String userId) throws JsonProcessingException, InterruptedException {
@ -1452,6 +1404,7 @@ public class DocApiController extends BaseController {
ZhyTask task=zhyTaskService.selectZhyTaskById(taskId);
System.out.println("111111111111111");
System.out.println(userId);
Map<String, String> urlMap = gson.fromJson(task.getUrl(), Map.class);
if(!task.getUserCommand().equals("")){
if(task.getType()==0){
Type typeData = new TypeToken<Map<String, Object>>(){}.getType();
@ -1526,13 +1479,13 @@ public class DocApiController extends BaseController {
map1.put("msg","正在抓取'"+info.getName1()+"-"+info.getName2()+"'数据");
webSocketService.sendToUser(userId,gson.toJson(map1));
if(info.getGroupId()==0l){
goPython(info,group0SearchItems,userId);
goPython(info,group0SearchItems,userId,urlMap);
}
if(info.getGroupId()==1l){
goPython(info,group1SearchItems,userId);
goPython(info,group1SearchItems,userId,urlMap);
}
if(info.getGroupId()==2l){
goPython(info,group2SearchItems,userId);
goPython(info,group2SearchItems,userId,urlMap);
}
}
@ -1573,7 +1526,7 @@ public class DocApiController extends BaseController {
map1.put("type","message");
map1.put("msg","正在抓取'"+info.getName1()+"'数据");
webSocketService.sendToUser(userId,gson.toJson(map1));
goPython(info,searchItems,userId);
goPython(info,searchItems,userId,urlMap);
}
boolean allStatusOne = true; // 假设所有状态都是1
@ -1608,6 +1561,16 @@ public class DocApiController extends BaseController {
task.setUserCommand(jsonString);
task.setType(0);
task.setStatus(0);
Object urlObj = data.get("url");
Map urlMap=new HashMap<>();
if (urlObj instanceof Map) {
urlMap = (Map<?, ?>) urlObj;
// 现在可以使用 map
System.out.println("Key set: " + urlMap.keySet());
} else {
System.out.println("对象不是 Map 类型");
}
task.setUrl(gson.toJson(urlObj));
zhyTaskService.insertZhyTask(task);
String userId=data.get("userId").toString();
@ -1725,7 +1688,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<g03.size();i++){
@ -1741,14 +1703,8 @@ public class DocApiController extends BaseController {
taskInfo.setGroupId(0l);
taskInfo.setStatus(0);
zhyTaskInfoService.insertZhyTaskInfo(taskInfo);
// goPython(doc1.getDocTitle(),doc2.getDocTitle(),group0SearchItems);
}
}
//group1
List<Long> group1_type1 = getIdsByGroupAndType(groupedResult, "group1", 1);
List<Long> group1_type2 = getIdsByGroupAndType(groupedResult, "group1", 2);
@ -1784,7 +1740,6 @@ public class DocApiController extends BaseController {
taskInfo.setGroupId(1l);
taskInfo.setStatus(0);
zhyTaskInfoService.insertZhyTaskInfo(taskInfo);
// goPython(doc1.getDocTitle(),doc2.getDocTitle(),group1SearchItems);
}
}
for(int i=0;i<g12.size();i++){
@ -1799,7 +1754,6 @@ public class DocApiController extends BaseController {
taskInfo.setName2(doc2.getDocTitle());
taskInfo.setGroupId(1l);
taskInfo.setStatus(0);
// goPython(doc1.getDocTitle(),doc2.getDocTitle(),group1SearchItems);
}
}
for(int i=0;i<g13.size();i++){
@ -1814,7 +1768,6 @@ public class DocApiController extends BaseController {
taskInfo.setName2(doc2.getDocTitle());
taskInfo.setGroupId(1l);
taskInfo.setStatus(0);
// goPython(doc1.getDocTitle(),doc2.getDocTitle(),group1SearchItems);
}
}
//group1
@ -1841,7 +1794,6 @@ public class DocApiController extends BaseController {
taskInfo.setGroupId(2l);
taskInfo.setStatus(0);
zhyTaskInfoService.insertZhyTaskInfo(taskInfo);
// goPython(doc1.getDocTitle(),doc2.getDocTitle(),group1SearchItems);
}
}
List<ZhyTaskInfo> taskInfos=zhyTaskInfoMapper.selectZhyTaskInfoByTaskId(task.getId());
@ -1859,13 +1811,13 @@ public class DocApiController extends BaseController {
webSocketService.sendToUser(userId,gson.toJson(map1));
}
if(info.getGroupId()==0l){
goPython(info,group0SearchItems,userId);
goPython(info,group0SearchItems,userId,urlMap);
}
if(info.getGroupId()==1l){
goPython(info,group1SearchItems,userId);
goPython(info,group1SearchItems,userId,urlMap);
}
if(info.getGroupId()==2l){
goPython(info,group2SearchItems,userId);
goPython(info,group2SearchItems,userId,urlMap);
}
}
@ -1908,13 +1860,17 @@ public class DocApiController extends BaseController {
//如果中途嘎了java等待,然后20分钟去访问mysql时间最后一条数据
}
public static Integer gopythonStatus = 0;
public void goPython(ZhyTaskInfo info, List<Map<String, Object>> searchItems,String userId)
public static Integer gopythonStatus = 0;
public void goPython(ZhyTaskInfo info, List<Map<String, Object>> searchItems,String userId,Map urlMap)
throws JsonProcessingException, InterruptedException {
if (gopythonStatus==1){
return;
}
gopythonStatus = 1;
String name = (String) urlMap.get("name");
String value = (String) urlMap.get("value");
List<String> keywords = new ArrayList<>();
keywords.add(info.getName1());
if(info.getName2()!=null){
@ -1930,7 +1886,8 @@ public void goPython(ZhyTaskInfo info, List<Map<String, Object>> searchItems,Str
Map<String, Object> map = new HashMap<>();
map.put("keywords", keywords);
map.put("searchItems", searchItems);
map.put("nbUrl", value);
map.put("nbName", name);
// 发送请求给 Python
sendPython(map);
@ -2078,6 +2035,63 @@ public void goPython(ZhyTaskInfo info, List<Map<String, Object>> searchItems,Str
}
}
// @PostMapping("/buildOne")
// public void buildOne(HttpServletRequest request,@RequestBody Map data) throws IOException {
// Map thesis =new HashMap<>();
// buildService.create(thesis);
// if (!data.get("l1").equals("")){
// Long l1 = Long.valueOf(String.valueOf(data.get("l1")));
// ZhyDoc doc=test1Mapper.selectDocByIdId(l1);
// data.put("l1",doc.getDocTitle());
// }else {
// Integer l1=null;
// }
// if (!data.get("l2").equals("")){
// Long l2 = Long.valueOf(String.valueOf(data.get("l2")));
// ZhyDoc doc=test1Mapper.selectDocByIdId(l2);
// data.put("l2",doc.getDocTitle());
// }else{
// Integer l2=null;
// }
// if (!data.get("l3").equals("")){
// Long l3 = Long.valueOf(String.valueOf(data.get("l3")));
// ZhyDoc doc=test1Mapper.selectDocByIdId(l3);
// data.put("l3",doc.getDocTitle());
// }else {
// Integer l3=null;
// }
// if (!data.get("l4").equals("")){
// Long l4 = Long.valueOf(String.valueOf(data.get("l4")));
// ZhyDoc doc=test1Mapper.selectDocByIdId(l4);
// data.put("l4",doc.getDocTitle());
// }else {
// Integer l4=null;
// }
//
// if (!data.get("l5").equals("")){
// Long l5 = Long.valueOf(String.valueOf(data.get("l5")));
// ZhyDoc doc=test1Mapper.selectDocByIdId(l5);
// data.put("l5",doc.getDocTitle());
// }else {
// Integer l5=null;
// }
//
// if (!data.get("l6").equals("")){
// Long l6 = Long.valueOf(String.valueOf(data.get("l6")));
// ZhyDoc doc=test1Mapper.selectDocByIdId(l6);
// data.put("l6",doc.getDocTitle());
// }else {
// Integer l6=null;
// }
//
// Websocket.start();
// Gson gson = new Gson();
// String json = gson.toJson(data);
// Websocket.sendMessage(json);
//
//
// }
//
}

10
ruoyi-system/src/main/java/com/ruoyi/system/domain/ZhyTask.java

@ -30,6 +30,16 @@ public class ZhyTask extends BaseEntity
@Excel(name = "状态1:完成2:进行中,3:中断")
private Integer status;
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getType() {
return type;
}

7
ruoyi-system/src/main/resources/mapper/system/ZhyTaskMapper.xml

@ -10,10 +10,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="type" column="type" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
<result property="url" column="url" />
</resultMap>
<sql id="selectZhyTaskVo">
select id, user_command, type, status, create_time from zhy_task
select id, user_command, type, status, create_time,url from zhy_task
</sql>
<select id="selectZhyTaskList" parameterType="ZhyTask" resultMap="ZhyTaskResult">
@ -21,7 +22,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="userCommand != null and userCommand != ''"> and user_command = #{userCommand}</if>
<if test="type != null"> and type = #{type}</if>
<if test="status != null"> and status = #{status}</if>
<if test="url != null and url != ''"> and url = #{url}</if>
</where>
</select>
@ -42,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null">type,</if>
<if test="status != null">status,</if>
<if test="createTime != null">create_time,</if>
<if test="url != null">url,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -49,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null">#{type},</if>
<if test="status != null">#{status},</if>
<if test="createTime != null">#{createTime},</if>
<if test="url != null">#{url},</if>
</trim>
</insert>

30
ruoyi-ui/src/views/system/create/index.vue

@ -15,7 +15,7 @@
</el-menu>
<div class="" style="margin-top: 2vw" v-if="activeIndex=='1'">
<div style="margin: auto;text-align: center;margin-bottom: 20px">
<el-radio-group v-model="radio1" style="margin-right: 20px" size="mini">
<el-radio-group v-model="selectedSource" style="margin-right: 20px" size="mini">
<el-radio-button label="CNKI"></el-radio-button>
<el-radio-button label="万方"></el-radio-button>
<el-radio-button label="维普"></el-radio-button>
@ -255,7 +255,7 @@ import {getUserProfile} from "../../../api/system/user";
export default {
data() {
return {
radio1:"CNKI",
selectedSource:"CNKI",
nodeTreeData:null,
imageUrl:"",
dialogImageUrl: "",
@ -366,7 +366,20 @@ export default {
userId:"",
};
},
computed: {
// label URL
sourceUrl() {
const urlMap = {
'CNKI': 'https://www.cnki.net',
'万方': 'https://www.wanfangdata.com.cn',
'维普': 'https://www.cqvip.com',
'CNKI博士': 'https://doctor.cnki.net',
'CNKI硕士': 'https://master.cnki.net',
'军事': 'https://www.military.com.cn' //
};
return urlMap[this.selectedSource];
}
},
methods: {
resetBuild(){
this.searchItems1 = this.resetSearchItems();
@ -522,6 +535,7 @@ export default {
// })
// },
async build(){
console.log( this.sourceUrl)
let data={
group0:{
selected:this.selected1,
@ -535,7 +549,12 @@ export default {
selected:this.selected3,
searchItems:this.searchItems3
},
userId:this.userId
userId:this.userId,
url:{
name:this.selectedSource,
value:this.sourceUrl
}
}
if(this.selected1.length==0&this.selected2.length==0&this.selected3.length==0){
this.$message.error('请选择要构建的节点');
@ -559,7 +578,8 @@ export default {
let data={
selected:this.selectedIds4,
searchItems:this.searchItems4,
userId:this.userId
userId:this.userId,
url:this.sourceUrl
}
if(this.selectedIds4.length>0){
await getIsTask().then(async res=>{

Loading…
Cancel
Save