whyclxw
2025-05-27 b1996cd1823d1fbd5c80f2f6d8f33db33a1bde18
实时监控页面推送top头部修改
4个文件已修改
40 ■■■■ 已修改文件
src/main/java/com/whyc/dto/Real/TopDto.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/factory/BattCapFactory.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BattInfService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/webSocket/RealTimeSocket.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/Real/TopDto.java
@@ -20,7 +20,7 @@
    private Integer captestTimelong;    //测试时长
    private Float captestCap;           //测试容量
    private Float restCap;              //预估剩余容量
    private Integer restTime;           //预估剩余续航时间
    private Float restTime;           //预估剩余续航时间
    public TopDto() {
        this.systemState = 0;
@@ -37,7 +37,7 @@
        this.captestTimelong = 0;
        this.captestCap = 0.0f;
        this.restCap = 0.0f;
        this.restTime = 0;
        this.restTime = 0.0f;
        this.allALmNum = 0;
    }
}
src/main/java/com/whyc/factory/BattCapFactory.java
@@ -163,10 +163,10 @@
    /**
     * 电池组的续航时长计算,单位:分钟
     */
    public static float getTheoryTime(float loadCurr, float battGroupCap, float battGroupCapStd){
    public static float getTheoryTime(float loadCurr, float restcap, float battGroupCapStd){
        double realCurr = 53*loadCurr/45;
        double hourRate = N_TO_10H(GetHourRate((int) Math.floor(battGroupCapStd), realCurr));
        float theoryTimeHour = realCurr == 0?0: (float) (battGroupCap / hourRate / realCurr);
        float theoryTimeHour = realCurr == 0?0: (float) (restcap / hourRate / realCurr);
        return theoryTimeHour*60;
    }
}
src/main/java/com/whyc/service/BattInfService.java
@@ -378,4 +378,13 @@
        return new Response().setII(1,list.size()>0,list,"获取设备型号(下拉)");
    }
    //根据电池组id获取电池组信息
    public BattInf getBinfByBattgroupId(Integer battgroupId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("battgroup_id",battgroupId);
        wrapper.last("limit 1");
        BattInf binf=mapper.selectOne(wrapper);
        return binf;
    }
}
src/main/java/com/whyc/webSocket/RealTimeSocket.java
@@ -8,6 +8,7 @@
import com.whyc.pojo.db_ram_db.BattRtstate;
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_user.User;
import com.whyc.service.*;
import com.whyc.util.ActionUtil;
@@ -43,6 +44,8 @@
    //放电记录
    private static BatttestdataInfService batttestdataInfService;
    //电池组信息
    private static BattInfService battInfService;
    private volatile boolean runFlag = true;
@@ -86,6 +89,11 @@
    @Autowired
    public void setBatttestdataInfService(BatttestdataInfService batttestdataInfService) {
        RealTimeSocket.batttestdataInfService = batttestdataInfService;
    }
    @Autowired
    public void seBattInfService(BattInfService battInfService) {
        RealTimeSocket.battInfService = battInfService;
    }
@@ -167,14 +175,11 @@
                    //剩余容量和剩余时间计算
                    Float restCap = batttestdataInfService.getLastTestDataRestCap(realDto.getBattgroupId());
                    topDto.setRestCap(restCap);
                    /*Integer restTime= BattCapFactory.getTheoryTime(deviceState.getDevCaptestCurr(), battRtstate.getBattGroupCap(), battRtstate.getBattGroupCapStd());
                    topDto.setRestTime(restTime);*/
                    BattInf binf=battInfService.getBinfByBattgroupId(realDto.getBattgroupId());
                    Float restTime= BattCapFactory.getTheoryTime(deviceState.getDevCaptestCurr(), restCap, binf.getMoncapstd());
                    topDto.setRestTime(restTime);
                }
                //实时获取电源信息
                PwrdevAcdcdata pwrdevAcdcdata = pwrdevAcdcdataService.getPwrRealInfo(realDto.getPowerId());
                if (pwrdevAcdcdata != null) {
                    //topDto.setPwrState(pwrdevAcdcdata.getPwrState());
                }
                //获取一级未处理实时告警数
                Integer battALmNum = battalarmDataService.getBattAlmNum(realDto.getBattgroupId());
                topDto.setBattALmNum(battALmNum);
@@ -185,6 +190,10 @@
                Integer pwrALmNum = pwrdevAlarmService.getPwrAlmNum(realDto.getPowerId());
                topDto.setPwrALmNum(pwrALmNum);
                //实时获取电源信息(是否存在电源告警信息)
                //PwrdevAcdcdata pwrdevAcdcdata = pwrdevAcdcdataService.getPwrRealInfo(realDto.getPowerId());
                topDto.setPwrState((pwrALmNum > 0 ? 1 : 0));
                Integer allALmNum = battALmNum + devALmNum + pwrALmNum;
                topDto.setAllALmNum(allALmNum);
                topDto.setSystemState((allALmNum > 0 ? 1 : 0));