|
@@ -27,13 +27,13 @@ public class QueryService {
|
|
|
this.tableService = tableService;
|
|
this.tableService = tableService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public PriceListDto performQueries(String[] exchanges, String coin, Integer startTime, Integer endTime) throws Exception {
|
|
|
|
|
|
|
+ public PriceListDto performQueries(String[] exchanges, String coin, Integer startTime, Integer endTime, boolean isAdd) throws Exception {
|
|
|
List<Future<ExchangeCoinPriceDto>> futures = new ArrayList<>();
|
|
List<Future<ExchangeCoinPriceDto>> futures = new ArrayList<>();
|
|
|
Set<ExchangeCoinPriceDto> results = new HashSet<>();
|
|
Set<ExchangeCoinPriceDto> results = new HashSet<>();
|
|
|
PriceListDto priceListDto = PriceListDto.builder().build();
|
|
PriceListDto priceListDto = PriceListDto.builder().build();
|
|
|
// 分发查询
|
|
// 分发查询
|
|
|
for (String exchange : exchanges) {
|
|
for (String exchange : exchanges) {
|
|
|
- TableQueryTask queryTask = new TableQueryTask(tableService, coin, exchange, startTime, endTime);
|
|
|
|
|
|
|
+ TableQueryTask queryTask = new TableQueryTask(tableService, coin, exchange, startTime, endTime, isAdd);
|
|
|
futures.add(executorService.submit(queryTask));
|
|
futures.add(executorService.submit(queryTask));
|
|
|
}
|
|
}
|
|
|
// 收集查询结果
|
|
// 收集查询结果
|
|
@@ -48,11 +48,14 @@ public class QueryService {
|
|
|
}
|
|
}
|
|
|
List<Future<ExchangeCoinPriceArrDto>> resultFutures = new LinkedList<>();
|
|
List<Future<ExchangeCoinPriceArrDto>> resultFutures = new LinkedList<>();
|
|
|
List<ExchangeCoinPriceArrDto> data = new LinkedList<>();
|
|
List<ExchangeCoinPriceArrDto> data = new LinkedList<>();
|
|
|
|
|
+ //
|
|
|
|
|
+ Set<Integer> times = generateArithmeticSequence(startTime, endTime);
|
|
|
|
|
+
|
|
|
// 获取已有时间的合集
|
|
// 获取已有时间的合集
|
|
|
- Set<Integer> times = new TreeSet<>();
|
|
|
|
|
- results.forEach(dto -> {
|
|
|
|
|
- times.addAll(dto.getPrices().keySet());
|
|
|
|
|
- });
|
|
|
|
|
|
|
+// Set<Integer> times = new TreeSet<>();
|
|
|
|
|
+// results.forEach(dto -> {
|
|
|
|
|
+// times.addAll(dto.getPrices().keySet());
|
|
|
|
|
+// });
|
|
|
|
|
|
|
|
for (ExchangeCoinPriceDto dto : results){
|
|
for (ExchangeCoinPriceDto dto : results){
|
|
|
DataAssembleTask task = new DataAssembleTask(dto, coin, times);
|
|
DataAssembleTask task = new DataAssembleTask(dto, coin, times);
|
|
@@ -85,13 +88,13 @@ public class QueryService {
|
|
|
return new Integer[]{startTimeInt, Math.toIntExact(threeDaysAgoSeconds)};
|
|
return new Integer[]{startTimeInt, Math.toIntExact(threeDaysAgoSeconds)};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static List<Integer> generateArithmeticSequence(int start, int end) {
|
|
|
|
|
|
|
+ public static Set<Integer> generateArithmeticSequence(int start, int end) {
|
|
|
if (start > end) {
|
|
if (start > end) {
|
|
|
System.out.println("start = " + start + ", end = " + end);
|
|
System.out.println("start = " + start + ", end = " + end);
|
|
|
throw new IllegalArgumentException("首项必须小于或等于末项");
|
|
throw new IllegalArgumentException("首项必须小于或等于末项");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- List<Integer> sequence = new ArrayList<>();
|
|
|
|
|
|
|
+ Set<Integer> sequence = new TreeSet<>();
|
|
|
for (int i = start; i <= end; i++) {
|
|
for (int i = start; i <= end; i++) {
|
|
|
sequence.add(i);
|
|
sequence.add(i);
|
|
|
}
|
|
}
|