刘小明
2024-09-03 b5a3c0f6823d17d4acd97545cee3556a07f09865
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/config/AppStartupRunner.java
@@ -1,15 +1,32 @@
package com.dy.pmsStation.config;
import com.dy.common.schedulerTask.SchedulerTaskSupport;
import com.dy.pmsGlobal.daoSta.StaDeviceProductionLogPastMapper;
import com.dy.pmsStation.task.LogMoveTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class AppStartupRunner implements CommandLineRunner {
    private StaDeviceProductionLogPastMapper pastMapper;
    @Autowired
    public void setPastMapper(StaDeviceProductionLogPastMapper pastMapper) {
        this.pastMapper = pastMapper;
    }
    @Override
    public void run(String... args) throws Exception {
        //服务启动时检查上次任务是否已执行
        Long count = pastMapper.countLastDayLogs();
        log.info("未移动记录数量:"+count);
        if(count >0){
            new LogMoveTask().execute(null);
        }
        SchedulerTaskSupport.addDailyJob("logMoveTask", "station", LogMoveTask.class,
                null, 0, 5);
    }