| | |
| | | if (stockList.size() > 0){ |
| | | stockListVOS.addAll(Objects.requireNonNull(StockApi.getStockReailTimes(stockList))); |
| | | } |
| | | |
| | | // Create a list to hold Futures |
| | | List<CompletableFuture<Void>> futures = new ArrayList<>(); |
| | | |
| | | // Use CompletableFuture to perform asynchronous processing for each stockListVO |
| | | // for (StockListVO stockListVO : stockListVOS) { |
| | | // CompletableFuture<Void> future = CompletableFuture.runAsync(() -> { |
| | | // stockListVO.setNowPrice(iPriceServices.getNowPrice(stockListVO.getCode(), stockType).toString()); |
| | | // Map<String, Object> newStock = iPriceServices.getNewStock(stockListVO.getCode()); |
| | | // stockListVO.setHcrateP(newStock.get("pcp").toString()); |
| | | // }); |
| | | // futures.add(future); |
| | | // } |
| | | // |
| | | // // Wait for all futures to complete |
| | | // CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); |
| | | |
| | | RPageInfo pageInfo = new RPageInfo(); |
| | | pageInfo.setList(stockListVOS); |
| | | pageInfo.setStockType(stockType); |
| | |
| | | stockVO.setSpell(stock.getStockSpell()); |
| | | stockVO.setGid(stock.getStockGid().toUpperCase()); |
| | | Map<String, Object> newStock = iPriceServices.getNewStock(stock.getStockCode()); |
| | | stockVO.setHcrate(newStock.get("pcp").toString().replaceAll("%", "")); |
| | | stockVO.setToday_max(newStock.get("high").toString()); |
| | | stockVO.setToday_min(newStock.get("low").toString()); |
| | | stockVO.setHcrate(newStock.get("ChgPct").toString().replaceAll("%", "")); |
| | | stockVO.setToday_max(newStock.get("High").toString()); |
| | | stockVO.setToday_min(newStock.get("Low").toString()); |
| | | if(null != cacheBaseStock){ |
| | | stockVO.setOpen_px(cacheBaseStock.getOpen()); |
| | | stockVO.setPreclose_px(cacheBaseStock.getPrevClose()); |