| | |
| | | package com.whyc.webSocket; |
| | | |
| | | import cn.hutool.db.DaoTemplate; |
| | | import com.whyc.config.WebSocketConfig; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.NjHomeStation; |
| | |
| | | import javax.websocket.*; |
| | | import javax.websocket.server.ServerEndpoint; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | @OnOpen |
| | | public void onOpen(Session session, EndpointConfig config){ |
| | | this.session = session; |
| | | //获取配置表中电池组信息 |
| | | NjHomeStation njHomeStation=njHomeStationService.getStation(); |
| | | Thread thread = new Thread() { |
| | | @Override |
| | | public void run() { |
| | | try{ |
| | | while (!currentThread().isInterrupted()) { |
| | | Map<String,Object> res=new HashMap<>(); |
| | | //获取配电柜(ac,dc,acdc)的实时数据 |
| | | Response pwrdevInfoRes=pwrdevAcdcservice.getPowerInfoById(njHomeStation.getPowerDevId()); |
| | | res.put("pwrdevInfo",pwrdevInfoRes); |
| | | //查询fbs9100信息 |
| | | Response f9100stateRes = f9100service.serchContactorState(njHomeStation.getDevId()); |
| | | res.put("f9100state", f9100stateRes); |
| | | //查询电池组端信息 |
| | | Response rtstateRes = rtstateservice.serchByCondition(njHomeStation.getBattgroupId()); |
| | | res.put("rtstate", rtstateRes); |
| | | session.getBasicRemote().sendObject(new Response<>().set(1,res,"查询完成")); |
| | | //获取配置表中电池组信息 |
| | | NjHomeStation njHomeStation=njHomeStationService.getStation(); |
| | | if(njHomeStation==null){ |
| | | session.getBasicRemote().sendObject(new Response<>().set(1,false,"查询完成")); |
| | | }else{ |
| | | //获取配电柜(ac,dc,acdc)的实时数据 |
| | | Response pwrdevInfoRes=pwrdevAcdcservice.getPowerInfoById(njHomeStation.getPowerDevId()); |
| | | res.put("pwrdevInfo",pwrdevInfoRes); |
| | | //查询fbs9100信息 |
| | | Response f9100stateRes = f9100service.serchContactorState(njHomeStation.getDevId()); |
| | | res.put("f9100state", f9100stateRes); |
| | | //查询电池组端信息 |
| | | Response rtstateRes = rtstateservice.serchByCondition(njHomeStation.getBattgroupId()); |
| | | res.put("rtstate", rtstateRes); |
| | | //推送时间 |
| | | res.put("LocalDate",new Date()); |
| | | session.getBasicRemote().sendObject(new Response<>().setII(1,true,res,"查询完成")); |
| | | } |
| | | sleep(4000); |
| | | } |
| | | } catch (Exception e) { |