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


import com.gci.boot.modules.customer.service.ITbScheduledPlanService;
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 SchedulePlanTask {
    @Autowired
    private ITbScheduledPlanService scheduledPlanService;

    /**
     * 每月一号
     */
    @Scheduled(cron = "0 0 0 1 * ? ")
    public void init () {
        long l = System.currentTimeMillis();
        log.info("定时每月一号生成巡检任务和客户回访开始");
        try {
            scheduledPlanService.initPlan();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("定时每月一号生成巡检任务和客户回访生成失败",e);
        }
        log.info("定时每月一号生成巡检任务和客户回访结束，耗时：{}",l - System.currentTimeMillis());
    }
}
