diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/SingleLineGNSSCalcService.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/SingleLineGNSSCalcService.java index dd93b0ee..2264f999 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/SingleLineGNSSCalcService.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/SingleLineGNSSCalcService.java @@ -151,21 +151,22 @@ public class SingleLineGNSSCalcService implements GNSSCalcService { GnssCalcData locationRecord = new GnssCalcData(); locationRecord.setCreatetime(resultTime); locationRecord.setDeviceid(deviceId); - if(b562Result!=null) { - locationRecord.setB562e(b562Result[0] * 10); //cm->mm - locationRecord.setB562n(b562Result[1] * 10); - locationRecord.setB562d(b562Result[2] * 10); - } + + // 调用这个函数之前已判断是否为null + locationRecord.setB562e(b562Result[0] * 10); //cm->mm + locationRecord.setB562n(b562Result[1] * 10); + locationRecord.setB562d(b562Result[2] * 10); + + locationRecord.setResulte(result[0]); + locationRecord.setResultn(result[1]); + locationRecord.setResultd(result[2]); + if(r9250Result!=null) { locationRecord.setR9250e(r9250Result[0]); locationRecord.setR9250n(r9250Result[1]); locationRecord.setR9250d(r9250Result[2]); } - if(result!=null) { - locationRecord.setResulte(result[0]); - locationRecord.setResultn(result[1]); - locationRecord.setResultd(result[2]); - } + locationRecord.setPps(delay); deviceService.postLocationRecord(locationRecord, isShocked); } diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/GNSSDeviceLocationRecordServiceImpl.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/GNSSDeviceLocationRecordServiceImpl.java index cc3650fb..517e06d0 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/GNSSDeviceLocationRecordServiceImpl.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/service/GNSSDeviceLocationRecordServiceImpl.java @@ -119,54 +119,49 @@ public class GNSSDeviceLocationRecordServiceImpl implements GNSSDeviceLocationRe * 计算东北天的最近融合数据的加权平均, 刘畅20230725 copy 自 avgEND; id>20, 滤波参数6h 或 25h */ public double[] calcFilterLocation(GnssCalcData newRecord, int filterCycleHour){ - String deviceId = newRecord.getDeviceid(); - - // 读取离newRecord创建时间最近的filterCycleHour小时内的记录,按时间倒序排序 - QueryWrapper query = new QueryWrapper<>(); - query.eq("deviceid", deviceId); - query.orderByDesc("createtime"); - query.last("limit "+FILTER_MAX_RECORD_NUM); - - List gnssDeviceLocationRecords = repository.selectList(query); - + // 选取[newRecordTime-filterCycleHour, newRcordTime]之间的记录做平滑 + // 如果这个时间段的记录数少于FILTER_MIN_RECORD_NUM,本次不做平滑 LocalDateTime newRecordTime = newRecord.getCreatetime(); LocalDateTime filterAfterTime = newRecordTime.minusHours(filterCycleHour); - boolean hasCheck = false; - if(gnssDeviceLocationRecords.size() > 0){ - // 求本组和最近recordNum组原始值的平均值 - double sumE = newRecord.getB562e(); - double sumN = newRecord.getB562n(); - double sumD = newRecord.getB562d(); - int count = 1; - for (int i = 0; i < gnssDeviceLocationRecords.size(); i++) { - GnssCalcData record = gnssDeviceLocationRecords.get(i); - if(record.getB562e()!=null && record.getB562n()!=null && record.getB562d()!=null) { - if(!hasCheck){ - // 检查是不是坏点,即使超过平滑周期的记录也要比较,因为有可能中间会缺数据 - if(Math.abs(newRecord.getB562e() - record.getB562e())>xyThreshold || - Math.abs(newRecord.getB562n() - record.getB562n())>xyThreshold || - Math.abs(newRecord.getB562d() - record.getB562d())>zThreshold ){ - newRecord.setEnabled(false); //记录为坏点,下次不参与滤波 - logger.info(deviceId + " abnormal gnss data"); - return null; - } - hasCheck = true; - } - // 如果记录超过平滑周期的不参与平滑计算 - if(record.getCreatetime().isBefore(filterAfterTime)) break; + QueryWrapper query = new QueryWrapper<>(); + query.eq("deviceid", deviceId); + query.ge("createtime", filterAfterTime.format(dateFormatter)); + query.le("createtime", newRecordTime.format(dateFormatter)); + query.orderByDesc("createtime"); + + List gnssDeviceLocationRecords = repository.selectList(query); + if(gnssDeviceLocationRecords.size() == 0){ + //第一个点无参考,当作坏点处理 + newRecord.setEnabled(false); + } + else { + GnssCalcData record0 = gnssDeviceLocationRecords.get(0); + // 检查是不是坏点 + if (Math.abs(newRecord.getB562e() - record0.getB562e()) > xyThreshold || + Math.abs(newRecord.getB562n() - record0.getB562n()) > xyThreshold || + Math.abs(newRecord.getB562d() - record0.getB562d()) > zThreshold) { + newRecord.setEnabled(false); //记录为坏点,下次不参与滤波 + logger.info(deviceId + " abnormal gnss data"); + } + else { + // 求本组和最近recordNum组原始值的平均值 + double sumE = newRecord.getB562e(); + double sumN = newRecord.getB562n(); + double sumD = newRecord.getB562d(); + int count = 1; + for (GnssCalcData record : gnssDeviceLocationRecords) { if (record.getEnabled()) {//只选取好点参与滤波 sumE += record.getB562e(); sumN += record.getB562n(); sumD += record.getB562d(); count++; } - } - } - logger.info(deviceId + " filter records num: "+count); - if(count >= FILTER_MIN_RECORD_NUM) { - return new double[]{sumE / count, sumN / count, sumD / count}; + logger.info(deviceId + " filter records num: " + count); + if (count >= FILTER_MIN_RECORD_NUM) { + return new double[]{sumE / count, sumN / count, sumD / count}; + } } } 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 8864ade5..c7cf9bce 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 @@ -85,6 +85,7 @@ public class WarningServiceImpl implements WarningService { 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); } }