|
@@ -41,10 +41,6 @@ public class SimulatorHistoryDao implements IHistoryDao {
|
|
|
|
|
|
List<DoubleStatData> result = new ArrayList<>();
|
|
|
|
|
|
-
|
|
|
- int num = new Random().nextInt(1000) + 1; // 生成随机数量,范围为[1,1000]
|
|
|
- List<Long> timestampList = generateTimestampList(tsQuery.getStartTs(), tsQuery.getEndTs(), num);
|
|
|
-
|
|
|
double v1 = generateRandomDouble(0.0, 1000.0);
|
|
|
double v2 = generateRandomDouble(0.0, 1000.0);
|
|
|
|
|
@@ -93,8 +89,7 @@ public class SimulatorHistoryDao implements IHistoryDao {
|
|
|
public List<TsData> getDoubleTsDataHistory(TsQuery tsQuery) throws Exception {
|
|
|
List<TsData> tsDataList = new ArrayList<>();
|
|
|
|
|
|
- int num = new Random().nextInt(1000) + 1; // 生成随机数量,范围为[1,1000]
|
|
|
- List<Long> timestampList = generateTimestampList(tsQuery.getStartTs(), tsQuery.getEndTs(), num);
|
|
|
+ List<Long> timestampList = generateTimestampList(tsQuery.getStartTs(), tsQuery.getEndTs(), tsQuery.getInterval()*1000L);
|
|
|
|
|
|
for (Long aLong : timestampList) {
|
|
|
tsDataList.add(new DoubleTsData(aLong, (short) 0, generateRandomDouble(0.0, 1000.0)));
|
|
@@ -107,8 +102,7 @@ public class SimulatorHistoryDao implements IHistoryDao {
|
|
|
public List<TsData> getLongTsDataHistory(TsQuery tsQuery) throws Exception {
|
|
|
List<TsData> tsDataList = new ArrayList<>();
|
|
|
|
|
|
- int num = new Random().nextInt(1000) + 1; // 生成随机数量,范围为[1,1000]
|
|
|
- List<Long> timestampList = generateTimestampList(tsQuery.getStartTs(), tsQuery.getEndTs(), num);
|
|
|
+ List<Long> timestampList = generateTimestampList(tsQuery.getStartTs(), tsQuery.getEndTs(), tsQuery.getInterval()*1000L);
|
|
|
|
|
|
for (Long aLong : timestampList) {
|
|
|
tsDataList.add(new LongTsData(aLong, (short) 0, generateRandomInt(0, 100000)));
|
|
@@ -120,8 +114,7 @@ public class SimulatorHistoryDao implements IHistoryDao {
|
|
|
public List<TsData> getBooleanTsDataHistory(TsQuery tsQuery) throws Exception {
|
|
|
List<TsData> tsDataList = new ArrayList<>();
|
|
|
|
|
|
- int num = new Random().nextInt(1000) + 1; // 生成随机数量,范围为[1,1000]
|
|
|
- List<Long> timestampList = generateTimestampList(tsQuery.getStartTs(), tsQuery.getEndTs(), num);
|
|
|
+ List<Long> timestampList = generateTimestampList(tsQuery.getStartTs(), tsQuery.getEndTs(), tsQuery.getInterval()*1000L);
|
|
|
|
|
|
for (Long aLong : timestampList) {
|
|
|
tsDataList.add(new BooleanTsData(aLong, (short) 0, random.nextBoolean()));
|
|
@@ -138,16 +131,12 @@ public class SimulatorHistoryDao implements IHistoryDao {
|
|
|
* @param num 时间戳列表数量
|
|
|
* @return 随机的时间戳列表
|
|
|
*/
|
|
|
- public static List<Long> generateTimestampList(long startTs, long endTs, int num) {
|
|
|
- List<Long> timestampList = new ArrayList<>();
|
|
|
-
|
|
|
- for (int i = 0; i < num; i++) {
|
|
|
- // 生成随机数,并计算该随机数对应的时间戳
|
|
|
- long randomValue = startTs + (long) (Math.random() * (endTs - startTs));
|
|
|
- timestampList.add(randomValue);
|
|
|
+ public static List<Long> generateTimestampList(long startTs, long endTs, long num) {
|
|
|
+ List<Long> list = new ArrayList<>();
|
|
|
+ for (long timestamp = startTs; timestamp <= endTs; timestamp += num) {
|
|
|
+ list.add(timestamp);
|
|
|
}
|
|
|
-
|
|
|
- return timestampList;
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
/**
|