|
|
|
@ -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; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|