Browse Source

自动脚本

zxm
hanyuqing 7 months ago
parent
commit
64b723009b
  1. 16
      ruoyi-api/src/main/java/com/ruoyi/api/Websocket.java
  2. 8
      ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java
  3. 10
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PythonService.java

16
ruoyi-api/src/main/java/com/ruoyi/api/Websocket.java

@ -4,6 +4,7 @@ package com.ruoyi.api;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.api.service.impl.BuildService;
import com.ruoyi.system.service.impl.PythonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
@ -22,10 +23,13 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Component
@Slf4j
public class Websocket {
@Autowired
static PythonService pythonService;
@Autowired
public BuildService buildService;
private static BuildService staticBuildService; // 静态引用
private static volatile WebSocketSession session;
@ -69,17 +73,7 @@ public class Websocket {
@Override
protected void handleTextMessage(WebSocketSession s, TextMessage message) throws Exception {
log.info("📩 收到消息: {}", message.getPayload());
String payload = message.getPayload();
ObjectMapper mapper = new ObjectMapper();
Map<String, String> map = mapper.readValue(payload, new TypeReference<Map<String, String>>() {});
if(map.get("code").equals("500")){
System.out.println(map.get("message"));
}
if(map.get("code").equals("200")){
if (map.get("function_name").equals("build")){
staticBuildService.create(map);
}
}
pythonService.flag=false;
}

8
ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java

@ -20,6 +20,7 @@ import com.ruoyi.system.domain.ZhyDoc;
import com.ruoyi.system.domain.ZhyUserselfDifficult;
import com.ruoyi.system.mapper.Test1Mapper;
import com.ruoyi.system.service.impl.LuceneUtil;
import com.ruoyi.system.service.impl.PythonService;
import com.ruoyi.system.service.impl.WordSplitter;
import org.apache.commons.text.similarity.CosineSimilarity;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,9 +43,8 @@ import com.ruoyi.api.util.PythonApiClient;
@RequestMapping("/api/doc")
public class DocApiController extends BaseController {
static boolean flag=false;
static String url="";
@Autowired
static PythonService pythonService;
@Autowired
LuceneUtil luceneUtil;
@ -1362,7 +1362,9 @@ public class DocApiController extends BaseController {
map.put("keywords",keywords);
map.put("searchItems",group0SearchItems);
sendPython(map);
while (pythonService.flag){
}
}
}

10
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PythonService.java

@ -0,0 +1,10 @@
package com.ruoyi.system.service.impl;
import org.springframework.stereotype.Service;
@Service
public class PythonService {
public static boolean flag=false;
public static String pythonMessage="";
}
Loading…
Cancel
Save