whycxzp
2025-06-10 73bb5617e6aeb4ee8f7dfd4ad54b61d477969d86
src/main/java/com/whyc/webSocket/BattSocket.java
@@ -1,25 +1,18 @@
package com.whyc.webSocket;
import com.whyc.config.WebSocketConfig;
import com.whyc.dto.Response;
import com.whyc.factory.ThreadPoolExecutorFactory;
import com.whyc.pojo.RtState;
import com.whyc.pojo.StationInf;
import com.whyc.service.*;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpSession;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
 * packageName com.whyc.websocket
@@ -28,7 +21,7 @@
 * @version JDK 8
 * @className BattSocket (此处以class为例)
 * @date 2024/6/15
 * @description TODO
 * @description
 */
@Component
@ServerEndpoint(value = "/batt", encoders = WebSocketEncoder.class)
@@ -83,13 +76,13 @@
    @OnMessage
    public void onMessage(Session session, String message) {
        int binfId=Integer.valueOf(message);
        thread = new Thread("Thread_RealTime") {
        thread = new Thread("Thread_BattSocket") {
            @Override
            public void run() {
                Map<String, Object> res = new HashMap<>();
                while (runFlag && !isInterrupted()) {
                    Thread thread = currentThread();
                    threadFlagMap.put(thread.getId(), true);
                    Map<String, Object> res = new HashMap<>();
                    try {
                        ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor();
                        CountDownLatch latch = new CountDownLatch(4);