package com.malk.aiwei.schedule; import com.malk.aiwei.service.AWClint; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; /** * @EnableScheduling 开启定时任务 [配置参考McScheduleTask] */ @Slf4j @Configuration @EnableScheduling @ConditionalOnProperty(name = {"spel.scheduling"}) public class AWScheduleTask { @Autowired private AWClint awClint; /** * 每天12.30,00.30点同步, 项目主数据 */ @Scheduled(cron = "0 30 0,12 * * ? ") public void sync_4() { try { awClint.syncProject(null); } catch (Exception e) { // 记录错误信息 e.printStackTrace(); } } /** * 每天凌晨1点同步, 预检项 */ @Scheduled(cron = "0 0 1 * * ? ") public void sync_1() { try { awClint.syncCheckList(0); } catch (Exception e) { // 记录错误信息 e.printStackTrace(); } } /** * 每天凌晨1.30点同步. 预检项 */ @Scheduled(cron = "0 30 1 * * ? ") public void sync_2() { try { awClint.syncCheckList(1); } catch (Exception e) { // 记录错误信息 e.printStackTrace(); } } /** * 每天凌晨2点同步, 预检项 */ @Scheduled(cron = "0 0 2 * * ? ") public void sync_3() { try { awClint.syncCheckList(2); } catch (Exception e) { // 记录错误信息 e.printStackTrace(); } } /** * 每天20点同步, 全量同步CRM */ @Scheduled(cron = "0 0 20 * * ? ") public void sync_5() { try { awClint.syncBaseLineForCRM(); } catch (Exception e) { // 记录错误信息 e.printStackTrace(); } } }