Merge branch 'develop' into 'main'
Develop See merge request india/india_market_java!57
This commit is contained in:
@@ -61,11 +61,11 @@ public class StockIpoPO {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否显示【1 显示,2 不显示】 */
|
* 是否显示【1 显示,2 不显示】 */
|
||||||
Integer isShow;
|
Integer isShow = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否上市【1 未上市,2 已上市】 */
|
* 是否上市【1 未上市,2 已上市】 */
|
||||||
Integer isList;
|
Integer isList = 1;
|
||||||
|
|
||||||
Date createDate;
|
Date createDate;
|
||||||
|
|
||||||
|
|||||||
@@ -116,10 +116,11 @@ public class Scraper {
|
|||||||
public void getMoneyControllerNewIPOSchedule() {
|
public void getMoneyControllerNewIPOSchedule() {
|
||||||
log.info("定时任务执行获取新股ipo的方法开始执行");
|
log.info("定时任务执行获取新股ipo的方法开始执行");
|
||||||
// 目标 URL
|
// 目标 URL
|
||||||
String url = "https://www.moneycontrol.com/ipo/open-upcoming-ipos";
|
List<String> urls = Arrays.asList("https://www.moneycontrol.com/ipo/upcoming-ipos/", "https://www.moneycontrol.com/ipo/open-ipos/");
|
||||||
// 创建 HttpClient 实例
|
// 创建 HttpClient 实例
|
||||||
HttpClient client = HttpClients.createDefault();
|
HttpClient client = HttpClients.createDefault();
|
||||||
// 创建 HttpGet 请求
|
// 创建 HttpGet 请求
|
||||||
|
for (String url : urls) {
|
||||||
HttpGet request = new HttpGet(url);
|
HttpGet request = new HttpGet(url);
|
||||||
try {
|
try {
|
||||||
// 执行请求
|
// 执行请求
|
||||||
@@ -144,11 +145,18 @@ public class Scraper {
|
|||||||
JSONObject jsonObject = JSONObject.parseObject(jsonDataStr);
|
JSONObject jsonObject = JSONObject.parseObject(jsonDataStr);
|
||||||
log.info("获取到新股的json信息:"+jsonObject.toJSONString());
|
log.info("获取到新股的json信息:"+jsonObject.toJSONString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JSONObject pageProps = jsonObject.getJSONObject("props").getJSONObject("pageProps");
|
JSONObject pageProps = jsonObject.getJSONObject("props").getJSONObject("pageProps");
|
||||||
JSONObject ipoTableData = pageProps.getJSONObject("ipoTableData");
|
JSONObject ipoTableData = pageProps.getJSONObject("ipoTableData");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 解析 openData 和 upcomingData
|
// 解析 openData 和 upcomingData
|
||||||
JSONArray openData = ipoTableData.getJSONArray("openData");
|
JSONArray openData = ipoTableData.getJSONArray("openData");
|
||||||
|
// if (openData.isEmpty()){
|
||||||
|
// openData = ipoTableData.getJSONArray("openUpcomingData");
|
||||||
|
// }
|
||||||
JSONArray upcomingData = ipoTableData.getJSONArray("upcomingData");
|
JSONArray upcomingData = ipoTableData.getJSONArray("upcomingData");
|
||||||
List<StockIpo> listStockIpoList = new ArrayList<>();
|
List<StockIpo> listStockIpoList = new ArrayList<>();
|
||||||
for (int i = 0; i < openData.size(); i++) {
|
for (int i = 0; i < openData.size(); i++) {
|
||||||
@@ -161,8 +169,7 @@ public class Scraper {
|
|||||||
stockIpo.setListingDate(convertStringToTimestamp(entry.getString("listing_date")));
|
stockIpo.setListingDate(convertStringToTimestamp(entry.getString("listing_date")));
|
||||||
Integer totalNumber = 0;
|
Integer totalNumber = 0;
|
||||||
if(null!=entry.getInteger("issue_size")&&entry.getBigDecimal("issue_price")!=null&&!entry.getBigDecimal("issue_price").equals(BigDecimal.valueOf(0))){
|
if(null!=entry.getInteger("issue_size")&&entry.getBigDecimal("issue_price")!=null&&!entry.getBigDecimal("issue_price").equals(BigDecimal.valueOf(0))){
|
||||||
Integer issue_size = entry.getInteger("issue_size");
|
BigDecimal issueSize = new BigDecimal(entry.getLong("issue_size"));
|
||||||
BigDecimal issueSize = new BigDecimal(issue_size);
|
|
||||||
BigDecimal totalNumberBigDecimal = issueSize.divide(entry.getBigDecimal("issue_price"), 2, BigDecimal.ROUND_HALF_UP);
|
BigDecimal totalNumberBigDecimal = issueSize.divide(entry.getBigDecimal("issue_price"), 2, BigDecimal.ROUND_HALF_UP);
|
||||||
totalNumber = totalNumberBigDecimal.intValue();
|
totalNumber = totalNumberBigDecimal.intValue();
|
||||||
}
|
}
|
||||||
@@ -175,8 +182,8 @@ public class Scraper {
|
|||||||
if (stockIpo.getStockCode() == null || stockIpo.getStockName() == null){
|
if (stockIpo.getStockCode() == null || stockIpo.getStockName() == null){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
String codeDetail = entry.getString("url").substring(entry.getString("url").lastIndexOf('/') + 1);;
|
||||||
List<String> exchanges = getIpoExchange(stockIpo.getStockName(), stockIpo.getStockCode());
|
List<String> exchanges = getIpoExchange(stockIpo.getStockName(), codeDetail);
|
||||||
|
|
||||||
for (String exchange : exchanges) {
|
for (String exchange : exchanges) {
|
||||||
StockIpo ipo = new StockIpo();
|
StockIpo ipo = new StockIpo();
|
||||||
@@ -190,7 +197,7 @@ public class Scraper {
|
|||||||
ipo.setCreateDate(stockIpo.getCreateDate());
|
ipo.setCreateDate(stockIpo.getCreateDate());
|
||||||
ipo.setUpdateDate(stockIpo.getUpdateDate());
|
ipo.setUpdateDate(stockIpo.getUpdateDate());
|
||||||
ipo.setExchangeType(exchange);
|
ipo.setExchangeType(exchange);
|
||||||
|
ipo.setSourceType("3");
|
||||||
listStockIpoList.add(ipo);
|
listStockIpoList.add(ipo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +241,7 @@ public class Scraper {
|
|||||||
ipo.setCreateDate(stockIpo.getCreateDate());
|
ipo.setCreateDate(stockIpo.getCreateDate());
|
||||||
ipo.setUpdateDate(stockIpo.getUpdateDate());
|
ipo.setUpdateDate(stockIpo.getUpdateDate());
|
||||||
ipo.setExchangeType(exchange);
|
ipo.setExchangeType(exchange);
|
||||||
|
ipo.setSourceType("3");
|
||||||
listStockIpoList.add(ipo);
|
listStockIpoList.add(ipo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,9 +260,18 @@ public class Scraper {
|
|||||||
.map(StockIpo::getStockCode)
|
.map(StockIpo::getStockCode)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
listStockIpoList = listStockIpoList.stream()
|
for (StockIpo stockIpo : listStockIpoList) {
|
||||||
.filter(stockIpos -> !existingStockScIds.contains(stockIpos.getStockCode())).filter(stockIpo -> StringUtils.isNotBlank(stockIpo.getStockName()))
|
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);
|
||||||
.collect(Collectors.toList());
|
if (existIpo != null) {
|
||||||
|
if (existIpo.getExchangeType() == null || existIpo.getExchangeType().isEmpty()){
|
||||||
|
existIpo.setExchangeType(stockIpo.getExchangeType());
|
||||||
|
}
|
||||||
|
stockIpo.setId(existIpo.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// listStockIpoList = listStockIpoList.stream()
|
||||||
|
// .filter(stockIpos -> !existingStockScIds.contains(stockIpos.getStockCode())).filter(stockIpo -> StringUtils.isNotBlank(stockIpo.getStockName()))
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
|
||||||
//保存全部的新股
|
//保存全部的新股
|
||||||
if(CollectionUtil.isNotEmpty(listStockIpoList)){
|
if(CollectionUtil.isNotEmpty(listStockIpoList)){
|
||||||
@@ -278,6 +294,8 @@ public class Scraper {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("获取新股接口发生异常",e);
|
log.error("获取新股接口发生异常",e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user