| | |
| | | */ |
| | | @GetMapping("acABC") |
| | | @ApiOperation(value = "交流ABC") |
| | | public Response<Map> getAcABCAnalysis(@RequestParam Integer userId){ |
| | | Response<Map> response = service.getAcABCAnalysis(userId); |
| | | public Response<List> getAcABCAnalysis(@RequestParam Integer userId){ |
| | | Response<List> response = service.getAcABCAnalysis(userId); |
| | | return response; |
| | | } |
| | | |
| | |
| | | |
| | | List<PowerAlarm> getAnalysis(int userId, List<Integer> types); |
| | | |
| | | int getAlarmStationCountSpec(int userId, List<Integer> types); |
| | | |
| | | int getAlarmStationCount(int userId); |
| | | |
| | | } |
| | |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //容量低告警占比 |
| | | String capLowRateStr = (String) MathUtil.divide(alarmNum,totalAlarmNum,false); |
| | | String capLowRateStr = (String) MathUtil.divide(alarmNum,totalAlarmNum,3); |
| | | //容量低告警机房占比 |
| | | String capLowStationRateStr = (String) MathUtil.divide(stationNum,totalStationNum,false); |
| | | String capLowStationRateStr = (String) MathUtil.divide(stationNum,totalStationNum,3); |
| | | |
| | | resultMap.put("告警数",alarmNum); |
| | | resultMap.put("告警总数",totalAlarmNum); |
| | |
| | | //总机房数 |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | //放电电流低告警占比 |
| | | String disChargeLowRateStr = (String) MathUtil.divide(disChargeAlarmNum,totalAlarmNum,false); |
| | | String disChargeLowRateStr = (String) MathUtil.divide(disChargeAlarmNum,totalAlarmNum,3); |
| | | //放电电流低告警机房占比 |
| | | String disChargeLowStationRateStr = (String) MathUtil.divide(disChargeStationNum,totalStationNum,false); |
| | | String disChargeLowStationRateStr = (String) MathUtil.divide(disChargeStationNum,totalStationNum,3); |
| | | |
| | | resultMap.put("低告警数量", disChargeAlarmNum); //低告警数量 alm_signal_id:DisChargeCurr 7 high; 8 low |
| | | resultMap.put("告警机房总数", disChargeStationNum); //告警机房总数 |
| | |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //放电电流高告警占比 |
| | | String dischargeRateStr = (String) MathUtil.divide(dischargeHighAlarmsNum,totalStationAlarmNum,false); |
| | | String dischargeRateStr = (String) MathUtil.divide(dischargeHighAlarmsNum,totalStationAlarmNum,3); |
| | | //放电电流高告警机房占比 |
| | | String dischargeStationRateStr = (String) MathUtil.divide(dischargeTotalAlarmStations,totalStationNum,false); |
| | | String dischargeStationRateStr = (String) MathUtil.divide(dischargeTotalAlarmStations,totalStationNum,3); |
| | | |
| | | disCharge.put("高告警数量",dischargeHighAlarmsNum); //高告警数量 alm_signal_id:ChargeCurrHigh 5 high; 6 low |
| | | disCharge.put("告警总数",totalStationAlarmNum); //告警总数 |
| | |
| | | int chargeTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.ALM_SIGNAL_ID_ChargeCurrHigh); |
| | | |
| | | //放电电流高告警占比 |
| | | String chargeRateStr = (String) MathUtil.divide(chargeHighAlarmsNum,totalStationAlarmNum,false); |
| | | String chargeRateStr = (String) MathUtil.divide(chargeHighAlarmsNum,totalStationAlarmNum,3); |
| | | //放电电流高告警机房占比 |
| | | String chargeStationRateStr = (String) MathUtil.divide(chargeTotalAlarmStations,totalStationNum,false); |
| | | String chargeStationRateStr = (String) MathUtil.divide(chargeTotalAlarmStations,totalStationNum,3); |
| | | |
| | | reCharge.put("高告警数量", chargeHighAlarmsNum); //高告警数量 |
| | | reCharge.put("告警总数", totalStationAlarmNum); //告警总数 |
| | |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //电压告警占比 |
| | | String volRateStr = (String) MathUtil.divide(volTotalAlarmNum,totalStationAlarmNum,false); |
| | | String volRateStr = (String) MathUtil.divide(volTotalAlarmNum,totalStationAlarmNum,3); |
| | | //电压告警机房占比 |
| | | String volStationRateStr = (String) MathUtil.divide(volTotalAlarmStations,totalStationNum,false); |
| | | String volStationRateStr = (String) MathUtil.divide(volTotalAlarmStations,totalStationNum,3); |
| | | |
| | | |
| | | monVolMap.put("高告警数量", volHighAlarmsNum); //高告警数量 alm_signal_id 9 |
| | |
| | | int resTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.Alarm_res_Monomer); |
| | | |
| | | //内阻告警占比 |
| | | String resRateStr = (String) MathUtil.divide(resTotalAlarmNum,totalStationAlarmNum,false); |
| | | String resRateStr = (String) MathUtil.divide(resTotalAlarmNum,totalStationAlarmNum,3); |
| | | //内阻告警机房占比 |
| | | String resStationRateStr = (String) MathUtil.divide(resTotalAlarmStations,totalStationNum,false); |
| | | String resStationRateStr = (String) MathUtil.divide(resTotalAlarmStations,totalStationNum,3); |
| | | |
| | | monResMap.put("高告警数量", resHighAlarmsNum); //高告警数量 alm_signal_id 13 |
| | | monResMap.put("低告警数量", resLowAlarmsNum); //低告警数量 alm_signal_id 14 |
| | |
| | | int tempTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.Alarm_tmp_Monomer); |
| | | |
| | | //温度告警占比 |
| | | String tempRateStr = (String) MathUtil.divide(tempTotalAlarmNum,totalStationAlarmNum,false); |
| | | String tempRateStr = (String) MathUtil.divide(tempTotalAlarmNum,totalStationAlarmNum,3); |
| | | //温度告警机房占比 |
| | | String tempStationRateStr = (String) MathUtil.divide(tempTotalAlarmStations,totalStationNum,false); |
| | | String tempStationRateStr = (String) MathUtil.divide(tempTotalAlarmStations,totalStationNum,3); |
| | | |
| | | monTemMap.put("高告警数量", tempHighAlarmsNum); //高告警数量 alm_signal_id 13 |
| | | monTemMap.put("低告警数量", tempLowAlarmsNum); //低告警数量 alm_signal_id 14 |
| | |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //告警占比 |
| | | String rate = (String) MathUtil.divide(alarmNum,totalAlarmNum,false); |
| | | String rate = (String) MathUtil.divide(alarmNum,totalAlarmNum,3); |
| | | //告警机房占比 |
| | | String stationRate = (String) MathUtil.divide(alarmStationNum,totalStationNum,false); |
| | | String stationRate = (String) MathUtil.divide(alarmStationNum,totalStationNum,3); |
| | | |
| | | resMap.put(alarmName,alarmNum); //告警数量 |
| | | resMap.put("告警总数", totalAlarmNum); //告警总数 |
| | |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //告警占比 |
| | | String rate = (String) MathUtil.divide(totalAlarmNum,totalAlarms,false); |
| | | String rate = (String) MathUtil.divide(totalAlarmNum,totalAlarms,3); |
| | | //告警机房占比 |
| | | String stationRate = (String) MathUtil.divide(alarmStationNum,totalStationNum,false); |
| | | String stationRate = (String) MathUtil.divide(alarmStationNum,totalStationNum,3); |
| | | |
| | | resMap.put(mapName1,alarmNum); //告警1数量 |
| | | resMap.put(mapName2,alarmNum2); //告警2数量 |
| | |
| | | |
| | | for (int i = 0; i < batteryRTStates.size(); i++) { |
| | | //每一个具体的续航进行分组 |
| | | if((Float)MathUtil.divide(batteryRTStates.get(i).getBatteryRealCap(),batteryRTStates.get(i).getMonCapStd(),true)<percents.get(0)){ |
| | | if((Float)MathUtil.divide(batteryRTStates.get(i).getBatteryRealCap(),batteryRTStates.get(i).getMonCapStd(),1)<percents.get(0)){ |
| | | map.put(percents.get(0)+"以下",Optional.ofNullable(map.get(percents.get(0)+"以下")).orElse(0)+1); |
| | | } |
| | | else if((Float)MathUtil.divide(batteryRTStates.get(i).getBatteryRealCap(),batteryRTStates.get(i).getMonCapStd(),true)>percents.get(percents.size()-1)){ |
| | | else if((Float)MathUtil.divide(batteryRTStates.get(i).getBatteryRealCap(),batteryRTStates.get(i).getMonCapStd(),1)>percents.get(percents.size()-1)){ |
| | | map.put(percents.get(percents.size()-1)+"以上",Optional.ofNullable(map.get(percents.get(percents.size()-1)+"以上")).orElse(0)+1); |
| | | }else { |
| | | for (int j = 0; j < percents.size(); j++) { |
| | | if ((Float)MathUtil.divide(batteryRTStates.get(i).getBatteryRealCap(),batteryRTStates.get(i).getMonCapStd(),true) <= percents.get(j)) { |
| | | if ((Float)MathUtil.divide(batteryRTStates.get(i).getBatteryRealCap(),batteryRTStates.get(i).getMonCapStd(),1) <= percents.get(j)) { |
| | | map.put(percents.get(j - 1) + "到" + percents.get(j), Optional.ofNullable(map.get(percents.get(j - 1) + "到" + percents.get(j))).orElse(0) + 1); |
| | | break; |
| | | } |
| | |
| | | * @return |
| | | * @param userId |
| | | */ |
| | | public Response<Map> getAcABCAnalysis(int userId){ |
| | | public Response<List> getAcABCAnalysis(int userId){ |
| | | |
| | | //交流A/B/C-过压, |
| | | //交流A/B/C-欠压, |
| | |
| | | |
| | | } |
| | | |
| | | return new Response<Map>().set(1,resultMap); |
| | | //告警机房总数和比例 |
| | | HashMap<String, Integer> map2 = new HashMap<>(); |
| | | |
| | | int alarmStationCount = mapper.getAlarmStationCountSpec(userId,types); |
| | | int stationCount = infoMapper.getStationCount(userId); |
| | | |
| | | map2.put("告警机房总数",alarmStationCount); |
| | | map2.put("告警机房数比例",(int)MathUtil.divide(alarmStationCount,stationCount,2)); |
| | | |
| | | List<Map<String, Integer>> mapList = Arrays.asList(resultMap, map2); |
| | | return new Response<List>().set(1,mapList); |
| | | } |
| | | |
| | | public Response<Map> getRectifierAnalysis(int userId){ |
| | |
| | | //总机房数 |
| | | int stationCount = infoMapper.getStationCount(userId); |
| | | //比例 |
| | | String alarmStationRate = (String) MathUtil.divide(alarmStationCount, stationCount,false); |
| | | String alarmStationRate = (String) MathUtil.divide(alarmStationCount, stationCount,3); |
| | | resultMap.put("告警机房数",alarmStationCount); |
| | | resultMap.put("告警机房比例",alarmStationRate); |
| | | |
| | |
| | | |
| | | /** |
| | | * 提取公共方法,相除获取比例,返回可选String或者Float |
| | | * @param type 1表示小数,2表示除去%的比例,3表示%的比例 |
| | | * @return Object String或者Float类型 |
| | | * */ |
| | | public static Object divide(Object num,Object num2,boolean isFloat){ |
| | | public static Object divide(Object num,Object num2,Integer type){ |
| | | float res = 0; |
| | | if(num instanceof Integer) { |
| | | res = BigDecimal.valueOf((Integer)num).divide(BigDecimal.valueOf((Integer)num2), 2, RoundingMode.HALF_UP).floatValue(); |
| | |
| | | if(num instanceof Double) { |
| | | res = BigDecimal.valueOf((Double)num).divide(BigDecimal.valueOf((Double)num2), 2, RoundingMode.HALF_UP).floatValue(); |
| | | } |
| | | if(isFloat){ |
| | | //0.05 |
| | | if(type==1){ |
| | | return res; |
| | | } |
| | | //5 |
| | | else if(type==2){ |
| | | return (int)(res*100); |
| | | } |
| | | //5% |
| | | return (int)(res*100)+"%"; |
| | | } |
| | | |
| | |
| | | group by inf.StationId |
| | | )temp |
| | | </select> |
| | | <select id="getAlarmStationCountSpec" resultType="java.lang.Integer"> |
| | | select count(distinct StationId) as num |
| | | from db_pwrdev_alarm.tb_pwrdev_alarm alarm,db_pwrdev_inf.tb_pwrdev_inf inf |
| | | where alarm.PowerDeviceId = inf.PowerDeviceId |
| | | and alm_cleared_type=0 |
| | | and alm_type in |
| | | <foreach collection="types" separator="," open="(" close=")" item="alarm_type"> |
| | | #{alarm_type} |
| | | </foreach> |
| | | and inf.StationId in ( select distinct inf.StationId from |
| | | (select StationId from db_battinf.tb_battinf union select StationId from db_pwrdev_inf.tb_pwrdev_inf ) 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> |