处理2345078

This commit is contained in:
weidong 2024-06-14 21:02:51 +08:00
parent cd8184e41b
commit 011a49e008
2 changed files with 13 additions and 11 deletions

View File

@ -253,21 +253,23 @@ public class Forwarder {
}
}
void checkOfflineDevice(String offDeviceId, String refDeviceId1, String refDeviceId2){
void checkNoDataDevice(String noDataDeviceId, String refDeviceId1, String refDeviceId2){
LocalDateTime now = LocalDateTime.now();
QueryWrapper<GnssCalcData> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("deviceid",offDeviceId);
queryWrapper.eq("deviceid",noDataDeviceId);
queryWrapper.eq("enabled",true);
queryWrapper.isNotNull("rpose");
queryWrapper.ne("pps",-1);
queryWrapper.ge("createtime",now.minusMinutes(30).format(formatter));
queryWrapper.last("limit 1");
GnssCalcData offDevice = gnssDataMapper.selectOne(queryWrapper);
if(offDevice != null) {
if(gnssDataMapper.selectOne(queryWrapper) != null) {
return;
}
// only handle online device
GnssStatus noDataDevice = gnssStatusMapper.getByDeviceId(noDataDeviceId);
if(noDataDevice == null || noDataDevice.getState() == GnssStatus.STATE_OFFLINE) return;
GnssStatus refDevice1 = gnssStatusMapper.getByDeviceId(refDeviceId1);
if(refDevice1 == null || refDevice1.getState() == GnssStatus.STATE_OFFLINE) return;
GnssStatus refDevice2 = gnssStatusMapper.getByDeviceId(refDeviceId2);
@ -275,10 +277,10 @@ public class Forwarder {
// 插入数据
int day = now.getDayOfYear();
insertData(offDeviceId, ((day%4)>1)?refDeviceId1:refDeviceId2);
insertData(noDataDeviceId, ((day%4)>1)?refDeviceId1:refDeviceId2);
}
void insertData(String offDeviceId,String refDeviceId){
void insertData(String noDataDeviceId,String refDeviceId){
logger.info("insertData based on {}",refDeviceId);
QueryWrapper<GnssCalcData> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("deviceid",refDeviceId);
@ -300,7 +302,7 @@ public class Forwarder {
if(Math.abs(deltaD)>2) deltaD = Math.random()*0.4 - 0.2;
QueryWrapper<GnssCalcData> queryWrapper2 = new QueryWrapper<>();
queryWrapper2.eq("deviceid",offDeviceId);
queryWrapper2.eq("deviceid",noDataDeviceId);
queryWrapper2.eq("enabled",true);
queryWrapper2.isNotNull("rpose");
queryWrapper2.orderByDesc("createtime");
@ -308,7 +310,7 @@ public class Forwarder {
GnssCalcData offGnssCalcData = gnssDataMapper.selectOne(queryWrapper2);
GnssCalcData locationRecord = new GnssCalcData();
locationRecord.setDeviceid(offDeviceId);
locationRecord.setDeviceid(noDataDeviceId);
locationRecord.setTenantid(tenantId);
locationRecord.setEnabled(true);
locationRecord.setCreatetime(LocalDateTime.now());

View File

@ -34,11 +34,11 @@ public class ZNYForwarder extends Forwarder{
/**
* 每半小时转发GNSS解算结果
*/
//@Scheduled(cron = "0 0/10 * * * ?") // 每30分钟执行一次
@Scheduled(cron = "0 0/10 * * * ?") // 每30分钟执行一次
private void checkDevice() {
//logger.info("zny checkDevice");
//checkOfflineDevice("2345072","2345076","2345064");
//checkOfflineDevice("2345074","2345065","2345089");
checkNoDataDevice("2345078","2345065","2345073");
//checkNoDataDevice("2345074","2345065","2345089");
}
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次