| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.constant.AlarmConstant; |
| | | import com.whyc.constant.BatteryConstant; |
| | | import com.whyc.constant.DeviceConstant; |
| | | import com.whyc.dto.BatteryAlarmDto; |
| | | import com.whyc.dto.Response; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | //TODO |
| | | public Response<Map> getOnlineAndGroupVolAnalysis(int userId) { |
| | | HashMap<String, Object> resultMap = new HashMap<>(); |
| | | Map<String, Object> disCharge = new HashMap<>();//放电电流 Alarm_curr_Discharge =119004 |
| | | Map<String, Object> reCharge = new HashMap<>();//充电电流 Alarm_curr_Charge =119003 |
| | | List<Integer> alarmIds = Arrays.asList(AlarmConstant.Alarm_vol_Online,AlarmConstant.Alarm_vol_Group); |
| | | List<String> alarmNames =Arrays.asList("在线电压","组端电压"); |
| | | List<Integer> alarmSignalIds = Arrays.asList( |
| | | AlarmConstant.ALM_SIGNAL_ID_OnlineVolHigh,AlarmConstant.ALM_SIGNAL_ID_OnlineVolLow, |
| | | AlarmConstant.ALM_SIGNAL_ID_GroupVolHigh,AlarmConstant.ALM_SIGNAL_ID_GroupVolLow); |
| | | String mapName1 = "高告警数量"; |
| | | String mapName2 = "低告警数量"; |
| | | |
| | | //放电电流高告警数量 |
| | | Integer dischargeHighAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_DisChargeCurrHigh); |
| | | Map<String, Map> doubleAnalysis = getDoubleAnalysis(userId, alarmIds, alarmSignalIds, alarmNames, mapName1, mapName2); |
| | | |
| | | //告警总数 |
| | | Integer totalStationAlarmNum =mapper.getTotalAlarms(userId); |
| | | |
| | | //放电电流高告警机房数 |
| | | int dischargeTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.ALM_SIGNAL_ID_DisChargeCurrHigh); |
| | | |
| | | //总机房数 |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //放电电流高告警占比 |
| | | String dischargeRateStr = MathUtil.divide(dischargeHighAlarmsNum,totalStationAlarmNum); |
| | | //放电电流高告警机房占比 |
| | | String dischargeStationRateStr = MathUtil.divide(dischargeTotalAlarmStations,totalStationNum); |
| | | |
| | | disCharge.put("高告警数量",dischargeHighAlarmsNum); //高告警数量 alm_signal_id:ChargeCurrHigh 5 high; 6 low |
| | | disCharge.put("告警总数",totalStationAlarmNum); //告警总数 |
| | | disCharge.put("告警总数比例", dischargeRateStr); //告警总数比例 |
| | | disCharge.put("告警机房总数", dischargeTotalAlarmStations); //告警机房总数 |
| | | disCharge.put("告警机房数比例",dischargeStationRateStr); //告警机房数比例 |
| | | resultMap.put("disCharge", disCharge); |
| | | |
| | | /*=====充电电流高======*/ |
| | | |
| | | //放电电流高告警数量 |
| | | Integer chargeHighAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_ChargeCurrHigh); |
| | | |
| | | //放电电流高告警机房数 |
| | | int chargeTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.ALM_SIGNAL_ID_ChargeCurrHigh); |
| | | |
| | | //放电电流高告警占比 |
| | | String chargeRateStr = MathUtil.divide(chargeHighAlarmsNum,totalStationAlarmNum); |
| | | //放电电流高告警机房占比 |
| | | String chargeStationRateStr = MathUtil.divide(chargeTotalAlarmStations,totalStationNum); |
| | | |
| | | reCharge.put("高告警数量", chargeHighAlarmsNum); //高告警数量 |
| | | reCharge.put("告警总数", totalStationAlarmNum); //告警总数 |
| | | reCharge.put("告警总数比例", chargeRateStr); //告警总数比例 |
| | | reCharge.put("告警机房总数", chargeTotalAlarmStations); //告警机房总数 |
| | | reCharge.put("告警机房数比例", chargeStationRateStr); //告警机房数比例 |
| | | resultMap.put("reCharge", reCharge); |
| | | |
| | | return new Response<Map>().set(1,resultMap); |
| | | return new Response<Map>().set(1,doubleAnalysis); |
| | | } |
| | | |
| | | public Response<Map> getBTSEquipStatus(int userId) { |
| | |
| | | * 单个告警-通过告警标识id |
| | | * @param userId |
| | | * @param alarmSignalId |
| | | * @param key1 |
| | | * @param alarmName |
| | | * @return |
| | | */ |
| | | public Map<String,Object> getSingleAnalysisOfSignal(int userId,int alarmSignalId,String alarmName){ |
| | | private Map<String,Object> getSingleAnalysisOfSignal(int userId,int alarmSignalId,String alarmName){ |
| | | Map<String, Object> resMap = new HashMap<>(); |
| | | |
| | | //告警数量 |
| | |
| | | /** |
| | | * 2个告警-通过告警id,告警标识id |
| | | * @param userId |
| | | * @param alarmSignalId |
| | | * @param key1 |
| | | * @param alarmIds 告警id列表 |
| | | * @param alarmSignalIds 告警标识id列表,为@alarmIds的两倍 |
| | | * @param alarmNames 告警名称,是单体电压/单体xxx |
| | | * @param mapName1 map的名1 |
| | | * @param mapName2 map的名2 |
| | | * @return |
| | | */ |
| | | public Map<String,Object> getDoubleAnalysis(int userId,int alarmId,int alarmSignalId, |
| | | String alarmName1,String alarmName2,String mapName1,String mapName2){ |
| | | private Map<String,Map> getDoubleAnalysis(int userId,List<Integer> alarmIds,List<Integer> alarmSignalIds, |
| | | List<String> alarmNames,String mapName1,String mapName2){ |
| | | Map<String,Map> res = new HashMap<>(); |
| | | Map<String, Object> resMap1 = new HashMap<>(); |
| | | Map<String, Object> resMap2 = new HashMap<>(); |
| | | for (int i = 0; i < alarmIds.size(); i++) { |
| | | Map<String, Object> resMap = new HashMap<>(); |
| | | //告警1数量 |
| | | Integer alarmNum = mapper.getAlarmHighLow(userId,alarmSignalIds.get(i)); |
| | | //告警2数量 |
| | | Integer alarmNum2 = mapper.getAlarmHighLow(userId,alarmSignalIds.get(i)+1); |
| | | |
| | | //告警数量 |
| | | Integer alarmNum = mapper.getAlarmHighLow(userId,alarmSignalId); |
| | | //告警总数 |
| | | Integer totalAlarmNum =alarmNum+alarmNum2; |
| | | |
| | | //告警总数 |
| | | Integer totalAlarmNum =mapper.getTotalAlarms(userId); |
| | | //总告警数 |
| | | Integer totalAlarms = mapper.getTotalAlarms(userId); |
| | | |
| | | //告警机房数 |
| | | int alarmStationNum = mapper.getTotalAlarmStations(userId,alarmSignalId); |
| | | //告警机房数 |
| | | int alarmStationNum = mapper.getTotalAlarmStations(userId,alarmIds.get(i)); |
| | | |
| | | //总机房数 |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | //总机房数 |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //告警占比 |
| | | String rate = MathUtil.divide(alarmNum,totalAlarmNum); |
| | | //告警机房占比 |
| | | String stationRate = MathUtil.divide(alarmStationNum,totalStationNum); |
| | | //告警占比 |
| | | String rate = MathUtil.divide(totalAlarmNum,totalAlarms); |
| | | //告警机房占比 |
| | | String stationRate = MathUtil.divide(alarmStationNum,totalStationNum); |
| | | |
| | | resMap1.put(alarmName1,alarmNum); //告警数量 |
| | | resMap1.put("告警总数", totalAlarmNum); //告警总数 |
| | | resMap1.put("告警总数比例", rate); //告警总数比例 |
| | | resMap1.put("告警机房总数", totalStationNum); //告警机房总数 |
| | | resMap1.put("告警机房数比例", stationRate); //告警机房数比例 |
| | | |
| | | return null; |
| | | resMap.put(mapName1,alarmNum); //告警1数量 |
| | | resMap.put(mapName2,alarmNum2); //告警2数量 |
| | | resMap.put("告警总数", totalAlarmNum); //告警总数 |
| | | resMap.put("告警总数比例", rate); //告警总数比例 |
| | | resMap.put("告警机房总数", alarmStationNum); //告警机房总数 |
| | | resMap.put("告警机房数比例", stationRate); //告警机房数比例 |
| | | res.put(alarmNames.get(i),resMap); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | } |