package com.njcn.influx.job;


import com.njcn.influx.service.OracleToMysqlService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;


/**
 * Description:
 * Date: 2026/04/20  上午 9:44【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Component
@EnableScheduling
@RequiredArgsConstructor
@Slf4j
public class OracleToMySqlJob {

    private final OracleToMysqlService oracleToMysqlService;


    @Scheduled(cron = "${business.executeEventExpression}")
    public void executeEvent() {
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();
        // 减去一个小时
        LocalDateTime oneHourAgo = now.minusHours(3);

        oracleToMysqlService.OracleToMySqlJob(oneHourAgo,now);
    }


    // ==============================
    // 每10分钟：重试 + 2天过期处理
    // ==============================
    @Scheduled(cron = "${business.retryAndCleanEvery10Min}")
    public void retryAndCleanEvery10Min() {

        oracleToMysqlService.retryAndCleanEvery10Min();;
    }
}
