调整py脚本
This commit is contained in:
@@ -39,16 +39,16 @@ public class BetSchedule {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BetRecordRepository betRecordRepository;
|
private BetRecordRepository betRecordRepository;
|
||||||
|
|
||||||
// 每天早上7.07分开始,每5分钟执行一次到第二天早上6点结束(7:07, 7:12, 7:17...23:57, 0:02, 0:07...5:57)
|
// 从7:02分钟起每5分钟执行一次
|
||||||
// @Scheduled(cron = "0 7/5 7-23,0-6 * * ?")
|
@Scheduled(cron = "30 2/5 * * * ?")
|
||||||
public void placeBet() {
|
public void placeBet() {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
int hour = now.getHour();
|
int hour = now.getHour();
|
||||||
int minute = now.getMinute();
|
int minute = now.getMinute();
|
||||||
|
|
||||||
// 检查是否在7:07到第二天6:00之间
|
// 检查是否在7:02到第二天6:00之间
|
||||||
// 如果时间在6:00到7:06之间,则跳过执行
|
// 如果时间在6:00到7:01之间,则跳过执行
|
||||||
if ((hour == 6) || (hour == 7 && minute < 7)) {
|
if ((hour == 6) || (hour == 7 && minute < 2)) {
|
||||||
String currentTime = now.format(
|
String currentTime = now.format(
|
||||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||||
);
|
);
|
||||||
@@ -127,7 +127,6 @@ public class BetSchedule {
|
|||||||
try {
|
try {
|
||||||
// 1. 获取当前时间,格式化为与betTime相同的格式(假设betTime格式为yyyy-MM-dd HH:mm:ss)
|
// 1. 获取当前时间,格式化为与betTime相同的格式(假设betTime格式为yyyy-MM-dd HH:mm:ss)
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
String currentTime = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
|
|
||||||
// 2. 从BetRecord中获取第一条记录(根据betTime排序)
|
// 2. 从BetRecord中获取第一条记录(根据betTime排序)
|
||||||
System.out.println(" - 从BetRecord中获取第一条记录...");
|
System.out.println(" - 从BetRecord中获取第一条记录...");
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ public class CrawlerSchedule {
|
|||||||
// @Scheduled(cron = "*/9 * * * * ?")
|
// @Scheduled(cron = "*/9 * * * * ?")
|
||||||
/*@Scheduled(cron = "0 6-59/5 7-23 * * ?")
|
/*@Scheduled(cron = "0 6-59/5 7-23 * * ?")
|
||||||
@Scheduled(cron = "0 0-55/5 0-6 * * ?")*/
|
@Scheduled(cron = "0 0-55/5 0-6 * * ?")*/
|
||||||
|
// 从7:00分30秒起每5分钟执行一次
|
||||||
|
@Scheduled(cron = "30 0/5 * * * ?")
|
||||||
public void executeLotteryDraw() {
|
public void executeLotteryDraw() {
|
||||||
System.out.println("开始爬取开奖结果...");
|
System.out.println("开始爬取开奖结果...");
|
||||||
int retryCount = 0;
|
int retryCount = 0;
|
||||||
@@ -112,8 +114,8 @@ public class CrawlerSchedule {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
// 每7秒执行一次爬取今日已经结算
|
// 从7:00分30秒起每5分钟执行一次爬取今日已经结算
|
||||||
//@Scheduled(cron = "*/7 * * * * ?")
|
@Scheduled(cron = "30 0/5 * * * ?")
|
||||||
public void executeSettlement() {
|
public void executeSettlement() {
|
||||||
System.out.println("开始爬取今日已经结算...");
|
System.out.println("开始爬取今日已经结算...");
|
||||||
int retryCount = 0;
|
int retryCount = 0;
|
||||||
|
|||||||
@@ -49,9 +49,22 @@ public class ExBetScriptSchedule {
|
|||||||
schedule.executePythonScript();
|
schedule.executePythonScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 每分钟执行一次
|
// 从7:01分钟起每5分钟执行一次
|
||||||
@Scheduled(cron = "0 * * * * ?")
|
@Scheduled(cron = "30 1/5 * * * ?")
|
||||||
public void executePythonScript() {
|
public void executePythonScript() {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
int hour = now.getHour();
|
||||||
|
int minute = now.getMinute();
|
||||||
|
// 检查是否在7:02到第二天6:00之间
|
||||||
|
// 如果时间在6:00到7:01之间,则跳过执行
|
||||||
|
if ((hour == 6) || (hour == 7 && minute < 1)) {
|
||||||
|
String currentTime = now.format(
|
||||||
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||||
|
);
|
||||||
|
System.out.println(currentTime + " - 不在投注时间范围内,跳过执行");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("开始执行Python脚本...");
|
System.out.println("开始执行Python脚本...");
|
||||||
|
|
||||||
// 获取当前时间,格式化为yyyy-MM-dd HH:mm:ss
|
// 获取当前时间,格式化为yyyy-MM-dd HH:mm:ss
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ public class LotteryWebMagicCrawler implements PageProcessor {
|
|||||||
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
|
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||||
|
|
||||||
// 定义输出目录
|
// 定义输出目录
|
||||||
String directoryPath = "PyModel/data_test_dir"; // 项目根目录下的 output/json 文件夹
|
String directoryPath = "PyModel/current_data"; // 项目根目录下的 output/json 文件夹
|
||||||
|
|
||||||
// 使用年月日作为文件名(格式:result_yyyyMMdd.json)
|
// 使用年月日作为文件名(格式:result_yyyyMMdd.json)
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|||||||
Reference in New Issue
Block a user