lxw
2023-03-07 097a19a80c2c4e5bfa41b0d48b818c20f030aea5
监控层,运维层首页+跳转页
8个文件已修改
118 ■■■■ 已修改文件
src/main/java/com/whyc/mapper/BadbattMonMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/StationInfMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/BattRtstate.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/StationInf.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/StationInfService.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/webSocket/DevOpSkipSocket.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BadbattMonMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/StationInfMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/BadbattMonMapper.java
@@ -36,4 +36,7 @@
    //查询年份内数据
    List<BadbattMon> getProductQuaAnalysis(int userId, int i, float capAlarm, float capChange);
    //判断是否落后
    int judgeBatt(int battGroupId);
}
src/main/java/com/whyc/mapper/StationInfMapper.java
@@ -11,7 +11,8 @@
    //总机房
    int getStation(int userId);
    //查询指定机房信息
    StationInf getSystemSkipStation(int userId, String stationId);
}
src/main/java/com/whyc/pojo/BattRtstate.java
@@ -70,4 +70,7 @@
    @TableField("dev_testPower")
    private Float devTestPower;
    @TableField(exist = false)
    private int badbattFlag;
}
src/main/java/com/whyc/pojo/StationInf.java
@@ -83,5 +83,6 @@
    @TableField(exist = false)
    private int pwrAlm;
    @TableField(exist = false)
    private BattEndurance endurance;
}
src/main/java/com/whyc/service/StationInfService.java
@@ -7,10 +7,7 @@
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.*;
import com.whyc.pojo.BattRtdata;
import com.whyc.pojo.BattRtstate;
import com.whyc.pojo.PwrdevAcdcdata;
import com.whyc.pojo.StationInf;
import com.whyc.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -41,6 +38,12 @@
    @Autowired(required = false)
    private PwrdevAlarmMapper pwrAlmMapper;
    @Autowired(required = false)
    private BadbattMonMapper badMapper;
    @Autowired(required = false)
    private BattEnduranceMapper endMapper;
    //插入站点
    public Response insertStation(StationInf stationInf) {
@@ -201,4 +204,68 @@
        }
    }
    //运维层首页:头部统计
    public Response getDevOpSkipHead(int userId) {
        try {
            Map<String, Object> map = new HashMap();
            //头部统计数据
            int stationNum = mapper.getStation(userId);
            map.put("stationNum", stationNum);
            //浮充/充电
            List<BattRtstate> stateList = rtstateMapper.getBattStateStatic(userId);
            Map<Integer, Integer> statemap = new HashMap();
            Map<Integer, List<BattRtstate>> battstateMap = stateList.stream().collect(Collectors.groupingBy(BattRtstate::getBattState));
            for (Integer state : battstateMap.keySet()) {
                statemap.put(state, battstateMap.get(state).size());
            }
            map.put("battState", statemap);
            //整流器故障/负载熔断
            List<PwrdevAcdcdata> acdcList = acdcMapper.getAcdcStatic(userId);
            Map<Integer, Integer> errmap = new HashMap();
            Map<Integer, List<PwrdevAcdcdata>> aderrMap = acdcList.stream().collect(Collectors.groupingBy(PwrdevAcdcdata::getAcdcErr));
            for (Integer acdcerr : aderrMap.keySet()) {
                errmap.put(acdcerr, aderrMap.get(acdcerr).size());
            }
            map.put("errmap", errmap);
            Map<Integer, Integer> fusemap = new HashMap();
            Map<Integer, List<PwrdevAcdcdata>> adfuseMap = acdcList.stream().collect(Collectors.groupingBy(PwrdevAcdcdata::getIsLoaderFuse));
            for (Integer fuse : adfuseMap.keySet()) {
                fusemap.put(fuse, adfuseMap.get(fuse).size());
            }
            map.put("fusemap", fusemap);
            //站点统计
            return new Response().setII(1, true, map, "站点实时数据推送");
        } catch (Exception e) {
            return new Response().set(1, false, "发生异常:" + e.getCause());
        }
    }
    //指定站点详情第一次跳转机房id为0:message
    public Response getDevOpSkipStation(int userId, String stationId) {
        //查询指定机房信息
        StationInf inf = mapper.getSystemSkipStation(userId, stationId);
        if (inf != null) {
            if (inf.getRtlist() != null && inf.getRtlist().size() > 0) {
                for (int i = 0; i < inf.getRtlist().size(); i++) {
                    //判断是否落后
                    int battGroupId = inf.getRtlist().get(i).getBattGroupId();
                    int badbattFlag = badMapper.judgeBatt(battGroupId);
                    inf.getRtlist().get(i).setBadbattFlag(badbattFlag);
                }
            }
            //查询停电续航时间
            QueryWrapper wrapper = new QueryWrapper();
            wrapper.eq("stationid", stationId);
            BattEndurance endurance = endMapper.selectOne(wrapper);
            if (endurance != null) {
                inf.setEndurance(endurance);
            }
            return new Response().setII(1, true, inf, "指定站点详情");
        } else {
            return new Response().set(1, false, "指定站点详情");
        }
    }
}
src/main/java/com/whyc/webSocket/DevOpSkipSocket.java
@@ -1,6 +1,7 @@
package com.whyc.webSocket;
import com.whyc.config.WebSocketConfig;
import com.whyc.dto.Response;
import com.whyc.service.StationInfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -28,6 +29,7 @@
    private static StationInfService service;
    private Session session;
    @Autowired
@@ -38,11 +40,16 @@
    @OnOpen
    public void onOpen(Session session, EndpointConfig config) {
        this.session = session;
    }
    @OnMessage
    public void onMessage(Session session, String message) {
        /*HttpSession httpSession = (HttpSession) config.getUserProperties().get("httpSession");
        UserInf user = (UserInf) httpSession.getAttribute("user");
        final int userId = user.getUId().intValue();*/
        final int userId = 1001;
        thread = new Thread("Thread_stationRt") {
        thread = new Thread("Thread_devOpSkip") {
            @Override
            public void run() {
                while (runFlag && !isInterrupted()) {
@@ -52,7 +59,16 @@
                        if (session.isOpen()) {
                            //推送信息
                            synchronized (session) {
                                session.getBasicRemote().sendObject(service.getSystemAll(userId));
                                Map<String, Object> map = new HashMap<>();
                                //运维层首页:头部统计
                                Response skipHeadRes = service.getDevOpSkipHead(userId);
                                map.put("skipHeadRes", skipHeadRes);
                                if (!message.equals("0")) {
                                    //指定站点详情第一次跳转机房id为0:message
                                    Response stationRes = service.getDevOpSkipStation(userId, message);
                                    map.put("stationRes", stationRes);
                                }
                                session.getBasicRemote().sendObject(new Response<>().setII(1, true, map, "管理员首页跳转"));
                            }
                            threadFlagMap.put(thread.getId(), false);
                        }
@@ -75,10 +91,6 @@
        }
        //将线程存储,便于调用定位
        threadMap.put(session.getId(), this.thread);
    }
    @OnMessage
    public void onMessage(Session session, String message) {
    }
    @OnClose
src/main/resources/mapper/BadbattMonMapper.xml
@@ -296,4 +296,9 @@
                                                        #{userId}
    )
  </select>
  <select id="judgeBatt" resultType="java.lang.Integer">
    select count(1)
    from web_site.tb_badbatt_mon
    where battgroupid = #{battGroupId}
  </select>
</mapper>
src/main/resources/mapper/StationInfMapper.xml
@@ -88,7 +88,7 @@
    <select id="getSystemSkipStation" resultMap="SystemRt">
        select distinct *
        from db_battinf.tb_station_inf
        where StationId = #{stationId}
        where StationId = #{StationId}
          and StationId in (select distinct StationId
                            from db_user.tb_user_battgroup_baojigroup_battgroup
                               , db_user.tb_user_battgroup_baojigroup_usr