示例#1
1
 public Map<String, Object> checkCommunicationStatus(UpsStatus upsStatus, AlarmRule alarmRule) {
   Map<String, Object> communicationStatusMap = 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();
   runState =
       alarmRuleService.ruleCompare(
           operationType,
           Double.parseDouble(upsStatus.getCommunicationStatus() + ""),
           value,
           minValue,
           maxValue,
           alarmRule.getState());
   if (runState != StateEnum.good) {
     alarmContent.append("").append(alarmRule.getRemark()).append("、");
     alarmRuleType.append(alarmRule.getAlarmRuleType()).append("、");
   }
   communicationStatusMap.put("runState", runState);
   communicationStatusMap.put("alarmContent", alarmContent.toString());
   communicationStatusMap.put("alarmRuleType", alarmRuleType.toString());
   return communicationStatusMap;
 }
示例#2
0
 public Map<String, Object> checkElectricQuantity(UpsStatus upsStatus, AlarmRule alarmRule) {
   Map<String, Object> electricQuantityMap = 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();
   runState =
       alarmRuleService.ruleCompare(
           operationType,
           upsStatus.getElectricQuantity(),
           value,
           minValue,
           maxValue,
           alarmRule.getState());
   if (runState != StateEnum.good) {
     alarmContent.append("").append(alarmRule.getRemark()).append("、");
     alarmRuleType.append(alarmRule.getAlarmRuleType()).append("、");
   }
   electricQuantityMap.put("runState", runState);
   electricQuantityMap.put("alarmContent", alarmContent.toString());
   electricQuantityMap.put("alarmRuleType", alarmRuleType.toString());
   return electricQuantityMap;
 }
示例#3
0
 @Override
 public Map<String, Object> checkBatteryVoltage(UpsStatus upsStatus, AlarmRule alarmRule) {
   Map<String, Object> batteryVoltageMap = 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();
   runState =
       alarmRuleService.ruleCompare(
           operationType,
           Double.parseDouble(upsStatus.getBatteryVoltage() + ""),
           value,
           minValue,
           maxValue,
           alarmRule.getState());
   if (runState == StateEnum.error) {
     alarmContent.append("").append(alarmRule.getRemark()).append("、");
     alarmRuleType.append(alarmRule.getAlarmRuleType()).append("、");
   }
   batteryVoltageMap.put("runState", runState);
   batteryVoltageMap.put("alarmContent", alarmContent.toString());
   batteryVoltageMap.put("alarmRuleType", alarmRuleType.toString());
   return batteryVoltageMap;
 }
示例#4
0
  @Override
  public Map<String, Object> checkOutputVoltage(UpsStatus upsStatus, AlarmRule alarmRule) {
    Map<String, Object> outputVoltageMap = 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.getOutputVoltage() != null) {
      String outputVoltage = upsStatus.getOutputVoltage();
      // 输出电压一
      Double outputVoltage_1 =
          Double.parseDouble(outputVoltage.substring(0, outputVoltage.indexOf("V")));
      // 判断UPS是三相电
      if (upsStatus.getUpsType() == 2 || upsStatus.getUpsType() == 3) {
        // 输出电压二
        Double outputVoltage_2 =
            Double.parseDouble(
                outputVoltage.substring(
                    outputVoltage.indexOf("/") + 1, outputVoltage.lastIndexOf("/") - 1));
        // 输出电压三
        Double outputVoltage_3 =
            Double.parseDouble(
                outputVoltage.substring(
                    outputVoltage.lastIndexOf("/") + 1, outputVoltage.length() - 1));
        runState =
            alarmRuleService.ruleCompare(
                operationType, outputVoltage_2, value, minValue, maxValue, alarmRule.getState());
        runState =
            alarmRuleService.ruleCompare(
                operationType, outputVoltage_3, value, minValue, maxValue, alarmRule.getState());
      }

      runState =
          alarmRuleService.ruleCompare(
              operationType, outputVoltage_1, value, minValue, maxValue, alarmRule.getState());
    }
    if (runState != StateEnum.good) {
      alarmContent.append("").append(alarmRule.getRemark()).append("、");
      alarmRuleType.append(alarmRule.getAlarmRuleType()).append("、");
    }
    outputVoltageMap.put("runState", runState);
    outputVoltageMap.put("alarmContent", alarmContent.toString());
    outputVoltageMap.put("alarmRuleType", alarmRuleType.toString());
    return outputVoltageMap;
  }
示例#5
0
  public Map<String, Object> checkLoad(UpsStatus upsStatus, AlarmRule alarmRule) {
    Map<String, Object> upsLoadMap = 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.getUpsLoad() != null) {
      String upsLoad = upsStatus.getUpsLoad();
      String[] upsLoads = upsLoad.split("%/");
      // 负载一
      Double upsLoad_1 = Double.parseDouble(upsLoads[0]);
      // 判断UPS是三相电
      if (upsStatus.getUpsType() == 2 || upsStatus.getUpsType() == 3) {
        // 负载二
        Double upsLoad_2 = Double.parseDouble(upsLoads[1]);
        // 负载三
        Double upsLoad_3 = Double.parseDouble(upsLoads[2]);
        runState =
            alarmRuleService.ruleCompare(
                operationType, upsLoad_2, value, minValue, maxValue, alarmRule.getState());
        runState =
            alarmRuleService.ruleCompare(
                operationType, upsLoad_3, value, minValue, maxValue, alarmRule.getState());
      }

      runState =
          alarmRuleService.ruleCompare(
              operationType, upsLoad_1, value, minValue, maxValue, alarmRule.getState());
    }
    if (runState != StateEnum.good) {
      alarmContent.append("").append(alarmRule.getRemark()).append("、");
      alarmRuleType.append(alarmRule.getAlarmRuleType()).append("、");
    }

    upsLoadMap.put("runState", runState);
    upsLoadMap.put("alarmContent", alarmContent.toString());
    upsLoadMap.put("alarmRuleType", alarmRuleType.toString());

    return upsLoadMap;
  }
示例#6
0
  @Override
  public Map<String, Object> checkInputVoltage(UpsStatus upsStatus, AlarmRule alarmRule) {
    Map<String, Object> inputVoltageMap = 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.getInputVoltage() != null) {
      String inputVoltage = upsStatus.getInputVoltage();
      String[] inputVoltages = inputVoltage.split("V/");
      // 输入电压一
      Double inputVoltage_1 = Double.parseDouble(inputVoltages[0]);
      // 判断UPS是三相电
      if (upsStatus.getUpsType() == 2 || upsStatus.getUpsType() == 3) {
        // 输入电压二
        Double inputVoltage_2 = Double.parseDouble(inputVoltages[1]);
        // 输入电压三
        Double inputVoltage_3 =
            Double.parseDouble(inputVoltages[2].substring(0, inputVoltages[2].length() - 1));
        runState =
            alarmRuleService.ruleCompare(
                operationType, inputVoltage_2, value, minValue, maxValue, alarmRule.getState());
        runState =
            alarmRuleService.ruleCompare(
                operationType, inputVoltage_3, value, minValue, maxValue, alarmRule.getState());
      }

      runState =
          alarmRuleService.ruleCompare(
              operationType, inputVoltage_1, value, minValue, maxValue, alarmRule.getState());
    }
    if (runState != StateEnum.good) {
      alarmContent.append("").append(alarmRule.getRemark()).append("、");
      alarmRuleType.append(alarmRule.getAlarmRuleType()).append("、");
    }
    inputVoltageMap.put("runState", runState);
    inputVoltageMap.put("alarmContent", alarmContent.toString());
    inputVoltageMap.put("alarmRuleType", alarmRuleType.toString());
    return inputVoltageMap;
  }
示例#7
0
  @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;
  }