whycxzp
2025-03-17 e50d8c30b43dd30daa77da27101ce21d8ef2fcef
src/main/java/com/whyc/webSocket/DevLithiumInfSocket.java
File was renamed from src/main/java/com/whyc/webSocket/DevInfSocket.java
@@ -4,7 +4,7 @@
import com.whyc.dto.DevInfDto;
import com.whyc.dto.Response;
import com.whyc.pojo.db_user.UserInf;
import com.whyc.service.DevInfService;
import com.whyc.service.DevLithiumInfService;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -17,16 +17,16 @@
/**
 * 设备实时连接信息
 * 锂电设备实时连接信息
 */
@Component
@ServerEndpoint(value = "/dinfSocket",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class)
public class DevInfSocket {
@ServerEndpoint(value = "/devLithiumInf",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class)
public class DevLithiumInfSocket {
    private Session session;
    private Thread thread;
    private static DevInfService dinfService;
    private static DevLithiumInfService service;
    private HttpSession httpSession;
@@ -37,8 +37,8 @@
    private volatile Map<Long,Boolean> threadFlagMap = new HashMap<>();
    @Autowired
    public void setDevInfService(DevInfService dinfService) {
        DevInfSocket.dinfService = dinfService;
    public void setService(DevLithiumInfService service) {
        DevLithiumInfSocket.service = service;
    }
    @OnOpen
@@ -52,14 +52,14 @@
        UserInf user = (UserInf) this.httpSession.getAttribute("user");
        final int userId = user.getUid();
        //final int userId = 101;
        thread = new Thread("Thread_DinfSocket") {
        thread = new Thread("Thread_DevLithiumInfSocket") {
            @Override
            public void run() {
                while (runFlag && !isInterrupted()) {
                    Thread thread = currentThread();
                    threadFlagMap.put(thread.getId(), true);
                    try {
                        Response res=dinfService.getAllInf(userId, devInfDto);
                        Response res=service.getAllInf(userId, devInfDto);
                        if (session.isOpen()) {
                            //推送信息
                            synchronized (session) {