|
|
|
@ -1084,104 +1084,89 @@ public class DocApiController extends BaseController { |
|
|
|
} |
|
|
|
@GetMapping("/getTitleByGroup") |
|
|
|
public Map getTitleByGroup(HttpServletRequest request) { |
|
|
|
String token = request.getHeader("Token"); |
|
|
|
if (!token.equals("")) { |
|
|
|
token = tokenService.parseToken(token).get("login_user_key", String.class); |
|
|
|
reushToken.DeletToken(token); |
|
|
|
LoginUser loginUser1 = redisCache.getCacheObject("login_tokens:" + token); |
|
|
|
if (loginUser1 != null) { |
|
|
|
//查询所有一级标题
|
|
|
|
|
|
|
|
List<ZhyDoc> g01=test1Mapper.selectDocByLevelByGroup(0l,1l); |
|
|
|
List<ZhyDoc> g02=test1Mapper.selectDocByLevelByGroup(0l,2l); |
|
|
|
List<ZhyDoc> g03=test1Mapper.selectDocByLevelByGroup(0l,3l); |
|
|
|
List<ZhyDoc> g04=test1Mapper.selectDocByLevelByGroup(0l,4l); |
|
|
|
|
|
|
|
//查询所有一级标题
|
|
|
|
List<ZhyDoc> g01=test1Mapper.selectDocByLevelByGroup(0l,1l); |
|
|
|
List<ZhyDoc> g02=test1Mapper.selectDocByLevelByGroup(0l,2l); |
|
|
|
List<ZhyDoc> g03=test1Mapper.selectDocByLevelByGroup(0l,3l); |
|
|
|
List<ZhyDoc> g04=test1Mapper.selectDocByLevelByGroup(0l,4l); |
|
|
|
|
|
|
|
|
|
|
|
List<ZhyDoc> g11=test1Mapper.selectDocByLevelByGroup(1l,1l); |
|
|
|
List<ZhyDoc> g12=test1Mapper.selectDocByLevelByGroup(1l,2l); |
|
|
|
List<ZhyDoc> g13=test1Mapper.selectDocByLevelByGroup(1l,3l); |
|
|
|
List<ZhyDoc> g14=test1Mapper.selectDocByLevelByGroup(1l,4l); |
|
|
|
|
|
|
|
List<ZhyDoc> g21=test1Mapper.selectDocByLevelByGroup(2l,1l); |
|
|
|
List<ZhyDoc> g22=test1Mapper.selectDocByLevelByGroup(2l,2l); |
|
|
|
List<ZhyDoc> g11=test1Mapper.selectDocByLevelByGroup(1l,1l); |
|
|
|
List<ZhyDoc> g12=test1Mapper.selectDocByLevelByGroup(1l,2l); |
|
|
|
List<ZhyDoc> g13=test1Mapper.selectDocByLevelByGroup(1l,3l); |
|
|
|
List<ZhyDoc> g14=test1Mapper.selectDocByLevelByGroup(1l,4l); |
|
|
|
|
|
|
|
Map mapAll=new HashMap<>(); |
|
|
|
Map map01=new HashMap<>(); |
|
|
|
map01.put("id",1); |
|
|
|
map01.put("name","方向"); |
|
|
|
map01.put("children",g01); |
|
|
|
List<ZhyDoc> g21=test1Mapper.selectDocByLevelByGroup(2l,1l); |
|
|
|
List<ZhyDoc> g22=test1Mapper.selectDocByLevelByGroup(2l,2l); |
|
|
|
|
|
|
|
Map map02=new HashMap<>(); |
|
|
|
map02.put("id",2); |
|
|
|
map02.put("name","作战"); |
|
|
|
map02.put("children",g02); |
|
|
|
Map mapAll=new HashMap<>(); |
|
|
|
Map map01=new HashMap<>(); |
|
|
|
map01.put("id",1); |
|
|
|
map01.put("name","方向"); |
|
|
|
map01.put("children",g01); |
|
|
|
|
|
|
|
Map map03=new HashMap<>(); |
|
|
|
map03.put("id",3); |
|
|
|
map03.put("name","装备"); |
|
|
|
map03.put("children",g03); |
|
|
|
Map map02=new HashMap<>(); |
|
|
|
map02.put("id",2); |
|
|
|
map02.put("name","作战"); |
|
|
|
map02.put("children",g02); |
|
|
|
|
|
|
|
Map map04=new HashMap<>(); |
|
|
|
map04.put("id",4); |
|
|
|
map04.put("name","环境"); |
|
|
|
map04.put("children",g04); |
|
|
|
Map map03=new HashMap<>(); |
|
|
|
map03.put("id",3); |
|
|
|
map03.put("name","装备"); |
|
|
|
map03.put("children",g03); |
|
|
|
|
|
|
|
Map map11=new HashMap<>(); |
|
|
|
map11.put("id",1); |
|
|
|
map11.put("name","业务系统"); |
|
|
|
map11.put("children",g11); |
|
|
|
Map map04=new HashMap<>(); |
|
|
|
map04.put("id",4); |
|
|
|
map04.put("name","环境"); |
|
|
|
map04.put("children",g04); |
|
|
|
|
|
|
|
Map map12=new HashMap<>(); |
|
|
|
map12.put("id",2); |
|
|
|
map12.put("name","模型库"); |
|
|
|
map12.put("children",g12); |
|
|
|
Map map11=new HashMap<>(); |
|
|
|
map11.put("id",1); |
|
|
|
map11.put("name","业务系统"); |
|
|
|
map11.put("children",g11); |
|
|
|
|
|
|
|
Map map13=new HashMap<>(); |
|
|
|
map13.put("id",3); |
|
|
|
map13.put("name","规则库"); |
|
|
|
map13.put("children",g13); |
|
|
|
Map map12=new HashMap<>(); |
|
|
|
map12.put("id",2); |
|
|
|
map12.put("name","模型库"); |
|
|
|
map12.put("children",g12); |
|
|
|
|
|
|
|
Map map14=new HashMap<>(); |
|
|
|
map14.put("id",4); |
|
|
|
map14.put("name","大类数据"); |
|
|
|
map14.put("children",g14); |
|
|
|
Map map13=new HashMap<>(); |
|
|
|
map13.put("id",3); |
|
|
|
map13.put("name","规则库"); |
|
|
|
map13.put("children",g13); |
|
|
|
|
|
|
|
Map map21=new HashMap<>(); |
|
|
|
map21.put("id",1); |
|
|
|
map21.put("name","模型方法"); |
|
|
|
map21.put("children",g21); |
|
|
|
Map map14=new HashMap<>(); |
|
|
|
map14.put("id",4); |
|
|
|
map14.put("name","大类数据"); |
|
|
|
map14.put("children",g14); |
|
|
|
|
|
|
|
Map map22=new HashMap<>(); |
|
|
|
map22.put("id",2); |
|
|
|
map22.put("name","指标"); |
|
|
|
map22.put("children",g22); |
|
|
|
Map map21=new HashMap<>(); |
|
|
|
map21.put("id",1); |
|
|
|
map21.put("name","模型方法"); |
|
|
|
map21.put("children",g21); |
|
|
|
|
|
|
|
Map map22=new HashMap<>(); |
|
|
|
map22.put("id",2); |
|
|
|
map22.put("name","指标"); |
|
|
|
map22.put("children",g22); |
|
|
|
|
|
|
|
mapAll.put("g01",map01); |
|
|
|
mapAll.put("g02",map02); |
|
|
|
mapAll.put("g03",map03); |
|
|
|
mapAll.put("g04",map04); |
|
|
|
|
|
|
|
mapAll.put("g11",map11); |
|
|
|
mapAll.put("g12",map12); |
|
|
|
mapAll.put("g13",map13); |
|
|
|
mapAll.put("g14",map14); |
|
|
|
mapAll.put("g01",map01); |
|
|
|
mapAll.put("g02",map02); |
|
|
|
mapAll.put("g03",map03); |
|
|
|
mapAll.put("g04",map04); |
|
|
|
|
|
|
|
mapAll.put("g21",map21); |
|
|
|
mapAll.put("g22",map22); |
|
|
|
mapAll.put("g11",map11); |
|
|
|
mapAll.put("g12",map12); |
|
|
|
mapAll.put("g13",map13); |
|
|
|
mapAll.put("g14",map14); |
|
|
|
|
|
|
|
mapAll.put("g21",map21); |
|
|
|
mapAll.put("g22",map22); |
|
|
|
|
|
|
|
|
|
|
|
return mapAll; |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
return mapAll; |
|
|
|
} |
|
|
|
@Autowired |
|
|
|
BuildService buildService; |
|
|
|
@ -1244,7 +1229,7 @@ public class DocApiController extends BaseController { |
|
|
|
|
|
|
|
} |
|
|
|
@PostMapping("/buildTwo") |
|
|
|
public void buildTwo(HttpServletRequest request,@RequestBody Map<String, Object> data) throws JsonProcessingException { |
|
|
|
public void buildTwo(HttpServletRequest request,@RequestBody Map<String, Object> data) throws JsonProcessingException, InterruptedException { |
|
|
|
|
|
|
|
System.out.println(data); |
|
|
|
// 存储结果:group -> type -> List<Long>(ID 列表)
|
|
|
|
@ -1450,37 +1435,126 @@ public class DocApiController extends BaseController { |
|
|
|
|
|
|
|
//如果中途嘎了java等待,然后20分钟去访问mysql时间最后一条数据
|
|
|
|
} |
|
|
|
public void goPython(String title1,String title2,List<Map<String, Object>> searchItems) throws JsonProcessingException { |
|
|
|
String[] keywords = new String[]{title1, title2}; |
|
|
|
Map map =new HashMap(); |
|
|
|
map.put("keywords",keywords); |
|
|
|
map.put("searchItems",searchItems); |
|
|
|
sendPython(map); |
|
|
|
while (pythonService.flag){ |
|
|
|
// public void goPython(String title1,String title2,List<Map<String, Object>> searchItems) throws JsonProcessingException, InterruptedException {
|
|
|
|
// String[] keywords = new String[]{title1, title2};
|
|
|
|
// Map map =new HashMap();
|
|
|
|
// map.put("keywords",keywords);
|
|
|
|
// map.put("searchItems",searchItems);
|
|
|
|
// sendPython(map);
|
|
|
|
// while (pythonService.flag){
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// pythonService.flag=true;
|
|
|
|
// System.out.println("22222222222222222222");
|
|
|
|
// System.out.println(pythonService.pythonMessage);
|
|
|
|
// String payload=pythonService.pythonMessage;
|
|
|
|
// ObjectMapper mapper=new ObjectMapper();
|
|
|
|
// Map<String,String> objMap =mapper.readValue(payload, new TypeReference<Map<String, String>>() {});
|
|
|
|
// if(objMap.get("code").equals("500")){
|
|
|
|
// System.out.println(objMap.get("message"));
|
|
|
|
// Thread.sleep(10 * 60 * 1000);
|
|
|
|
// }
|
|
|
|
// if(objMap.get("code").equals("200")){
|
|
|
|
// if (objMap.get("function_name").equals("build")){
|
|
|
|
// System.out.println("1111111111111");
|
|
|
|
// System.out.println(objMap);
|
|
|
|
// staticBuildService.create(objMap);
|
|
|
|
// }
|
|
|
|
// if (objMap.get("function_name").equals("none")){
|
|
|
|
//// staticBuildService.create(objMap);
|
|
|
|
// System.out.println("没有数据");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
public void goPython(String title1, String title2, List<Map<String, Object>> searchItems) |
|
|
|
throws JsonProcessingException, InterruptedException { |
|
|
|
|
|
|
|
} |
|
|
|
pythonService.flag=false; |
|
|
|
System.out.println("22222222222222222222"); |
|
|
|
System.out.println(pythonService.pythonMessage); |
|
|
|
String payload=pythonService.pythonMessage; |
|
|
|
ObjectMapper mapper=new ObjectMapper(); |
|
|
|
Map<String,String> objMap =mapper.readValue(payload, new TypeReference<Map<String, String>>() {}); |
|
|
|
if(objMap.get("code").equals("500")){ |
|
|
|
System.out.println(objMap.get("message")); |
|
|
|
} |
|
|
|
if(objMap.get("code").equals("200")){ |
|
|
|
if (objMap.get("function_name").equals("build")){ |
|
|
|
System.out.println("1111111111111"); |
|
|
|
System.out.println(objMap); |
|
|
|
staticBuildService.create(objMap); |
|
|
|
String[] keywords = new String[]{title1, title2}; |
|
|
|
int maxRetries = 3; // 最大重试次数,避免无限重试
|
|
|
|
int retryCount = 0; |
|
|
|
|
|
|
|
while (retryCount <= maxRetries) { |
|
|
|
try { |
|
|
|
// 构建请求数据
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("keywords", keywords); |
|
|
|
map.put("searchItems", searchItems); |
|
|
|
|
|
|
|
// 发送请求给 Python
|
|
|
|
sendPython(map); |
|
|
|
|
|
|
|
// 等待 Python 执行完成(通过 flag 控制)
|
|
|
|
while (pythonService.flag) { |
|
|
|
Thread.sleep(1000); // 每秒检查一次,避免忙等
|
|
|
|
} |
|
|
|
|
|
|
|
// 标志位重置(假设下次调用前需要手动重置)
|
|
|
|
pythonService.flag = true; |
|
|
|
|
|
|
|
System.out.println("从 Python 收到响应: " + pythonService.pythonMessage); |
|
|
|
String payload = pythonService.pythonMessage; |
|
|
|
|
|
|
|
// 解析 JSON 响应
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String, String> objMap = mapper.readValue(payload, new TypeReference<Map<String, String>>() {}); |
|
|
|
|
|
|
|
// 检查响应状态
|
|
|
|
if ("500".equals(objMap.get("code"))) { |
|
|
|
System.out.println("Python 执行失败: " + objMap.get("message")); |
|
|
|
retryCount++; |
|
|
|
if (retryCount > maxRetries) { |
|
|
|
System.out.println("已达到最大重试次数,放弃重试。"); |
|
|
|
break; |
|
|
|
} |
|
|
|
System.out.println("将在 10 分钟后重试... (第 " + retryCount + " 次重试)"); |
|
|
|
Thread.sleep(10 * 60 * 1000); // 等待 10 分钟后重试
|
|
|
|
continue; // 重要:跳回循环开头,重新执行整个流程
|
|
|
|
} |
|
|
|
|
|
|
|
// 成功响应
|
|
|
|
if ("200".equals(objMap.get("code"))) { |
|
|
|
String functionName = objMap.get("function_name"); |
|
|
|
if ("build".equals(functionName)) { |
|
|
|
System.out.println("执行 build 逻辑..."); |
|
|
|
staticBuildService.create(objMap); |
|
|
|
} else if ("none".equals(functionName)) { |
|
|
|
System.out.println("Python 返回:没有数据"); |
|
|
|
} else { |
|
|
|
System.out.println("未知的 function_name: " + functionName); |
|
|
|
} |
|
|
|
// 成功处理,跳出循环
|
|
|
|
break; |
|
|
|
} |
|
|
|
if (objMap.get("function_name").equals("none")){ |
|
|
|
// staticBuildService.create(objMap);
|
|
|
|
System.out.println("没有数据"); |
|
|
|
|
|
|
|
// 如果 code 既不是 200 也不是 500,也应重试
|
|
|
|
System.out.println("收到未知响应 code: " + objMap.get("code") + ", 消息: " + objMap.get("message")); |
|
|
|
retryCount++; |
|
|
|
if (retryCount > maxRetries) { |
|
|
|
System.out.println("未知响应,已达到最大重试次数。"); |
|
|
|
break; |
|
|
|
} |
|
|
|
Thread.sleep(10 * 60 * 1000); |
|
|
|
continue; |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
// 处理 JSON 解析异常等
|
|
|
|
System.err.println("处理 Python 响应时发生错误: " + e.getMessage()); |
|
|
|
retryCount++; |
|
|
|
if (retryCount > maxRetries) break; |
|
|
|
Thread.sleep(10 * 60 * 1000); |
|
|
|
continue; |
|
|
|
} catch (Exception e) { |
|
|
|
// 其他潜在异常,如 sendPython 抛出的异常
|
|
|
|
System.err.println("调用 Python 时发生异常: " + e.getMessage()); |
|
|
|
retryCount++; |
|
|
|
if (retryCount > maxRetries) break; |
|
|
|
Thread.sleep(10 * 60 * 1000); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("goPython 流程结束。"); |
|
|
|
} |
|
|
|
public List<Long> getIdsByGroupAndType( |
|
|
|
Map<String, Map<Object, List<Long>>> result, |
|
|
|
String groupName, |
|
|
|
|