update money ipo check
This commit is contained in:
@@ -528,22 +528,23 @@ public class Scraper {
|
|||||||
public List<MoneyStock> convertToMoneyStock(List<StockIpo> stockIpoList) {
|
public List<MoneyStock> convertToMoneyStock(List<StockIpo> stockIpoList) {
|
||||||
// Lấy danh sách tất cả stockCode và exchangeType từ stockIpoList
|
// Lấy danh sách tất cả stockCode và exchangeType từ stockIpoList
|
||||||
Set<String> stockCodes = stockIpoList.stream().map(StockIpo::getStockCode).collect(Collectors.toSet());
|
Set<String> stockCodes = stockIpoList.stream().map(StockIpo::getStockCode).collect(Collectors.toSet());
|
||||||
Set<String> exchangeTypes = stockIpoList.stream().map(StockIpo::getExchangeType).collect(Collectors.toSet());
|
// Set<String> exchangeTypes = stockIpoList.stream().map(StockIpo::getExchangeType).collect(Collectors.toSet());
|
||||||
|
Set<String> 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
|
// Lấy tất cả các MoneyStock tồn tại trong database với stockCode và exchangeType trong stockIpoList
|
||||||
List<MoneyStock> existingMoneyStocks = moneyStockRepository.findAll(
|
List<MoneyStock> existingMoneyStocks = moneyStockRepository.findAll(
|
||||||
QMoneyStockPO.moneyStockPO.moneyScId.in(stockCodes)
|
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
|
// Lưu các stockCode và exchangeType đã tồn tại
|
||||||
Set<String> existingKeys = existingMoneyStocks.stream()
|
Set<String> existingKeys = existingMoneyStocks.stream()
|
||||||
.map(ms -> ms.getMoneyScId() + ms.getStockType())
|
.map(ms -> ms.getMoneyScId() + ms.getStockType().toUpperCase())
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
// Chỉ giữ những StockIpo chưa tồn tại
|
// Chỉ giữ những StockIpo chưa tồn tại
|
||||||
return stockIpoList.stream()
|
return stockIpoList.stream()
|
||||||
.filter(stockIpo -> !existingKeys.contains(stockIpo.getStockCode() + stockIpo.getExchangeType()))
|
.filter(stockIpo -> !existingKeys.contains(stockIpo.getStockCode() + stockIpo.getExchangeType().toUpperCase()))
|
||||||
.map(this::convert)
|
.map(this::convert)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user