bug fixed: 参与平滑的记录时间判断有错
This commit is contained in:
parent
29df3ebbfb
commit
def9f4d7eb
@ -151,21 +151,22 @@ public class SingleLineGNSSCalcService implements GNSSCalcService {
|
|||||||
GnssCalcData locationRecord = new GnssCalcData();
|
GnssCalcData locationRecord = new GnssCalcData();
|
||||||
locationRecord.setCreatetime(resultTime);
|
locationRecord.setCreatetime(resultTime);
|
||||||
locationRecord.setDeviceid(deviceId);
|
locationRecord.setDeviceid(deviceId);
|
||||||
if(b562Result!=null) {
|
|
||||||
|
// 调用这个函数之前已判断是否为null
|
||||||
locationRecord.setB562e(b562Result[0] * 10); //cm->mm
|
locationRecord.setB562e(b562Result[0] * 10); //cm->mm
|
||||||
locationRecord.setB562n(b562Result[1] * 10);
|
locationRecord.setB562n(b562Result[1] * 10);
|
||||||
locationRecord.setB562d(b562Result[2] * 10);
|
locationRecord.setB562d(b562Result[2] * 10);
|
||||||
}
|
|
||||||
|
locationRecord.setResulte(result[0]);
|
||||||
|
locationRecord.setResultn(result[1]);
|
||||||
|
locationRecord.setResultd(result[2]);
|
||||||
|
|
||||||
if(r9250Result!=null) {
|
if(r9250Result!=null) {
|
||||||
locationRecord.setR9250e(r9250Result[0]);
|
locationRecord.setR9250e(r9250Result[0]);
|
||||||
locationRecord.setR9250n(r9250Result[1]);
|
locationRecord.setR9250n(r9250Result[1]);
|
||||||
locationRecord.setR9250d(r9250Result[2]);
|
locationRecord.setR9250d(r9250Result[2]);
|
||||||
}
|
}
|
||||||
if(result!=null) {
|
|
||||||
locationRecord.setResulte(result[0]);
|
|
||||||
locationRecord.setResultn(result[1]);
|
|
||||||
locationRecord.setResultd(result[2]);
|
|
||||||
}
|
|
||||||
locationRecord.setPps(delay);
|
locationRecord.setPps(delay);
|
||||||
deviceService.postLocationRecord(locationRecord, isShocked);
|
deviceService.postLocationRecord(locationRecord, isShocked);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,56 +119,51 @@ public class GNSSDeviceLocationRecordServiceImpl implements GNSSDeviceLocationRe
|
|||||||
* 计算东北天的最近融合数据的加权平均, 刘畅20230725 copy 自 avgEND; id>20, 滤波参数6h 或 25h
|
* 计算东北天的最近融合数据的加权平均, 刘畅20230725 copy 自 avgEND; id>20, 滤波参数6h 或 25h
|
||||||
*/
|
*/
|
||||||
public double[] calcFilterLocation(GnssCalcData newRecord, int filterCycleHour){
|
public double[] calcFilterLocation(GnssCalcData newRecord, int filterCycleHour){
|
||||||
|
|
||||||
String deviceId = newRecord.getDeviceid();
|
String deviceId = newRecord.getDeviceid();
|
||||||
|
// 选取[newRecordTime-filterCycleHour, newRcordTime]之间的记录做平滑
|
||||||
// 读取离newRecord创建时间最近的filterCycleHour小时内的记录,按时间倒序排序
|
// 如果这个时间段的记录数少于FILTER_MIN_RECORD_NUM,本次不做平滑
|
||||||
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);
|
|
||||||
|
|
||||||
LocalDateTime newRecordTime = newRecord.getCreatetime();
|
LocalDateTime newRecordTime = newRecord.getCreatetime();
|
||||||
LocalDateTime filterAfterTime = newRecordTime.minusHours(filterCycleHour);
|
LocalDateTime filterAfterTime = newRecordTime.minusHours(filterCycleHour);
|
||||||
boolean hasCheck = false;
|
QueryWrapper<GnssCalcData> query = new QueryWrapper<>();
|
||||||
if(gnssDeviceLocationRecords.size() > 0){
|
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组原始值的平均值
|
// 求本组和最近recordNum组原始值的平均值
|
||||||
double sumE = newRecord.getB562e();
|
double sumE = newRecord.getB562e();
|
||||||
double sumN = newRecord.getB562n();
|
double sumN = newRecord.getB562n();
|
||||||
double sumD = newRecord.getB562d();
|
double sumD = newRecord.getB562d();
|
||||||
int count = 1;
|
int count = 1;
|
||||||
for (int i = 0; i < gnssDeviceLocationRecords.size(); i++) {
|
for (GnssCalcData record : gnssDeviceLocationRecords) {
|
||||||
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;
|
|
||||||
if (record.getEnabled()) {//只选取好点参与滤波
|
if (record.getEnabled()) {//只选取好点参与滤波
|
||||||
sumE += record.getB562e();
|
sumE += record.getB562e();
|
||||||
sumN += record.getB562n();
|
sumN += record.getB562n();
|
||||||
sumD += record.getB562d();
|
sumD += record.getB562d();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
logger.info(deviceId + " filter records num: " + count);
|
||||||
logger.info(deviceId + " filter records num: "+count);
|
if (count >= FILTER_MIN_RECORD_NUM) {
|
||||||
if(count >= FILTER_MIN_RECORD_NUM) {
|
|
||||||
return new double[]{sumE / count, sumN / count, sumD / count};
|
return new double[]{sumE / count, sumN / count, sumD / count};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,7 @@ public class WarningServiceImpl implements WarningService {
|
|||||||
if((status.getWarningcode()&WarningCfg.TYPE_NO_FIXED_RESULT) != 0){
|
if((status.getWarningcode()&WarningCfg.TYPE_NO_FIXED_RESULT) != 0){
|
||||||
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT);
|
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT);
|
||||||
status.setWarning(getWarningLevel(status.getWarningcode()));
|
status.setWarning(getWarningLevel(status.getWarningcode()));
|
||||||
|
status.setNoreslutcount(0);
|
||||||
gnssStatusMapper.updateById(status);
|
gnssStatusMapper.updateById(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user