package com.songshu.mongo.controller; import com.songshu.mongo.service.StaticScheduleTaskService; import com.songshu.mongo.service.UpdateTingcheService; 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; import java.time.LocalDateTime; /** * cw * 定时任务 */ @Configuration @EnableScheduling @Slf4j public class StaticScheduleTaskController { @Autowired private StaticScheduleTaskService staticScheduleTaskService; @Autowired private UpdateTingcheService updateTingcheService; // /** // * @Scheduled-cron : 指定定时任务的执行时间 // * 或直接指定时间间隔,例如:5秒 // * @Scheduled(fixedRate=5000) 案例-案例 // */ // @Scheduled(cron = "0/5 * * * * ?") // private void configureTask() { // log.info("执行静态定时任务时间: {}", LocalDateTime.now()); // } // 每隔5秒执行一次:*/5 * * * * ? // 每隔1分钟执行一次:0 */1 * * * ? // 每天23点执行一次:0 0 23 * * ? // 每天凌晨1点执行一次:0 0 1 * * ? // 每月1号凌晨1点执行一次:0 0 1 1 * ? // 每月最后一天23点执行一次:0 0 23 L * ? // 每周星期天凌晨1点实行一次:0 0 1 ? * L // 在26分、29分、33分执行一次:0 26,29,33 * * * ? // 每天的0点、13点、18点、21点都执行一次:0 0 0,13,18,21 * * ? /** * 租赁合同 */ @Scheduled(cron = "0 0 1 * * ?") private void ScheduledTask() { //room 表 staticScheduleTaskService.SynchronousDataRoom(); //buildings 楼宇表 staticScheduleTaskService.SynchronousDataRuildings(); //客户合同 staticScheduleTaskService.SynchronousDataContracts(); //客户合同-房间 staticScheduleTaskService.SynchronousDataContractsRoom(); //客户 staticScheduleTaskService.SynchronousDataAccounts(); //合同收款表 staticScheduleTaskService.SynchronousDataContractReceipts(); } /*** * 停车 */ @Scheduled(cron = "0 */5 * * * ?") private void ScheduledTask2() { updateTingcheService.updateTjTcsjtjn(); updateTingcheService.updateTjCljrsctjn(); updateTingcheService.updateTjCljrsctjy(); updateTingcheService.updateTjCljrsctjr(); updateTingcheService.updateTjParkingPayment(); updateTingcheService.updateTjVehicleRecords(); } }