1、推送bug修改:如果只有项目号没有设备号,会推送全部项目
This commit is contained in:
parent
243406ec53
commit
0c1f0edf41
@ -2,6 +2,9 @@ package com.imdroid.beidou_fwd.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.imdroid.beidou_fwd.entity.GZYMQTTData;
|
||||
import com.imdroid.common.util.GsonUtil;
|
||||
import com.imdroid.common.util.NumberUtils;
|
||||
import com.imdroid.common.util.ThreadManager;
|
||||
import com.imdroid.secapi.dto.*;
|
||||
import org.slf4j.Logger;
|
||||
@ -89,9 +92,10 @@ public class Forwarder {
|
||||
/***
|
||||
* 推送指定企业、设备ID、时间的GNSS记录,查找指定时间前cycle分钟的有效数据推送
|
||||
* @param sendTime:要推送的记录的时间
|
||||
* @param deviceId:设备ID,如果没有指定,则推送全部
|
||||
* @param resendRecord:重发记录
|
||||
*/
|
||||
private boolean forwardGnssRecords(LocalDateTime sendTime, String deviceId, ResendRecord resendRecord) {
|
||||
|
||||
private boolean forwardGnssRecords(LocalDateTime sendTime, ResendRecord resendRecord) {
|
||||
String endTime = sendTime.format(formatter);
|
||||
String beginTime = sendTime.minusMinutes(fwdCycleMinutes).format(formatter);
|
||||
|
||||
@ -122,8 +126,8 @@ public class Forwarder {
|
||||
gnssQueryWrapper.orderByDesc("createtime");
|
||||
gnssQueryWrapper.eq("enabled",true);
|
||||
gnssQueryWrapper.isNotNull("rpose");
|
||||
if(deviceId != null){
|
||||
gnssQueryWrapper.eq("deviceid", deviceId);
|
||||
if(resendRecord != null && resendRecord.getDeviceid()!=null){
|
||||
gnssQueryWrapper.eq("deviceid", resendRecord.getDeviceid());
|
||||
}
|
||||
List<GnssCalcData> locationRecords = gnssDataMapper.selectList(gnssQueryWrapper);
|
||||
if(locationRecords.size() == 0) return false;
|
||||
@ -141,6 +145,9 @@ public class Forwarder {
|
||||
}
|
||||
}
|
||||
if(projectId == null) continue;
|
||||
if(resendRecord != null && !projectId.equals(resendRecord.getProjectid())){
|
||||
continue;
|
||||
}
|
||||
|
||||
List<GnssCalcData> recordsToSend = projects.get(projectId);
|
||||
if(recordsToSend == null){
|
||||
@ -238,7 +245,7 @@ public class Forwarder {
|
||||
}
|
||||
|
||||
void forwardCurrentGnss() {
|
||||
if(forwardGnssRecords(LocalDateTime.now(),null,null)) {
|
||||
if(forwardGnssRecords(LocalDateTime.now(),null)) {
|
||||
// 推送失败记录、补发记录
|
||||
ThreadManager.getScheduledThreadPool().schedule(() -> {
|
||||
this.forwardHistoryGnss();
|
||||
@ -267,7 +274,7 @@ public class Forwarder {
|
||||
void forwardBatchGnssRecords(ResendRecord record) {
|
||||
LocalDateTime sendTime = record.getStarttime();
|
||||
while(sendTime.isBefore(record.getEndtime()) || sendTime.isEqual(record.getEndtime())){
|
||||
forwardGnssRecords(sendTime,record.getDeviceid(),record);
|
||||
forwardGnssRecords(sendTime,record);
|
||||
sendTime = sendTime.plusMinutes(fwdCycleMinutes);
|
||||
}
|
||||
}
|
||||
@ -364,4 +371,27 @@ public class Forwarder {
|
||||
gnssDataMapper.insert(locationRecord);
|
||||
}
|
||||
}
|
||||
|
||||
int sendTest(String projectId, List<GnssCalcData> records, LocalDateTime sentTime) {
|
||||
int sendNum = 0;
|
||||
|
||||
for (GnssCalcData locationRecord : records) {
|
||||
GZYMQTTData tranData = new GZYMQTTData();
|
||||
tranData.setCollectTime(locationRecord.getCreatetime().format(formatter));
|
||||
double n = NumberUtils.scale(locationRecord.getRposn(), 2);
|
||||
double e = NumberUtils.scale(locationRecord.getRpose(), 2);
|
||||
double d = NumberUtils.scale(locationRecord.getRposd(), 2);
|
||||
tranData.setX(n);
|
||||
tranData.setY(e);
|
||||
tranData.setZ(d);
|
||||
tranData.setDeviceType(2);
|
||||
tranData.setDeviceSn(locationRecord.getDeviceid());
|
||||
String json = GsonUtil.toJson(tranData);
|
||||
logger.info("forward to GZY mqtt: {}",json);
|
||||
|
||||
sendNum++;
|
||||
}
|
||||
|
||||
return sendNum;
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class GZYMQTTForwarder extends Forwarder {
|
||||
* 每半小时转发GNSS解算结果
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0/1 * * ?") // 每小时执行一次
|
||||
//@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
||||
//@Scheduled(cron = "0 0/5 * * * ?") // 每30分钟执行一次
|
||||
private void forwardGnss() {
|
||||
logger.info("gzy mqtt forwardGnss");
|
||||
forwardCurrentGnss();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user