New file |
| | |
| | | package com.whyc.dto; |
| | | |
| | | import java.beans.Transient; |
| | | |
| | | /** |
| | | * 电池状态 |
| | | */ |
| | | public class BatteryRTState { |
| | | |
| | | private Integer batteryGroupId; |
| | | /**电池状态*/ |
| | | private Integer batteryState; |
| | | /**电池实际容量*/ |
| | | private Float batteryRealCap; |
| | | /**单体电池容量标准*/ |
| | | private Float monCapStd; |
| | | |
| | | public Integer getBatteryGroupId() { |
| | | return batteryGroupId; |
| | | } |
| | | |
| | | public void setBatteryGroupId(Integer batteryGroupId) { |
| | | this.batteryGroupId = batteryGroupId; |
| | | } |
| | | |
| | | public Integer getBatteryState() { |
| | | return batteryState; |
| | | } |
| | | |
| | | public void setBatteryState(Integer batteryState) { |
| | | this.batteryState = batteryState; |
| | | } |
| | | |
| | | public Float getBatteryRealCap() { |
| | | return batteryRealCap; |
| | | } |
| | | |
| | | public void setBatteryRealCap(Float batteryRealCap) { |
| | | this.batteryRealCap = batteryRealCap; |
| | | } |
| | | |
| | | @Transient |
| | | public Float getMonCapStd() { |
| | | return monCapStd; |
| | | } |
| | | |
| | | public void setMonCapStd(Float monCapStd) { |
| | | this.monCapStd = monCapStd; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.whyc.dto.BattInfAndEnduranceDTO; |
| | | import com.whyc.dto.BattInfDTO; |
| | | import com.whyc.dto.BatteryRTState; |
| | | import com.whyc.dto.ReportBattDTO; |
| | | import com.whyc.pojo.Battinf; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | |
| | | List<Battinf> getBattGroupList(int userId); |
| | | |
| | | List<BatteryRTState> getBatteryCap(int userId); |
| | | |
| | | } |
| | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.BattInfAndEnduranceDTO; |
| | | import com.whyc.dto.BatteryRTState; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattInfMapper; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.pojo.PowerInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.MathUtil; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | public Response<Map> getDevCountMap(int userId) { |
| | | public Response getDevCountMap(int userId) { |
| | | try { |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | int battGroupCount = battInfMapper.getBattGroupNum(userId); |
| | | int devCount = battInfMapper.getDevNum(userId); |
| | |
| | | map.put("battGroupCount",battGroupCount); |
| | | map.put("devCount",devCount); |
| | | map.put("powerNum",powerNum); |
| | | return new Response<Map>().set(1,map); |
| | | return new Response().setII(1,true, map,null); |
| | | }catch (Exception e){ |
| | | return new Response<>().set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | |
| | | public List<Battinf> getBattGroupList(int userId) { |
| | | return battInfMapper.getBattGroupList(userId); |
| | | } |
| | | /** |
| | | * 获取电池组的实际容量 |
| | | */ |
| | | public List<BatteryRTState> getBatteryCap(int userId){ |
| | | return battInfMapper.getBatteryCap(userId); |
| | | } |
| | | |
| | | public int getCapAlarmNum(int userId){ |
| | | int capAlarmNum=0; |
| | | List<BatteryRTState> stateList = getBatteryCap(userId); |
| | | //查询容量告警阈值,暂定为70% TODO 后续从数据库读取 |
| | | for (int i = 0; i < stateList.size(); i++) { |
| | | BatteryRTState state = stateList.get(i); |
| | | Float batteryRealCap = state.getBatteryRealCap(); |
| | | Float capStd = state.getMonCapStd(); |
| | | Float realCapDivide = (Float) MathUtil.divide(batteryRealCap, capStd, MathUtil.TYPE_FLOAT); |
| | | if(realCapDivide<=0.7){ |
| | | capAlarmNum++; |
| | | } |
| | | } |
| | | return capAlarmNum; |
| | | } |
| | | } |
| | |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | public Response<Map> getMonCapacityLowAnalysis(int userId) { |
| | | Response<Map> response = new Response(); |
| | | public Response getMonCapacityLowAnalysis(int userId) { |
| | | Response response = new Response(); |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | |
| | | try { |
| | |
| | | //resultMap.put("告警机房数",alarmNum); |
| | | //resultMap.put("告警机房占比",capLowStationRateStr); |
| | | |
| | | response.set(1, resultMap); |
| | | response.setII(1,true, resultMap,null); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return response.set(0); |
| | | return response.set(0,false,"发生异常:"+e.getCause()); |
| | | } |
| | | return response; |
| | | } |
| | |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | public Response<Map> getMonVRTAnalysis(int userId) { |
| | | public Response getMonVRTAnalysis(int userId) { |
| | | |
| | | Response<Map> response = new Response(); |
| | | Response response = new Response(); |
| | | try { |
| | | HashMap<String, Object> resultMap = new HashMap<>(); |
| | | Map<String, Object> monVolMap = new HashMap<>();//单体电压 Alarm_vol_Monomer =119005; |
| | | Map<String, Object> monResMap = new HashMap<>();//单体内阻 Alarm_res_Monomer =119007 |
| | |
| | | //monTemMap.put("告警机房数比例", tempStationRateStr); //告警机房数比例 |
| | | resultMap.put("单体温度", monTemMap); |
| | | |
| | | response.setCode(1); |
| | | response.setData(resultMap); |
| | | return response; |
| | | return response.setII(1,true,resultMap,null); |
| | | }catch (Exception e){ |
| | | return response.set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | } |
| | |
| | | return list; |
| | | } |
| | | |
| | | public Response<Map> getBTSEquipStatus(int userId) throws ParseException { |
| | | public Response getBTSEquipStatus(int userId) throws ParseException { |
| | | |
| | | Response<Map> response = new Response(); |
| | | Response response = new Response(); |
| | | try { |
| | | Map<String, Integer> resultMap = new HashMap<>(); |
| | | resultMap.put("在线浮充数量",0); |
| | | resultMap.put("预充电数量",0); |
| | |
| | | } |
| | | } |
| | | |
| | | return new Response<Map>().set(1,resultMap); |
| | | return response.setII(1,true,resultMap,null); |
| | | }catch (Exception e){ |
| | | return response.set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @return |
| | | * @param userId |
| | | */ |
| | | public Response<List> getAcABCAnalysis(int userId){ |
| | | public Response getAcABCAnalysis(int userId){ |
| | | |
| | | //交流A/B/C-过压, |
| | | //交流A/B/C-欠压, |
| | |
| | | resultMap.put("欠压",0); |
| | | resultMap.put("缺相",0); |
| | | resultMap.put("过流",0); |
| | | |
| | | try { |
| | | List<Integer> types = Arrays.asList( |
| | | AlarmConstant.acIn1_over_volA, |
| | | AlarmConstant.acIn1_over_volB, |
| | |
| | | resultMap.put("过流",resultMap.get("过流")+data.get(i).getNum().intValue()); |
| | | break; |
| | | default: |
| | | throw new IllegalStateException("Unexpected value: " + data.get(i)); |
| | | } |
| | | |
| | | } |
| | |
| | | //map2.put("告警机房数比例",(int)MathUtil.divide(alarmStationCount,stationCount,2)); |
| | | |
| | | List<Map<String, Integer>> mapList = Arrays.asList(resultMap, map2); |
| | | return new Response<List>().set(1,mapList); |
| | | return new Response<>().setII(1, true,mapList,null); |
| | | }catch (Exception e){ |
| | | return new Response<>().set(0,false,"发生异常"); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public class MathUtil { |
| | | |
| | | public static final Integer TYPE_FLOAT = 1; |
| | | public static final Integer TYPE_FLOAT_100 = 2; |
| | | public static final Integer TYPE_FLOAT_PERCENT = 3; |
| | | /** |
| | | * 提取公共方法,相除获取比例,返回可选String或者Float |
| | | * @param type 1表示小数,2表示除去%的比例,3表示%的比例 |
| | |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Map<String, Response> res = new HashMap<>(); |
| | | Map<String, Object> res = new HashMap<>(); |
| | | Response sessionRes = new Response().set(1, httpSession.getId()); |
| | | while (!currentThread().isInterrupted()) { |
| | | //一体 告警:交流ABC |
| | |
| | | //一体 告警:单体容量 |
| | | Response res_monCapacityLowAnalysis = battAlarmDataService.getMonCapacityLowAnalysis(userId); |
| | | //一体 告警:单体温度内阻温度 |
| | | Response<Map> res_monVRTAnalysis = battAlarmDataService.getMonVRTAnalysis(userId); |
| | | Response res_monVRTAnalysis = battAlarmDataService.getMonVRTAnalysis(userId); |
| | | //一体 统计:三种设备类型 告警数统计 |
| | | Response res_devAlarmNum = new Response(); |
| | | Map<String, Integer> devAlarmNumMap = new HashMap<>(); |
| | | try { |
| | | int battAlarmNum = battAlarmDataService.serchRealTime(userId).getCode(); |
| | | int devAlarmNum = devAlarmDataService.getAlarmNum(userId); |
| | | int powerAlarmNum = (int) powerAlarmService.getAlarmNum().getData(); |
| | | devAlarmNumMap.put("battAlarmNum",battAlarmNum); |
| | | devAlarmNumMap.put("devAlarmNum",devAlarmNum); |
| | | devAlarmNumMap.put("powerAlarmNum",powerAlarmNum); |
| | | res_devAlarmNum.setII(1,true,devAlarmNumMap,null); |
| | | }catch (Exception e){ |
| | | res_devAlarmNum.set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | |
| | | //一体 统计:电池统计 分为品牌和标称电压 |
| | | Response res_battGroupInfo = new Response(); |
| | | try { |
| | | List<Battinf> battinfList = battInfService.getBattGroupList(userId); |
| | | Map<String, List<Battinf>> battProducerMap = battinfList.stream().collect(Collectors.groupingBy(Battinf::getBattProducer)); |
| | | Map<Float, List<Battinf>> battMonVolStdMap = battinfList.stream().collect(Collectors.groupingBy(Battinf::getMonVolStd)); |
| | | Map<String,Object> battGroupInfoMap = new HashMap<>(); |
| | | for(String producer : battGroupInfoMap.keySet()){ |
| | | |
| | | for (String producer : battProducerMap.keySet()) { |
| | | battGroupInfoMap.put(producer, battProducerMap.get(producer).size()); |
| | | } |
| | | for (Float monVolStd : battMonVolStdMap.keySet()) { |
| | | battGroupInfoMap.put(Float.toString(monVolStd), battMonVolStdMap.get(monVolStd).size()); |
| | | } |
| | | res_battGroupInfo.setII(1,true,battGroupInfoMap,null); |
| | | }catch (Exception e){ |
| | | res_battGroupInfo.set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | |
| | | //一体 统计:设备状态 |
| | | Response<Map> res_devStates = fbs9100StateService.getBTSEquipStatus(userId); |
| | | //一体 统计:各种设备类型总数 电池 设备 电源 站点 |
| | | Response<Map> res_devCountMap = battInfService.getDevCountMap(userId); |
| | | //续航检测??? TODO |
| | | |
| | | //续航检测:按照电池组为单位进行检测,告警判定:实际容量/标称容量<=某个百分比 TODO 续航表中读取需要询问李军确认 |
| | | Response res_capAlarmNum = new Response(); |
| | | try { |
| | | int capAlarmNum = battInfService.getCapAlarmNum(userId); |
| | | res_capAlarmNum.setII(1,true,capAlarmNum,null); |
| | | }catch (Exception e){ |
| | | res_capAlarmNum.set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | |
| | | res.put("acABC", res_acABC); |
| | | res.put("monCapacityLowAnalysis", res_monCapacityLowAnalysis); |
| | | res.put("monVRTAnalysis", res_monVRTAnalysis); |
| | | res.put("devAlarmNum", res_devAlarmNum); |
| | | res.put("battGroupInfo", res_battGroupInfo); |
| | | res.put("devStates", res_devStates); |
| | | res.put("devCountMap", res_devCountMap); |
| | | res.put("capAlarmNum", res_capAlarmNum); |
| | | session.getBasicRemote().sendObject(new Response().set(1, res)); |
| | | sleep(4000); |
| | | } |
| | |
| | | and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid |
| | | and db_user.tb_user_inf.uid=#{userId}) |
| | | </select> |
| | | <select id="getBatteryCap" resultType="com.whyc.dto.BatteryRTState"> |
| | | SELECT |
| | | state.batt_real_cap AS batteryRealCap, |
| | | battInf.MonCapStd AS monCapStd |
| | | FROM |
| | | db_ram_db.tb_batt_rtstate state, |
| | | db_battinf.tb_battinf battInf |
| | | WHERE |
| | | state.BattGroupId = battInf.BattGroupId |
| | | AND batt_real_cap > 0 |
| | | AND state.BattGroupId IN ( |
| | | SELECT DISTINCT |
| | | db_battinf.tb_battinf.BattGroupId |
| | | FROM |
| | | db_battinf.tb_battinf |
| | | LEFT OUTER JOIN db_user.tb_user_battgroup_baojigroup_battgroup ON db_user.tb_user_battgroup_baojigroup_battgroup.stationid = db_battinf.tb_battinf.stationid |
| | | LEFT OUTER JOIN db_user.tb_user_battgroup_baojigroup_usr ON db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id = db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id |
| | | LEFT OUTER JOIN db_user.tb_user_inf ON tb_user_inf.uid = db_user.tb_user_battgroup_baojigroup_usr.uid |
| | | WHERE |
| | | db_user.tb_user_inf.uid = #{userId} |
| | | ) |
| | | </select> |
| | | |
| | | </mapper> |