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