whycxzp
2023-03-08 dcf0b3fa409e7d4fb4276ea4c44b040ace8928f3
首页站点统计
12个文件已修改
155 ■■■■ 已修改文件
src/main/java/com/whyc/mapper/BattalarmDataMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/DevalarmDataMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/PwrdevAlarmMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BattalarmDataService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DevalarmDataService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/Fbs9100StateService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/PwrdevAlarmService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/StationInfService.java 66 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/webSocket/StationStatisticsSocket.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BattalarmDataMapper.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DevalarmDataMapper.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/PwrdevAlarmMapper.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/BattalarmDataMapper.java
@@ -67,4 +67,7 @@
    //今日实时告警
    List<BattalarmData> getBalmToday(int userId);
    List<Integer> getStationList(int userId);
}
src/main/java/com/whyc/mapper/DevalarmDataMapper.java
@@ -32,4 +32,7 @@
    //今日实时告警
    List<DevalarmData> getDalmToday(int userId);
    List<Integer> getStationList(int userId);
}
src/main/java/com/whyc/mapper/PwrdevAlarmMapper.java
@@ -39,4 +39,6 @@
    //今日实时告警
    List<PwrdevAlarm> getPalmToday(int userId);
    List<Integer> getStationList(int userId);
}
src/main/java/com/whyc/service/BattalarmDataService.java
@@ -568,4 +568,8 @@
            return new Response().set(1, false, "出现异常" + e.getMessage());
        }
    }
    public List<Integer> getStationList(int userId) {
        return mapper.getStationList(userId);
    }
}
src/main/java/com/whyc/service/DevalarmDataService.java
@@ -146,4 +146,8 @@
            return new Response().set(1, false, "出现异常" + e.getMessage());
        }
    }
    public List<Integer> getStationList(int userId) {
        return mapper.getStationList(userId);
    }
}
src/main/java/com/whyc/service/Fbs9100StateService.java
@@ -189,5 +189,10 @@
            return response.set(1, false, "发生异常:" + e.getCause());
        }
    }
    public List<Fbs9100State> getStateList(int userId) {
        QueryWrapper<Fbs9100State> wrapper = Wrappers.query();
        wrapper.select("dev_workstate");
        return mapper.selectList(wrapper);
    }
}
src/main/java/com/whyc/service/PwrdevAlarmService.java
@@ -316,4 +316,8 @@
            return new Response().set(1, false, "出现异常" + e.getMessage());
        }
    }
    public List<Integer> getStationList(int userId) {
        return mapper.getStationList(userId);
    }
}
src/main/java/com/whyc/service/StationInfService.java
@@ -12,10 +12,7 @@
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Service
@@ -49,6 +46,14 @@
    @Autowired
    @Lazy
    private BattInfService battInfService;
    @Autowired
    private Fbs9100StateService fbs9100StateService;
    @Autowired
    private BattalarmDataService battAlarmDataService;
    @Autowired
    private DevalarmDataService devAlarmDataService;
    @Autowired
    private PwrdevAlarmService powerAlarmService;
    //插入站点
    public Response insertStation(StationInf stationInf) {
@@ -122,18 +127,49 @@
     *
     */
    public Response getStationStatistic(int userId) {
        Map<String,Integer> stationInfoMap = new HashMap<>();
        List<StationInf> stationInfList = mapper.getStationInfList(userId);
        //站点数
        stationInfoMap.put("stationCount",stationInfList.size());
        //110v/35v/...
        Map<String, List<StationInf>> stationTypeMap = stationInfList.stream().filter(stationInf -> !stationInf.getStationType().equals("")).collect(Collectors.groupingBy(StationInf::getStationType));
        Set<String> stationTypeSet = stationTypeMap.keySet();
        for(String stationType : stationTypeSet){
            stationInfoMap.put(stationType,stationTypeMap.get(stationType).size());
        }
        try {
            Map<String, Integer> stationInfoMap = new HashMap<>();
            List<StationInf> stationInfList = mapper.getStationInfList(userId);
            //站点数
            stationInfoMap.put("stationCount", stationInfList.size());
            //110v/35v/...
            Map<String, List<StationInf>> stationTypeMap = stationInfList.stream().filter(stationInf -> !stationInf.getStationType().equals("")).collect(Collectors.groupingBy(StationInf::getStationType));
            Set<String> stationTypeSet = stationTypeMap.keySet();
            for (String stationType : stationTypeSet) {
                stationInfoMap.put(stationType, stationTypeMap.get(stationType).size());
            }
            //节点站和普通站
            List<Battinf> stationList = battInfService.getSateAnalysis(userId);
            Map<Integer, List<Battinf>> nodeStationMap = stationList.stream().collect(Collectors.groupingBy(Battinf::getNodeStation));
        return new Response().set(1,stationInfoMap);
            stationInfoMap.put("nomalStation", nodeStationMap.get(0) == null ? 0 : nodeStationMap.get(0).size());
            stationInfoMap.put("nodeStation", nodeStationMap.get(1) == null ? 0 : nodeStationMap.get(1).size());
            //停电站和核容放电站
            List<Fbs9100State> stateList = fbs9100StateService.getStateList(userId);
            Map<Integer, List<Fbs9100State>> stateMap = stateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevWorkstate));
            stationInfoMap.put("checkCapDischarge", stateMap.get(2) == null ? 0 : stateMap.get(2).size());
            stationInfoMap.put("powerOff", stateMap.get(3) == null ? 0 : stateMap.get(3).size());
            //故障告警站: 电池/设备/电源告警
            List<Integer> battStationList = battAlarmDataService.getStationList(userId);
            List<Integer> devStationList = devAlarmDataService.getStationList(userId);
            List<Integer> powerStationList = powerAlarmService.getStationList(userId);
            List<Integer> stationIdList = new LinkedList<>(battStationList);
            for (Integer integer : devStationList) {
                if (!stationIdList.contains(integer)) {
                    stationIdList.add(integer);
                }
            }
            for (Integer integer : powerStationList) {
                if (!stationIdList.contains(integer)) {
                    stationIdList.add(integer);
                }
            }
            stationInfoMap.put("alarmStationCount", stationIdList.size());
            return new Response().setII(1,true,stationInfoMap,null);
        }catch (Exception e){
            return new Response().set(1,false,"发生异常:"+e.getCause());
        }
    }
    //运维层首页:站点实时数据推送
src/main/java/com/whyc/webSocket/StationStatisticsSocket.java
@@ -31,12 +31,12 @@
    }
    @OnOpen
    public void onOpen(Session session, EndpointConfig config){
    public void onOpen(Session session){
        this.session = session;
        HttpSession httpSession = (HttpSession) config.getUserProperties().get("httpSession");
        /*HttpSession httpSession = (HttpSession) config.getUserProperties().get("httpSession");
        UserInf user = (UserInf) httpSession.getAttribute("user");
        final int userId = user.getUId().intValue();
        //final int userId = 1001;
        final int userId = user.getUId().intValue();*/
        final int userId = 1001;
        Thread thread = new Thread() {
            @Override
            public void run() {
src/main/resources/mapper/BattalarmDataMapper.xml
@@ -404,4 +404,22 @@
                                                      db_user.tb_user_battgroup_baojigroup_usr.uid
                                                  and db_user.tb_user_inf.uid = #{userId})
    </select>
    <select id="getStationList" resultType="integer">
        SELECT distinct inf.StationId
        FROM db_alarm.tb_battalarm_data alarm,
        db_battinf.tb_battinf inf
        WHERE alarm.BattGroupId = inf.BattGroupId
        AND inf.StationId IN (
            SELECT DISTINCT inf.StationId
            FROM db_battinf.tb_battinf inf,
            db_user.tb_user_battgroup_baojigroup_battgroup,
            db_user.tb_user_battgroup_baojigroup_usr,
            db_user.tb_user_inf
            WHERE db_user.tb_user_battgroup_baojigroup_battgroup.StationId = inf.StationId
            AND db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id =
            db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id
            AND db_user.tb_user_inf.uid = db_user.tb_user_battgroup_baojigroup_usr.uid
            AND db_user.tb_user_inf.uid = #{userId}
        )
    </select>
</mapper>
src/main/resources/mapper/DevalarmDataMapper.xml
@@ -225,4 +225,22 @@
                                                db_user.tb_user_battgroup_baojigroup_usr.uid
                                            and db_user.tb_user_inf.uid = #{userId})
    </select>
    <select id="getStationList" resultType="java.lang.Integer">
        SELECT distinct inf.StationId
        FROM db_alarm.tb_devalarm_data alarm,
        db_battinf.tb_battinf inf
        WHERE alarm.dev_id = inf.FBSDeviceId
        AND inf.StationId IN (
            SELECT DISTINCT inf.StationId
            FROM db_battinf.tb_battinf inf,
            db_user.tb_user_battgroup_baojigroup_battgroup,
            db_user.tb_user_battgroup_baojigroup_usr,
            db_user.tb_user_inf
            WHERE db_user.tb_user_battgroup_baojigroup_battgroup.StationId = inf.StationId
            AND db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id =
            db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id
            AND db_user.tb_user_inf.uid = db_user.tb_user_battgroup_baojigroup_usr.uid
            AND db_user.tb_user_inf.uid = #{userId}
        )
    </select>
</mapper>
src/main/resources/mapper/PwrdevAlarmMapper.xml
@@ -296,4 +296,22 @@
                                                      db_user.tb_user_battgroup_baojigroup_usr.uid
                                                  and db_user.tb_user_inf.uid = #{userId})
    </select>
    <select id="getStationList" resultType="java.lang.Integer">
        SELECT distinct inf.StationId
        FROM db_pwrdev_alarm.tb_pwrdev_alarm alarm,
        db_battinf.tb_battinf inf
        WHERE alarm.PowerDeviceId = inf.FBSDeviceId
        AND inf.StationId IN (
            SELECT DISTINCT inf.StationId
            FROM db_battinf.tb_battinf inf,
            db_user.tb_user_battgroup_baojigroup_battgroup,
            db_user.tb_user_battgroup_baojigroup_usr,
            db_user.tb_user_inf
            WHERE db_user.tb_user_battgroup_baojigroup_battgroup.StationId = inf.StationId
            AND db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id =
            db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id
            AND db_user.tb_user_inf.uid = db_user.tb_user_battgroup_baojigroup_usr.uid
            AND db_user.tb_user_inf.uid = #{userId}
        )
    </select>
</mapper>