package org.springblade.modules.quartz.task; import org.springblade.modules.system.service.IUserService; import org.springblade.modules.training.service.TrainingRegistrationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; import java.text.SimpleDateFormat; import java.util.Date; /** * 定时任务 * @author zhongrj * @since 2022-03-10 */ @Component("task") public class Task { @Autowired private TrainingRegistrationService trainingRegistrationService; @Autowired private IUserService userService; public void testTask(){ System.out.println("测试定时任务执行-----------------"); } /** * 定时任务,每天凌晨1点执行一次, * 自动处理之前报了名,申请了考试又没有去考试的,做缺考标记,并将报名状态修改为已取消报名 */ // @Scheduled(cron = "0 0 23 * * ?") public void examApplyStatus(){ System.out.println("定时任务1:执行时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //自动处理之前报了名,申请了考试又没有去考试的,做缺考标记,并将报名状态修改为已取消报名 trainingRegistrationService.examApplyStatus(); } /** * 定时任务,处理考试中的人员 */ public void examLoading(){ System.out.println("定时任务,处理考试中的人员:执行时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //自动处理之前报了名,考试忘记提交或者中断考试的 trainingRegistrationService.examLoading(); } /** * 定时任务,6个月未登录人员,进行冻结 */ public void sixMonthNotLoginHandle(){ System.out.println("定时任务,6个月未登录人员,进行冻结:执行时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); userService.sixMonthNotLoginHandle(); } /** * 定时任务,12个月未登录人员,进行注销 */ public void oneYearNotLoginHandle(){ System.out.println("定时任务,12个月未登录人员,进行注销:执行时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); userService.oneYearNotLoginHandle(); } }