package com.ydtech.modules.fnc.timer; import com.ydtech.modules.fnc.service.InsExcelTaskAsyncService; import com.ydtech.utils.DateUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.text.SimpleDateFormat; import java.util.Date; /** * 控制台导出任务 添加定时任务 */ @Slf4j @Component public class InsExcelTaskAsyncTimer { @Autowired private InsExcelTaskAsyncService insExcelTaskAsyncService; /** * @version * @author: whp * @Description: 任务中心的数据保留7天,7天后删除任务中心数据以及任务中心列表。 */ @Scheduled(cron = "0 0 0 * * *") private void updateOrderDateNoon() { //如果合同得失效日期有值如果过今天 超过失效日期则改为合同失效 log.info("定时删除控制台任务导出数据,启动时间:{}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); String nowTime = DateUtil.getDateFormat(new Date(), "yyyy-MM-dd HH:mm:ss"); try { insExcelTaskAsyncService.batchDelete(nowTime); log.info("定时删除控制台任务导出数据"); } catch (Exception e) { e.printStackTrace(); log.error("定时删除控制台任务导出数据失败:{}", e.getMessage()); } } }