修正备选基站推送bug,增加切换日志
This commit is contained in:
parent
38ba6f83a4
commit
918fe5452d
@ -25,7 +25,9 @@ import javax.annotation.Resource;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,6 +39,7 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
|
private static final Map<String ,Boolean> deviceBackupStatus = new ConcurrentHashMap<>();
|
||||||
@Resource(name = "local")
|
@Resource(name = "local")
|
||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -83,11 +86,18 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
Device primaryBase = deviceService.findByDeviceId(primaryBaseId);
|
Device primaryBase = deviceService.findByDeviceId(primaryBaseId);
|
||||||
// 如果主基站仍然在线,则跳过备选基站的数据
|
// 如果主基站仍然在线,则跳过备选基站的数据
|
||||||
if (primaryBase != null && isBaseStationOnline(primaryBase)) {
|
if (primaryBase != null && isBaseStationOnline(primaryBase)) {
|
||||||
|
if(deviceBackupStatus.remove(deviceId) != null){
|
||||||
|
logger.info("设备 {} 从备用基站 {} 切换回主基站 {}",
|
||||||
|
deviceId, id, primaryBaseId);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String hexPrimaryBase = String.format("%06x",Integer.parseInt(primaryBaseId));
|
String hexPrimaryBase = String.format("%06x",Integer.parseInt(primaryBaseId));
|
||||||
System.out.println(hexPrimaryBase);
|
if(deviceBackupStatus.putIfAbsent(deviceId,true) == null){
|
||||||
|
logger.info("设备 {} 从主基站 {} 切换到备用基站 {}",
|
||||||
|
deviceId, primaryBaseId, id);
|
||||||
|
}
|
||||||
|
|
||||||
modifyData[5] = (byte) Integer.parseInt(hexPrimaryBase.substring(0,2),16);
|
modifyData[5] = (byte) Integer.parseInt(hexPrimaryBase.substring(0,2),16);
|
||||||
modifyData[6] = (byte) Integer.parseInt(hexPrimaryBase.substring(2,4),16);
|
modifyData[6] = (byte) Integer.parseInt(hexPrimaryBase.substring(2,4),16);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user