|
|
@ -2,6 +2,7 @@ package com.ruoyi.api.controller; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
import com.alibaba.fastjson2.JSON; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.google.gson.Gson; |
|
|
import com.google.gson.Gson; |
|
|
import com.ruoyi.api.Websocket; |
|
|
import com.ruoyi.api.Websocket; |
|
|
@ -39,10 +40,12 @@ import java.util.stream.Collectors; |
|
|
import com.ruoyi.api.util.PythonApiClient; |
|
|
import com.ruoyi.api.util.PythonApiClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/api/doc") |
|
|
@RequestMapping("/api/doc") |
|
|
public class DocApiController extends BaseController { |
|
|
public class DocApiController extends BaseController { |
|
|
|
|
|
@Autowired |
|
|
|
|
|
BuildService staticBuildService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
static PythonService pythonService; |
|
|
static PythonService pythonService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
@ -1241,7 +1244,7 @@ public class DocApiController extends BaseController { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@PostMapping("/buildTwo") |
|
|
@PostMapping("/buildTwo") |
|
|
public void buildTwo(HttpServletRequest request,@RequestBody Map<String, Object> data) { |
|
|
public void buildTwo(HttpServletRequest request,@RequestBody Map<String, Object> data) throws JsonProcessingException { |
|
|
|
|
|
|
|
|
System.out.println(data); |
|
|
System.out.println(data); |
|
|
// 存储结果:group -> type -> List<Long>(ID 列表)
|
|
|
// 存储结果:group -> type -> List<Long>(ID 列表)
|
|
|
@ -1330,6 +1333,7 @@ public class DocApiController extends BaseController { |
|
|
List<Map<String, Object>> group2SearchItems = searchItemsMap.get("group2"); |
|
|
List<Map<String, Object>> group2SearchItems = searchItemsMap.get("group2"); |
|
|
// 直接获取,即使 key 不存在也不会报错
|
|
|
// 直接获取,即使 key 不存在也不会报错
|
|
|
//获取第一组的数据节点
|
|
|
//获取第一组的数据节点
|
|
|
|
|
|
//group0
|
|
|
List<Long> group0_type1 = getIdsByGroupAndType(groupedResult, "group0", 1); |
|
|
List<Long> group0_type1 = getIdsByGroupAndType(groupedResult, "group0", 1); |
|
|
List<Long> group0_type2 = getIdsByGroupAndType(groupedResult, "group0", 2); |
|
|
List<Long> group0_type2 = getIdsByGroupAndType(groupedResult, "group0", 2); |
|
|
List<Long> group0_type3 = getIdsByGroupAndType(groupedResult, "group0", 3); |
|
|
List<Long> group0_type3 = getIdsByGroupAndType(groupedResult, "group0", 3); |
|
|
@ -1357,29 +1361,78 @@ public class DocApiController extends BaseController { |
|
|
ZhyDoc doc2=g02.get(j); |
|
|
ZhyDoc doc2=g02.get(j); |
|
|
//websocket python
|
|
|
//websocket python
|
|
|
//websocket vue
|
|
|
//websocket vue
|
|
|
String[] keywords = new String[]{doc1.getDocTitle(), doc2.getDocTitle()}; |
|
|
goPython(doc1.getDocTitle(),doc2.getDocTitle(),group0SearchItems); |
|
|
Map map =new HashMap(); |
|
|
} |
|
|
map.put("keywords",keywords); |
|
|
} |
|
|
map.put("searchItems",group0SearchItems); |
|
|
for(int i=0;i<g02.size();i++){ |
|
|
sendPython(map); |
|
|
ZhyDoc doc1=g02.get(i); |
|
|
while (pythonService.flag){ |
|
|
for(int j=0;j<g03.size();j++){ |
|
|
|
|
|
ZhyDoc doc2=g03.get(j); |
|
|
} |
|
|
//websocket python
|
|
|
|
|
|
//websocket vue
|
|
|
|
|
|
goPython(doc1.getDocTitle(),doc2.getDocTitle(),group0SearchItems); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
for(int i=0;i<g03.size();i++){ |
|
|
|
|
|
ZhyDoc doc1=g03.get(i); |
|
|
|
|
|
for(int j=0;j<g04.size();j++){ |
|
|
|
|
|
ZhyDoc doc2=g04.get(j); |
|
|
|
|
|
//websocket python
|
|
|
|
|
|
//websocket vue
|
|
|
|
|
|
goPython(doc1.getDocTitle(),doc2.getDocTitle(),group0SearchItems); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//group1
|
|
|
List<Long> group1_type1 = getIdsByGroupAndType(groupedResult, "group1", 1); |
|
|
List<Long> group1_type1 = getIdsByGroupAndType(groupedResult, "group1", 1); |
|
|
List<Long> group2_type1 = getIdsByGroupAndType(groupedResult, "group2", 1); |
|
|
List<Long> group1_type2 = getIdsByGroupAndType(groupedResult, "group1", 2); |
|
|
|
|
|
List<Long> group1_type3 = getIdsByGroupAndType(groupedResult, "group1", 3); |
|
|
System.out.println("group0_type1 = " + group0_type1); // [79804]
|
|
|
List<Long> group1_type4 = getIdsByGroupAndType(groupedResult, "group1", 4); |
|
|
System.out.println("group1_type1 = " + group1_type1); // [79824]
|
|
|
List<ZhyDoc> g11=new ArrayList<>(); |
|
|
System.out.println("group2_type1 = " + group2_type1); // [79812]
|
|
|
List<ZhyDoc> g12=new ArrayList<>(); |
|
|
|
|
|
List<ZhyDoc> g13=new ArrayList<>(); |
|
|
|
|
|
List<ZhyDoc> g14=new ArrayList<>(); |
|
|
|
|
|
if(group1_type1.size()>0){ |
|
|
|
|
|
g11=test1Mapper.selectDocByIds(group1_type1); |
|
|
|
|
|
} |
|
|
|
|
|
if(group1_type2.size()>0){ |
|
|
|
|
|
g12=test1Mapper.selectDocByIds(group1_type2); |
|
|
|
|
|
} |
|
|
|
|
|
if(group1_type3.size()>0){ |
|
|
|
|
|
g13=test1Mapper.selectDocByIds(group1_type3); |
|
|
|
|
|
} |
|
|
|
|
|
if(group1_type4.size()>0){ |
|
|
|
|
|
g14=test1Mapper.selectDocByIds(group1_type4); |
|
|
|
|
|
} |
|
|
|
|
|
for(int i=0;i<g11.size();i++){ |
|
|
|
|
|
ZhyDoc doc1=g11.get(i); |
|
|
|
|
|
for(int j=0;j<g12.size();j++){ |
|
|
|
|
|
ZhyDoc doc2=g12.get(j); |
|
|
|
|
|
//websocket python
|
|
|
|
|
|
//websocket vue
|
|
|
|
|
|
goPython(doc1.getDocTitle(),doc2.getDocTitle(),group1SearchItems); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
for(int i=0;i<g12.size();i++){ |
|
|
|
|
|
ZhyDoc doc1=g12.get(i); |
|
|
|
|
|
for(int j=0;j<g13.size();j++){ |
|
|
|
|
|
ZhyDoc doc2=g13.get(j); |
|
|
|
|
|
//websocket python
|
|
|
|
|
|
//websocket vue
|
|
|
|
|
|
goPython(doc1.getDocTitle(),doc2.getDocTitle(),group1SearchItems); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
for(int i=0;i<g13.size();i++){ |
|
|
|
|
|
ZhyDoc doc1=g13.get(i); |
|
|
|
|
|
for(int j=0;j<g14.size();j++){ |
|
|
|
|
|
ZhyDoc doc2=g14.get(j); |
|
|
|
|
|
//websocket python
|
|
|
|
|
|
//websocket vue
|
|
|
|
|
|
goPython(doc1.getDocTitle(),doc2.getDocTitle(),group1SearchItems); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
System.out.println(group0SearchItems+"0"); |
|
|
|
|
|
System.out.println(group1SearchItems+"1"); |
|
|
|
|
|
System.out.println(group2SearchItems+"2"); |
|
|
|
|
|
//构建定时图谱
|
|
|
//构建定时图谱
|
|
|
//定时去跑这个脚本
|
|
|
//定时去跑这个脚本
|
|
|
//获取所有的节点信息,包括名称、group分组
|
|
|
//获取所有的节点信息,包括名称、group分组
|
|
|
@ -1397,6 +1450,36 @@ public class DocApiController extends BaseController { |
|
|
|
|
|
|
|
|
//如果中途嘎了java等待,然后20分钟去访问mysql时间最后一条数据
|
|
|
//如果中途嘎了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){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
if (objMap.get("function_name").equals("none")){ |
|
|
|
|
|
// staticBuildService.create(objMap);
|
|
|
|
|
|
System.out.println("没有数据"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public List<Long> getIdsByGroupAndType( |
|
|
public List<Long> getIdsByGroupAndType( |
|
|
Map<String, Map<Object, List<Long>>> result, |
|
|
Map<String, Map<Object, List<Long>>> result, |
|
|
|