1、广西交科10分钟推送频率

This commit is contained in:
weidong 2024-08-06 11:56:14 +08:00
parent b6b915f0d2
commit df54876e79
2 changed files with 36 additions and 23 deletions

View File

@ -36,7 +36,7 @@ public class GXJKForwarder extends Forwarder {
@PostConstruct
void registerMe() throws MqttException {
init(FORWARDER_NAME, "MQTT "+brokerUrl,7,FWD_DEVICE_NAME,60);
init(FORWARDER_NAME, "MQTT "+brokerUrl,7,FWD_DEVICE_NAME,10);
mqttClient = new MQTTClient(brokerUrl, username, password,clientid);
mqttClient.connect();
}
@ -44,7 +44,7 @@ public class GXJKForwarder extends Forwarder {
/**
* 每半小时转发GNSS解算结果
*/
@Scheduled(cron = "0 0 0/1 * * ?") // 每30分钟执行一次
@Scheduled(cron = "0 0/10 * * * ?") // 每30分钟执行一次
private void forwardGnss() {
logger.info("gxjk forwardGnss");
forwardCurrentGnss();

View File

@ -2,15 +2,13 @@ package com.imdroid.sideslope.executor;
import com.imdroid.common.util.HexUtil;
import com.imdroid.secapi.client.BeidouClient;
import com.imdroid.secapi.dto.GnssMsg;
import com.imdroid.secapi.dto.GnssMsgMapper;
import com.imdroid.secapi.dto.GnssStatus;
import com.imdroid.secapi.client.RtcmClient;
import com.imdroid.secapi.dto.*;
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
import com.imdroid.sideslope.sal.DeviceService;
import com.imdroid.sideslope.sal.Device;
import com.imdroid.sideslope.service.DataPersistService;
import com.imdroid.common.util.ThreadManager;
import com.imdroid.sideslope.web.ApiController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +17,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
* @author Layton
* @date 2023/2/2 20:40
@ -38,16 +37,22 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
@Resource(name = "local")
private DeviceService deviceService;
@Autowired
ApiController apiController;
private GnssGroupMapper gnssGroupMapper;
@Autowired
RtcmClient rtcmClient;
@Override
public Void execute(D3F0SelfCheckMessage message) {
if (logger.isDebugEnabled()) {
logger.debug("receive d3f0 message of device: "+message.getId());
}
// 补齐tenantId
Device device = deviceService.findByDeviceId(message.getId());
if(device == null) return null;
// 检查是否需要对设备的F9P进行断电操作
checkAndSendF9PPowerOffCommand(device);
// 补齐tenantId
message.setTenantId(device.getTenantId());
device.updateRx(message.getHeader(),message.getLen(),1);
@ -66,7 +71,6 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
}
dataPersistService.saveDeviceState(message);
checkAndSendF9PPowerOffCommand(device);
});
return null;
@ -81,28 +85,24 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
private void checkAndSendF9PPowerOffCommand(Device device){
LocalDateTime now = LocalDateTime.now();
// 针对 2419 编号开头的测站设备检查其 F9P 运行的时间每隔48小时需要使其断电
// 断电时间记录保存于缓存之中不必查询数据库
// 平台重启会清除缓存所以每次重启后收到该设备的第一条D3F0自检消息后让其 F9P 断电以保证F9P断电时间小于等于 48 小时
if(device.getDeviceId().startsWith("2419") && device.getDeviceType() == 0){
// 缓存中若没有 F9P 最近一次断电时间的记录则初始化它为当前时间
// 缓存中若没有 F9P 最近一次断电时间的记录立即发送F9P断电指令
if(device.getLastF9PPowerOffTime() == null){
sendF9PPowerOffCommand(device);
// 初始化 F9P 断电时间
device.setLastF9PPowerOffTime(now);
logger.debug("设备" + device.getDeviceId() + ": F9P 最近一次断电时间初始化为 " + device.getLastF9PPowerOffTime());
}
// 检查 F9P 最近一次断电时间是否超过 48 小时 若是则发送断电指令
if(device.getLastF9PPowerOffTime().isBefore(now.minusHours(48))){
else if(device.getLastF9PPowerOffTime().isBefore(now.minusHours(48))){
logger.debug("设备 "+device.getDeviceId()+" 的 F9P 距离上一次断电已超过48小时发送F9P断电指令");
int flag = 0xD313;
String sendCmd = "2500";
short len = (short) (sendCmd.length()/2+4);
sendCmd = Integer.toHexString(flag)+
HexUtil.Short2HexString(len)+
HexUtil.Int2HexString(Integer.parseInt(device.getDeviceId()))+
sendCmd;
apiController.config(device.getDeviceId(), sendCmd);
saveMsg(device.getDeviceId(), device.getTenantId(),0xD313, sendCmd, true);
sendF9PPowerOffCommand(device);
// 更新F9P断电时间用于下一个48小时周期后的判断
device.setLastF9PPowerOffTime(now);
}else{
logger.debug("设备 "+device.getDeviceId()+" 的 F9P 距离上一次断电时间为:"+device.getLastF9PPowerOffTime());
}
}
}
@ -123,4 +123,17 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
gnssMsg.setContent(content.substring(0,128));
msgMapper.insert(gnssMsg);
}
void sendF9PPowerOffCommand(Device device){
int flag = 0xD313;
String sendCmd = "2500";
short len = (short) (sendCmd.length()/2+4);
sendCmd = Integer.toHexString(flag)+
HexUtil.Short2HexString(len)+
HexUtil.Int2HexString(Integer.parseInt(device.getDeviceId()))+
sendCmd;
rtcmClient.config(device.getDeviceId(), sendCmd);
saveMsg(device.getDeviceId(), device.getTenantId(),0xD313, sendCmd, true);
}
}