@Slf4j
@Component
@Configuration
@EnableScheduling
public class SaticScheduleTask {
@Autowired
private UserService userService;
/**
*更新库
* @throws Exception
*/
@Scheduled(cron = "0 0 23 26 1 ?")
public void updateUserDeptCode() throws Exception{
Date date = new Date();
log.info("执行更库任务开始时间:{}",date);
String time = "2021-01-26 23:59:59";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date pointTime = simpleDateFormat.parse(time);
//为了防止执行时间配错,做的校验
if (date.after(pointTime)){
return;
}
//执行你更新的数据
userService.updateDeptCode();
log.info("执行更库任务结束");
}
}
@Scheduled(cron = “0 0 23 26 1 ?”)
corn="",这个字符串自己查配上就可以了啥时候执行项目支持几位