diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/Websocket.java b/ruoyi-api/src/main/java/com/ruoyi/api/Websocket.java index b4df415..f8a7b7d 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/Websocket.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/Websocket.java @@ -74,7 +74,7 @@ public class Websocket { protected void handleTextMessage(WebSocketSession s, TextMessage message) throws Exception { log.info("📩 收到消息: {}", message.getPayload()); pythonService.flag=false; - + pythonService.pythonMessage=message.getPayload(); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java b/ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java index d4833d6..b764619 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java @@ -2,6 +2,7 @@ package com.ruoyi.api.controller; import com.alibaba.fastjson2.JSON; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.ruoyi.api.Websocket; @@ -39,10 +40,12 @@ import java.util.stream.Collectors; import com.ruoyi.api.util.PythonApiClient; + @RestController @RequestMapping("/api/doc") public class DocApiController extends BaseController { - + @Autowired + BuildService staticBuildService; @Autowired static PythonService pythonService; @Autowired @@ -1241,7 +1244,7 @@ public class DocApiController extends BaseController { } @PostMapping("/buildTwo") - public void buildTwo(HttpServletRequest request,@RequestBody Map data) { + public void buildTwo(HttpServletRequest request,@RequestBody Map data) throws JsonProcessingException { System.out.println(data); // 存储结果:group -> type -> List(ID 列表) @@ -1330,6 +1333,7 @@ public class DocApiController extends BaseController { List> group2SearchItems = searchItemsMap.get("group2"); // 直接获取,即使 key 不存在也不会报错 //获取第一组的数据节点 + //group0 List group0_type1 = getIdsByGroupAndType(groupedResult, "group0", 1); List group0_type2 = getIdsByGroupAndType(groupedResult, "group0", 2); List group0_type3 = getIdsByGroupAndType(groupedResult, "group0", 3); @@ -1357,29 +1361,78 @@ public class DocApiController extends BaseController { ZhyDoc doc2=g02.get(j); //websocket python //websocket vue - String[] keywords = new String[]{doc1.getDocTitle(), doc2.getDocTitle()}; - Map map =new HashMap(); - map.put("keywords",keywords); - map.put("searchItems",group0SearchItems); - sendPython(map); - while (pythonService.flag){ - - } - + goPython(doc1.getDocTitle(),doc2.getDocTitle(),group0SearchItems); + } + } + for(int i=0;i group1_type1 = getIdsByGroupAndType(groupedResult, "group1", 1); - List group2_type1 = getIdsByGroupAndType(groupedResult, "group2", 1); - - System.out.println("group0_type1 = " + group0_type1); // [79804] - System.out.println("group1_type1 = " + group1_type1); // [79824] - System.out.println("group2_type1 = " + group2_type1); // [79812] + List group1_type2 = getIdsByGroupAndType(groupedResult, "group1", 2); + List group1_type3 = getIdsByGroupAndType(groupedResult, "group1", 3); + List group1_type4 = getIdsByGroupAndType(groupedResult, "group1", 4); + List g11=new ArrayList<>(); + List g12=new ArrayList<>(); + List g13=new ArrayList<>(); + List 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> 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 objMap =mapper.readValue(payload, new TypeReference>() {}); + 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 getIdsByGroupAndType( Map>> result, diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java index c0eddd2..52f049d 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/BuildService.java @@ -277,21 +277,6 @@ public class BuildService { return result.toArray(new String[0]); } - public static void main(String[] args) { - // 已知的本地根目录 - String basePath = "D:\\project\\gyx\\tupudata\\results"; - // 假设这是从 CSV 读取的论文标题 - String title = "基于深度学习的图像识别"; - - // 生成文件名:01_标题.txt(你可以根据序号动态生成) - String filename = "01_" + title + ".txt"; - - // 拼接完整路径 - File file = new File(basePath, filename); - System.out.println("文件路径: " + file.getAbsolutePath()); - - - } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PythonService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PythonService.java index 87c97c0..b83ac6e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PythonService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PythonService.java @@ -4,7 +4,7 @@ import org.springframework.stereotype.Service; @Service public class PythonService { - public static boolean flag=false; + public static boolean flag=true; public static String pythonMessage=""; }