Merge branch 'develop' into 'main'
Develop See merge request india/india_market_java!62
This commit is contained in:
@@ -261,7 +261,7 @@ public class Scraper {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
for (StockIpo stockIpo : listStockIpoList) {
|
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 != null) {
|
||||||
if (existIpo.getExchangeType() == null || existIpo.getExchangeType().isEmpty()){
|
if (existIpo.getExchangeType() == null || existIpo.getExchangeType().isEmpty()){
|
||||||
existIpo.setExchangeType(stockIpo.getExchangeType());
|
existIpo.setExchangeType(stockIpo.getExchangeType());
|
||||||
@@ -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