1、优化告警处理
This commit is contained in:
parent
0211098b05
commit
a4bc54eb08
@ -59,4 +59,6 @@ public class GnssTrxMsg {
|
||||
|
||||
@ExcelProperty("D3XX")
|
||||
Integer d3xxbytes;
|
||||
@ExcelProperty("使用卫星数")
|
||||
Integer satelliteinuse;
|
||||
}
|
||||
|
||||
@ -40,6 +40,8 @@ public class WarningCfg {
|
||||
public static final String TYPE_NAME_NO_FIXED_RESULT = "连续无固定解";
|
||||
public static final int TYPE_BS_NO_RESULT = 0x200;
|
||||
public static final String TYPE_NAME_BS_NO_RESULT = "基站下的测站均无解";
|
||||
public static final int TYPE_INCLINE = 0x400;
|
||||
public static final String TYPE_NAME_INCLINE = "异常倾斜";
|
||||
|
||||
// warning level definition
|
||||
public static final short LEVEL_0 = 0; //正常
|
||||
@ -65,6 +67,7 @@ public class WarningCfg {
|
||||
if((code & TYPE_LESS_B562) !=0) warningInfo.add(TYPE_NAME_LESS_B562);
|
||||
if((code & TYPE_NO_FIXED_RESULT) !=0) warningInfo.add(TYPE_NAME_NO_FIXED_RESULT);
|
||||
if((code & TYPE_BS_NO_RESULT) !=0) warningInfo.add(TYPE_NAME_BS_NO_RESULT);
|
||||
if((code & TYPE_INCLINE) !=0) warningInfo.add(TYPE_NAME_INCLINE);
|
||||
return warningInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,6 +92,7 @@ public class DataPersistServiceImpl implements DataPersistService {
|
||||
// 添加到trxmsg里
|
||||
GnssTrxMsg trxMsg = message.getTrxMsg();
|
||||
trxMsg.setTenantid(message.getTenantId());
|
||||
trxMsg.setSatelliteinuse(device.getSatelitesInUse());
|
||||
trxMsgMapper.insert(trxMsg);
|
||||
// 保存消息摘要
|
||||
saveMsg(message,null);
|
||||
|
||||
@ -49,55 +49,28 @@ public class WarningServiceImpl implements WarningService {
|
||||
if(status == null) return;
|
||||
|
||||
boolean isUpdated = false;
|
||||
if ((status.getWarningcode() & (WarningCfg.TYPE_NO_FIXED_RESULT
|
||||
| WarningCfg.TYPE_LESS_B562
|
||||
| WarningCfg.TYPE_LESS_D3XX)) != 0) {
|
||||
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT);
|
||||
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_B562);
|
||||
if ((status.getWarningcode() & WarningCfg.TYPE_LESS_D3XX) != 0) {
|
||||
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_D3XX);
|
||||
isUpdated = true;
|
||||
}
|
||||
|
||||
// b562少
|
||||
int[] threshold = cfgMap.get(WarningCfg.TYPE_LESS_B562);
|
||||
if(threshold != null && (numB562Stat[0] < threshold[1])) {
|
||||
WarningMsg warningMsg = new WarningMsg();
|
||||
warningMsg.setDeviceid(deviceId);
|
||||
warningMsg.setTenantid(tenantId);
|
||||
warningMsg.setCreatetime(LocalDateTime.now());
|
||||
warningMsg.setDevicetype(WarningCfg.TYPE_GNSS);
|
||||
warningMsg.setCode(WarningCfg.TYPE_LESS_B562);
|
||||
warningMsg.setLevel((short) threshold[0]);
|
||||
warningMsg.setInfo(WarningCfg.TYPE_NAME_LESS_B562+",固定解:" + numB562Stat[0] + ",非固定解:"+numB562Stat[1]+",无B562:"+numB562Stat[2]);
|
||||
warningMsgMapper.insert(warningMsg);
|
||||
status.setWarningcode(status.getWarningcode()|WarningCfg.TYPE_LESS_B562);
|
||||
isUpdated = true;
|
||||
}
|
||||
if(check(status, WarningCfg.TYPE_LESS_B562,
|
||||
WarningCfg.TYPE_NAME_LESS_B562,true,
|
||||
numB562Stat[0],null)) isUpdated=true;
|
||||
|
||||
//连续无b562
|
||||
if(0 == numB562Stat[0]){
|
||||
// 记录连续无固定解的轮数
|
||||
int count = status.getNoreslutcount()+1;
|
||||
status.setNoreslutcount(count);
|
||||
int[] threshold2 = cfgMap.get(WarningCfg.TYPE_NO_FIXED_RESULT);
|
||||
if(threshold2!=null && count >= threshold2[1]){
|
||||
// 连续6个周期无固定解则产生严重告警
|
||||
WarningMsg warningMsg = new WarningMsg();
|
||||
warningMsg.setDeviceid(deviceId);
|
||||
warningMsg.setTenantid(tenantId);
|
||||
warningMsg.setCreatetime(LocalDateTime.now());
|
||||
warningMsg.setDevicetype(WarningCfg.TYPE_GNSS);
|
||||
warningMsg.setCode(WarningCfg.TYPE_NO_FIXED_RESULT);
|
||||
warningMsg.setLevel((short) threshold2[0]);
|
||||
warningMsg.setInfo("连续" + count+"周期无固定解");
|
||||
warningMsgMapper.insert(warningMsg);
|
||||
status.setWarningcode(status.getWarningcode()|WarningCfg.TYPE_NO_FIXED_RESULT);
|
||||
}
|
||||
isUpdated = true;
|
||||
|
||||
if(check(status, WarningCfg.TYPE_NO_FIXED_RESULT,
|
||||
WarningCfg.TYPE_NAME_NO_FIXED_RESULT, false,
|
||||
count, null)) isUpdated=true;
|
||||
}
|
||||
else if(isUpdated){ //b562有告警标志
|
||||
status.setNoreslutcount(0);
|
||||
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT);
|
||||
}
|
||||
|
||||
if(isUpdated){
|
||||
@ -115,48 +88,29 @@ public class WarningServiceImpl implements WarningService {
|
||||
if(curStatus.getWarningcode() == null) curStatus.setWarningcode(0);
|
||||
boolean isUpdated = false;
|
||||
|
||||
//清除原来的告警
|
||||
if ((curStatus.getWarningcode() & (WarningCfg.TYPE_DEVICE_OFF_LINE
|
||||
| WarningCfg.TYPE_LOW_VOLTAGE
|
||||
| WarningCfg.TYPE_LOW_RSSI)) != 0) {
|
||||
if ((curStatus.getWarningcode() & WarningCfg.TYPE_DEVICE_OFF_LINE) != 0) {
|
||||
curStatus.setWarningcode(curStatus.getWarningcode() & ~WarningCfg.TYPE_DEVICE_OFF_LINE);
|
||||
curStatus.setWarningcode(curStatus.getWarningcode() & ~WarningCfg.TYPE_LOW_VOLTAGE);
|
||||
curStatus.setWarningcode(curStatus.getWarningcode() & ~WarningCfg.TYPE_LOW_RSSI);
|
||||
isUpdated = true;
|
||||
}
|
||||
|
||||
int[] lowVoltage = cfgMap.get(WarningCfg.TYPE_LOW_VOLTAGE);
|
||||
if(lowVoltage!=null && statusMsg.getVoltage() <= lowVoltage[1]){
|
||||
// 检测电压
|
||||
WarningMsg warningMsg = new WarningMsg();
|
||||
warningMsg.setDeviceid(statusMsg.getDeviceid());
|
||||
warningMsg.setTenantid(statusMsg.getTenantid());
|
||||
warningMsg.setCreatetime(LocalDateTime.now());
|
||||
warningMsg.setDevicetype(WarningCfg.TYPE_GNSS);
|
||||
warningMsg.setCode(WarningCfg.TYPE_LOW_VOLTAGE);
|
||||
warningMsg.setLevel((short) lowVoltage[0]);
|
||||
warningMsg.setInfo("低电压:" + statusMsg.getVoltage() + "mV");
|
||||
warningMsgMapper.insert(warningMsg);
|
||||
//告警级别
|
||||
curStatus.setWarningcode(curStatus.getWarningcode() | WarningCfg.TYPE_LOW_VOLTAGE);
|
||||
isUpdated = true;
|
||||
//低电压告警
|
||||
if(statusMsg.getVoltage()!=null) {
|
||||
if(check(curStatus, WarningCfg.TYPE_LOW_VOLTAGE,
|
||||
WarningCfg.TYPE_NAME_LOW_VOLTAGE,true,
|
||||
statusMsg.getVoltage(), null)) isUpdated=true;
|
||||
}
|
||||
|
||||
int[] lowRSSI = cfgMap.get(WarningCfg.TYPE_LOW_RSSI);
|
||||
if(lowRSSI!=null && statusMsg.getRssi() <= lowRSSI[1]){
|
||||
// 检测RSSI
|
||||
WarningMsg warningMsg = new WarningMsg();
|
||||
warningMsg.setDeviceid(statusMsg.getDeviceid());
|
||||
warningMsg.setTenantid(statusMsg.getTenantid());
|
||||
warningMsg.setCreatetime(LocalDateTime.now());
|
||||
warningMsg.setDevicetype(WarningCfg.TYPE_GNSS);
|
||||
warningMsg.setCode( WarningCfg.TYPE_LOW_RSSI);
|
||||
warningMsg.setLevel((short) lowRSSI[0]);
|
||||
warningMsg.setInfo("4G信号弱:" + statusMsg.getRssi());
|
||||
warningMsgMapper.insert(warningMsg);
|
||||
//告警级别
|
||||
curStatus.setWarningcode(curStatus.getWarningcode() | WarningCfg.TYPE_LOW_RSSI);
|
||||
isUpdated = true;
|
||||
//低RSSI
|
||||
if(statusMsg.getRssi()!=null) {
|
||||
if(check(curStatus, WarningCfg.TYPE_LOW_RSSI,
|
||||
WarningCfg.TYPE_NAME_LOW_RSSI,true,
|
||||
statusMsg.getRssi().intValue(), null)) isUpdated=true;
|
||||
}
|
||||
//倾角异常告警
|
||||
if(statusMsg.getPitch()!=null) {
|
||||
if(check(curStatus, WarningCfg.TYPE_INCLINE,
|
||||
WarningCfg.TYPE_NAME_INCLINE,false,
|
||||
Math.abs(statusMsg.getPitch().intValue()),
|
||||
Math.abs(statusMsg.getRoll().intValue()))) isUpdated=true;
|
||||
}
|
||||
|
||||
// 根据告警码确定告警级别
|
||||
@ -165,6 +119,56 @@ public class WarningServiceImpl implements WarningService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boolean check(GnssStatus curStatus, int warningType, String warningName, boolean isLessCmp, Integer value1, Integer value2){
|
||||
boolean isUpdated=false;
|
||||
int newWarningCode = 0;
|
||||
int[] warningValues = cfgMap.get(warningType);
|
||||
if(warningValues!=null){
|
||||
if(isLessCmp) {
|
||||
if (value1 != null && value1 <= warningValues[1]) {
|
||||
newWarningCode = warningType;
|
||||
}
|
||||
if (value2 != null && value2 <= warningValues[1]) {
|
||||
newWarningCode = warningType;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (value1 != null && value1 >= warningValues[1]) {
|
||||
newWarningCode = warningType;
|
||||
}
|
||||
if (value2 != null && value2 >= warningValues[1]) {
|
||||
newWarningCode = warningType;
|
||||
}
|
||||
}
|
||||
}
|
||||
else return isUpdated;
|
||||
|
||||
int oldWarningCode = curStatus.getWarningcode() & warningType;
|
||||
if(newWarningCode != oldWarningCode){
|
||||
if(newWarningCode == 0){
|
||||
curStatus.setWarningcode(curStatus.getWarningcode() & ~warningType);
|
||||
}
|
||||
else {
|
||||
WarningMsg warningMsg = new WarningMsg();
|
||||
warningMsg.setDeviceid(curStatus.getDeviceid());
|
||||
warningMsg.setTenantid(curStatus.getTenantid());
|
||||
warningMsg.setCreatetime(LocalDateTime.now());
|
||||
warningMsg.setDevicetype(WarningCfg.TYPE_GNSS);
|
||||
warningMsg.setCode(warningType);
|
||||
warningMsg.setLevel((short) warningValues[0]);
|
||||
String info = warningName + ":" + value1;
|
||||
if(value2!=null) info = info +","+value2;
|
||||
warningMsg.setInfo(info);
|
||||
warningMsgMapper.insert(warningMsg);
|
||||
//告警级别
|
||||
curStatus.setWarningcode(curStatus.getWarningcode() | warningType);
|
||||
}
|
||||
isUpdated = true;
|
||||
}
|
||||
return isUpdated;
|
||||
}
|
||||
|
||||
/***
|
||||
* 检查未知报文是否较多
|
||||
*/
|
||||
@ -186,29 +190,15 @@ public class WarningServiceImpl implements WarningService {
|
||||
boolean isUpdated = false;
|
||||
// 清除b562告警
|
||||
if((status.getWarningcode() & (WarningCfg.TYPE_NO_FIXED_RESULT
|
||||
|WarningCfg.TYPE_LESS_B562
|
||||
|WarningCfg.TYPE_LESS_D3XX)) !=0 ) {
|
||||
|WarningCfg.TYPE_LESS_B562)) !=0 ) {
|
||||
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT);
|
||||
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_B562);
|
||||
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_D3XX);
|
||||
isUpdated = true;
|
||||
}
|
||||
// 检查d331告警
|
||||
if(cfgMap.size() == 0) refreshCfg();
|
||||
int[] threshold = cfgMap.get(WarningCfg.TYPE_LESS_D3XX);
|
||||
if(threshold != null && (device.getD3xxCount() < threshold[1])) {
|
||||
WarningMsg warningMsg = new WarningMsg();
|
||||
warningMsg.setDeviceid(device.getDeviceId());
|
||||
warningMsg.setTenantid(device.getTenantId());
|
||||
warningMsg.setCreatetime(LocalDateTime.now());
|
||||
warningMsg.setDevicetype(WarningCfg.TYPE_GNSS);
|
||||
warningMsg.setCode(WarningCfg.TYPE_LESS_D3XX);
|
||||
warningMsg.setLevel((short) threshold[0]);
|
||||
warningMsg.setInfo(WarningCfg.TYPE_NAME_LESS_D3XX+"," + device.getD3xxCount());
|
||||
warningMsgMapper.insert(warningMsg);
|
||||
status.setWarningcode(status.getWarningcode()|WarningCfg.TYPE_LESS_D3XX);
|
||||
isUpdated = true;
|
||||
}
|
||||
if(check(status, WarningCfg.TYPE_LESS_D3XX,
|
||||
WarningCfg.TYPE_NAME_LESS_D3XX,true,
|
||||
device.getD3xxCount(), null)) isUpdated=true;
|
||||
|
||||
if(isUpdated) {
|
||||
status.setWarning(getWarningLevel(status.getWarningcode()));
|
||||
|
||||
@ -44,6 +44,7 @@ public class WarningController extends BasicController implements CommonExcelSer
|
||||
warningMap.put(WarningCfg.TYPE_LOW_VOLTAGE, WarningCfg.TYPE_NAME_LOW_VOLTAGE);
|
||||
warningMap.put(WarningCfg.TYPE_LOW_RSSI, WarningCfg.TYPE_NAME_LOW_RSSI);
|
||||
warningMap.put(WarningCfg.TYPE_RX_MUCH_UNKNOWN, WarningCfg.TYPE_NAME_RX_MUCH_UNKNOWN);
|
||||
warningMap.put(WarningCfg.TYPE_INCLINE, WarningCfg.TYPE_NAME_INCLINE);
|
||||
}
|
||||
|
||||
/**** 推送页面 *****/
|
||||
|
||||
@ -212,6 +212,7 @@ CREATE TABLE IF NOT EXISTS `gnsstrxmsg` (
|
||||
`uart2unknown` int DEFAULT NULL,
|
||||
`b562bytes` int DEFAULT NULL,
|
||||
`d3xxbytes` int DEFAULT NULL,
|
||||
`satelliteinuse` int DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
@ -83,7 +83,8 @@
|
||||
{field: 'uart1unknown', title: '串口1未知'},
|
||||
{field: 'uart2txbytes', title: '串口2发'},
|
||||
{field: 'uart2rxbytes', title: '串口2收'},
|
||||
{field: 'uart2unknown', title: '串口2未知'}
|
||||
{field: 'uart2unknown', title: '串口2未知'},
|
||||
{field: 'satelliteinuse', title: '使用卫星数'}
|
||||
]],
|
||||
limits: [10, 15, 20, 25, 50, 100],
|
||||
limit: 15,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user