1、优化告警处理

This commit is contained in:
weidong 2024-02-14 17:51:01 +08:00
parent 0211098b05
commit a4bc54eb08
7 changed files with 90 additions and 91 deletions

View File

@ -59,4 +59,6 @@ public class GnssTrxMsg {
@ExcelProperty("D3XX") @ExcelProperty("D3XX")
Integer d3xxbytes; Integer d3xxbytes;
@ExcelProperty("使用卫星数")
Integer satelliteinuse;
} }

View File

@ -40,6 +40,8 @@ public class WarningCfg {
public static final String TYPE_NAME_NO_FIXED_RESULT = "连续无固定解"; public static final String TYPE_NAME_NO_FIXED_RESULT = "连续无固定解";
public static final int TYPE_BS_NO_RESULT = 0x200; public static final int TYPE_BS_NO_RESULT = 0x200;
public static final String TYPE_NAME_BS_NO_RESULT = "基站下的测站均无解"; 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 // warning level definition
public static final short LEVEL_0 = 0; //正常 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_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_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_BS_NO_RESULT) !=0) warningInfo.add(TYPE_NAME_BS_NO_RESULT);
if((code & TYPE_INCLINE) !=0) warningInfo.add(TYPE_NAME_INCLINE);
return warningInfo; return warningInfo;
} }
} }

View File

@ -92,6 +92,7 @@ public class DataPersistServiceImpl implements DataPersistService {
// 添加到trxmsg里 // 添加到trxmsg里
GnssTrxMsg trxMsg = message.getTrxMsg(); GnssTrxMsg trxMsg = message.getTrxMsg();
trxMsg.setTenantid(message.getTenantId()); trxMsg.setTenantid(message.getTenantId());
trxMsg.setSatelliteinuse(device.getSatelitesInUse());
trxMsgMapper.insert(trxMsg); trxMsgMapper.insert(trxMsg);
// 保存消息摘要 // 保存消息摘要
saveMsg(message,null); saveMsg(message,null);

View File

@ -49,55 +49,28 @@ public class WarningServiceImpl implements WarningService {
if(status == null) return; if(status == null) return;
boolean isUpdated = false; boolean isUpdated = false;
if ((status.getWarningcode() & (WarningCfg.TYPE_NO_FIXED_RESULT if ((status.getWarningcode() & WarningCfg.TYPE_LESS_D3XX) != 0) {
| 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);
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_D3XX); status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_D3XX);
isUpdated = true; isUpdated = true;
} }
// b562少 // b562少
int[] threshold = cfgMap.get(WarningCfg.TYPE_LESS_B562); if(check(status, WarningCfg.TYPE_LESS_B562,
if(threshold != null && (numB562Stat[0] < threshold[1])) { WarningCfg.TYPE_NAME_LESS_B562,true,
WarningMsg warningMsg = new WarningMsg(); numB562Stat[0],null)) isUpdated=true;
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;
}
//连续无b562 //连续无b562
if(0 == numB562Stat[0]){ if(0 == numB562Stat[0]){
// 记录连续无固定解的轮数 // 记录连续无固定解的轮数
int count = status.getNoreslutcount()+1; int count = status.getNoreslutcount()+1;
status.setNoreslutcount(count); status.setNoreslutcount(count);
int[] threshold2 = cfgMap.get(WarningCfg.TYPE_NO_FIXED_RESULT); if(check(status, WarningCfg.TYPE_NO_FIXED_RESULT,
if(threshold2!=null && count >= threshold2[1]){ WarningCfg.TYPE_NAME_NO_FIXED_RESULT, false,
// 连续6个周期无固定解则产生严重告警 count, null)) isUpdated=true;
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;
} }
else if(isUpdated){ //b562有告警标志 else if(isUpdated){ //b562有告警标志
status.setNoreslutcount(0); status.setNoreslutcount(0);
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT);
} }
if(isUpdated){ if(isUpdated){
@ -115,48 +88,29 @@ public class WarningServiceImpl implements WarningService {
if(curStatus.getWarningcode() == null) curStatus.setWarningcode(0); if(curStatus.getWarningcode() == null) curStatus.setWarningcode(0);
boolean isUpdated = false; boolean isUpdated = false;
//清除原来的告警 if ((curStatus.getWarningcode() & WarningCfg.TYPE_DEVICE_OFF_LINE) != 0) {
if ((curStatus.getWarningcode() & (WarningCfg.TYPE_DEVICE_OFF_LINE
| WarningCfg.TYPE_LOW_VOLTAGE
| WarningCfg.TYPE_LOW_RSSI)) != 0) {
curStatus.setWarningcode(curStatus.getWarningcode() & ~WarningCfg.TYPE_DEVICE_OFF_LINE); 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; isUpdated = true;
} }
int[] lowVoltage = cfgMap.get(WarningCfg.TYPE_LOW_VOLTAGE); //低电压告警
if(lowVoltage!=null && statusMsg.getVoltage() <= lowVoltage[1]){ if(statusMsg.getVoltage()!=null) {
// 检测电压 if(check(curStatus, WarningCfg.TYPE_LOW_VOLTAGE,
WarningMsg warningMsg = new WarningMsg(); WarningCfg.TYPE_NAME_LOW_VOLTAGE,true,
warningMsg.setDeviceid(statusMsg.getDeviceid()); statusMsg.getVoltage(), null)) isUpdated=true;
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;
} }
//低RSSI
int[] lowRSSI = cfgMap.get(WarningCfg.TYPE_LOW_RSSI); if(statusMsg.getRssi()!=null) {
if(lowRSSI!=null && statusMsg.getRssi() <= lowRSSI[1]){ if(check(curStatus, WarningCfg.TYPE_LOW_RSSI,
// 检测RSSI WarningCfg.TYPE_NAME_LOW_RSSI,true,
WarningMsg warningMsg = new WarningMsg(); statusMsg.getRssi().intValue(), null)) isUpdated=true;
warningMsg.setDeviceid(statusMsg.getDeviceid()); }
warningMsg.setTenantid(statusMsg.getTenantid()); //倾角异常告警
warningMsg.setCreatetime(LocalDateTime.now()); if(statusMsg.getPitch()!=null) {
warningMsg.setDevicetype(WarningCfg.TYPE_GNSS); if(check(curStatus, WarningCfg.TYPE_INCLINE,
warningMsg.setCode( WarningCfg.TYPE_LOW_RSSI); WarningCfg.TYPE_NAME_INCLINE,false,
warningMsg.setLevel((short) lowRSSI[0]); Math.abs(statusMsg.getPitch().intValue()),
warningMsg.setInfo("4G信号弱" + statusMsg.getRssi()); Math.abs(statusMsg.getRoll().intValue()))) isUpdated=true;
warningMsgMapper.insert(warningMsg);
//告警级别
curStatus.setWarningcode(curStatus.getWarningcode() | WarningCfg.TYPE_LOW_RSSI);
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; boolean isUpdated = false;
// 清除b562告警 // 清除b562告警
if((status.getWarningcode() & (WarningCfg.TYPE_NO_FIXED_RESULT if((status.getWarningcode() & (WarningCfg.TYPE_NO_FIXED_RESULT
|WarningCfg.TYPE_LESS_B562 |WarningCfg.TYPE_LESS_B562)) !=0 ) {
|WarningCfg.TYPE_LESS_D3XX)) !=0 ) {
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT); status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT);
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_B562); status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_B562);
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_D3XX);
isUpdated = true; isUpdated = true;
} }
// 检查d331告警 // 检查d331告警
if(cfgMap.size() == 0) refreshCfg(); if(check(status, WarningCfg.TYPE_LESS_D3XX,
int[] threshold = cfgMap.get(WarningCfg.TYPE_LESS_D3XX); WarningCfg.TYPE_NAME_LESS_D3XX,true,
if(threshold != null && (device.getD3xxCount() < threshold[1])) { device.getD3xxCount(), null)) isUpdated=true;
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(isUpdated) { if(isUpdated) {
status.setWarning(getWarningLevel(status.getWarningcode())); status.setWarning(getWarningLevel(status.getWarningcode()));

View File

@ -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_VOLTAGE, WarningCfg.TYPE_NAME_LOW_VOLTAGE);
warningMap.put(WarningCfg.TYPE_LOW_RSSI, WarningCfg.TYPE_NAME_LOW_RSSI); 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_RX_MUCH_UNKNOWN, WarningCfg.TYPE_NAME_RX_MUCH_UNKNOWN);
warningMap.put(WarningCfg.TYPE_INCLINE, WarningCfg.TYPE_NAME_INCLINE);
} }
/**** 推送页面 *****/ /**** 推送页面 *****/

View File

@ -212,6 +212,7 @@ CREATE TABLE IF NOT EXISTS `gnsstrxmsg` (
`uart2unknown` int DEFAULT NULL, `uart2unknown` int DEFAULT NULL,
`b562bytes` int DEFAULT NULL, `b562bytes` int DEFAULT NULL,
`d3xxbytes` int DEFAULT NULL, `d3xxbytes` int DEFAULT NULL,
`satelliteinuse` int DEFAULT 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -83,7 +83,8 @@
{field: 'uart1unknown', title: '串口1未知'}, {field: 'uart1unknown', title: '串口1未知'},
{field: 'uart2txbytes', title: '串口2发'}, {field: 'uart2txbytes', title: '串口2发'},
{field: 'uart2rxbytes', title: '串口2收'}, {field: 'uart2rxbytes', title: '串口2收'},
{field: 'uart2unknown', title: '串口2未知'} {field: 'uart2unknown', title: '串口2未知'},
{field: 'satelliteinuse', title: '使用卫星数'}
]], ]],
limits: [10, 15, 20, 25, 50, 100], limits: [10, 15, 20, 25, 50, 100],
limit: 15, limit: 15,