Commit 5e290a4d authored by 张辰's avatar 张辰

cron topic report

parent d29ce8f9
package com.tanpu.community.manager;
import com.tanpu.community.service.*;
import com.tanpu.community.service.quartz.TopicReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
......@@ -27,6 +28,9 @@ public class ConJobManager {
@Autowired
private RecommendService recommendService;
@Autowired
private TopicReportService topicReportService;
/**
* 定时统计 话题 访问数据,并刷到redis
*/
......@@ -61,4 +65,23 @@ public class ConJobManager {
public void clearRankLog() {
rankLogService.clearRankLog();
}
/**
* 每个工作日早上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();
}
}
......@@ -50,6 +50,13 @@ public class TopicReportService {
// 每个工作日早上09:30汇报
public static String content_report_topic_weekday = "话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 昨日新增成员: %s, 昨日新增讨论";
public void reportTopicWeekday() {
// 跳过双休日
Date now = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(now);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w == 6 || w == 7) return;
List<TopicEntity> topics = topicService.queryTopicNeedReport();
for (TopicEntity topic : topics) {
// 当前总成员
......@@ -80,6 +87,15 @@ public class TopicReportService {
}
}
public static void main(String[] args) {
Date date = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
System.out.println(w);
}
// 每周六早上09:00汇报
public static String content_report_topic_saturday = "话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 截至本周五新增成员: %s, 昨日新增讨论";
public void reportTopicSaturday() {
......
......@@ -101,6 +101,11 @@ recommend:
tmpfile:
dir: /data/tmp
wxcp:
topicreport:
agentId: 1000025
corpId: IC6Hpbct4OrYzacDnzXqSRC17vrpNwDZ1HZvFef1QQc
logging.level.com.tanpu: debug
tanpu:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment