|
|
@@ -11,10 +11,12 @@ import com.liangjiang.price_collection.utils.TableQueryTask;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.print.DocFlavor;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.Future;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class QueryService {
|
|
|
@@ -44,13 +46,15 @@ public class QueryService {
|
|
|
}
|
|
|
}
|
|
|
if(CollectionUtil.isEmpty(results)){
|
|
|
- return PriceListDto.builder().time(new LinkedList<>()).values(new LinkedList<>()).build();
|
|
|
+ return PriceListDto.builder().time(new HashSet<>()).values(new LinkedList<>()).build();
|
|
|
}
|
|
|
List<Future<ExchangeCoinPriceArrDto>> resultFutures = new LinkedList<>();
|
|
|
List<ExchangeCoinPriceArrDto> data = new LinkedList<>();
|
|
|
- // 获取时间段的所有秒级
|
|
|
- List<Integer> times = generateArithmeticSequence(startTime, endTime);
|
|
|
-
|
|
|
+ // 获取已有时间的合集
|
|
|
+ Set<Integer> times = new HashSet<>();
|
|
|
+ results.forEach(dto -> {
|
|
|
+ times.addAll(dto.getPrices().keySet());
|
|
|
+ });
|
|
|
for (ExchangeCoinPriceDto dto : results){
|
|
|
DataAssembleTask task = new DataAssembleTask(dto, coin, times);
|
|
|
resultFutures.add(executorService.submit(task));
|
|
|
@@ -62,7 +66,7 @@ public class QueryService {
|
|
|
data.add(dto);
|
|
|
}
|
|
|
priceListDto.setTime(times);
|
|
|
- priceListDto.setValues(data);
|
|
|
+ priceListDto.setValues(data.stream().sorted(Comparator.comparing(ExchangeCoinPriceArrDto::getExchange)).collect(Collectors.toList()));
|
|
|
return priceListDto;
|
|
|
}
|
|
|
|