bug fixed: 没有推送出去;滤波增加最小记录数判断,如果有效数小于10条,也不滤波
This commit is contained in:
parent
88b540b536
commit
86e633483a
@ -15,6 +15,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@ -50,7 +51,7 @@ public class ForwardGnssTask {
|
||||
forwardGnssToXFZ(1);
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
||||
@Scheduled(cron = "0 10 * * * ?") // 每小时的10分钟执行一次
|
||||
private void forwardHistoryGnss() {
|
||||
// 1.从转发记录表里检索待补传记录时间表,含设备Id,时间段
|
||||
// 2.检索这个这个时间段的解算结果,如果有数据则单个终端转发,标志记录为已补传
|
||||
@ -62,33 +63,37 @@ public class ForwardGnssTask {
|
||||
ConcurrentHashMap<String, List<GnssCalcData>> projects = new ConcurrentHashMap<>();
|
||||
|
||||
// 转发新发展数据
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String sendTime = nowTime.format(formatter);
|
||||
String sendAfterTime = nowTime.minusMinutes(30).format(formatter);
|
||||
|
||||
QueryWrapper<GnssDevice> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("tenantid", tenantId);
|
||||
List<GnssDevice> gnssDeviceList = deviceMapper.selectList(queryWrapper);
|
||||
List<GnssCalcData> records;
|
||||
List<GnssCalcData> recordsToSend;
|
||||
for(GnssDevice device:gnssDeviceList){
|
||||
String projectId = device.getProject_id();
|
||||
if(projectId == null) continue;
|
||||
|
||||
records = projects.get(projectId);
|
||||
if(records == null){
|
||||
records = new ArrayList<>();
|
||||
projects.put(projectId,records);
|
||||
recordsToSend = projects.get(projectId);
|
||||
if(recordsToSend == null){
|
||||
recordsToSend = new ArrayList<>();
|
||||
projects.put(projectId,recordsToSend);
|
||||
}
|
||||
QueryWrapper<GnssCalcData> gnssQueryWrapper = new QueryWrapper<>();
|
||||
gnssQueryWrapper.eq("deviceid",device.getDeviceid());
|
||||
gnssQueryWrapper.ge("createtime",sendAfterTime);
|
||||
gnssQueryWrapper.orderByDesc("createtime");
|
||||
gnssQueryWrapper.last("limit 1");
|
||||
GnssCalcData record = gnssDataMapper.selectOne(gnssQueryWrapper);
|
||||
if(record != null && record.getEnabled()){
|
||||
if(nowTime.isBefore(record.getCreatetime().plusMinutes(40))) {
|
||||
records.add(record);
|
||||
List<GnssCalcData> records = gnssDataMapper.selectList(gnssQueryWrapper);
|
||||
for(GnssCalcData record:records) {
|
||||
if (record.getEnabled()) {
|
||||
recordsToSend.add(record);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 按项目打包推送
|
||||
String sendTime = nowTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
for (Map.Entry<String, List<GnssCalcData>> entry: projects.entrySet()){
|
||||
SendToXFZ(entry.getKey(), entry.getValue(), sendTime);
|
||||
}
|
||||
@ -119,6 +124,7 @@ public class ForwardGnssTask {
|
||||
String json = GsonUtil.toJson(xfzTcpMessage);
|
||||
xfzTcpClient.writeAndFlush(json);
|
||||
logger.info("project " + projectId + ": push calculation result to XFZ");
|
||||
logger.info(json);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,13 +27,13 @@ public class XFZTcpClient implements ApplicationRunner {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
//@Value("${xfz.server.host}")
|
||||
private String host="171.106.48.63";
|
||||
private String host="115.236.153.174";//"171.106.48.63";
|
||||
|
||||
//@Value("${xfz.server.port}")
|
||||
private int port=52000;
|
||||
private int port=45996; //52000;
|
||||
|
||||
//@Value("${xfz.server.data.send}")
|
||||
private boolean send=false;
|
||||
private boolean send=true;
|
||||
|
||||
private Bootstrap bootstrap;
|
||||
private EventLoopGroup group;
|
||||
|
||||
@ -43,6 +43,7 @@ public class GNSSDeviceLocationRecordServiceImpl implements GNSSDeviceLocationRe
|
||||
public static final int FILTER_SHORT_CYCLE_HOUR = 4;
|
||||
public static final int FILTER_LONG_CYCLE_HOUR = 25;
|
||||
static final int FILTER_MAX_RECORD_NUM = 50;
|
||||
static final int FILTER_MIN_RECORD_NUM = 10;
|
||||
static final double XY_THRESHOLD = 30; //水平异常点30mm
|
||||
static final double Z_THRESHOLD = 30; //高程异常点30mm
|
||||
|
||||
@ -121,16 +122,16 @@ public class GNSSDeviceLocationRecordServiceImpl implements GNSSDeviceLocationRe
|
||||
|
||||
String deviceId = newRecord.getDeviceid();
|
||||
|
||||
// 读取离newRecord的创建时间之前最近recordNum个原始值,按时间倒序排序
|
||||
// 读取离newRecord创建时间最近的filterCycleHour小时内的记录,按时间倒序排序
|
||||
QueryWrapper<GnssCalcData> query = new QueryWrapper<>();
|
||||
query.orderByDesc("createtime");
|
||||
query.eq("deviceid", deviceId);
|
||||
query.le("createtime", newRecord.getCreatetime().format(dateFormatter));
|
||||
query.orderByDesc("createtime");
|
||||
query.last("limit "+FILTER_MAX_RECORD_NUM);
|
||||
|
||||
List<GnssCalcData> gnssDeviceLocationRecords = repository.selectList(query);
|
||||
|
||||
LocalDateTime newRecordTime = newRecord.getCreatetime();
|
||||
LocalDateTime filterAfterTime = newRecordTime.plusHours(filterCycleHour);
|
||||
boolean hasCheck = false;
|
||||
if(gnssDeviceLocationRecords.size() > 0){
|
||||
// 求本组和最近recordNum组原始值的平均值
|
||||
@ -153,7 +154,7 @@ public class GNSSDeviceLocationRecordServiceImpl implements GNSSDeviceLocationRe
|
||||
hasCheck = true;
|
||||
}
|
||||
// 超过平滑周期的不参与平滑计算
|
||||
if(newRecordTime.isAfter(record.getCreatetime().plusHours(filterCycleHour))) break;
|
||||
if(newRecordTime.isAfter(filterAfterTime)) break;
|
||||
if (record.getEnabled()) {//只选取好点参与滤波
|
||||
sumE += record.getB562e();
|
||||
sumN += record.getB562n();
|
||||
@ -164,11 +165,12 @@ public class GNSSDeviceLocationRecordServiceImpl implements GNSSDeviceLocationRe
|
||||
}
|
||||
}
|
||||
logger.info(deviceId + " filter records num: "+count);
|
||||
return new double[]{sumE/count, sumN/count, sumD/count};
|
||||
}
|
||||
else{
|
||||
return new double[]{newRecord.getB562e(),newRecord.getB562n(),newRecord.getB562d()};
|
||||
if(count >= FILTER_MIN_RECORD_NUM) {
|
||||
return new double[]{sumE / count, sumN / count, sumD / count};
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user