package com.integrated.zyyt; import com.integrated.zyyt.service.ZyytService; import com.integrated.zyyt.util.ZyytUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource; import java.time.LocalDate; import java.time.temporal.ChronoUnit; /** * @ClassName ZyytQuartz * @Author cy * @Date 2022/11/15 * @Description * @Version 1.0 **/ @Configuration @Slf4j public class ZyytQuartz { @Resource private ZyytService zyytService; @Resource private JdbcTemplate jdbcTemplate; @Scheduled(cron = "0 0/30 * * * ?") private void stationInfoTask() { LocalDate yestDay = LocalDate.now().minus(1, ChronoUnit.DAYS); if (ZyytUtil.canGetAgain("STATIONINFO", yestDay)) { log.info("执行stationInfoTask--{}", yestDay); zyytService.stationInfoTasks(); } else { log.info("放弃执行stationInfoTask--{}", yestDay); } } @Scheduled(cron = "0 3/30 * * * ?") private void shkdrbTasks() { LocalDate yestDay = LocalDate.now().minus(1, ChronoUnit.DAYS); if (ZyytUtil.canGetAgain("YYZT_T_SHKDRB", yestDay)) { log.info("执行shkdrbTasks--{}", yestDay); zyytService.shkdrbTasks(yestDay); } else { log.info("放弃执行shkdrbTasks--{}", yestDay); } } @Scheduled(cron = "0 7/30 * * * ?") private void djtjbTasks() { LocalDate yestDay = LocalDate.now().minus(1, ChronoUnit.DAYS); if (!ZyytUtil.canGetAgain("YYZT_T_DJTJB", yestDay)) { log.info("放弃执行djtjbTasks--{}", yestDay); } log.info("执行djtjbTasks--{}", yestDay); zyytService.djtjbTasks(yestDay); } }