whyclxw
2025-05-28 e787bc5515949320b1d3c6e521b9fee6b72c1d04
src/main/java/com/whyc/webSocket/RealTimeSocket.java
@@ -9,6 +9,8 @@
import com.whyc.pojo.db_ram_db.DeviceState;
import com.whyc.pojo.db_ram_db.PwrdevAcdcdata;
import com.whyc.pojo.db_station.BattInf;
import com.whyc.pojo.db_station.PowerInf;
import com.whyc.pojo.db_station.StationInf;
import com.whyc.pojo.db_user.User;
import com.whyc.service.*;
import com.whyc.util.ActionUtil;
@@ -47,6 +49,12 @@
    //电池组信息
    private static BattInfService battInfService;
    //机房信息
    private static StationInfService stationInfService;
    //电源信息
    private static PowerInfService powerInfService;
    private volatile boolean runFlag = true;
@@ -93,8 +101,18 @@
    }
    @Autowired
    public void seBattInfService(BattInfService battInfService) {
    public void setBattInfService(BattInfService battInfService) {
        RealTimeSocket.battInfService = battInfService;
    }
    @Autowired
    public void setStationInfService(StationInfService stationInfService) {
        RealTimeSocket.stationInfService = stationInfService;
    }
    @Autowired
    public void setPowerInfService(PowerInfService powerInfService) {
        RealTimeSocket.powerInfService = powerInfService;
    }
@@ -165,6 +183,26 @@
                topDto.setOnlineVol(battRtstate.getOnlineVol());
                topDto.setRecordtime(ThreadLocalUtil.format(battRtstate.getRecDatetime(),1));
            }
            //实时获取电池组信息
            BattInf binf=battInfService.getBinfByBattgroupId(realDto.getBattgroupId());
            if(binf!=null){
                topDto.setBattGroupName(binf.getBattgroupName());
                topDto.setDevName(binf.getDevName());
            }
            //获取机房信息
            StationInf stationInf = stationInfService.getStationInfById(binf.getStationId());
            if(stationInf!=null){
                topDto.setStationName(stationInf.getStationName());
                topDto.setProvice(stationInf.getProvice());
                topDto.setCity(stationInf.getCity());
                topDto.setCounty(stationInf.getCountry());
                topDto.setFullName(stationInf.getFullName());
            }
            //获取电源信息
            PowerInf powerInf = powerInfService.getPowerInfById(binf.getPowerId());
            if(powerInf!=null){
                topDto.setPowerName(powerInf.getPowerName());
            }
            //实时获取设备信息
            DeviceState deviceState = deviceStateService.getDevRealInfo(realDto.getDevId());
            if (deviceState != null) {
@@ -177,7 +215,6 @@
                    //剩余容量和剩余时间计算
                    Float restCap = batttestdataInfService.getLastTestDataRestCap(realDto.getBattgroupId());
                    topDto.setRestCap(restCap);
                    BattInf binf=battInfService.getBinfByBattgroupId(realDto.getBattgroupId());
                    //实时组端电流,剩余容量,标称容量
                    if(battRtstate!=null){
                        Float restTime= BattCapFactory.getTheoryTime(battRtstate.getGroupCurr(), restCap, binf.getMoncapstd());