package com.gci.boot.modules.task.vehicles;

import com.gci.boot.modules.vehicles.service.ITbAnnualInspectionRemindService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration
@EnableScheduling
@Slf4j
public class AnnualInspectionRemindTask {
    @Autowired
    private ITbAnnualInspectionRemindService annualInspectionRemindService;

    /**
     * 每日凌晨更新年检提醒数据
     */
    @Scheduled(cron = "30 0 00 * * ? ")
    public void init () {
        long l = System.currentTimeMillis();
        log.info("每日凌晨更新年检提醒数据开始");
        try {
            annualInspectionRemindService.updateDate();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("每日凌晨更新年检提醒数据生成失败",e);
        }
        log.info("每日凌晨更新年检提醒数据结束，耗时：{}",l - System.currentTimeMillis());
    }
}
