package com.whyc.service;
|
|
import com.whyc.constant.AlarmConstant;
|
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 org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
@Service
|
public class BatteryAlarmService {
|
|
@Resource
|
private BatteryAlarmMapper mapper;
|
|
@Resource
|
private Fbs9100StateMapper fbs9100StateMapper;
|
|
@Resource
|
private BatteryInfoMapper infoMapper;
|
|
/**
|
* 单体容量 monCapStd
|
* alm_id
|
* Alarm_CapAlarm =119010
|
* @param userId
|
* @return
|
*/
|
public Response<Map> getMonCapacityLowAnalysis(int userId) {
|
Response<Map> response = new Response();
|
Map<String, Object> resultMap = new HashMap<>();
|
|
try {
|
//单体容量低告警数和对应的告警机房数
|
BatteryAlarmDto batteryAlarmDto = mapper.getLowCapacityAlarms(userId,AlarmConstant.Alarm_IGNAL_ID_CapAlarmLow);
|
int alarmNum = batteryAlarmDto.getNum();
|
int stationNum = batteryAlarmDto.getStationNum();
|
//总告警数
|
Integer totalAlarmNum = mapper.getTotalAlarms(userId);
|
//总机房数
|
int totalStationNum = infoMapper.getStationCount(userId);
|
|
//容量低告警占比
|
double capLowRate = BigDecimal.valueOf(alarmNum).divide(BigDecimal.valueOf(totalAlarmNum), 2, RoundingMode.HALF_UP).doubleValue();
|
String capLowRateStr = (int)(capLowRate*100)+"%";
|
//容量低告警机房占比
|
double capLowStationRate = BigDecimal.valueOf(stationNum).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue();
|
String capLowStationRateStr = (int)(capLowStationRate*100)+"%";
|
|
resultMap.put("告警数",alarmNum);
|
resultMap.put("告警总数",totalAlarmNum);
|
resultMap.put("告警占比",capLowRateStr);
|
|
resultMap.put("告警机房数",alarmNum);
|
resultMap.put("告警机房占比",capLowStationRateStr);
|
|
response.set(1, resultMap);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return response.set(0);
|
}
|
return response;
|
}
|
|
/**
|
* 在线电压和组端电压
|
* alm_id 电池告警参数
|
* Alarm_vol_Online =119001
|
* Alarm_vol_Group =119002
|
*
|
* @param userId
|
* @return
|
*/
|
//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<>();//故障数量
|
|
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 highAlarmNum = onlinebatteryAlarmDto.getNum();
|
Integer stationNum = onlinebatteryAlarmDto.getStationNum();
|
resMap.put("高告警数量", 1); //高告警数量 alm_signal_id:online 1 high; 2 low
|
|
resMap.put("低告警数量", 1); //低告警数量
|
resMap.put("告警总数比例", 1); //告警总数比例
|
|
Integer totalAlarmNum = mapper.getTotalAlarms(userId);
|
resMap.put("告警总数", totalAlarmNum); //告警总数
|
|
Integer totalAlarmRooms = mapper.getTotalAlarmRooms(userId);
|
resMap.put("告警机房总数", 1); //告警机房总数
|
|
resMap.put("低告警机房数比例", 1); //低告警机房数比例
|
resultMap.put("内阻测试数量", resMap);
|
|
|
errMap.put("高告警数量", 1); //高告警数量
|
errMap.put("低告警数量", 1); //低告警数量
|
errMap.put("告警总数比例", 1); //告警总数比例
|
errMap.put("告警总数", 1); //告警总数
|
errMap.put("告警机房总数", 1); //告警机房总数
|
errMap.put("低告警机房数比例", 1); //低告警机房数比例
|
resultMap.put("故障数量", errMap);
|
|
response.setCode(1);
|
response.setData(resultMap);
|
} catch (Exception e) {
|
e.printStackTrace();
|
response.setCode(0);
|
return response;
|
}
|
|
return response;
|
}
|
|
|
/**
|
* 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); //故障数量
|
response.setCode(1);
|
response.setData(resultMap);
|
} catch (Exception e) {
|
e.printStackTrace();
|
response.setCode(0);
|
return response;
|
}
|
return response;
|
}
|
|
|
/**
|
* 放电电流 Alarm_curr_Discharge =119004
|
* alm_signal_id 查询条件 ALM_SIGNAL_ID_DisChargeCurrLow
|
* @param userId
|
* @return
|
*/
|
public Response<Map> getDischargeAnalysis(int userId) {
|
|
Response<Map> response = new Response();
|
Map<String, Object> resultMap = new HashMap<>();
|
|
try {
|
//放电电流低告警数和对应的告警机房数
|
BatteryAlarmDto batteryAlarmDto = mapper.getLowDischargeAlarms(userId,AlarmConstant.ALM_SIGNAL_ID_DisChargeCurrLow);
|
int disChargeAlarmNum = batteryAlarmDto.getNum();
|
int disChargeStationNum = batteryAlarmDto.getStationNum();
|
|
//总告警数
|
Integer totalAlarmNum = mapper.getTotalAlarms(userId);
|
//总机房数
|
int totalStationNum = infoMapper.getStationCount(userId);
|
//放电电流低告警占比
|
double disChargeLowRate = BigDecimal.valueOf(disChargeAlarmNum).divide(BigDecimal.valueOf(totalAlarmNum), 2, RoundingMode.HALF_UP).doubleValue();
|
String disChargeLowRateStr = (int)(disChargeLowRate*100)+"%";
|
//放电电流低告警机房占比
|
double disChargeLowStationRate = BigDecimal.valueOf(disChargeStationNum).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue();
|
String disChargeLowStationRateStr = (int)(disChargeLowStationRate*100)+"%";
|
|
resultMap.put("低告警数量", disChargeAlarmNum); //低告警数量 alm_signal_id:DisChargeCurr 7 high; 8 low
|
resultMap.put("告警机房总数", disChargeStationNum); //告警机房总数
|
resultMap.put("告警机房数比例", disChargeLowRateStr); //告警机房数比例
|
resultMap.put("告警总数", totalAlarmNum); //告警总数
|
resultMap.put("告警总数比例", disChargeLowStationRateStr); //告警总数比例
|
response.setCode(1);
|
response.setData(resultMap);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return response.setCode(0);
|
}
|
return response;
|
}
|
|
/**
|
* 放电和充电电流 高
|
* alm_id 电池告警参数
|
* @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
|
|
disCharge.put("高告警数量", 1); //高告警数量 alm_signal_id:ChargeCurrHigh 5 high; 6 low
|
disCharge.put("告警总数", 1); //告警总数
|
disCharge.put("告警总数比例", 1); //告警总数比例
|
disCharge.put("告警机房总数", 1); //告警机房总数
|
disCharge.put("告警机房数比例", 1); //告警机房数比例
|
resultMap.put("disCharge", disCharge);
|
|
reCharge.put("高告警数量", 1); //高告警数量
|
reCharge.put("告警总数", 1); //告警总数
|
reCharge.put("告警总数比例", 1); //告警总数比例
|
reCharge.put("告警机房总数", 1); //告警机房总数
|
reCharge.put("告警机房数比例", 1); //告警机房数比例
|
resultMap.put("reCharge", reCharge);
|
|
response.setCode(1);
|
response.setData(resultMap);
|
return response;
|
}
|
|
|
/**
|
* 单体电压、内阻和温度
|
* alm_id 电池告警参数
|
* 三个告警总数不同,带条件?电压、内阻、温度
|
* @param userId
|
* @return
|
*/
|
public Response<Map> getMonVRTAnalysis(int userId) {
|
|
Response<Map> response = new Response();
|
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
|
Map<String, Object> monTemMap = new HashMap<>();//单体温度 Alarm_tmp_Monomer =119006
|
|
/*======单体电压======*/
|
|
//高告警数量
|
Integer volHighAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_MonVolHigh);
|
//低告警数量
|
Integer volLowAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_MonVolLow);
|
|
//单体电压总告警数
|
Integer volTotalAlarmNum = volHighAlarmsNum+volLowAlarmsNum;
|
|
//告警总数
|
Integer totalStationAlarmNum =mapper.getTotalAlarms(userId);
|
|
//电压告警机房数
|
int volTotalAlarmStations = mapper.getTotalAlarmStations(userId,AlarmConstant.Alarm_vol_Monomer);
|
|
//总机房数
|
int totalStationNum = infoMapper.getStationCount(userId);
|
|
//电压告警占比
|
double volRate = BigDecimal.valueOf(volTotalAlarmNum).divide(BigDecimal.valueOf(totalStationAlarmNum), 2, RoundingMode.HALF_UP).doubleValue();
|
String volRateStr = (int)(volRate*100)+"%";
|
//电压告警机房占比
|
double volStationRate = BigDecimal.valueOf(volTotalAlarmStations).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue();
|
String volStationRateStr = (int)(volStationRate*100)+"%";
|
|
|
monVolMap.put("高告警数量", volHighAlarmsNum); //高告警数量 alm_signal_id 9
|
monVolMap.put("低告警数量", volLowAlarmsNum); //低告警数量 alm_signal_id 10
|
monVolMap.put("告警总数", volTotalAlarmNum); //告警总数
|
monVolMap.put("告警总数比例", volRateStr); //告警总数比例
|
monVolMap.put("告警机房总数", volTotalAlarmStations); //告警机房总数
|
monVolMap.put("告警机房数比例", volStationRateStr); //告警机房数比例
|
resultMap.put("单体电压", monVolMap);
|
|
|
|
/*======单体内阻======*/
|
|
//高告警数量
|
Integer resHighAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_MonResHigh);
|
//低告警数量
|
Integer resLowAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_MonResLow);
|
|
//单体内阻总告警数
|
Integer resTotalAlarmNum = resHighAlarmsNum+resLowAlarmsNum;
|
|
//内阻告警机房数
|
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)+"%";
|
//内阻告警机房占比
|
double resStationRate = BigDecimal.valueOf(resTotalAlarmStations).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue();
|
String resStationRateStr = (int)(resStationRate*100)+"%";
|
|
monResMap.put("高告警数量", resHighAlarmsNum); //高告警数量 alm_signal_id 13
|
monResMap.put("低告警数量", resLowAlarmsNum); //低告警数量 alm_signal_id 14
|
monResMap.put("告警总数", resTotalAlarmNum); //告警总数
|
monResMap.put("告警总数比例", resRateStr); //告警总数比例
|
monResMap.put("告警机房总数", resTotalAlarmStations); //告警机房总数
|
monResMap.put("告警机房数比例", resStationRateStr); //告警机房数比例
|
resultMap.put("单体内阻", monResMap);
|
|
/*======单体温度======*/
|
|
//高告警数量
|
Integer tempHighAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_MonTmpHigh);
|
//低告警数量
|
Integer tempLowAlarmsNum = mapper.getAlarmHighLow(userId,AlarmConstant.ALM_SIGNAL_ID_MonTmpLow);
|
|
//单体温度总告警数
|
Integer tempTotalAlarmNum = tempHighAlarmsNum+tempLowAlarmsNum;
|
|
//温度告警机房数
|
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)+"%";
|
//温度告警机房占比
|
double tempStationRate = BigDecimal.valueOf(tempTotalAlarmStations).divide(BigDecimal.valueOf(totalStationNum), 2, RoundingMode.HALF_UP).doubleValue();
|
String tempStationRateStr = (int)(tempStationRate*100)+"%";
|
|
monTemMap.put("高告警数量", tempHighAlarmsNum); //高告警数量 alm_signal_id 13
|
monTemMap.put("低告警数量", tempLowAlarmsNum); //低告警数量 alm_signal_id 14
|
monTemMap.put("告警总数", tempTotalAlarmNum); //告警总数
|
monTemMap.put("告警总数比例", tempRateStr); //告警总数比例
|
monTemMap.put("告警机房总数", tempTotalAlarmStations); //告警机房总数
|
monTemMap.put("告警机房数比例", tempStationRateStr); //告警机房数比例
|
resultMap.put("单体温度", monTemMap);
|
|
response.setCode(1);
|
response.setData(resultMap);
|
return response;
|
}
|
|
}
|