package com.njcn.mysql.job;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.njcn.mysql.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: 2024/1/18  10:15【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Component
@EnableScheduling
@RequiredArgsConstructor
@Slf4j
public class OracleToMysqlDBJob {

    private final OracleToMysqlService oracleToMysqlService;


    @Scheduled(cron="0 0 8 * * ?")
    public void executeEvent() {
        // 获取当前时间
        String date = DateUtil.format(LocalDateTime.now().minusDays(1), DatePattern.NORM_DATE_PATTERN);
        System.out.println("-----------------------------day表同步------------------------------------------");
        oracleToMysqlService.insertDayHarmRateV(date,date);
        oracleToMysqlService.insertPqsIntegrity(date,date);
        oracleToMysqlService.insertDayV(date,date);
        oracleToMysqlService.insertLimitRate(date,date);
        oracleToMysqlService.insertLimitTarget(date,date);
        oracleToMysqlService.insertComAsses(date,date);
        oracleToMysqlService.insertAsses(date,date);
        oracleToMysqlService.insertDataI(date,date);
        oracleToMysqlService.insertPlt(date,date);
        oracleToMysqlService.insertFlicker(date,date);
        oracleToMysqlService.insertInHarmV(date,date);
        System.out.println("--------------------------------------------------------------------------------\n");
    }

    @Scheduled(cron="0 0/10 * * * ?")
    public void executeLineRunFlag() {
        // 获取当前时间
        System.out.println("--------------------------------监测点运行状态同步------------------------------------");
        oracleToMysqlService.LineRunFlag();
        System.out.println("-----------------------------------------------------------------------------------\n");
    }

}
