diff --git a/src/main/java/cn/stock/market/infrastructure/job/Scraper.java b/src/main/java/cn/stock/market/infrastructure/job/Scraper.java index 6216088..de781c2 100644 --- a/src/main/java/cn/stock/market/infrastructure/job/Scraper.java +++ b/src/main/java/cn/stock/market/infrastructure/job/Scraper.java @@ -261,7 +261,7 @@ public class Scraper { .collect(Collectors.toList()); for (StockIpo stockIpo : listStockIpoList) { - StockIpo existIpo = existStockIpoList.stream().filter(a -> a.getStockCode().equals(stockIpo.getStockCode()) && (a.getExchangeType() == null || a.getExchangeType().isEmpty() || a.getExchangeType().equals(stockIpo.getExchangeType()) )).findFirst().orElse(null); + StockIpo existIpo = existStockIpoList.stream().filter(a -> a.getStockCode().equals(stockIpo.getStockCode()) && (a.getExchangeType() == null || a.getExchangeType().isEmpty() || a.getExchangeType().toLowerCase().trim().equals(stockIpo.getExchangeType().toLowerCase().trim()))).findFirst().orElse(null); if (existIpo != null) { if (existIpo.getExchangeType() == null || existIpo.getExchangeType().isEmpty()){ existIpo.setExchangeType(stockIpo.getExchangeType()); @@ -528,22 +528,23 @@ public class Scraper { public List convertToMoneyStock(List stockIpoList) { // Lấy danh sách tất cả stockCode và exchangeType từ stockIpoList Set stockCodes = stockIpoList.stream().map(StockIpo::getStockCode).collect(Collectors.toSet()); - Set exchangeTypes = stockIpoList.stream().map(StockIpo::getExchangeType).collect(Collectors.toSet()); +// Set exchangeTypes = stockIpoList.stream().map(StockIpo::getExchangeType).collect(Collectors.toSet()); + Set exchangeTypes = stockIpoList.stream().map(stockIpo -> stockIpo.getExchangeType().toUpperCase()).collect(Collectors.toSet()); // Lấy tất cả các MoneyStock tồn tại trong database với stockCode và exchangeType trong stockIpoList List existingMoneyStocks = moneyStockRepository.findAll( QMoneyStockPO.moneyStockPO.moneyScId.in(stockCodes) - .and(QMoneyStockPO.moneyStockPO.stockType.in(exchangeTypes)) + .and(QMoneyStockPO.moneyStockPO.stockType.upper().in(exchangeTypes)) ); // Lưu các stockCode và exchangeType đã tồn tại Set existingKeys = existingMoneyStocks.stream() - .map(ms -> ms.getMoneyScId() + ms.getStockType()) + .map(ms -> ms.getMoneyScId() + ms.getStockType().toUpperCase()) .collect(Collectors.toSet()); // Chỉ giữ những StockIpo chưa tồn tại return stockIpoList.stream() - .filter(stockIpo -> !existingKeys.contains(stockIpo.getStockCode() + stockIpo.getExchangeType())) + .filter(stockIpo -> !existingKeys.contains(stockIpo.getStockCode() + stockIpo.getExchangeType().toUpperCase())) .map(this::convert) .collect(Collectors.toList()); }