package com.whyc.service;
|
|
import com.whyc.constant.Constant_SNMP_OID_A_250;
|
import com.whyc.constant.Constant_SNMP_OID_B_247;
|
import com.whyc.dto.Response;
|
import com.whyc.pojo.UpsPowerAlarm;
|
import com.whyc.pojo.UpsPowerAlarmHistory;
|
import com.whyc.pojo.UpsPowerSignal;
|
import com.whyc.pojo.UpsPowerSimulate;
|
import lombok.extern.slf4j.Slf4j;
|
import org.snmp4j.PDU;
|
import org.snmp4j.Snmp;
|
import org.snmp4j.Target;
|
import org.snmp4j.event.ResponseEvent;
|
import org.snmp4j.smi.*;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.system.ApplicationHome;
|
import org.springframework.stereotype.Service;
|
|
import java.io.*;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
@Service
|
@Slf4j
|
public class SNMPConnectService {
|
|
@Autowired
|
private Target target;
|
@Autowired
|
private Snmp snmp;
|
@Autowired
|
private Address address;
|
|
@Autowired
|
private UpsPowerAlarmService alarmService;
|
|
@Autowired
|
private UpsPowerAlarmHistoryService alarmHistoryService;
|
|
@Autowired
|
private UpsPowerSimulateService simulateService;
|
|
@Autowired
|
private UpsPowerSignalService signalService;
|
|
|
public Response getData() {
|
ApplicationHome applicationHome = new ApplicationHome(SNMPConnectService.class);
|
File dir = applicationHome.getDir();
|
|
List<String> oIdList = getDataOIDList();
|
//List<String> oIdList = new LinkedList<>();
|
//oIdList.add("1.3.6.1.2.1.1.3.0");
|
//oIdList.add("1.3.6.1.2.1.1.1.0");
|
//oIdList.add("1.3.6.1.2.4.1.1.0");
|
|
PDU pdu = new PDU();
|
for (String oId : oIdList) {
|
OID oid = new OID(oId);
|
pdu.add(new VariableBinding(oid));
|
}
|
pdu.setType(PDU.GET);
|
try {
|
ResponseEvent responseEvent = snmp.send(pdu, target);
|
String responseRecord = "Synchronize(同步) message(消息) from(来自) "
|
+ responseEvent.getPeerAddress() + "\r\n" + "request(发送的请求):"
|
+ responseEvent.getRequest() + "\r\n" + "response(返回的响应):"
|
+ responseEvent.getResponse();
|
PDU pduBack = responseEvent.getResponse();
|
|
System.out.println(responseRecord);
|
|
FileOutputStream fileOutputStream = new FileOutputStream(dir.getAbsolutePath() + File.separator+"data.txt");
|
byte[] bytes = responseRecord.getBytes();
|
fileOutputStream.write(bytes);
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return new Response().set(1);
|
|
}
|
|
public Response getSignal() {
|
ApplicationHome applicationHome = new ApplicationHome(SNMPConnectService.class);
|
File dir = applicationHome.getDir();
|
|
List<String> oIdList = getSignalOIDList();
|
|
PDU pdu = new PDU();
|
for (String oId : oIdList) {
|
OID oid = new OID(oId);
|
pdu.add(new VariableBinding(oid));
|
}
|
pdu.setType(PDU.GET);
|
try {
|
ResponseEvent responseEvent = snmp.send(pdu, target);
|
String responseRecord = "Synchronize(同步) message(消息) from(来自) "
|
+ responseEvent.getPeerAddress() + "\r\n" + "request(发送的请求):"
|
+ responseEvent.getRequest() + "\r\n" + "response(返回的响应):"
|
+ responseEvent.getResponse();
|
FileOutputStream fileOutputStream = new FileOutputStream(dir.getAbsolutePath() + File.separator+"signal.txt");
|
byte[] bytes = responseRecord.getBytes();
|
fileOutputStream.write(bytes);
|
|
System.out.println(responseRecord);
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return new Response().set(1);
|
|
}
|
|
public Response getAlarm() {
|
ApplicationHome applicationHome = new ApplicationHome(SNMPConnectService.class);
|
File dir = applicationHome.getDir();
|
|
List<String> oIdList = getAlarmOIDList();
|
|
PDU pdu = new PDU();
|
for (String oId : oIdList) {
|
OID oid = new OID(oId);
|
pdu.add(new VariableBinding(oid));
|
}
|
pdu.setType(PDU.GET);
|
try {
|
ResponseEvent responseEvent = snmp.send(pdu, target);
|
String responseRecord = "Synchronize(同步) message(消息) from(来自) "
|
+ responseEvent.getPeerAddress() + "\r\n" + "request(发送的请求):"
|
+ responseEvent.getRequest() + "\r\n" + "response(返回的响应):"
|
+ responseEvent.getResponse();
|
FileOutputStream fileOutputStream = new FileOutputStream(dir.getAbsolutePath() + File.separator+"alarm.txt");
|
byte[] bytes = responseRecord.getBytes();
|
fileOutputStream.write(bytes);
|
|
System.out.println(responseRecord);
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return new Response().set(1);
|
|
}
|
|
private List<String> getDataOIDList() {
|
List<String> oIdList = new LinkedList<>();
|
//A相输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.2.0");
|
//B相输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.3.0");
|
//C相输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.4.0");
|
//A相输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.5.0");
|
//B相输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.6.0");
|
//C相输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.7.0");
|
//A相输出电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.8.0");
|
//B相输出电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.9.0");
|
//C相输出电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.10.0");
|
//直流输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.11.0");
|
//输出频率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.12.0");
|
//AB线输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.19.0");
|
//BC线输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.20.0");
|
//CA线输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.21.0");
|
//A相输入电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.22.0");
|
//B相输入电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.23.0");
|
//C相输入电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.24.0");
|
//输入频率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.25.0");
|
//A相输入功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.26.0");
|
//B相输入功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.27.0");
|
//C相输入功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.28.0");
|
//A相旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.29.0");
|
//B相旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.30.0");
|
//C相旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.31.0");
|
//旁路频率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.32.0");
|
//AB线输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.33.0");
|
//BC线输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.34.0");
|
//CA线输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.35.0");
|
//AB线旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.36.0");
|
//BC线旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.37.0");
|
//CA线旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.38.0");
|
//A相输出功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.42.0");
|
//B相输出功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.43.0");
|
//C相输出功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.44.0");
|
//A相输出峰值比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.45.0");
|
//B相输出峰值比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.46.0");
|
//C相输出峰值比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.47.0");
|
//A相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.48.0");
|
//B相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.49.0");
|
//C相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.50.0");
|
//A相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.51.0");
|
//B相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.52.0");
|
//C相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.53.0");
|
//A相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.54.0");
|
//B相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.55.0");
|
//C相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.56.0");
|
//A相输出负载百分比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.57.0");
|
//B相输出负载百分比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.58.0");
|
//C相输出负载百分比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.59.0");
|
//系统A相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.62.0");
|
//系统B相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.63.0");
|
//系统C相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.64.0");
|
//系统A相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.65.0");
|
//系统B相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.66.0");
|
//系统C相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.67.0");
|
//系统A相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.68.0");
|
//系统B相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.69.0");
|
//系统C相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.70.0");
|
//整机环境温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.71.0");
|
//电池后备时间
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.75.0");
|
//正电池电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.76.0");
|
//正电池电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.77.0");
|
//负电池电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.78.0");
|
//负电池电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.79.0");
|
//电池老化系数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.80.0");
|
//电池温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.81.0");
|
//环境温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.82.0");
|
//A相输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.2.0");
|
//B相输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.3.0");
|
//C相输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.4.0");
|
//A相输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.5.0");
|
//B相输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.6.0");
|
//C相输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.7.0");
|
//A相输出电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.8.0");
|
//B相输出电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.9.0");
|
//C相输出电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.10.0");
|
//直流输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.11.0");
|
//输出频率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.12.0");
|
//AB线输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.19.0");
|
//BC线输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.20.0");
|
//CA线输入电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.21.0");
|
//A相输入电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.22.0");
|
//B相输入电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.23.0");
|
//C相输入电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.24.0");
|
//输入频率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.25.0");
|
//A相输入功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.26.0");
|
//B相输入功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.27.0");
|
//C相输入功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.28.0");
|
//A相旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.29.0");
|
//B相旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.30.0");
|
//C相旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.31.0");
|
//旁路频率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.32.0");
|
//AB线输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.33.0");
|
//BC线输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.34.0");
|
//CA线输出电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.35.0");
|
//AB线旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.36.0");
|
//BC线旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.37.0");
|
//CA线旁路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.38.0");
|
//A相输出功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.42.0");
|
//B相输出功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.43.0");
|
//C相输出功率因数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.44.0");
|
//A相输出峰值比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.45.0");
|
//B相输出峰值比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.46.0");
|
//C相输出峰值比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.47.0");
|
//A相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.48.0");
|
//B相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.49.0");
|
//C相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.50.0");
|
//A相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.51.0");
|
//B相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.52.0");
|
//C相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.53.0");
|
//A相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.54.0");
|
//B相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.55.0");
|
//C相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.56.0");
|
//A相输出负载百分比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.57.0");
|
//B相输出负载百分比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.58.0");
|
//C相输出负载百分比
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.59.0");
|
//系统A相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.62.0");
|
//系统B相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.63.0");
|
//系统C相输出有功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.64.0");
|
//系统A相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.65.0");
|
//系统B相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.66.0");
|
//系统C相输出视在功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.67.0");
|
//系统A相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.68.0");
|
//系统B相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.69.0");
|
//系统C相输出无功功率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.70.0");
|
//整机环境温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.71.0");
|
//电池后备时间
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.75.0");
|
//正电池电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.76.0");
|
//正电池电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.77.0");
|
//负电池电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.78.0");
|
//负电池电流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.79.0");
|
//电池老化系数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.80.0");
|
//电池温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.81.0");
|
//环境温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.82.0");
|
return oIdList;
|
}
|
|
private List<String> getSignalOIDList() {
|
List<String> oIdList = new LinkedList<>();
|
//供电方式
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.84.0");
|
//电池自检
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.86.0");
|
//电池充电状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.87.0");
|
//逆变器开/关机状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.88.0");
|
//整流器供电状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.89.0");
|
//发电机接入状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.90.0");
|
//输入空开状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.91.0");
|
//维修空开状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.92.0");
|
//旁路空开状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.93.0");
|
//输出空开状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.94.0");
|
//整机工作模式
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.95.0");
|
//并机系统供电状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.96.0");
|
//模块1在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.97.0");
|
//模块2在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.98.0");
|
//模块3在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.99.0");
|
//模块4在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.100.0");
|
//模块5在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.101.0");
|
//模块6在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.102.0");
|
//模块7在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.103.0");
|
//模块8在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.104.0");
|
//模块9在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.105.0");
|
//模块10在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.106.0");
|
//模块11在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.107.0");
|
//模块12在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.108.0");
|
//供电方式
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.84.0");
|
//电池自检
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.86.0");
|
//电池充电状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.87.0");
|
//逆变器开/关机状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.88.0");
|
//整流器供电状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.89.0");
|
//发电机接入状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.90.0");
|
//输入空开状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.91.0");
|
//维修空开状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.92.0");
|
//旁路空开状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.93.0");
|
//输出空开状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.94.0");
|
//整机工作模式
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.95.0");
|
//并机系统供电状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.96.0");
|
//模块1在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.97.0");
|
//模块2在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.98.0");
|
//模块3在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.99.0");
|
//模块4在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.100.0");
|
//模块5在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.101.0");
|
//模块6在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.102.0");
|
//模块7在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.103.0");
|
//模块8在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.104.0");
|
//模块9在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.105.0");
|
//模块10在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.106.0");
|
//模块11在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.107.0");
|
//模块12在线状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.108.0");
|
|
return oIdList;
|
}
|
|
private List<String> getAlarmOIDList() {
|
List<String> oIdList = new LinkedList<>();
|
//逆变器同步/不同步
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.110.0");
|
//主路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.111.0");
|
//整流器
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.112.0");
|
//逆变
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.113.0");
|
//旁路
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.114.0");
|
//电池
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.115.0");
|
//ParaMonCAN通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.118.0");
|
//PowerCAN通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.119.0");
|
//整流DSP程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.120.0");
|
//整流FPGA程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.121.0");
|
//逆变DSP程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.122.0");
|
//逆变FPGA程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.123.0");
|
//旁路DSP程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.124.0");
|
//旁路FPGA程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.125.0");
|
//机架内离散总线通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.126.0");
|
//机架间离散总线通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.127.0");
|
//主控模块设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.132.0");
|
//LBS
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.133.0");
|
//紧急关机状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.134.0");
|
//旁路晶闸管
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.135.0");
|
//旁路相序反
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.136.0");
|
//旁路过流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.137.0");
|
//旁路异常关机
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.138.0");
|
//切换次数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.139.0");
|
//ECO切换次数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.140.0");
|
//ParaPowerCAN通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.141.0");
|
//电池放电
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.142.0");
|
//放电器
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.143.0");
|
//充电器
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.144.0");
|
//LBS连接线
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.145.0");
|
//电池维护
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.146.0");
|
//电池温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.147.0");
|
//电池接地
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.148.0");
|
//主路频率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.149.0");
|
//模块温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.150.0");
|
//从控模块设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.151.0");
|
//接口模块设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.152.0");
|
//均充时间
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.153.0");
|
//辅助电源
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.154.0");
|
//主路相序反
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.155.0");
|
//整流器软启动
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.156.0");
|
//用户操作
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.157.0");
|
//输出熔丝
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.158.0");
|
//输出过载
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.159.0");
|
//系统过载
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.160.0");
|
//输出过载超时
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.161.0");
|
//负载冲击转旁路
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.162.0");
|
//并机均流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.163.0");
|
//母线异常关机
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.164.0");
|
//邻机请求转旁路
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.165.0");
|
//直流母线过压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.166.0");
|
//MonCAN通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.167.0");
|
//输入缺零故障
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.168.0");
|
//逆变继电器
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.169.0");
|
//主路反灌
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.170.0");
|
//输入电流异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.171.0");
|
//输出电压异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.172.0");
|
//输入电流超限
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.173.0");
|
//旁路过温
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.174.0");
|
//邻机旁路晶闸管
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.175.0");
|
//并机连接线
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.176.0");
|
//充电器温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.177.0");
|
//电池端口短路
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.178.0");
|
//电池房环境异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.179.0");
|
//风扇异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.180.0");
|
//旁路缺零故障
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.181.0");
|
//旁路接管
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.182.0");
|
//BCB1状态异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.183.0");
|
//BCB2状态异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.184.0");
|
//BCB3状态异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.185.0");
|
//BCB4状态异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.186.0");
|
//旁路SCR风扇
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.187.0");
|
//平衡电路故障
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.188.0");
|
//平衡电路过流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.189.0");
|
//平衡电路过温
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.190.0");
|
//失去冗余
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.191.0");
|
//容量过载
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.192.0");
|
//功率板设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.193.0");
|
//旁路设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.194.0");
|
//上抽风风扇
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.195.0");
|
//系统A相输出熔丝
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.196.0");
|
//系统B相输出熔丝
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.197.0");
|
//系统C相输出熔丝
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.198.0");
|
//旁路无效
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.199.0");
|
//整流器过流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.200.0");
|
//旁路过流超时
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.201.0");
|
//输出零地过压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.202.0");
|
//输入熔丝断
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.203.0");
|
//旁路熔丝断
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.247.204.0");
|
//逆变器同步/不同步
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.110.0");
|
//主路电压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.111.0");
|
//整流器
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.112.0");
|
//逆变
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.113.0");
|
//旁路
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.114.0");
|
//电池
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.115.0");
|
//ParaMonCAN通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.118.0");
|
//PowerCAN通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.119.0");
|
//整流DSP程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.120.0");
|
//整流FPGA程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.121.0");
|
//逆变DSP程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.122.0");
|
//逆变FPGA程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.123.0");
|
//旁路DSP程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.124.0");
|
//旁路FPGA程序
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.125.0");
|
//机架内离散总线通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.126.0");
|
//机架间离散总线通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.127.0");
|
//主控模块设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.132.0");
|
//LBS
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.133.0");
|
//紧急关机状态
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.134.0");
|
//旁路晶闸管
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.135.0");
|
//旁路相序反
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.136.0");
|
//旁路过流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.137.0");
|
//旁路异常关机
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.138.0");
|
//切换次数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.139.0");
|
//ECO切换次数
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.140.0");
|
//ParaPowerCAN通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.141.0");
|
//电池放电
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.142.0");
|
//放电器
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.143.0");
|
//充电器
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.144.0");
|
//LBS连接线
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.145.0");
|
//电池维护
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.146.0");
|
//电池温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.147.0");
|
//电池接地
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.148.0");
|
//主路频率
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.149.0");
|
//模块温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.150.0");
|
//从控模块设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.151.0");
|
//接口模块设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.152.0");
|
//均充时间
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.153.0");
|
//辅助电源
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.154.0");
|
//主路相序反
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.155.0");
|
//整流器软启动
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.156.0");
|
//用户操作
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.157.0");
|
//输出熔丝
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.158.0");
|
//输出过载
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.159.0");
|
//系统过载
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.160.0");
|
//输出过载超时
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.161.0");
|
//负载冲击转旁路
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.162.0");
|
//并机均流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.163.0");
|
//母线异常关机
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.164.0");
|
//邻机请求转旁路
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.165.0");
|
//直流母线过压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.166.0");
|
//MonCAN通讯
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.167.0");
|
//输入缺零故障
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.168.0");
|
//逆变继电器
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.169.0");
|
//主路反灌
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.170.0");
|
//输入电流异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.171.0");
|
//输出电压异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.172.0");
|
//输入电流超限
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.173.0");
|
//旁路过温
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.174.0");
|
//邻机旁路晶闸管
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.175.0");
|
//并机连接线
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.176.0");
|
//充电器温度
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.177.0");
|
//电池端口短路
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.178.0");
|
//电池房环境异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.179.0");
|
//风扇异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.180.0");
|
//旁路缺零故障
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.181.0");
|
//旁路接管
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.182.0");
|
//BCB1状态异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.183.0");
|
//BCB2状态异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.184.0");
|
//BCB3状态异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.185.0");
|
//BCB4状态异常
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.186.0");
|
//旁路SCR风扇
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.187.0");
|
//平衡电路故障
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.188.0");
|
//平衡电路过流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.189.0");
|
//平衡电路过温
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.190.0");
|
//失去冗余
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.191.0");
|
//容量过载
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.192.0");
|
//功率板设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.193.0");
|
//旁路设置
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.194.0");
|
//上抽风风扇
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.195.0");
|
//系统A相输出熔丝
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.196.0");
|
//系统B相输出熔丝
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.197.0");
|
//系统C相输出熔丝
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.198.0");
|
//旁路无效
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.199.0");
|
//整流器过流
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.200.0");
|
//旁路过流超时
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.201.0");
|
//输出零地过压
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.202.0");
|
//输入熔丝断
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.203.0");
|
//旁路熔丝断
|
oIdList.add(".1.3.6.1.4.1.41477.3.5.250.204.0");
|
return oIdList;
|
}
|
|
public void getAndSaveB247(){
|
List<String> oidListAll = Constant_SNMP_OID_B_247.getOidListAll();
|
/*List<String> oIdList = new LinkedList<>();
|
oIdList.add(".1.3.6.1.2.1.1.3.0");
|
oIdList.add(".1.3.6.1.2.1.1.1.0");
|
oIdList.add(".1.3.6.1.4.1.1.1.0");*/
|
|
PDU pdu = new PDU();
|
for (String oId : oidListAll) {
|
OID oid = new OID(oId);
|
pdu.add(new VariableBinding(oid));
|
}
|
pdu.setType(PDU.GET);
|
try {
|
ResponseEvent responseEvent = snmp.send(pdu, target);
|
PDU pduBack = responseEvent.getResponse();
|
//处理返回数据
|
Vector<? extends VariableBinding> bindings = pduBack.getVariableBindings();
|
|
List<UpsPowerAlarm> alarmListInDB = alarmService.getListByDeviceId(116000247);
|
Map<String, Object> dataMap = Constant_SNMP_OID_B_247.assembleBindings(bindings, alarmListInDB);
|
|
UpsPowerSignal signal = (UpsPowerSignal) dataMap.get("signal");
|
UpsPowerSimulate simulate = (UpsPowerSimulate) dataMap.get("simulate");
|
List<UpsPowerAlarm> alarmAddList = (List<UpsPowerAlarm>) dataMap.get("alarmAddList");
|
List<UpsPowerAlarm> alarmRemoveList = (List<UpsPowerAlarm>) dataMap.get("alarmRemoveList");
|
List<UpsPowerAlarmHistory> alarmHistoryAddList = (List<UpsPowerAlarmHistory>) dataMap.get("alarmHistoryAddList");
|
|
List<UpsPowerSignal> signalListInDB = signalService.getList();
|
List<UpsPowerSimulate> simulateListInDB = simulateService.getList();
|
List<Integer> signalDeviceIdList = signalListInDB.stream().map(UpsPowerSignal::getPowerDeviceId).collect(Collectors.toList());
|
List<Integer> simulateDeviceIdList = simulateListInDB.stream().map(UpsPowerSimulate::getPowerDeviceId).collect(Collectors.toList());
|
|
if(signalDeviceIdList.contains(signal.getPowerDeviceId())){ //存在,更新
|
signalService.update(signal);
|
}else{
|
signalService.add(signal);
|
}
|
|
if(simulateDeviceIdList.contains(simulate.getPowerDeviceId())){ //存在,更新
|
simulateService.update(simulate);
|
}else{
|
simulateService.add(simulate);
|
}
|
|
if(alarmRemoveList.size()>0) {
|
alarmService.removeList(alarmRemoveList.stream().map(UpsPowerAlarm::getNum).collect(Collectors.toList()));
|
}
|
if(alarmAddList.size()>0) {
|
alarmService.addBatch(alarmAddList);
|
}
|
if(alarmHistoryAddList.size()>0) {
|
alarmHistoryService.addBatch(alarmHistoryAddList);
|
}
|
|
/*for (VariableBinding binding : bindings) {
|
OID oid = binding.getOid();
|
String oidStr = oid.toString();
|
Variable variable = binding.getVariable();
|
if(variable instanceof Null) {
|
System.out.println("是null");
|
String value = binding.getVariable().toString();
|
System.out.println(value);
|
}
|
|
}*/
|
}catch (Exception e){
|
//e.printStackTrace();
|
}
|
|
}
|
|
public void getAndSaveA250(){
|
List<String> oidListAll = Constant_SNMP_OID_A_250.getOidListAll();
|
/*List<String> oIdList = new LinkedList<>();
|
oIdList.add(".1.3.6.1.2.1.1.3.0");
|
oIdList.add(".1.3.6.1.2.1.1.1.0");
|
oIdList.add(".1.3.6.1.4.1.1.1.0");*/
|
|
PDU pdu = new PDU();
|
for (String oId : oidListAll) {
|
OID oid = new OID(oId);
|
pdu.add(new VariableBinding(oid));
|
}
|
pdu.setType(PDU.GET);
|
try {
|
ResponseEvent responseEvent = snmp.send(pdu, target);
|
PDU pduBack = responseEvent.getResponse();
|
//处理返回数据
|
Vector<? extends VariableBinding> bindings = pduBack.getVariableBindings();
|
|
List<UpsPowerAlarm> alarmListInDB = alarmService.getListByDeviceId(116000250);
|
Map<String, Object> dataMap = Constant_SNMP_OID_A_250.assembleBindings(bindings, alarmListInDB);
|
|
UpsPowerSignal signal = (UpsPowerSignal) dataMap.get("signal");
|
UpsPowerSimulate simulate = (UpsPowerSimulate) dataMap.get("simulate");
|
List<UpsPowerAlarm> alarmAddList = (List<UpsPowerAlarm>) dataMap.get("alarmAddList");
|
List<UpsPowerAlarm> alarmRemoveList = (List<UpsPowerAlarm>) dataMap.get("alarmRemoveList");
|
List<UpsPowerAlarmHistory> alarmHistoryAddList = (List<UpsPowerAlarmHistory>) dataMap.get("alarmHistoryAddList");
|
|
List<UpsPowerSignal> signalListInDB = signalService.getList();
|
List<UpsPowerSimulate> simulateListInDB = simulateService.getList();
|
List<Integer> signalDeviceIdList = signalListInDB.stream().map(UpsPowerSignal::getPowerDeviceId).collect(Collectors.toList());
|
List<Integer> simulateDeviceIdList = simulateListInDB.stream().map(UpsPowerSimulate::getPowerDeviceId).collect(Collectors.toList());
|
|
if(signalDeviceIdList.contains(signal.getPowerDeviceId())){ //存在,更新
|
signalService.update(signal);
|
}else{
|
signalService.add(signal);
|
}
|
|
if(simulateDeviceIdList.contains(simulate.getPowerDeviceId())){ //存在,更新
|
simulateService.update(simulate);
|
}else{
|
simulateService.add(simulate);
|
}
|
|
if(alarmRemoveList.size()>0) {
|
alarmService.removeList(alarmRemoveList.stream().map(UpsPowerAlarm::getNum).collect(Collectors.toList()));
|
}
|
if(alarmAddList.size()>0) {
|
alarmService.addBatch(alarmAddList);
|
}
|
if(alarmHistoryAddList.size()>0) {
|
alarmHistoryService.addBatch(alarmHistoryAddList);
|
}
|
|
/*for (VariableBinding binding : bindings) {
|
OID oid = binding.getOid();
|
String oidStr = oid.toString();
|
Variable variable = binding.getVariable();
|
if(variable instanceof Null) {
|
System.out.println("是null");
|
String value = binding.getVariable().toString();
|
System.out.println(value);
|
}
|
|
}*/
|
}catch (Exception e){
|
//e.printStackTrace();
|
}
|
|
}
|
|
}
|