1、广西交科10分钟推送频率
This commit is contained in:
parent
b6b915f0d2
commit
df54876e79
@ -36,7 +36,7 @@ public class GXJKForwarder extends Forwarder {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
void registerMe() throws MqttException {
|
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 = new MQTTClient(brokerUrl, username, password,clientid);
|
||||||
mqttClient.connect();
|
mqttClient.connect();
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ public class GXJKForwarder extends Forwarder {
|
|||||||
/**
|
/**
|
||||||
* 每半小时转发GNSS解算结果
|
* 每半小时转发GNSS解算结果
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 0/1 * * ?") // 每30分钟执行一次
|
@Scheduled(cron = "0 0/10 * * * ?") // 每30分钟执行一次
|
||||||
private void forwardGnss() {
|
private void forwardGnss() {
|
||||||
logger.info("gxjk forwardGnss");
|
logger.info("gxjk forwardGnss");
|
||||||
forwardCurrentGnss();
|
forwardCurrentGnss();
|
||||||
|
|||||||
@ -2,15 +2,13 @@ package com.imdroid.sideslope.executor;
|
|||||||
|
|
||||||
import com.imdroid.common.util.HexUtil;
|
import com.imdroid.common.util.HexUtil;
|
||||||
import com.imdroid.secapi.client.BeidouClient;
|
import com.imdroid.secapi.client.BeidouClient;
|
||||||
import com.imdroid.secapi.dto.GnssMsg;
|
import com.imdroid.secapi.client.RtcmClient;
|
||||||
import com.imdroid.secapi.dto.GnssMsgMapper;
|
import com.imdroid.secapi.dto.*;
|
||||||
import com.imdroid.secapi.dto.GnssStatus;
|
|
||||||
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
|
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
|
||||||
import com.imdroid.sideslope.sal.DeviceService;
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
import com.imdroid.sideslope.sal.Device;
|
import com.imdroid.sideslope.sal.Device;
|
||||||
import com.imdroid.sideslope.service.DataPersistService;
|
import com.imdroid.sideslope.service.DataPersistService;
|
||||||
import com.imdroid.common.util.ThreadManager;
|
import com.imdroid.common.util.ThreadManager;
|
||||||
import com.imdroid.sideslope.web.ApiController;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -19,6 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Layton
|
* @author Layton
|
||||||
* @date 2023/2/2 20:40
|
* @date 2023/2/2 20:40
|
||||||
@ -38,16 +37,22 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
@Resource(name = "local")
|
@Resource(name = "local")
|
||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
@Autowired
|
@Autowired
|
||||||
ApiController apiController;
|
private GnssGroupMapper gnssGroupMapper;
|
||||||
|
@Autowired
|
||||||
|
RtcmClient rtcmClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void execute(D3F0SelfCheckMessage message) {
|
public Void execute(D3F0SelfCheckMessage message) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("receive d3f0 message of device: "+message.getId());
|
logger.debug("receive d3f0 message of device: "+message.getId());
|
||||||
}
|
}
|
||||||
// 补齐tenantId
|
|
||||||
Device device = deviceService.findByDeviceId(message.getId());
|
Device device = deviceService.findByDeviceId(message.getId());
|
||||||
if(device == null) return null;
|
if(device == null) return null;
|
||||||
|
|
||||||
|
// 检查是否需要对设备的F9P进行断电操作
|
||||||
|
checkAndSendF9PPowerOffCommand(device);
|
||||||
|
// 补齐tenantId
|
||||||
message.setTenantId(device.getTenantId());
|
message.setTenantId(device.getTenantId());
|
||||||
device.updateRx(message.getHeader(),message.getLen(),1);
|
device.updateRx(message.getHeader(),message.getLen(),1);
|
||||||
|
|
||||||
@ -66,7 +71,6 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
|
|
||||||
}
|
}
|
||||||
dataPersistService.saveDeviceState(message);
|
dataPersistService.saveDeviceState(message);
|
||||||
checkAndSendF9PPowerOffCommand(device);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -81,28 +85,24 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
private void checkAndSendF9PPowerOffCommand(Device device){
|
private void checkAndSendF9PPowerOffCommand(Device device){
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
// 针对 2419 编号开头的测站设备,检查其 F9P 运行的时间,每隔48小时需要使其断电
|
// 针对 2419 编号开头的测站设备,检查其 F9P 运行的时间,每隔48小时需要使其断电
|
||||||
|
// 断电时间记录保存于缓存之中,不必查询数据库
|
||||||
|
// 平台重启会清除缓存,所以每次重启后收到该设备的第一条D3F0自检消息后,让其 F9P 断电,以保证F9P断电时间小于等于 48 小时
|
||||||
if(device.getDeviceId().startsWith("2419") && device.getDeviceType() == 0){
|
if(device.getDeviceId().startsWith("2419") && device.getDeviceType() == 0){
|
||||||
// 缓存中若没有 F9P 最近一次断电时间的记录,则初始化它为当前时间
|
// 缓存中若没有 F9P 最近一次断电时间的记录,则立即发送F9P断电指令
|
||||||
if(device.getLastF9PPowerOffTime() == null){
|
if(device.getLastF9PPowerOffTime() == null){
|
||||||
|
sendF9PPowerOffCommand(device);
|
||||||
|
// 初始化 F9P 断电时间
|
||||||
device.setLastF9PPowerOffTime(now);
|
device.setLastF9PPowerOffTime(now);
|
||||||
logger.debug("设备" + device.getDeviceId() + ": F9P 最近一次断电时间初始化为 " + device.getLastF9PPowerOffTime());
|
logger.debug("设备" + device.getDeviceId() + ": F9P 最近一次断电时间初始化为 " + device.getLastF9PPowerOffTime());
|
||||||
}
|
}
|
||||||
// 检查 F9P 最近一次断电时间是否超过 48 小时 ,若是,则发送断电指令
|
// 检查 F9P 最近一次断电时间是否超过 48 小时 ,若是,则发送断电指令
|
||||||
if(device.getLastF9PPowerOffTime().isBefore(now.minusHours(48))){
|
else if(device.getLastF9PPowerOffTime().isBefore(now.minusHours(48))){
|
||||||
logger.debug("设备 "+device.getDeviceId()+" 的 F9P 距离上一次断电已超过48小时,发送F9P断电指令");
|
logger.debug("设备 "+device.getDeviceId()+" 的 F9P 距离上一次断电已超过48小时,发送F9P断电指令");
|
||||||
|
sendF9PPowerOffCommand(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;
|
|
||||||
|
|
||||||
apiController.config(device.getDeviceId(), sendCmd);
|
|
||||||
saveMsg(device.getDeviceId(), device.getTenantId(),0xD313, sendCmd, true);
|
|
||||||
// 更新F9P断电时间,用于下一个48小时周期后的判断
|
// 更新F9P断电时间,用于下一个48小时周期后的判断
|
||||||
device.setLastF9PPowerOffTime(now);
|
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));
|
gnssMsg.setContent(content.substring(0,128));
|
||||||
msgMapper.insert(gnssMsg);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user