diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningServiceImpl.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningServiceImpl.java index c3bfb67a..7f140ac2 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningServiceImpl.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/WarningServiceImpl.java @@ -42,10 +42,23 @@ public class WarningServiceImpl implements WarningService { @Override public void checkB562Num(String deviceId, Integer tenantId, int[] numB562Stat){ + GnssStatus status = gnssStatusMapper.getByDeviceId(deviceId); + if(status == null) return; + if(cfgMap.size() == 0) refreshCfg(); + 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); + 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])) { - // 检测电压和RSSI WarningMsg warningMsg = new WarningMsg(); warningMsg.setDeviceid(deviceId); warningMsg.setTenantid(tenantId); @@ -55,43 +68,40 @@ public class WarningServiceImpl implements WarningService { 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; } - GnssStatus status = gnssStatusMapper.getByDeviceId(deviceId); - // 清除d331告警 - status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_LESS_D3XX); - + //连续无b562 if(0 == numB562Stat[0]){ // 记录连续无固定解的轮数 - if(status != null){ - int count = status.getNoreslutcount()+1; - status.setNoreslutcount(count); - int[] threshold2 = cfgMap.get(WarningCfg.TYPE_NO_FIXED_RESULT); - if(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); - // 根据告警码确定告警级别 - status.setWarning(getWarningLevel(status.getWarningcode())); - } - gnssStatusMapper.updateById(status); + int count = status.getNoreslutcount()+1; + status.setNoreslutcount(count); + int[] threshold2 = cfgMap.get(WarningCfg.TYPE_NO_FIXED_RESULT); + if(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; + } - else{ - if((status.getWarningcode()&WarningCfg.TYPE_NO_FIXED_RESULT) != 0){ - status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT); - status.setWarning(getWarningLevel(status.getWarningcode())); - status.setNoreslutcount(0); - gnssStatusMapper.updateById(status); - } + else if(isUpdated){ //b562有告警标志 + status.setNoreslutcount(0); + } + + if(isUpdated){ + // 根据告警码确定告警级别 + status.setWarning(getWarningLevel(status.getWarningcode())); + gnssStatusMapper.updateById(status); } } /*** @@ -165,28 +175,36 @@ public class WarningServiceImpl implements WarningService { @Override public void checkD3xxNum(Device device){ - if(device.getD3xxCount() > 0) { - GnssStatus status = gnssStatusMapper.getByDeviceId(device.getDeviceId()); - if(status != null) { - // 清除b562告警 + GnssStatus status = gnssStatusMapper.getByDeviceId(device.getDeviceId()); + if(status != null) { + boolean isUpdated = false; + // 清除b562告警 + 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); + 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; + } - // 检查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); - } + if(isUpdated) { status.setWarning(getWarningLevel(status.getWarningcode())); gnssStatusMapper.updateById(status); }