Пример #1
0
  /** @return */
  @Override
  public StockStatics getStocksByIncreaseTotal() {
    List<String> codes = stockStatisticsRepository.findByIncrease();

    List<Stock> stocks = new ArrayList<>(codes.size());
    Timestamp from = TimeUtil.oneMonthAgo();
    Timestamp to = TimeUtil.now();
    for (String code : codes) {
      Stock stock = getStockByCodeAndTime(code, from, to);
      if (stock == null) continue;
      stocks.add(stock);
    }

    return new StockStatics(stocks);
  }
Пример #2
0
  @Override
  public Stock getStockByCode(String code) {
    List<StockItem> items = stockItemRepository.getStocksByCode(code);

    if (items.isEmpty()) return null;

    Stock stock = new Stock(items);
    StockStatistics stat = stockStatisticsRepository.findByCode(code);

    if (stat != null) {
      stock.setIncreaseTotal(stat.getIncreaseTotal());
      stock.setHighestPrice(stat.getHighestPrice());
      stock.setAverageGoldDays(stat.getAverageGoldDays());
    }

    return stock;
  }