长时间没有接收数据重新获取基础数据(行车计划)调整
This commit is contained in:
parent
b51b9f7bba
commit
f78920ea33
@ -27,6 +27,8 @@ public class OccMessageManage implements ApplicationRunner {
|
||||
private Integer lineId;
|
||||
@Value("${occ.collectorData:false}")
|
||||
private Boolean collectorData;
|
||||
@Value("${receive-msg-timeout:6}")
|
||||
private Integer receiveMsgTimeout;
|
||||
Map<Integer, XianOccMessagingClient> clientMap = new HashMap<>();
|
||||
|
||||
public void sendMsg(Integer lineId, MessageData md, boolean isRealTime) {
|
||||
@ -46,7 +48,7 @@ public class OccMessageManage implements ApplicationRunner {
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
DeviceNameChangerManage.init();
|
||||
// 读取数据配置,创建客户端
|
||||
this.registerClient(new XianOccMessagingClient(this.lineId, this.realPort, this.unRealPort, this.serverHost, this.collectorData));
|
||||
this.registerClient(new XianOccMessagingClient(this.lineId, this.realPort, this.unRealPort, this.serverHost, this.collectorData, receiveMsgTimeout));
|
||||
for (XianOccMessagingClient client : this.clientMap.values()) {
|
||||
client.connect();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest;
|
||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum;
|
||||
import java.sql.Time;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -34,6 +35,8 @@ public class XianOccMessagingClient {
|
||||
*/
|
||||
private AtomicBoolean requestBaseDataFlag = new AtomicBoolean(false);
|
||||
|
||||
private final Long requestBaseTime;
|
||||
|
||||
public void send(MessageData md, boolean isRealTime) {
|
||||
OccTcpClientConnection conn = isRealTime ? rtConnection : nrtConnection;
|
||||
if (conn.connected) {
|
||||
@ -45,24 +48,22 @@ public class XianOccMessagingClient {
|
||||
}
|
||||
|
||||
|
||||
public XianOccMessagingClient(int lineId, Integer realPort, Integer unRealPort, String host, boolean collectorData) {
|
||||
public XianOccMessagingClient(int lineId, Integer realPort, Integer unRealPort, String host, boolean collectorData, Integer receiveMsgTimeout) {
|
||||
this.host = host;
|
||||
this.lineId = lineId;
|
||||
|
||||
this.requestBaseTime = TimeUnit.HOURS.toMillis(receiveMsgTimeout);
|
||||
// 创建实时和非实时消息连接
|
||||
this.rtConnection = new OccTcpClientConnection(this, host, realPort, collectorData);
|
||||
this.nrtConnection = new OccTcpClientConnection(this, host, unRealPort, false);
|
||||
}
|
||||
|
||||
|
||||
private final static long RESET_REQUEST_BASE_TIME = TimeUnit.HOURS.toMillis(2);
|
||||
|
||||
/**
|
||||
* 重置重新获取基础数据
|
||||
*/
|
||||
public void resetRequestBaseDataFlag() {
|
||||
//实时数据客户端断开,并且最新的获取时间 + 2小时小于当前时间
|
||||
if (Objects.equals(false, this.rtConnection.connected) && (this.rtConnection.receiveMessageLatest + RESET_REQUEST_BASE_TIME) < System.currentTimeMillis()) {
|
||||
if (Objects.equals(false, this.rtConnection.connected) && (this.rtConnection.receiveMessageLatest + this.requestBaseTime) < System.currentTimeMillis()) {
|
||||
this.requestBaseDataFlag.set(false);
|
||||
}
|
||||
}
|
||||
|
@ -42,5 +42,7 @@ jwt:
|
||||
key:
|
||||
pub: classpath:app.pub
|
||||
prv: classpath:app.key
|
||||
|
||||
#过滤OCC 数据中的rtu
|
||||
occ-not-handle-rtu: '{3: "81,82"}'
|
||||
#长时间没有接收occ数据超时,重新获取基础数据时间(小时)
|
||||
receive-msg-timeout: 1
|
||||
|
Loading…
Reference in New Issue
Block a user