public Map<String, Object> checkByPassVoltage(UpsStatus upsStatus, AlarmRule alarmRule) { Map<String, Object> byPassVoltageMap = new HashMap<String, Object>(); StateEnum runState = StateEnum.good; StringBuffer alarmContent = new StringBuffer(); StringBuffer alarmRuleType = new StringBuffer(); OperationType operationType = alarmRule.getOperationType(); Integer value = alarmRule.getValue(); Integer minValue = alarmRule.getMinValue(); Integer maxValue = alarmRule.getMaxValue(); if (upsStatus.getBypassVoltage() != null) { String byPassVoltage = upsStatus.getBypassVoltage(); // 旁路电压一 Double byPassVoltage_1 = Double.parseDouble(byPassVoltage.substring(0, byPassVoltage.indexOf("V"))); // 判断UPS是三相电 if (upsStatus.getUpsType() == 2 || upsStatus.getUpsType() == 3) { // 旁路电压二 Double byPassVoltage_2 = Double.parseDouble( byPassVoltage.substring( byPassVoltage.indexOf("/") + 1, byPassVoltage.lastIndexOf("/") - 1)); // 旁路电压三 Double byPassVoltage_3 = Double.parseDouble( byPassVoltage.substring( byPassVoltage.lastIndexOf("/") + 1, byPassVoltage.length() - 1)); runState = alarmRuleService.ruleCompare( operationType, byPassVoltage_2, value, minValue, maxValue, alarmRule.getState()); runState = alarmRuleService.ruleCompare( operationType, byPassVoltage_3, value, minValue, maxValue, alarmRule.getState()); } runState = alarmRuleService.ruleCompare( operationType, byPassVoltage_1, value, minValue, maxValue, alarmRule.getState()); } if (runState != StateEnum.good) { alarmContent.append("").append(alarmRule.getRemark()).append("、"); alarmRuleType.append(alarmRule.getAlarmRuleType()).append("、"); } byPassVoltageMap.put("runState", runState); byPassVoltageMap.put("alarmContent", alarmContent.toString()); byPassVoltageMap.put("alarmRuleType", alarmRuleType.toString()); return byPassVoltageMap; }
@Override public Map<String, Object> upsDeviceAlarm(UpsStatus upsStatus, AlarmCondition alarmCondition) { Map<String, Object> alarmResultMap = new HashMap<String, Object>(); StateEnum runState = StateEnum.good; List<AlarmRule> alarmRules = alarmRuleDao.getListByConditionIdAndAlarmOptionType( alarmCondition.getId(), AlarmOptionType.UPS); StringBuffer alarmContent = new StringBuffer(); StringBuffer alarmRuleType = new StringBuffer(); for (AlarmRule alarmRule : alarmRules) { // 通讯状态规则 if (alarmRule.getAlarmRuleType() == AlarmRuleType.COMMUNICATIONSTATUS) { Map<String, Object> communicationStatusMap = checkCommunicationStatus(upsStatus, alarmRule); if (runState.ordinal() < StateEnum.valueOf(communicationStatusMap.get("runState").toString()).ordinal()) { runState = StateEnum.valueOf(communicationStatusMap.get("runState").toString()); } alarmContent.append(communicationStatusMap.get("alarmContent").toString()); alarmRuleType.append(communicationStatusMap.get("alarmRuleType").toString()); } if (alarmRule.getAlarmRuleType() == AlarmRuleType.BYPASSVOLTAGE) { // UPS旁路电压 if (upsStatus.getBypassVoltage() != null) { Map<String, Object> byPassVoltageMap = checkByPassVoltage(upsStatus, alarmRule); if (runState.ordinal() < StateEnum.valueOf(byPassVoltageMap.get("runState").toString()).ordinal()) { runState = StateEnum.valueOf(byPassVoltageMap.get("runState").toString()); } alarmContent.append(byPassVoltageMap.get("alarmContent").toString()); alarmRuleType.append(byPassVoltageMap.get("alarmRuleType").toString()); } } if (alarmRule.getAlarmRuleType() == AlarmRuleType.INPUTVOLTAGE) { if (upsStatus.getInputVoltage() != null) { Map<String, Object> inputVoltageMap = checkInputVoltage(upsStatus, alarmRule); if (runState.ordinal() < StateEnum.valueOf(inputVoltageMap.get("runState").toString()).ordinal()) { runState = StateEnum.valueOf(inputVoltageMap.get("runState").toString()); } alarmContent.append(inputVoltageMap.get("alarmContent").toString()); alarmRuleType.append(inputVoltageMap.get("alarmRuleType").toString()); } } if (alarmRule.getAlarmRuleType() == AlarmRuleType.OUTPUTVOLTAGE) { if (upsStatus.getOutputVoltage() != null) { Map<String, Object> outputVoltageMap = checkOutputVoltage(upsStatus, alarmRule); if (runState.ordinal() < StateEnum.valueOf(outputVoltageMap.get("runState").toString()).ordinal()) { runState = StateEnum.valueOf(outputVoltageMap.get("runState").toString()); } alarmContent.append(outputVoltageMap.get("alarmContent").toString()); alarmRuleType.append(outputVoltageMap.get("alarmRuleType").toString()); } } // 机内温度规则 if (alarmRule.getAlarmRuleType() == AlarmRuleType.INTERNALTEMPERATURE) { Map<String, Object> internalTemperatureMap = checkInternalTemperature(upsStatus, alarmRule); if (runState.ordinal() < StateEnum.valueOf(internalTemperatureMap.get("runState").toString()).ordinal()) { runState = StateEnum.valueOf(internalTemperatureMap.get("runState").toString()); } alarmContent.append(internalTemperatureMap.get("alarmContent").toString()); alarmRuleType.append(internalTemperatureMap.get("alarmRuleType").toString()); } // 电池电压 if (alarmRule.getAlarmRuleType() == AlarmRuleType.BATTERYVOLTAGE) { Map<String, Object> batteryVoltageMap = checkBatteryVoltage(upsStatus, alarmRule); if (runState.ordinal() < StateEnum.valueOf(batteryVoltageMap.get("runState").toString()).ordinal()) { runState = StateEnum.valueOf(batteryVoltageMap.get("runState").toString()); } alarmContent.append(batteryVoltageMap.get("alarmContent").toString()); alarmRuleType.append(batteryVoltageMap.get("alarmRuleType").toString()); } if (upsStatus.getUpsType() != 2 && upsStatus.getUpsType() != 3) { // 电池电量 if (alarmRule.getAlarmRuleType() == AlarmRuleType.ELECTRICQUANTITY) { Map<String, Object> electricQuantityMap = checkElectricQuantity(upsStatus, alarmRule); if (runState.ordinal() < StateEnum.valueOf(electricQuantityMap.get("runState").toString()).ordinal()) { runState = StateEnum.valueOf(electricQuantityMap.get("runState").toString()); } alarmContent.append(electricQuantityMap.get("alarmContent").toString()); alarmRuleType.append(electricQuantityMap.get("alarmRuleType").toString()); } } // 负载 if (alarmRule.getAlarmRuleType() == AlarmRuleType.LOAD) { Map<String, Object> loadMap = checkLoad(upsStatus, alarmRule); if (runState.ordinal() < StateEnum.valueOf(loadMap.get("runState").toString()).ordinal()) { runState = StateEnum.valueOf(loadMap.get("runState").toString()); } alarmContent.append(loadMap.get("alarmContent").toString()); alarmContent.append(loadMap.get("alarmRuleType").toString()); } } if (alarmContent.indexOf("、") > 0) { alarmContent = new StringBuffer(alarmContent.substring(0, alarmContent.length() - 1)); alarmRuleType = new StringBuffer(alarmRuleType.substring(0, alarmRuleType.length() - 1)); } alarmResultMap.put("runState", runState); alarmResultMap.put("alarmContent", alarmContent.toString()); alarmResultMap.put("alarmRuleType", alarmRuleType.toString()); return alarmResultMap; }