lxw
2023-08-15 160e150009b51a39fa95d9462c3798ba28d51a09
src/main/java/com/whyc/service/StationInfService.java
@@ -60,23 +60,285 @@
    private PwrdevAlarmService powerAlarmService;
    @Resource
    BadbattMonMapper badbattMonMapper;
    private BadbattMonMapper badbattMonMapper;
    @Resource
    AlarmParamMapper alarmParamMapper;
    private AlarmParamMapper alarmParamMapper;
    @Resource
    BattInfMapper binfMapper;
    private BattInfMapper binfMapper;
    @Resource
    private PowerInfMapper pinfMapper;
    @Resource
    private BattMapInformationMapper mapMapper;
    @Resource
    private BatttestdataInfService testInfService;
    //查询最大的自增标识同一机房的标识
    public int getMaxTogetherFlag() {
        int togetherFlag = mapper.getMaxTogetherFlag();
        return togetherFlag;
    }
    //根据statidonId去查同一机房的标识
    public int getTogetherFlag(String stationIdTogether) {
        int togetherFlag = mapper.getTogetherFlag(stationIdTogether);
        return togetherFlag;
    }
    //根据stationId和togetherFlag查询另外相同的机房
    public Response getTogetherFlagStationInf(String stationId, int togetherFlag) {
        QueryWrapper wrapper = Wrappers.query();
        wrapper.eq("together_flag", togetherFlag);
        wrapper.ne("stationId", stationId);
        wrapper.last("limit 1");
        StationInf sinf = mapper.selectOne(wrapper);
        return new Response().setII(1, sinf != null ? true : false, sinf, "根据stationId和togetherFlag查询另外相同的机房");
    }
    //插入站点
    @Transactional
    public Response insertStation(StationInf stationInf) {
        String stationId = stationInf.getStationId();
        String stationIdTogether = stationInf.getStationIdTogether();
        int togetherFlag = 0;
        if (stationId == null || stationId.isEmpty()) {
            stationId = String.valueOf(Integer.valueOf(getMaxStationId()) + 1);
            stationInf.setStationId(stationId);
        }
        if (stationIdTogether == null || stationIdTogether.isEmpty()) {
            togetherFlag = mapper.getMaxTogetherFlag() + 1;
        } else {
            //1.先验证同一机房结点信息和电压等级是否一样,若不一样则不允许添加
            QueryWrapper wrapper = Wrappers.query();
            wrapper.ne("stationId", stationIdTogether);
            wrapper.last("limit 1");
            StationInf sinf = mapper.selectOne(wrapper);
            if (stationInf.getNodeStation() != sinf.getNodeStation()) {
                return new Response().set(1, false, "设置同一站点时,两站点节点属性不一致");
            }
            if (!stationInf.getStationType().equals(sinf.getStationType())) {
                return new Response().set(1, false, "设置同一站点时,两站点电压等级属性不一致");
            }
            //2.相同设置同一站点
            togetherFlag = mapper.getTogetherFlag(stationIdTogether);
        }
        stationInf.setTogetherFlag(togetherFlag);
        int flag = mapper.insert(stationInf);
        return new Response().set(1, flag > 0, "插入站点");
        //往map表插入
        BattMapInformation mapInfo = new BattMapInformation();
        mapInfo.setStationId(stationId);
        mapInfo.setStationName(stationInf.getStationName());
        mapInfo.setAddress(stationInf.getStationAddr() == null ? "" : stationInf.getStationAddr());
        mapInfo.setLongitude(stationInf.getStationLongitude());
        mapInfo.setLatitude(stationInf.getStationLatitude());
        mapInfo.setStationName3(stationInf.getStationName3());
        mapMapper.insert(mapInfo);
        return new Response().set(1, flag > 0, flag > 0 ? "插入站点成功" : "插入站点失败");
    }
    //编辑机房名
    @Transactional
    public Response updateName(String stationName, String stationName1, String stationName2, String stationName3, String stationName4, String stationName5
            , String stationIdTogether, String stationId) {
        UpdateWrapper wrapper = new UpdateWrapper();
        wrapper.eq("stationId", stationId);
        UpdateWrapper sinfWrapper = new UpdateWrapper();
        sinfWrapper.eq("stationId", stationId);
        if (stationName != null && !stationName.isEmpty()) {
            wrapper.set("stationName", stationName);
            sinfWrapper.set("stationName", stationName);
        }
        if (stationName1 != null && !stationName1.isEmpty()) {
            wrapper.set("stationName1", stationName1);
            sinfWrapper.set("stationName1", stationName1);
        }
        if (stationName2 != null && !stationName2.isEmpty()) {
            wrapper.set("stationName2", stationName2);
            sinfWrapper.set("stationName2", stationName2);
        }
        if (stationName3 != null && !stationName3.isEmpty()) {
            wrapper.set("stationName3", stationName3);
            sinfWrapper.set("stationName3", stationName3);
        }
        if (stationName4 != null && !stationName4.isEmpty()) {
            wrapper.set("stationName4", stationName4);
            sinfWrapper.set("stationName4", stationName4);
        }
        if (stationName5 != null && !stationName5.isEmpty()) {
            wrapper.set("stationName5", stationName5);
            sinfWrapper.set("stationName5", stationName5);
        }
        if (stationIdTogether != null && !stationIdTogether.isEmpty()) {
            //1.先验证同一机房结点信息和电压等级是否一样,若不一样则不允许添加
            QueryWrapper wrapperZj = new QueryWrapper();
            QueryWrapper wrapperGl = new QueryWrapper();
            wrapperZj.eq("stationId", stationId);
            wrapperGl.eq("stationId", stationIdTogether);
            wrapper.last("limit 1");
            StationInf sinfZj = mapper.selectOne(wrapperZj);
            StationInf sinfGl = mapper.selectOne(wrapperGl);
            if (sinfZj.getNodeStation() != sinfGl.getNodeStation()) {
                return new Response().set(1, false, "设置同一站点时,两站点节点属性不一致");
            }
            if (!sinfZj.getStationType().equals(sinfGl.getStationType())) {
                return new Response().set(1, false, "设置同一站点时,两站点电压等级属性不一致");
            }
            if (sinfZj.getStationLongitude() != sinfGl.getStationLongitude()) {
                return new Response().set(1, false, "设置同一站点时,两站点地址的经度属性不一致");
            }
            if (sinfZj.getStationLatitude() != sinfGl.getStationLatitude()) {
                return new Response().set(1, false, "设置同一站点时,两站点地址的维度属性不一致");
            }
            if (!sinfZj.getStationAddr().equals(sinfGl.getStationAddr())) {
                return new Response().set(1, false, "设置同一站点时,两站点详细地址属性不一致");
            }
            int togetherFlag = mapper.getTogetherFlag(stationIdTogether);
            sinfWrapper.set("together_flag", togetherFlag);
        } else {
            int togetherFlag = mapper.getMaxTogetherFlag() + 1;
            sinfWrapper.set("together_flag", togetherFlag);
        }
        int flag = mapper.update(null, sinfWrapper);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("stationId", stationId);
        List listB = binfMapper.selectList(queryWrapper);
        if (listB != null && listB.size() > 0) {
            binfMapper.update(null, wrapper);
        }
        List listP = pinfMapper.selectList(queryWrapper);
        if (listP != null && listP.size() > 0) {
            pinfMapper.update(null, wrapper);
        }
        return new Response().set(1, flag > 0, flag > 0 ? "编辑机房名成功" : "编辑机房名失败");
    }
    //编辑站点
    @Transactional
    public Response updateStation(String nodeStation, String stationType
            , String stationLongitude, String stationLatitude
            , String stationAddr, int togetherFlag, String stationId) {
        int nofla = 0;
        int stlag = 0;
        int lofla = 0;
        int lafla = 0;
        int addfla = 0;
        //往map表插入
        BattMapInformation mapInfo = new BattMapInformation();
        UpdateWrapper wrapper = new UpdateWrapper();
        UpdateWrapper wrapperEx = new UpdateWrapper();
        UpdateWrapper infwrapper = new UpdateWrapper();
        UpdateWrapper infwrapperEx = new UpdateWrapper();
        UpdateWrapper mapwrapper = new UpdateWrapper();
        UpdateWrapper mapwrapperEx = new UpdateWrapper();
        wrapper.eq("stationId", stationId);
        infwrapper.eq("stationId", stationId);
        mapwrapper.eq("stationId", stationId);
        //根据togetherFlag和stationId查询相同机房
        QueryWrapper togetWapper = Wrappers.query();
        togetWapper.eq("together_flag", togetherFlag);
        togetWapper.ne("stationId", stationId);
        togetWapper.last("limit 1");
        StationInf sinfEx = mapper.selectOne(togetWapper);
        if (nodeStation != null && !nodeStation.isEmpty()) {
            nofla = 1;
            wrapper.set("nodeStation", nodeStation);
            infwrapper.set("nodeStation", nodeStation);
            wrapperEx.set("nodeStation", nodeStation);
            infwrapperEx.set("nodeStation", nodeStation);
        }
        if (stationType != null && !stationType.isEmpty()) {
            stlag = 1;
            wrapper.set("stationType", stationType);
            infwrapper.set("stationType", stationType);
            wrapperEx.set("stationType", stationType);
            infwrapperEx.set("stationType", stationType);
        }
        if (stationLongitude != null && !stationLongitude.isEmpty()) {
            lofla = 1;
            mapInfo.setLongitude(Double.parseDouble(stationLongitude));
            wrapper.set("stationLongitude", stationLongitude);
            wrapperEx.set("stationLongitude", stationLongitude);
            mapwrapper.set("longitude", stationLongitude);
            mapwrapperEx.set("longitude", stationLongitude);
        }
        if (stationLatitude != null && !stationLatitude.isEmpty()) {
            lafla = 1;
            mapInfo.setLatitude(Double.parseDouble(stationLatitude));
            wrapper.set("stationLatitude", stationLatitude);
            wrapperEx.set("stationLatitude", stationLatitude);
            mapwrapper.set("latitude", stationLatitude);
            mapwrapperEx.set("latitude", stationLatitude);
        }
        if (stationAddr != null && !stationAddr.isEmpty()) {
            addfla = 1;
            mapInfo.setAddress(stationAddr);
            wrapper.set("stationAddr", stationAddr);
            wrapperEx.set("stationAddr", stationAddr);
            mapwrapper.set("address", stationAddr);
            mapwrapperEx.set("address", stationAddr);
        } else {
            mapInfo.setAddress("");
        }
        int flag = mapper.update(null, wrapper);
        if (nofla > 0 || stlag > 0) {
            QueryWrapper qwrapper = new QueryWrapper();
            qwrapper.eq("stationId", stationId);
            List list = binfMapper.selectList(qwrapper);
            if (list.size() > 0) {
                binfMapper.update(null, infwrapper);
            }
            //修改相同机房
            if (sinfEx != null) {
                wrapperEx.eq("stationId", sinfEx.getStationId());
                infwrapperEx.eq("stationId", sinfEx.getStationId());
                mapper.update(null, wrapperEx);
                binfMapper.update(null, infwrapperEx);
            }
        }
        if (lofla > 0 || lafla > 0 || addfla > 0) {
            QueryWrapper mwrapper = new QueryWrapper();
            mwrapper.eq("stationId", stationId);
            List list = mapMapper.selectList(mwrapper);
            if (list.size() > 0) {
                mapMapper.update(null, mapwrapper);
            } else {
                QueryWrapper swrapper = new QueryWrapper();
                swrapper.eq("stationId", stationId);
                swrapper.last("limit 1");
                StationInf sinf = mapper.selectOne(swrapper);
                //插入map
                mapInfo.setStationId(stationId);
                mapInfo.setStationName(sinf.getStationName());
                mapInfo.setStationName3(sinf.getStationName3());
                mapMapper.insert(mapInfo);
            }
            //修改相同机房
            if (sinfEx != null) {
                QueryWrapper mwrapperEx = new QueryWrapper();
                mwrapperEx.eq("stationId", sinfEx.getStationId());
                List listEx = mapMapper.selectList(mwrapperEx);
                if (listEx.size() > 0) {
                    mapMapper.update(null, mapwrapperEx);
                } else {
                    //插入map
                    mapInfo.setStationId(sinfEx.getStationId());
                    mapInfo.setStationName(sinfEx.getStationName());
                    mapInfo.setStationName3(sinfEx.getStationName3());
                    mapMapper.insert(mapInfo);
                }
            }
        }
        return new Response().set(1, flag > 0, "编辑站点");
    }
    //查询所有的站点
    public Response searchStationAll(int pageCurr, int pageSize, String stationName1, String stationName2, String stationName5) {
    public Response searchStationAll(int pageCurr, int pageSize, String stationName1, String stationName2, String stationName5, String nodeStation, String stationType) {
        PageHelper.startPage(pageCurr, pageSize);
        QueryWrapper wrapper = new QueryWrapper();
       /* QueryWrapper wrapper = new QueryWrapper();
        if (!(stationName1 == null || stationName1.isEmpty())) {
            wrapper.eq("stationName1", stationName1);
        }
@@ -86,17 +348,30 @@
        if (!(stationName5 == null || stationName5.isEmpty())) {
            wrapper.eq("stationName5", stationName5);
        }
        List<StationInf> list = mapper.selectList(wrapper);
        List<StationInf> list = mapper.selectList(wrapper);*/
        String uId = ActionUtil.getUser().getUId().toString();
        List<StationInf> list = mapper.searchStationAll(stationName1, stationName2, stationName5, nodeStation, stationType, uId);
        PageInfo pageInfo = new PageInfo(list);
        return new Response().setII(1, list.size() > 0, pageInfo, "查询站点");
    }
    //删除总站点
    public Response deleteStation(int num) {
    @Transactional
    public Response deleteStation(String stationId) {
        UpdateWrapper wrapper = new UpdateWrapper();
        wrapper.eq("num", num);
        wrapper.eq("stationId", stationId);
        int flag = mapper.delete(wrapper);
        return new Response().set(1, flag > 0, "插入站点");
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("stationId", stationId);
        List listB = binfMapper.selectList(queryWrapper);
        if (listB != null && listB.size() > 0) {
            binfMapper.delete(wrapper);
        }
        List listP = pinfMapper.selectList(queryWrapper);
        if (listP != null && listP.size() > 0) {
            pinfMapper.delete(wrapper);
        }
        return new Response().set(1, flag > 0, "删除总站点");
    }
    //管理员首页:站点实时数据推送
@@ -111,9 +386,10 @@
            Map<String, Integer> statemap = new HashMap();
            statemap.put("batt1", 0);
            statemap.put("batt2", 0);
            statemap.put("batt3", 0);
            Map<Integer, List<BattRtstate>> battstateMap = stateList.stream().collect(Collectors.groupingBy(BattRtstate::getBattState));
            for (Integer state : battstateMap.keySet()) {
                if (state == 1 || state == 2) {
                if (state == 1 || state == 2 || state == 3) {
                    statemap.put("batt" + state, battstateMap.get(state).size());
                }
            }
@@ -136,6 +412,13 @@
                fusemap.put("fuse" + fuse, adfuseMap.get(fuse).size());
            }
            map.put("fusemap", fusemap);
            //本年度核容放电电池组.
            int hrdisNum = testInfService.getYearAnalysis(userId);
            map.put("hrdisNum", hrdisNum);
            //实时停电放电
            int jcdisNum = fbs9100StateService.getJcAnalysis(userId);
            map.put("jcdisNum", jcdisNum);
            //视图
            List<StationInf> list = mapper.getSystemAll(userId);
            for (StationInf inf : list) {
                String stationId = inf.getStationId();
@@ -149,8 +432,8 @@
                    sgblist.get(i).setMaxNum(maxData.getMonNum());
                    //查询机房下最低的单体电压和单体
                    BattRtdata minData = rtdataMapper.minData(battGroupId);
                    sgblist.get(i).setMinVol(maxData.getMonVol());
                    sgblist.get(i).setMinNum(maxData.getMonNum());
                    sgblist.get(i).setMinVol(minData.getMonVol());
                    sgblist.get(i).setMinNum(minData.getMonNum());
                    //查询实时告警总数
                    int battAlm = battAlmMapper.getbattAlm(battGroupId);
                    sgblist.get(i).setBattAlm(battAlm);
@@ -162,64 +445,26 @@
                inf.setPwrAlm(pwrAlm);
            }
            map.put("data", list);
            //站点统计
            List<StationInf> stationInfList = mapper.getStationInfList(userId);
            //站点数
            map.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) {
                map.put(stationType, stationTypeMap.get(stationType).size());
            }
            //节点站和普通站
            List<Battinf> stationList = battInfService.getSateAnalysis(userId);
            Map<Integer, List<Battinf>> nodeStationMap = stationList.stream().collect(Collectors.groupingBy(Battinf::getNodeStation));
            map.put("nomalStation", nodeStationMap.get(0) == null ? 0 : nodeStationMap.get(0).size());
            map.put("nodeStation", nodeStationMap.get(1) == null ? 0 : nodeStationMap.get(1).size());
            //停电站和核容放电站
            List<Fbs9100State> f9100stateList = fbs9100StateService.getStateList(userId);
            Map<Integer, List<Fbs9100State>> stateMap = f9100stateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevWorkstate));
            map.put("checkCapDischarge", stateMap.get(2) == null ? 0 : stateMap.get(2).size());
            map.put("powerOff", stateMap.get(3) == null ? 0 : stateMap.get(3).size());
            //1.查询劣化(告警)和损坏(更换)的阈值
            QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
            alarmWrapper.and(wrapper -> {
                return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
            });
            alarmWrapper.orderByAsc("alm_id");
            List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
            float capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
            float capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
            //劣化数量(包含损坏)
            int alarmNum = badbattMonMapper.getQualityAnalysis(userId, capAlarm);
            //损坏数量
            int changeNum = badbattMonMapper.getQualityAnalysis(userId, capChange);
            map.put("alarmNum", (alarmNum - changeNum));
            map.put("changeNum", changeNum);
            int battAlarmNum = battAlarmDataService.serchRealTime(userId).getCode();
            int devAlarmNum = devAlarmDataService.getAlarmNum(userId);
            int powerAlarmNum = (int) powerAlarmService.getHomeAlarmNum(userId);
            map.put("battAlarmNum", battAlarmNum);
            map.put("devAlarmNum", devAlarmNum);
            map.put("powerAlarmNum", powerAlarmNum);
            return new Response().setII(1, true, map, "站点实时数据推送");
        } catch (Exception e) {
            return new Response().set(1, false, "发生异常:" + e.getCause());
        }
    }
    //找最大的stationid
    public String getMaxStationId() {
        QueryWrapper<StationInf> query = Wrappers.query();
        query.select("stationId").orderByDesc("num").last(" limit 1");
        /*QueryWrapper<StationInf> query = Wrappers.query();
        query.select("stationId").orderByDesc("stationId").last(" limit 1");
        StationInf stationInf = mapper.selectOne(query);
        if (stationInf == null) {
            return "42000000";
        } else {
            return stationInf.getStationId();
        }*/
        String stationid = mapper.getMaxStationId();
        if (stationid == null) {
            return "42000000";
        } else {
            return stationid;
        }
    }
@@ -249,8 +494,8 @@
                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));
            //List<Battinf> stationList = battInfService.getSateAnalysis(userId);
            Map<Integer, List<StationInf>> nodeStationMap = stationInfList.stream().collect(Collectors.groupingBy(StationInf::getNodeStation));
            stationInfoMap.put("nomalStation", nodeStationMap.get(0) == null ? 0 : nodeStationMap.get(0).size());
            stationInfoMap.put("nodeStation", nodeStationMap.get(1) == null ? 0 : nodeStationMap.get(1).size());
@@ -278,15 +523,22 @@
            stationInfoMap.put("alarmStationCount", stationIdList.size());
            //站点地图
            List<StationInf> mapAndWorkStateList = getStationMapAndWorkState(userId);
            stationInfoMap.put("stationMap",mapAndWorkStateList);
            return new Response().setII(1,true,stationInfoMap,null);
        }catch (Exception e){
            return new Response().set(1,false,"发生异常:"+e.getCause());
            stationInfoMap.put("stationMap", mapAndWorkStateList);
            return new Response().setII(1, true, stationInfoMap, null);
        } catch (Exception e) {
            return new Response().set(1, false, "发生异常:" + e.getCause());
        }
    }
    public List<StationInf> getStationMapAndWorkState(int userId) {
        return mapper.getStationMapAndWorkState(userId);
    }
    //监控层地图信息
    public List<StationInf> getStationMapInMonitor(int userId) {
        //下面各个站点数据
        List<StationInf> list = mapper.getSystemAll(userId);
        return list;
    }
    //运维层首页:站点实时数据推送
@@ -301,9 +553,10 @@
            Map<String, Integer> statemap = new HashMap();
            statemap.put("batt1", 0);
            statemap.put("batt2", 0);
            statemap.put("batt3", 0);
            Map<Integer, List<BattRtstate>> battstateMap = stateList.stream().collect(Collectors.groupingBy(BattRtstate::getBattState));
            for (Integer state : battstateMap.keySet()) {
                if (state == 1 || state == 2) {
                if (state == 1 || state == 2 || state == 3) {
                    statemap.put("batt" + state, battstateMap.get(state).size());
                }
            }
@@ -326,47 +579,50 @@
                fusemap.put("fuse" + fuse, adfuseMap.get(fuse).size());
            }
            map.put("fusemap", fusemap);
            //本年度核容放电电池组
            int hrdisNum = testInfService.getYearAnalysis(userId);
            map.put("hrdisNum", hrdisNum);
            //实时停电放电
            int jcdisNum = fbs9100StateService.getJcAnalysis(userId);
            map.put("jcdisNum", jcdisNum);
            //下面各个站点数据
            List<StationInf> list = mapper.getSystemAll(userId);
            for (StationInf inf : list) {
                String stationId = inf.getStationId();
                //查询分组电池信息
                List<SystemGrdoupBatt> sgblist = rtstateMapper.selectSystemGrdoupBatt(stationId);
                for (int i = 0; i < sgblist.size(); i++) {
                    int battGroupId = sgblist.get(i).getBattGroupId();
                    //查询机房下最大的单体电压和单体
                    BattRtdata maxData = rtdataMapper.maxData(battGroupId);
                    sgblist.get(i).setMaxVol(maxData.getMonVol());
                    sgblist.get(i).setMaxNum(maxData.getMonNum());
                    //查询机房下最低的单体电压和单体
                    BattRtdata minData = rtdataMapper.minData(battGroupId);
                    sgblist.get(i).setMinVol(maxData.getMonVol());
                    sgblist.get(i).setMinNum(maxData.getMonNum());
                    //查询实时告警总数
                    int battAlm = battAlmMapper.getbattAlm(battGroupId);
                    sgblist.get(i).setBattAlm(battAlm);
                if (sgblist != null && sgblist.size() > 0) {
                    for (int i = 0; i < sgblist.size(); i++) {
                        //判断是否落后
                        int battGroupId = sgblist.get(i).getBattGroupId();
                        Integer badbattFlag = badMapper.judgeBatt(battGroupId);
                        sgblist.get(i).setBadbattFlag(badbattFlag);
                        //根据电池组查询续航时间
                        String enduranceActualTimelong = endMapper.getACTime(battGroupId);
                        if (enduranceActualTimelong == null) {
                            enduranceActualTimelong = "0";
                        }
                        sgblist.get(i).setEnduranceActualTimelong(Float.valueOf(enduranceActualTimelong));
                    }
                    inf.setSgbList(sgblist);
                }
                inf.setSgbList(sgblist);
                int devAlm = devAlmMapper.getdevAlm(stationId);
                inf.setDevAlm(devAlm);
                int pwrAlm = pwrAlmMapper.getpwrAlm(stationId);
                inf.setPwrAlm(pwrAlm);
            }
            map.put("data", list);
            //站点统计
            List<StationInf> stationInfList = mapper.getStationInfList(userId);
            //站点数
            map.put("stationCount", stationInfList.size());
            //110v/35v/...
            //List<StationInf> stationInfList = mapper.getStationInfList(userId);
            List<StationInf> stationInfList = mapper.getSateAnalysis(userId);//和homeAdmin相同
            //110kv/35kv/...
            Map<String, Object> kvMap = new HashMap();
            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) {
                map.put(stationType, stationTypeMap.get(stationType).size());
                kvMap.put(stationType, stationTypeMap.get(stationType).size());
            }
            map.put("kvMap", kvMap);
            //节点站和普通站
            List<Battinf> stationList = battInfService.getSateAnalysis(userId);
            Map<Integer, List<Battinf>> nodeStationMap = stationList.stream().collect(Collectors.groupingBy(Battinf::getNodeStation));
            //List<Battinf> stationList = battInfService.getSateAnalysis(userId);
            //Map<Integer, List<Battinf>> nodeStationMap = stationList.stream().collect(Collectors.groupingBy(Battinf::getNodeStation));
            Map<Integer, List<StationInf>> nodeStationMap = stationInfList.stream().collect(Collectors.groupingBy(StationInf::getNodeStation));
            map.put("nomalStation", nodeStationMap.get(0) == null ? 0 : nodeStationMap.get(0).size());
            map.put("nodeStation", nodeStationMap.get(1) == null ? 0 : nodeStationMap.get(1).size());
@@ -383,17 +639,28 @@
            });
            alarmWrapper.orderByAsc("alm_id");
            List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
            float capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
            float capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
            //劣化数量(包含损坏)
            int alarmNum = badbattMonMapper.getQualityAnalysis(userId, capAlarm);
            //损坏数量
            int changeNum = badbattMonMapper.getQualityAnalysis(userId, capChange);
            float capAlarm = 0f;
            float capChange = 0f;
            if (paramList != null && paramList.size() > 0) {
                capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
                capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
            } else {
                capAlarm = 0.8f;
                capChange = 0.6f;
            }
            //站点劣化数量(包含损坏)
            int alarmNum = badbattMonMapper.getQualityAnalysisStation(userId, capAlarm);
            //站点损坏数量
            int changeNum = badbattMonMapper.getQualityAnalysisStation(userId, capChange);
            map.put("alarmNum", (alarmNum - changeNum));
            map.put("changeNum", changeNum);
            int battAlarmNum = battAlarmDataService.serchRealTime(userId).getCode();
            int devAlarmNum = devAlarmDataService.getAlarmNum(userId);
            int powerAlarmNum = (int) powerAlarmService.getHomeAlarmNum(userId);
            //电池告警机房
            int battAlarmNum = battAlmMapper.getQualityAnalysisStation(userId);
            //设备告警机房
            int devAlarmNum = devAlmMapper.getQualityAnalysisStation(userId);
            //电源设备告警机房
            int powerAlarmNum = pwrAlmMapper.getQualityAnalysisStation(userId);
            map.put("battAlarmNum", battAlarmNum);
            map.put("devAlarmNum", devAlarmNum);
            map.put("powerAlarmNum", powerAlarmNum);
@@ -409,13 +676,9 @@
        return mapper.getStation(userId);
    }
    //监控层首页:站点实时数据推送
    public Object getMonitorAll(int userId) {
        return new Response().set(1, true, "站点实时数据推送");
    }
    //管理员首页:头部统计
    public Response getSystemSkipHead(int userId) {
    //运维层首页:头部统计
    public Response getDevOpSkipHead(int userId) {
        try {
            Map<String, Object> map = new HashMap();
            //头部统计数据
@@ -423,66 +686,13 @@
            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);
            return new Response().setII(1, true, map, "管理员首页:头部统计");
        } catch (Exception e) {
            return new Response().set(1, false, "发生异常:" + e.getCause());
        }
    }
    //指定站点详情第一次跳转机房id为0:message
    public Response getSystemSkipStation(int userId, String stationId) {
        //查询指定机房信息
        StationInf inf = mapper.getSystemSkipStation(userId, stationId);
        if (inf != null) {
            //查询分组电池信息
            List<SystemGrdoupBatt> sgblist = rtstateMapper.selectSystemGrdoupBatt(stationId);
            for (int i = 0; i < sgblist.size(); i++) {
                int battGroupId = sgblist.get(i).getBattGroupId();
                //查询机房下最大的单体电压和单体
                BattRtdata maxData = rtdataMapper.maxData(battGroupId);
                sgblist.get(i).setMaxVol(maxData.getMonVol());
                sgblist.get(i).setMaxNum(maxData.getMonNum());
                //查询机房下最低的单体电压和单体
                BattRtdata minData = rtdataMapper.minData(battGroupId);
                sgblist.get(i).setMinVol(maxData.getMonVol());
                sgblist.get(i).setMinNum(maxData.getMonNum());
                //查询实时告警总数
                int battAlm = battAlmMapper.getbattAlm(battGroupId);
                sgblist.get(i).setBattAlm(battAlm);
            }
            inf.setSgbList(sgblist);
            int devAlm = devAlmMapper.getdevAlm(stationId);
            inf.setDevAlm(devAlm);
            int pwrAlm = pwrAlmMapper.getpwrAlm(stationId);
            inf.setPwrAlm(pwrAlm);
            return new Response().setII(1, true, inf, "指定站点详情");
        } else {
            return new Response().set(1, false, "指定站点详情");
        }
    }
    //运维层首页:头部统计
    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<String, Integer> statemap = new HashMap();
            statemap.put("batt1", 0);
            statemap.put("batt2", 0);
            statemap.put("batt3", 0);
            Map<Integer, List<BattRtstate>> battstateMap = stateList.stream().collect(Collectors.groupingBy(BattRtstate::getBattState));
            for (Integer state : battstateMap.keySet()) {
                if (state == 1 || state == 2) {
                if (state == 1 || state == 2 || state == 3) {
                    statemap.put("batt" + state, battstateMap.get(state).size());
                }
            }
@@ -505,10 +715,14 @@
                fusemap.put("fuse" + fuse, adfuseMap.get(fuse).size());
            }
            map.put("fusemap", fusemap);
            //本年度核容放电电池组.停电放电电池组
            int hrdisNum = testInfService.getYearAnalysis(userId);
            map.put("hrdisNum", hrdisNum);
            //实时停电放电
            int jcdisNum = fbs9100StateService.getJcAnalysis(userId);
            map.put("jcdisNum", jcdisNum);
            //站点统计
            List<StationInf> stationInfList = mapper.getStationInfList(userId);
            //站点数
            map.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();
@@ -516,9 +730,9 @@
                map.put(stationType, stationTypeMap.get(stationType).size());
            }
            //节点站和普通站
            List<Battinf> stationList = battInfService.getSateAnalysis(userId);
            Map<Integer, List<Battinf>> nodeStationMap = stationList.stream().collect(Collectors.groupingBy(Battinf::getNodeStation));
            //List<Battinf> stationList = battInfService.getSateAnalysis(userId);
            //Map<Integer, List<Battinf>> nodeStationMap = stationList.stream().collect(Collectors.groupingBy(Battinf::getNodeStation));
            Map<Integer, List<StationInf>> nodeStationMap = stationInfList.stream().collect(Collectors.groupingBy(StationInf::getNodeStation));
            map.put("nomalStation", nodeStationMap.get(0) == null ? 0 : nodeStationMap.get(0).size());
            map.put("nodeStation", nodeStationMap.get(1) == null ? 0 : nodeStationMap.get(1).size());
@@ -537,15 +751,19 @@
            List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
            float capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
            float capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
            //劣化数量(包含损坏)
            int alarmNum = badbattMonMapper.getQualityAnalysis(userId, capAlarm);
            //损坏数量
            int changeNum = badbattMonMapper.getQualityAnalysis(userId, capChange);
            //站点劣化数量(包含损坏)
            int alarmNum = badbattMonMapper.getQualityAnalysisStation(userId, capAlarm);
            //站点损坏数量
            int changeNum = badbattMonMapper.getQualityAnalysisStation(userId, capChange);
            map.put("alarmNum", (alarmNum - changeNum));
            map.put("changeNum", changeNum);
            int battAlarmNum = battAlarmDataService.serchRealTime(userId).getCode();
            int devAlarmNum = devAlarmDataService.getAlarmNum(userId);
            int powerAlarmNum = (int) powerAlarmService.getAlarmNum().getData();
            //电池告警机房
            int battAlarmNum = battAlmMapper.getQualityAnalysisStation(userId);
            //设备告警机房
            int devAlarmNum = devAlmMapper.getQualityAnalysisStation(userId);
            //电源设备告警机房
            int powerAlarmNum = pwrAlmMapper.getQualityAnalysisStation(userId);
            map.put("battAlarmNum", battAlarmNum);
            map.put("devAlarmNum", devAlarmNum);
            map.put("powerAlarmNum", powerAlarmNum);
@@ -569,15 +787,14 @@
                    int battGroupId = sgblist.get(i).getBattGroupId();
                    int badbattFlag = badMapper.judgeBatt(battGroupId);
                    sgblist.get(i).setBadbattFlag(badbattFlag);
                    //根据电池组查询续航时间
                    String enduranceActualTimelong = endMapper.getACTime(battGroupId);
                    if (enduranceActualTimelong == null) {
                        enduranceActualTimelong = "0";
                    }
                    sgblist.get(i).setEnduranceActualTimelong(Float.valueOf(enduranceActualTimelong));
                }
                inf.setSgbList(sgblist);
            }
            //查询停电续航时间
            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 {
@@ -637,14 +854,82 @@
    //首页上点击整流器故障
    public Response searchAcdcModError() {
        String uId = String.valueOf(ActionUtil.getUser().getUId());
        List<PwrdevAcdcdata> list = acdcMapper.searchAcdcModError(uId);
        List<PowerInf> list = acdcMapper.searchAcdcModError(uId);
        return new Response().setII(1, list.size() > 0, list, "首页上点击整流器故障");
    }
    //首页上点击负载熔断
    public Response searchFuse() {
        String uId = String.valueOf(ActionUtil.getUser().getUId());
        List<PwrdevAcdcdata> list = acdcMapper.searchFuse(uId);
        List<PowerInf> list = acdcMapper.searchFuse(uId);
        return new Response().setII(1, list.size() > 0, list, "首页上点击整流器故障");
    }
    //首页上点击停电站
    public Response searchPowerOff() {
        String uId = String.valueOf(ActionUtil.getUser().getUId());
        List<Battinf> list = fbs9100StateService.searchPowerOff(uId);
        return new Response().setII(1, list.size() > 0, list, "首页上点击停电站");
    }
    //首页上点击核容放电站
    public Response searchCheckCapDischarge() {
        String uId = String.valueOf(ActionUtil.getUser().getUId());
        List<Battinf> list = fbs9100StateService.searchCheckCapDischarge(uId);
        return new Response().setII(1, list.size() > 0, list, "首页上点击核容放电站");
    }
    //首页上点击容量不足站
    public Response searchCapAlarm() {
        int uId = ActionUtil.getUser().getUId().intValue();
        //1.查询劣化(告警)和损坏(更换)的阈值
        QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
        alarmWrapper.and(wrapper -> {
            return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
        });
        alarmWrapper.orderByAsc("alm_id");
        List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
        float capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
        float capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
        List<Battinf> list = badbattMonMapper.searchCapAlarm(uId, capAlarm, capChange);
        return new Response().setII(1, list.size() > 0, list, "首页上点击容量不足站");
    }
    //首页上点击电池损坏站
    public Response searCapChange() {
        int uId = ActionUtil.getUser().getUId().intValue();
        //1.查询劣化(告警)和损坏(更换)的阈值
        QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
        alarmWrapper.and(wrapper -> {
            return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
        });
        alarmWrapper.orderByAsc("alm_id");
        List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
        float capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
        List<Battinf> list = badbattMonMapper.searCapChange(uId, capChange);
        return new Response().setII(1, list.size() > 0, list, "首页上点击电池损坏站");
    }
    //站点信息
    public List<StationInf> getSateAnalysis(int userId) {
        List<StationInf> list = mapper.getSateAnalysis(userId);
        return list;
    }
    public List<StationInf> getStationInfList(int userId) {
        return mapper.getStationInfList(userId);
    }
    //查询所有的站点电压等级
    public Response searStationType() {
        List<String> list = mapper.searStationType();
        return new Response().setII(1, list.size() > 0 ? true : false, list, "查询所有的站点电压等级");
    }
    //添加关联时下拉显示
    public Response getTogetherStations(String stationName1, String stationName2, String stationName5) {
        List<StationInf> list = mapper.getTogetherStations(stationName1, stationName2, stationName5);
        return new Response().set(1, list, "查询成功");
    }
}