| | |
| | | if (list.isEmpty()) { |
| | | return; |
| | | } |
| | | List<String> stockCodeList = list.stream().map(StockRealTimeBean::getSymbol).collect(Collectors.toList()); |
| | | List<Item> stockList = itemService.list(new QueryWrapper<Item>().in("symbol", stockCodeList)); |
| | | List<String> stockCodeList = list.stream().map(StockRealTimeBean::getId).collect(Collectors.toList()); |
| | | List<Item> stockList = itemService.list(new QueryWrapper<Item>() |
| | | .eq("type", Item.US_STOCKS).in("stock_code", stockCodeList)); |
| | | |
| | | List<Item> indicesList = itemService.list(new QueryWrapper<Item>() |
| | | .eq("type", Item.indices)); |
| | | |
| | | log.info("同步股票 已有数据 {} 获取数据 {}", stockList.size(), list.size()); |
| | | System.out.println(stockList); |
| | | List<Item> updateStockList = new ArrayList<>(); |
| | | for (StockRealTimeBean o : list) { |
| | | //System.out.println(o); |
| | | Item item = stockList.stream() |
| | | .filter(x -> x.getSymbol().equals(o.getSymbol()) && |
| | | x.getStockCode().equals(o.getId())) |
| | | .findFirst() |
| | | .orElse(null); |
| | | if (item != null) { //已有不添加 |
| | | continue; |
| | | } |
| | | item = indicesList.stream() |
| | | .filter(x -> x.getSymbol().equals(o.getSymbol())) |
| | | .findFirst() |
| | | .orElse(null); |
| | | if (item == null) { |
| | | item = new Item(); |
| | | if (item != null) { //已有不添加 |
| | | continue; |
| | | } |
| | | |
| | | item = new Item(); |
| | | String name = StringUtils.trim(o.getName()); |
| | | item.setEnName(name); |
| | | item.setName(name); |
| | |
| | | item.setShowStatus("1"); |
| | | item.setTradeStatus("1"); |
| | | item.setQuoteCurrency("USDT"); |
| | | item.setCrawlStatus("default_active"); |
| | | item.setStockCode(o.getId()); |
| | | |
| | | updateStockList.add(item); |
| | | |
| | |
| | | |
| | | DataCache.putRealtime(realtime.getSymbol(), realtime); |
| | | } |
| | | itemService.saveOrUpdateBatch(updateStockList); |
| | | log.info("同步股票 数据 成功 {} 总共同步数据 {}", eStockType.getCode(), list.size()); |
| | | if (!updateStockList.isEmpty()) { |
| | | itemService.saveOrUpdateBatch(updateStockList); |
| | | } |
| | | log.info("同步股票 数据 成功 {} 总共同步数据 {}", eStockType.getCode(), updateStockList.size()); |
| | | } catch ( |
| | | Exception e) { |
| | | log.error("同步出错", e); |