修改了getModel

This commit is contained in:
zms 2025-05-14 17:42:27 +08:00
parent 918fe5452d
commit cd74050fa9

View File

@ -47,6 +47,10 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
@Autowired @Autowired
private DataPersistService dataPersistService; private DataPersistService dataPersistService;
// 添加一个成员变量用于追踪每个测站最后一次转发D300数据的时间
private final Map<String, Long> lastD300ForwardTimeMap = new ConcurrentHashMap<>();
private static final long D300_FORWARD_INTERVAL = 10000; // 10秒单位毫秒
@Override @Override
public Void execute(D331RtcmMessage message) { public Void execute(D331RtcmMessage message) {
String id = message.getId(); String id = message.getId();
@ -117,18 +121,61 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
deviceChannel = OnlineChannels.INSTANCE.getConfigChannel(deviceId); deviceChannel = OnlineChannels.INSTANCE.getConfigChannel(deviceId);
} }
// 读取数据库中model字段判断基站类型
Short baseStationModel = deviceBs.getModel();
if (baseStationModel == 1) {
// 基站类型为1正常执行
if(deviceChannel != null && deviceChannel.isOnline()) { if(deviceChannel != null && deviceChannel.isOnline()) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("forward d331 rtcm from {} to device {}", id, deviceId); logger.debug("forward d331 rtcm from {} to device {}", id, deviceId);
} }
if (deviceId.startsWith("2307")) { ByteBuf buf = Unpooled.buffer();
buf.writeBytes(forwardBytes);
deviceChannel.writeAndFlush(buf);
}
} else if (baseStationModel == 0) {
// 基站类型为0判断测站类型
if(device.getModel() == 0){
// 测站类型为0正常执行
if(deviceId.startsWith("2307")){
// 处理2307型号的测站
forwardBytes[2] = (byte) (forwardBytes[2] & 0x07);//兼容不带序号的测站 forwardBytes[2] = (byte) (forwardBytes[2] & 0x07);//兼容不带序号的测站
}
// 对所有测站类型为0的设备执行转发
if(deviceChannel != null && deviceChannel.isOnline()) {
if (logger.isDebugEnabled()) {
logger.debug("forward d331 rtcm from {} to device {}", id, deviceId);
} }
ByteBuf buf = Unpooled.buffer(); ByteBuf buf = Unpooled.buffer();
buf.writeBytes(forwardBytes); buf.writeBytes(forwardBytes);
deviceChannel.writeAndFlush(buf); deviceChannel.writeAndFlush(buf);
} }
} }
else if(device.getModel() == 1){
// 在转发的数据后添加特定字符串且频率为5秒一次
if(deviceChannel != null && deviceChannel.isOnline()) {
if (logger.isDebugEnabled()) {
logger.debug("forward d331 rtcm from {} to device {}", id, deviceId);
}
ByteBuf buf = Unpooled.buffer();
buf.writeBytes(forwardBytes);
// 检查是否满足10秒转发间隔只有满足条件时才添加D300字符串
long currentTime = System.currentTimeMillis();
Long lastForwardTime = lastD300ForwardTimeMap.getOrDefault(deviceId, 0L);
if(currentTime - lastForwardTime >= D300_FORWARD_INTERVAL) {
// 每10秒添加一次D300字符串
buf.writeBytes("D300133ED67C033A96442E358C8B47FE2B05CD2770B9E41915".getBytes());
// 更新最后转发时间
lastD300ForwardTimeMap.put(deviceId, currentTime);
}
deviceChannel.writeAndFlush(buf);
}
}
}
}
} }
// 如果30分钟内收到不到d3f0和d3f2则根据UDP最后一个报文触发状态更新和统计 // 如果30分钟内收到不到d3f0和d3f2则根据UDP最后一个报文触发状态更新和统计