TransferContentScheduleTask.java
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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();
}
}