| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.constant.AlarmConstant; |
| | | import com.whyc.constant.DeviceConstant; |
| | | import com.whyc.dto.BatteryAlarmDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BatteryAlarmMapper; |
| | | import com.whyc.mapper.BatteryInfoMapper; |
| | | import com.whyc.mapper.Fbs9100StateMapper; |
| | | import com.whyc.pojo.FBS9100State; |
| | | import com.whyc.util.MathUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //容量低告警占比 |
| | | double capLowRate = BigDecimal.valueOf(alarmNum).divide(BigDecimal.valueOf(totalAlarmNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String capLowRateStr = (int)(capLowRate*100)+"%"; |
| | | String capLowRateStr = MathUtil.divide(alarmNum,totalAlarmNum); |
| | | //容量低告警机房占比 |
| | | double capLowStationRate = BigDecimal.valueOf(stationNum).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String capLowStationRateStr = (int)(capLowStationRate*100)+"%"; |
| | | String capLowStationRateStr = MathUtil.divide(stationNum,totalStationNum); |
| | | |
| | | resultMap.put("告警数",alarmNum); |
| | | resultMap.put("告警总数",totalAlarmNum); |
| | |
| | | */ |
| | | //TODO |
| | | public Response<Map> getOnlineAndGroupVolAnalysis(int userId) { |
| | | // select alm_signal_id,count(alm_signal_id) as num from db_alarm.tb_battalarm_data alarm where alm_id in (119001,119002,119003,119004) |
| | | Response<Map> response = new Response(); |
| | | HashMap<String, Object> resultMap = new HashMap<>(); |
| | | Map<String, Integer> resMap = new HashMap<>();//内阻测试数量 |
| | | Map<String, Integer> errMap = new HashMap<>();//故障数量 |
| | | Map<String, Object> disCharge = new HashMap<>();//放电电流 Alarm_curr_Discharge =119004 |
| | | Map<String, Object> reCharge = new HashMap<>();//充电电流 Alarm_curr_Charge =119003 |
| | | |
| | | try { |
| | | BatteryAlarmDto onlinebatteryAlarmDto = mapper.getOnlineAndGroupAlarms(AlarmConstant.Alarm_res_Monomer,AlarmConstant.ALM_SIGNAL_ID_OnlineVolHigh, userId); |
| | | BatteryAlarmDto groupbatteryAlarmDto = mapper.getOnlineAndGroupAlarms(AlarmConstant.Alarm_vol_Group,AlarmConstant.ALM_SIGNAL_ID_OnlineVolHigh, userId); |
| | | //放电电流高告警数量 |
| | | Integer dischargeHighAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_DisChargeCurrHigh); |
| | | |
| | | Integer highAlarmNum = onlinebatteryAlarmDto.getNum(); |
| | | Integer stationNum = onlinebatteryAlarmDto.getStationNum(); |
| | | resMap.put("高告警数量", 1); //高告警数量 alm_signal_id:online 1 high; 2 low |
| | | //告警总数 |
| | | Integer totalStationAlarmNum =mapper.getTotalAlarms(userId); |
| | | |
| | | resMap.put("低告警数量", 1); //低告警数量 |
| | | resMap.put("告警总数比例", 1); //告警总数比例 |
| | | //放电电流高告警机房数 |
| | | int dischargeTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.ALM_SIGNAL_ID_DisChargeCurrHigh); |
| | | |
| | | Integer totalAlarmNum = mapper.getTotalAlarms(userId); |
| | | resMap.put("告警总数", totalAlarmNum); //告警总数 |
| | | //总机房数 |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | Integer totalAlarmRooms = mapper.getTotalAlarmRooms(userId); |
| | | resMap.put("告警机房总数", 1); //告警机房总数 |
| | | //放电电流高告警占比 |
| | | String dischargeRateStr = MathUtil.divide(dischargeHighAlarmsNum,totalStationAlarmNum); |
| | | //放电电流高告警机房占比 |
| | | String dischargeStationRateStr = MathUtil.divide(dischargeTotalAlarmStations,totalStationNum); |
| | | |
| | | resMap.put("低告警机房数比例", 1); //低告警机房数比例 |
| | | resultMap.put("内阻测试数量", resMap); |
| | | 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); |
| | | |
| | | /*=====充电电流高======*/ |
| | | |
| | | errMap.put("高告警数量", 1); //高告警数量 |
| | | errMap.put("低告警数量", 1); //低告警数量 |
| | | errMap.put("告警总数比例", 1); //告警总数比例 |
| | | errMap.put("告警总数", 1); //告警总数 |
| | | errMap.put("告警机房总数", 1); //告警机房总数 |
| | | errMap.put("低告警机房数比例", 1); //低告警机房数比例 |
| | | resultMap.put("故障数量", errMap); |
| | | //放电电流高告警数量 |
| | | Integer chargeHighAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_ChargeCurrHigh); |
| | | |
| | | response.setCode(1); |
| | | response.setData(resultMap); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | response.setCode(0); |
| | | return response; |
| | | } |
| | | //放电电流高告警机房数 |
| | | int chargeTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.ALM_SIGNAL_ID_ChargeCurrHigh); |
| | | |
| | | return response; |
| | | //放电电流高告警占比 |
| | | 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); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * BTS 设备状态 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | //TODO |
| | | public Response<Map> getBTSEquipStatus(int userId) { |
| | | |
| | | Response<Map> response = new Response(); |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | try { |
| | | |
| | | |
| | | int devId = 910000001; |
| | | Integer herongNO = fbs9100StateMapper.getHeRongNO(devId, userId); //dev_workstate 0 在线浮充; 2 核容测试; 4 内阻测试; |
| | | // com.fgkj.dao.impl.ram.Fbs9100_stateImpl#seach6185Nuclear_cap 核容测试 |
| | | // Integer onlineFloatNO = fbs9100StateMapper.getOnlineFloatNO(devId,userId); |
| | | // Integer chargeNO = fbs9100StateMapper.getChargeNO(devId,userId); |
| | | // Integer resTestNO = fbs9100StateMapper.getResTestNO(devId,userId); |
| | | // Integer errNO = fbs9100StateMapper.getErrNO(devId,userId); |
| | | resultMap.put("核容数量", herongNO); //核容数量 |
| | | resultMap.put("在线浮充数量", 1); //在线浮充数量 |
| | | resultMap.put("充电数量", 1); //充电数量 |
| | | resultMap.put("内阻测试数量", 1); //内阻测试数量 |
| | | resultMap.put("故障数量", 1); //故障数量 |
| | | List<FBS9100State> statusList = fbs9100StateMapper.getStatus(userId); |
| | | for (int i = 0; i < statusList.size(); i++) { |
| | | switch (statusList.get(i).getWorkState()){ |
| | | case DeviceConstant.DEV_ONLINE_CHARGE: |
| | | resultMap.put("在线浮充",statusList.get(i).getNum()); |
| | | break; |
| | | case DeviceConstant.DEV_PRE_CHARGE: |
| | | resultMap.put("预充电",statusList.get(i).getNum()); |
| | | break; |
| | | case DeviceConstant.DEV_NUCLEAR_CAP: |
| | | resultMap.put("核容测试",statusList.get(i).getNum()); |
| | | break; |
| | | case DeviceConstant.DEV_RES_TEST: |
| | | resultMap.put("内阻测试",statusList.get(i).getNum()); |
| | | break; |
| | | } |
| | | } |
| | | response.setCode(1); |
| | | response.setData(resultMap); |
| | | } catch (Exception e) { |
| | |
| | | //总机房数 |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | //放电电流低告警占比 |
| | | double disChargeLowRate = BigDecimal.valueOf(disChargeAlarmNum).divide(BigDecimal.valueOf(totalAlarmNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String disChargeLowRateStr = (int)(disChargeLowRate*100)+"%"; |
| | | String disChargeLowRateStr = MathUtil.divide(disChargeAlarmNum,totalAlarmNum); |
| | | //放电电流低告警机房占比 |
| | | double disChargeLowStationRate = BigDecimal.valueOf(disChargeStationNum).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String disChargeLowStationRateStr = (int)(disChargeLowStationRate*100)+"%"; |
| | | String disChargeLowStationRateStr = MathUtil.divide(disChargeStationNum,totalStationNum); |
| | | |
| | | resultMap.put("低告警数量", disChargeAlarmNum); //低告警数量 alm_signal_id:DisChargeCurr 7 high; 8 low |
| | | resultMap.put("告警机房总数", disChargeStationNum); //告警机房总数 |
| | |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | //TODO |
| | | public Response<Map> getChargeAnalysis(int userId) { |
| | | |
| | | Response<Map> response = new Response(); |
| | | HashMap<String, Object> resultMap = new HashMap<>(); |
| | | Map<String, Integer> disCharge = new HashMap<>();//放电电流 Alarm_curr_Discharge =119004 |
| | | Map<String, Integer> reCharge = new HashMap<>();//充电电流 Alarm_curr_Charge =119003 |
| | | Map<String, Object> disCharge = new HashMap<>();//放电电流 Alarm_curr_Discharge =119004 |
| | | Map<String, Object> reCharge = new HashMap<>();//充电电流 Alarm_curr_Charge =119003 |
| | | |
| | | disCharge.put("高告警数量", 1); //高告警数量 alm_signal_id:ChargeCurrHigh 5 high; 6 low |
| | | disCharge.put("告警总数", 1); //告警总数 |
| | | disCharge.put("告警总数比例", 1); //告警总数比例 |
| | | disCharge.put("告警机房总数", 1); //告警机房总数 |
| | | disCharge.put("告警机房数比例", 1); //告警机房数比例 |
| | | //放电电流高告警数量 |
| | | Integer dischargeHighAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_DisChargeCurrHigh); |
| | | |
| | | //告警总数 |
| | | 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); |
| | | |
| | | reCharge.put("高告警数量", 1); //高告警数量 |
| | | reCharge.put("告警总数", 1); //告警总数 |
| | | reCharge.put("告警总数比例", 1); //告警总数比例 |
| | | reCharge.put("告警机房总数", 1); //告警机房总数 |
| | | reCharge.put("告警机房数比例", 1); //告警机房数比例 |
| | | /*=====充电电流高======*/ |
| | | |
| | | //放电电流高告警数量 |
| | | 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); |
| | | |
| | | response.setCode(1); |
| | | response.setData(resultMap); |
| | | return response; |
| | | return new Response<Map>().set(1,resultMap); |
| | | } |
| | | |
| | | |
| | |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //电压告警占比 |
| | | double volRate = BigDecimal.valueOf(volTotalAlarmNum).divide(BigDecimal.valueOf(totalStationAlarmNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String volRateStr = (int)(volRate*100)+"%"; |
| | | String volRateStr = MathUtil.divide(volTotalAlarmNum,totalStationAlarmNum); |
| | | //电压告警机房占比 |
| | | double volStationRate = BigDecimal.valueOf(volTotalAlarmStations).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String volStationRateStr = (int)(volStationRate*100)+"%"; |
| | | String volStationRateStr = MathUtil.divide(volTotalAlarmStations,totalStationNum); |
| | | |
| | | |
| | | monVolMap.put("高告警数量", volHighAlarmsNum); //高告警数量 alm_signal_id 9 |
| | |
| | | int resTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.Alarm_res_Monomer); |
| | | |
| | | //内阻告警占比 |
| | | double resRate = BigDecimal.valueOf(resTotalAlarmNum).divide(BigDecimal.valueOf(totalStationAlarmNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String resRateStr = (int)(resRate*100)+"%"; |
| | | String resRateStr = MathUtil.divide(resTotalAlarmNum,totalStationAlarmNum); |
| | | //内阻告警机房占比 |
| | | double resStationRate = BigDecimal.valueOf(resTotalAlarmStations).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String resStationRateStr = (int)(resStationRate*100)+"%"; |
| | | String resStationRateStr = MathUtil.divide(resTotalAlarmStations,totalStationNum); |
| | | |
| | | monResMap.put("高告警数量", resHighAlarmsNum); //高告警数量 alm_signal_id 13 |
| | | monResMap.put("低告警数量", resLowAlarmsNum); //低告警数量 alm_signal_id 14 |
| | |
| | | int tempTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.Alarm_tmp_Monomer); |
| | | |
| | | //温度告警占比 |
| | | double tempRate = BigDecimal.valueOf(tempTotalAlarmNum).divide(BigDecimal.valueOf(totalStationAlarmNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String tempRateStr = (int)(tempRate*100)+"%"; |
| | | String tempRateStr = MathUtil.divide(tempTotalAlarmNum,totalStationAlarmNum); |
| | | //温度告警机房占比 |
| | | double tempStationRate = BigDecimal.valueOf(tempTotalAlarmStations).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue(); |
| | | String tempStationRateStr = (int)(tempStationRate*100)+"%"; |
| | | String tempStationRateStr = MathUtil.divide(tempTotalAlarmStations,totalStationNum); |
| | | |
| | | monTemMap.put("高告警数量", tempHighAlarmsNum); //高告警数量 alm_signal_id 13 |
| | | monTemMap.put("低告警数量", tempLowAlarmsNum); //低告警数量 alm_signal_id 14 |
| | |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 单个告警-通过告警标识id |
| | | * @param userId |
| | | * @param alarmSignalId |
| | | * @param key1 |
| | | * @return |
| | | */ |
| | | public Map<String,Object> getSingleAnalysisOfSignal(int userId,int alarmSignalId,String alarmName){ |
| | | Map<String, Object> resMap = new HashMap<>(); |
| | | |
| | | //告警数量 |
| | | Integer alarmNum = mapper.getAlarmHighLow(userId,alarmSignalId); |
| | | |
| | | //告警总数 |
| | | Integer totalAlarmNum =mapper.getTotalAlarms(userId); |
| | | |
| | | //告警机房数 |
| | | int alarmStationNum = mapper.getTotalAlarmStations(userId,alarmSignalId); |
| | | |
| | | //总机房数 |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //告警占比 |
| | | String rate = MathUtil.divide(alarmNum,totalAlarmNum); |
| | | //告警机房占比 |
| | | String stationRate = MathUtil.divide(alarmStationNum,totalStationNum); |
| | | |
| | | resMap.put(alarmName,alarmNum); //告警数量 |
| | | resMap.put("告警总数", totalAlarmNum); //告警总数 |
| | | resMap.put("告警总数比例", rate); //告警总数比例 |
| | | resMap.put("告警机房总数", totalStationNum); //告警机房总数 |
| | | resMap.put("告警机房数比例", stationRate); //告警机房数比例 |
| | | return resMap; |
| | | } |
| | | |
| | | /** |
| | | * 2个告警-通过告警id,告警标识id |
| | | * @param userId |
| | | * @param alarmSignalId |
| | | * @param key1 |
| | | * @return |
| | | */ |
| | | public Map<String,Object> getDoubleAnalysis(int userId,int alarmId,int alarmSignalId, |
| | | String alarmName1,String alarmName2,String mapName1,String mapName2){ |
| | | Map<String,Map> res = new HashMap<>(); |
| | | Map<String, Object> resMap1 = new HashMap<>(); |
| | | Map<String, Object> resMap2 = new HashMap<>(); |
| | | |
| | | //告警数量 |
| | | Integer alarmNum = mapper.getAlarmHighLow(userId,alarmSignalId); |
| | | |
| | | //告警总数 |
| | | Integer totalAlarmNum =mapper.getTotalAlarms(userId); |
| | | |
| | | //告警机房数 |
| | | int alarmStationNum = mapper.getTotalAlarmStations(userId,alarmSignalId); |
| | | |
| | | //总机房数 |
| | | int totalStationNum = infoMapper.getStationCount(userId); |
| | | |
| | | //告警占比 |
| | | String rate = MathUtil.divide(alarmNum,totalAlarmNum); |
| | | //告警机房占比 |
| | | String stationRate = MathUtil.divide(alarmStationNum,totalStationNum); |
| | | |
| | | resMap1.put(alarmName1,alarmNum); //告警数量 |
| | | resMap1.put("告警总数", totalAlarmNum); //告警总数 |
| | | resMap1.put("告警总数比例", rate); //告警总数比例 |
| | | resMap1.put("告警机房总数", totalStationNum); //告警机房总数 |
| | | resMap1.put("告警机房数比例", stationRate); //告警机房数比例 |
| | | |
| | | return null; |
| | | } |
| | | |
| | | } |