whycxzp
2025-03-17 e50d8c30b43dd30daa77da27101ce21d8ef2fcef
src/main/java/com/whyc/webSocket/DevLithiumAlmPopupSocket.java
copy from src/main/java/com/whyc/webSocket/DevLineSocket.java copy to src/main/java/com/whyc/webSocket/DevLithiumAlmPopupSocket.java
File was copied from src/main/java/com/whyc/webSocket/DevLineSocket.java
@@ -3,7 +3,7 @@
import com.whyc.config.WebSocketConfig;
import com.whyc.dto.Response;
import com.whyc.pojo.db_user.UserInf;
import com.whyc.service.DevInfService;
import com.whyc.service.DevLithiumAlarmDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -13,22 +13,22 @@
import java.io.IOException;
/**
 * 左侧列表
 * 锂电设备告警弹窗
 */
@Component
@ServerEndpoint(value = "/lineSocket",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class)
public class DevLineSocket{
@ServerEndpoint(value = "/devLithiumAlmPopup",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class)
public class DevLithiumAlmPopupSocket {
    private Session session;
    private Thread thread;
    private static DevInfService dinfService;
    private static DevLithiumAlarmDataService devLithiumAlarmDataService;
    private HttpSession httpSession;
    @Autowired
    public void setDevInfService(DevInfService dinfService) {
        DevLineSocket.dinfService = dinfService;
    public void setDevLithiumAlarmDataService(DevLithiumAlarmDataService devLithiumAlarmDataService) {
        DevLithiumAlmPopupSocket.devLithiumAlarmDataService = devLithiumAlarmDataService;
    }
    @OnOpen
@@ -37,12 +37,12 @@
        UserInf user = (UserInf) this.httpSession.getAttribute("user");
        final int userId = user.getUid();
        //final int userId = 101;
        Thread thread = new Thread() {
        Thread thread = new Thread("Thread_DevLithiumAlmPopupSocket") {
            @Override
            public void run() {
                try {
                    while (!currentThread().isInterrupted()) {
                        Response res = dinfService.getDevType(userId);
                        Response res = devLithiumAlarmDataService.getPopup(userId);
                        session.getBasicRemote().sendObject(res);
                        sleep(4000);
                    }