ConJobManager.java 2.18 KB
Newer Older
张辰's avatar
张辰 committed
1 2
package com.tanpu.community.manager;

张辰's avatar
张辰 committed
3
import com.tanpu.community.service.*;
张辰's avatar
张辰 committed
4
import com.tanpu.community.service.quartz.TopicReportService;
张辰's avatar
张辰 committed
5 6 7 8 9 10 11 12 13 14 15 16
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@Configuration
public class ConJobManager {

    @Autowired
刘基明's avatar
刘基明 committed
17
    private VisitLogService visitLogService;
张辰's avatar
张辰 committed
18 19 20 21

    @Autowired
    private RedisService redisService;

刘基明's avatar
刘基明 committed
22 23 24
    @Autowired
    private RankService rankService;

张辰's avatar
张辰 committed
25 26 27
    @Autowired
    private RankLogService rankLogService;

28 29 30
    @Autowired
    private RecommendService recommendService;

张辰's avatar
张辰 committed
31 32 33
    @Autowired
    private TopicReportService topicReportService;

张辰's avatar
张辰 committed
34 35 36
    /**
     * 定时统计 话题 访问数据,并刷到redis
     */
刘基明's avatar
刘基明 committed
37
    // @Scheduled(cron = "*/10 * * * * ?")
张辰's avatar
张辰 committed
38 39
    public void topicVisitorStats() {
        String topicId = "123";
刘基明's avatar
刘基明 committed
40
        Integer detailVisitTimes = visitLogService.queryTopicDetailVisit(topicId);
张辰's avatar
张辰 committed
41 42
        redisService.set("topicVisitorStats", detailVisitTimes);
    }
刘基明's avatar
刘基明 committed
43 44

    /**
45
     * 定时统计主题、话题排行
刘基明's avatar
刘基明 committed
46
     */
刘基明's avatar
刘基明 committed
47
    @Scheduled(cron = "10 0/2 * * * ?")
刘基明's avatar
刘基明 committed
48 49
    public void themeRank() {
        rankService.rankThemes();
刘基明's avatar
刘基明 committed
50
        rankService.rankTopics();
刘基明's avatar
刘基明 committed
51 52 53
    }

    /**
刘基明's avatar
刘基明 committed
54
     * 定时刷新最新帖子
刘基明's avatar
刘基明 committed
55
     */
刘基明's avatar
刘基明 committed
56
    @Scheduled(cron = "*/10 * * * * ?")
刘基明's avatar
刘基明 committed
57
    public void getThemeNewest() {
58
        recommendService.refreshNewestThemes();
刘基明's avatar
刘基明 committed
59
    }
张辰's avatar
张辰 committed
60 61 62 63 64 65 66 67

    /**
     * 定时把rank_log的日志拿出来,清理数据库
     */
    @Scheduled(cron = "0 0 0 ? * 1")
    public void clearRankLog() {
        rankLogService.clearRankLog();
    }
张辰's avatar
张辰 committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86


    /**
     * 每个工作日早上09:30汇报 topic数据
     */
    @Scheduled(cron = "0 30 9 ? * *")
    public void reportTopicWeekday() {
        log.info("reportTopicWeekday start");
        topicReportService.reportTopicWeekday();
    }

    /**
     * 每周六早上09:00汇报 topic数据
     */
    @Scheduled(cron = "0 0 9 ? * SAT")
    public void reportTopicSaturday() {
        log.info("reportTopicSaturday start");
        topicReportService.reportTopicSaturday();
    }
张辰's avatar
张辰 committed
87
}