新股修改的时间获取

This commit is contained in:
Achilles
2024-02-02 14:46:14 +08:00
parent 960946692d
commit 7b87dd8186

View File

@@ -9,6 +9,7 @@ import cn.stock.market.dto.StockIpoDTO;
import cn.stock.market.infrastructure.db.po.QStockIpoPO; import cn.stock.market.infrastructure.db.po.QStockIpoPO;
import cn.stock.market.infrastructure.db.po.StockIpoPO; import cn.stock.market.infrastructure.db.po.StockIpoPO;
import cn.stock.market.infrastructure.db.repo.BtodayStockRepo; import cn.stock.market.infrastructure.db.repo.BtodayStockRepo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -102,9 +103,10 @@ public class Scraper {
@Scheduled(cron = "0 0 5 * * ?") @Scheduled(cron = "0 0 15 * * ?")
@RequestMapping("/testScraperGetMoneyControllerNewIPO") @RequestMapping("/testScraperGetMoneyControllerNewIPO")
public void schedule2() { public void getMoneyControllerNewIPOSchedule() {
log.info("定时任务执行获取新股ipo的方法开始执行");
// 目标 URL // 目标 URL
String url = "https://www.moneycontrol.com/ipo/open-upcoming-ipos"; String url = "https://www.moneycontrol.com/ipo/open-upcoming-ipos";
// 创建 HttpClient 实例 // 创建 HttpClient 实例
@@ -197,12 +199,15 @@ public class Scraper {
.collect(Collectors.toList()); .collect(Collectors.toList());
listStockIpoList = listStockIpoList.stream() listStockIpoList = listStockIpoList.stream()
.filter(stockIpos -> !existingStockScIds.contains(stockIpos.getStockCode())).filter(stockIpo -> StringUtils.isNotBlank(stockIpo.getStockName())) .filter(stockIpos -> !existingStockScIds.contains(stockIpos.getStockCode()))/*.filter(stockIpo -> StringUtils.isNotBlank(stockIpo.getStockName()))*/
.collect(Collectors.toList()); .collect(Collectors.toList());
//保存全部的新股 //保存全部的新股
if(CollectionUtil.isNotEmpty(listStockIpoList)){ if(CollectionUtil.isNotEmpty(listStockIpoList)){
stockIpoRepository.saveAll(listStockIpoList); stockIpoRepository.saveAll(listStockIpoList);
log.info("定时任务执行获取新股ipo的方法开始结束,保存了数据:{}", JSON.toJSONString(listStockIpoList));
}else {
log.info("定时任务执行获取新股ipo的方法开始结束,没有数据");
} }
} }
@@ -217,6 +222,7 @@ public class Scraper {
} catch (IOException e) { } catch (IOException e) {
log.error("获取新股接口发生异常",e); log.error("获取新股接口发生异常",e);
} }
} }