|
|
@ -1261,7 +1261,11 @@ public class DocApiController extends BaseController { |
|
|
List<ZhyTaskInfo> taskInfos=zhyTaskInfoMapper.selectZhyTaskInfoByTaskId(task.getId()); |
|
|
List<ZhyTaskInfo> taskInfos=zhyTaskInfoMapper.selectZhyTaskInfoByTaskId(task.getId()); |
|
|
for(int i=0;i<taskInfos.size();i++){ |
|
|
for(int i=0;i<taskInfos.size();i++){ |
|
|
ZhyTaskInfo info=taskInfos.get(i); |
|
|
ZhyTaskInfo info=taskInfos.get(i); |
|
|
webSocketService.sendToUser("123","正在抓取‘"+info.getName1()+"数据"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在抓取'"+info.getName1()+"'数据"); |
|
|
|
|
|
|
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
goPython(info,searchItems); |
|
|
goPython(info,searchItems); |
|
|
} |
|
|
} |
|
|
task.setStatus(1); |
|
|
task.setStatus(1); |
|
|
@ -1329,11 +1333,11 @@ public class DocApiController extends BaseController { |
|
|
|
|
|
|
|
|
@GetMapping("/proceed/{taskId}") |
|
|
@GetMapping("/proceed/{taskId}") |
|
|
public void proceed(HttpServletRequest request,@PathVariable("taskId")Long taskId) throws JsonProcessingException, InterruptedException { |
|
|
public void proceed(HttpServletRequest request,@PathVariable("taskId")Long taskId) throws JsonProcessingException, InterruptedException { |
|
|
|
|
|
Gson gson = new Gson(); |
|
|
ZhyTask task=zhyTaskService.selectZhyTaskById(taskId); |
|
|
ZhyTask task=zhyTaskService.selectZhyTaskById(taskId); |
|
|
System.out.println("111111111111111"); |
|
|
System.out.println("111111111111111"); |
|
|
if(!task.getUserCommand().equals("")){ |
|
|
if(!task.getUserCommand().equals("")){ |
|
|
if(task.getType()==0){ |
|
|
if(task.getType()==0){ |
|
|
Gson gson = new Gson(); |
|
|
|
|
|
Type typeData = new TypeToken<Map<String, Object>>(){}.getType(); |
|
|
Type typeData = new TypeToken<Map<String, Object>>(){}.getType(); |
|
|
Map<String, Object> data = gson.fromJson(task.getUserCommand(), typeData); |
|
|
Map<String, Object> data = gson.fromJson(task.getUserCommand(), typeData); |
|
|
// 存储结果:group -> type -> List<Long>(ID 列表)
|
|
|
// 存储结果:group -> type -> List<Long>(ID 列表)
|
|
|
@ -1400,7 +1404,10 @@ public class DocApiController extends BaseController { |
|
|
List<ZhyTaskInfo> taskInfos1=zhyTaskInfoMapper.selectZhyTaskInfoByTaskIdAndStatus(taskId,0); |
|
|
List<ZhyTaskInfo> taskInfos1=zhyTaskInfoMapper.selectZhyTaskInfoByTaskIdAndStatus(taskId,0); |
|
|
for(int i=0;i<taskInfos.size();i++){ |
|
|
for(int i=0;i<taskInfos.size();i++){ |
|
|
ZhyTaskInfo info=taskInfos.get(i); |
|
|
ZhyTaskInfo info=taskInfos.get(i); |
|
|
webSocketService.sendToUser("123","正在抓取‘"+info.getName1()+"-"+info.getName2()+"’数据"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在抓取'"+info.getName1()+"-"+info.getName2()+"'数据"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
if(info.getGroupId()==0l){ |
|
|
if(info.getGroupId()==0l){ |
|
|
goPython(info,group0SearchItems); |
|
|
goPython(info,group0SearchItems); |
|
|
} |
|
|
} |
|
|
@ -1414,7 +1421,10 @@ public class DocApiController extends BaseController { |
|
|
} |
|
|
} |
|
|
for(int i=0;i<taskInfos1.size();i++){ |
|
|
for(int i=0;i<taskInfos1.size();i++){ |
|
|
ZhyTaskInfo info=taskInfos1.get(i); |
|
|
ZhyTaskInfo info=taskInfos1.get(i); |
|
|
webSocketService.sendToUser("123","正在抓取‘"+info.getName1()+"-"+info.getName2()+"’数据"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在抓取'"+info.getName1()+"-"+info.getName2()+"'数据"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
if(info.getGroupId()==0l){ |
|
|
if(info.getGroupId()==0l){ |
|
|
goPython(info,group0SearchItems); |
|
|
goPython(info,group0SearchItems); |
|
|
} |
|
|
} |
|
|
@ -1427,7 +1437,6 @@ public class DocApiController extends BaseController { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}else if(task.getType()==1){ |
|
|
}else if(task.getType()==1){ |
|
|
Gson gson = new Gson(); |
|
|
|
|
|
Type typeData = new TypeToken<Map<String, Object>>(){}.getType(); |
|
|
Type typeData = new TypeToken<Map<String, Object>>(){}.getType(); |
|
|
Map<String, Object> data = gson.fromJson(task.getUserCommand(), typeData); |
|
|
Map<String, Object> data = gson.fromJson(task.getUserCommand(), typeData); |
|
|
List<Map<String, Object>> searchItems = new ArrayList<>(); |
|
|
List<Map<String, Object>> searchItems = new ArrayList<>(); |
|
|
@ -1442,17 +1451,27 @@ public class DocApiController extends BaseController { |
|
|
List<ZhyTaskInfo> taskInfos1=zhyTaskInfoMapper.selectZhyTaskInfoByTaskIdAndStatus(taskId,0); |
|
|
List<ZhyTaskInfo> taskInfos1=zhyTaskInfoMapper.selectZhyTaskInfoByTaskIdAndStatus(taskId,0); |
|
|
for(int i=0;i<taskInfos.size();i++){ |
|
|
for(int i=0;i<taskInfos.size();i++){ |
|
|
ZhyTaskInfo info=taskInfos.get(i); |
|
|
ZhyTaskInfo info=taskInfos.get(i); |
|
|
webSocketService.sendToUser("123","正在抓取‘"+info.getName1()+"数据"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在抓取'"+info.getName1()+"'数据"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
goPython(info,searchItems); |
|
|
goPython(info,searchItems); |
|
|
} |
|
|
} |
|
|
for(int i=0;i<taskInfos1.size();i++){ |
|
|
for(int i=0;i<taskInfos1.size();i++){ |
|
|
ZhyTaskInfo info=taskInfos1.get(i); |
|
|
ZhyTaskInfo info=taskInfos1.get(i); |
|
|
webSocketService.sendToUser("123","正在抓取‘"+info.getName1()+"数据"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在抓取'"+info.getName1()+"'数据"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
goPython(info,searchItems); |
|
|
goPython(info,searchItems); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
task.setStatus(1); |
|
|
task.setStatus(1); |
|
|
zhyTaskService.updateZhyTask(task); |
|
|
zhyTaskService.updateZhyTask(task); |
|
|
|
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","构建完成"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1731,9 +1750,15 @@ public class DocApiController extends BaseController { |
|
|
for(int i=0;i<taskInfos.size();i++){ |
|
|
for(int i=0;i<taskInfos.size();i++){ |
|
|
ZhyTaskInfo info=taskInfos.get(i); |
|
|
ZhyTaskInfo info=taskInfos.get(i); |
|
|
if(info.getName2()!=null){ |
|
|
if(info.getName2()!=null){ |
|
|
webSocketService.sendToUser("123","正在抓取‘"+info.getName1()+"-"+info.getName2()+"’数据"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在抓取'"+info.getName1()+"-"+info.getName2()+"'数据"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
}else{ |
|
|
}else{ |
|
|
webSocketService.sendToUser("123","正在抓取‘"+info.getName1()+"数据"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在抓取'"+info.getName1()+"'数据"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
} |
|
|
} |
|
|
if(info.getGroupId()==0l){ |
|
|
if(info.getGroupId()==0l){ |
|
|
goPython(info,group0SearchItems); |
|
|
goPython(info,group0SearchItems); |
|
|
@ -1748,6 +1773,10 @@ public class DocApiController extends BaseController { |
|
|
} |
|
|
} |
|
|
task.setStatus(1); |
|
|
task.setStatus(1); |
|
|
zhyTaskService.updateZhyTask(task); |
|
|
zhyTaskService.updateZhyTask(task); |
|
|
|
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","构建完成"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
//构建定时图谱
|
|
|
//构建定时图谱
|
|
|
//定时去跑这个脚本
|
|
|
//定时去跑这个脚本
|
|
|
//获取所有的节点信息,包括名称、group分组
|
|
|
//获取所有的节点信息,包括名称、group分组
|
|
|
@ -1806,7 +1835,7 @@ public void goPython(ZhyTaskInfo info, List<Map<String, Object>> searchItems) |
|
|
} |
|
|
} |
|
|
int maxRetries = 3; // 最大重试次数,避免无限重试
|
|
|
int maxRetries = 3; // 最大重试次数,避免无限重试
|
|
|
int retryCount = 0; |
|
|
int retryCount = 0; |
|
|
|
|
|
Gson gson = new Gson(); |
|
|
while (retryCount <= maxRetries) { |
|
|
while (retryCount <= maxRetries) { |
|
|
try { |
|
|
try { |
|
|
// 构建请求数据
|
|
|
// 构建请求数据
|
|
|
@ -1855,9 +1884,15 @@ public void goPython(ZhyTaskInfo info, List<Map<String, Object>> searchItems) |
|
|
if ("build".equals(functionName)) { |
|
|
if ("build".equals(functionName)) { |
|
|
System.out.println("执行 build 逻辑..."); |
|
|
System.out.println("执行 build 逻辑..."); |
|
|
if(info.getName2()!=null){ |
|
|
if(info.getName2()!=null){ |
|
|
webSocketService.sendToUser("123","正在构建‘"+info.getName1()+"-"+info.getName2()+"’图谱"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在构建'"+info.getName1()+"-"+info.getName2()+"'图谱"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
}else{ |
|
|
}else{ |
|
|
webSocketService.sendToUser("123","正在构建‘"+info.getName1()+"图谱"); |
|
|
Map map1=new HashMap(); |
|
|
|
|
|
map1.put("type","message"); |
|
|
|
|
|
map1.put("msg","正在构建'"+info.getName1()+"'图谱"); |
|
|
|
|
|
webSocketService.sendToUser("123",gson.toJson(map1)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
staticBuildService.create(objMap); |
|
|
staticBuildService.create(objMap); |
|
|
|