TransferContentScheduleTask.java 1.08 KB
package com.topdraw.schedule;

import com.topdraw.business.process.calculate.task.ContentCalculateTask;
import com.topdraw.business.process.calculate.task.PvUvCalculateTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Slf4j
@EnableScheduling
public class TransferContentScheduleTask {

    @Autowired
    private ContentCalculateTask contentCalculateTask;

    @Value("${cronContent:0 0/5 * * * ?}")
    private String cron;

    public String cron(){
        return cron;
    }

    /**
     * 统计pv、uv
     */
    @Scheduled(cron = "#{transferContentScheduleTask.cron()}")
    public void calculatePvUv2Mysql(){
        log.info("专题内容pv、uv统计 ===>>> 开始 !!!" + LocalDateTime.now());
        this.contentCalculateTask.calculateRedisData2Mysql();
    }

}