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