【线网测试数据查询频率】
This commit is contained in:
parent
f7879fe0d7
commit
56b7a0d14e
@ -25,9 +25,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 线路设备信息更新
|
||||
*/
|
||||
/** 线路设备信息更新 */
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LineDeviceStatusService {
|
||||
@ -73,17 +71,31 @@ public class LineDeviceStatusService {
|
||||
public void refreshTestData() {
|
||||
List<MessageData> allMockData = nccMockDataService.loadAllTrainInitData();
|
||||
DeviceStatusConvertorManager.doConvertor(allMockData);
|
||||
int frequency = 1500, stopTime = 30000;
|
||||
AtomicLong id = new AtomicLong(0);
|
||||
AtomicLong resetTimes = new AtomicLong(stopTime);
|
||||
Executors.newSingleThreadScheduledExecutor()
|
||||
.scheduleWithFixedDelay(
|
||||
() -> {
|
||||
int count = (int) (Math.random() * 12);
|
||||
List<MessageData> updateMockData =
|
||||
nccMockDataService.loadUpdateData(id, MessageId.TRAIN_RECORD.name(), count);
|
||||
DeviceStatusConvertorManager.doConvertor(updateMockData);
|
||||
boolean isEmpty = true;
|
||||
if (resetTimes.get() == stopTime) { // 代表还没有停顿,不相等说明已经进入空循环
|
||||
int count = (int) (Math.random() * 12);
|
||||
List<MessageData> updateMockData =
|
||||
nccMockDataService.loadUpdateData(id, MessageId.TRAIN_RECORD.name(), count);
|
||||
DeviceStatusConvertorManager.doConvertor(updateMockData);
|
||||
isEmpty = updateMockData.size() == 0;
|
||||
}
|
||||
if (isEmpty) { // 假数据已经用完了,开始重复使用,中间停顿30000ms
|
||||
if (resetTimes.get() <= 0) {
|
||||
id.set(0);
|
||||
resetTimes.set(stopTime);
|
||||
} else {
|
||||
resetTimes.set(resetTimes.get() - frequency);
|
||||
}
|
||||
}
|
||||
},
|
||||
1500,
|
||||
1500,
|
||||
frequency,
|
||||
frequency,
|
||||
TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user