bug fixed: 参与平滑的记录时间判断有错

This commit is contained in:
weidong 2023-12-10 22:02:12 +08:00
parent 29df3ebbfb
commit def9f4d7eb
3 changed files with 45 additions and 48 deletions

View File

@ -151,21 +151,22 @@ public class SingleLineGNSSCalcService implements GNSSCalcService {
GnssCalcData locationRecord = new GnssCalcData();
locationRecord.setCreatetime(resultTime);
locationRecord.setDeviceid(deviceId);
if(b562Result!=null) {
// 调用这个函数之前已判断是否为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);
}

View File

@ -119,56 +119,51 @@ 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<GnssCalcData> query = new QueryWrapper<>();
query.eq("deviceid", deviceId);
query.orderByDesc("createtime");
query.last("limit "+FILTER_MAX_RECORD_NUM);
List<GnssCalcData> 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){
QueryWrapper<GnssCalcData> query = new QueryWrapper<>();
query.eq("deviceid", deviceId);
query.ge("createtime", filterAfterTime.format(dateFormatter));
query.le("createtime", newRecordTime.format(dateFormatter));
query.orderByDesc("createtime");
List<GnssCalcData> 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 (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;
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) {
logger.info(deviceId + " filter records num: " + count);
if (count >= FILTER_MIN_RECORD_NUM) {
return new double[]{sumE / count, sumN / count, sumD / count};
}
}
}
return null;
}

View File

@ -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);
}
}