package cn.com.taiji.beidou.ship.task;

import cn.com.taiji.beidou.common.core.redis.RedisCache;
import cn.com.taiji.beidou.ship.archives.domain.ShipArchivesTotal;
import cn.com.taiji.beidou.ship.archives.service.ShipArchivesService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 定时任务
 * @Author CHEN
 * @Date 2023/1/6 10:45
 */
@Component
public class ShipSchedulersTask {

    @Resource
    private RedisCache redisCache;

    @Resource
    private ShipArchivesService shipArchivesService;

    /**
     * 每十秒更新一次
     */
    @Scheduled(cron = "1/10 * * * * ?")
    public void setShipTotalToRedis(){
        ShipArchivesTotal shipTotal = shipArchivesService.getShipTotal(null,null);
        redisCache.setCacheObject("SHIP_TOTAL_4635",shipTotal);
    }
}
