//package com.njcn.oracle.job;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.njcn.oracle.bo.param.DataAsynParam;
//import com.njcn.oracle.bo.param.ServiceTypeEnum;
//import com.njcn.oracle.bo.po.JobHistoryLog;
//import com.njcn.oracle.service.IOracleService;
//import com.njcn.oracle.service.JobHistoryLogService;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Objects;
//import java.util.Optional;
//
///**
// * Description:
// * Date: 2024/1/18  10:08【需求编号】
// *
// * @author clam
// * @version V1.0.0
// */
//
//@Component
//@EnableScheduling
//@RequiredArgsConstructor
//@Slf4j
//public class OracleToOralceJob {
//    private final IOracleService oracleService;
//
//    private final JobHistoryLogService jobHistoryLogService;
//
//    @Value("${job.slice:3}")
//    private int slice;
//    @Value("${job.startime}")
//    private String startime;
//    @Value("${job.endtime}")
//    private String endtime;
//
//    @Scheduled(cron="0 5 0 * * ?")
//    public void execute() {
//        QueryWrapper<JobHistoryLog> queryWrapper = new QueryWrapper<>();
//        queryWrapper.select("min(LAST_DATE) as LAST_DATE");
//        LocalDate startDate ;
//        LocalDate endDate ;
//        JobHistoryLog one = jobHistoryLogService.getBaseMapper().selectOne(queryWrapper);
//        //获取当前任务的结束时间
//        if (Objects.isNull(one)){
//            startDate =LocalDate.parse(startime);
//
//        }else {
//            startDate = one.getLastDate();
//            startDate = startDate.plusDays(-1);
//        }
//        //获取配置的endtime和执行到时时间减去执行天数当startday最大值当当前任务的开始时间
//        List<LocalDate> dates = Arrays.asList(LocalDate.parse(endtime), startDate.plusDays(-(slice-1)));
//
//        endDate = dates.stream().max(LocalDate::compareTo).get();
//
//
//        DataAsynParam dataAsynParam = new DataAsynParam();
//        dataAsynParam.setStartTime(endDate);
//        dataAsynParam.setEndTime(startDate);
//        dataAsynParam.setTableNames(ServiceTypeEnum.getExecutableTypes());
//        dataAsynParam.setExcuteType(2);
//        oracleService.dataBacthSysc(dataAsynParam);
//    }
//
//}
