|
@@ -1,13 +1,15 @@
|
|
|
-package com.tzld.piaoquan.recommend.server.service;
|
|
|
+package com.tzld.piaoquan.recommend.server.xxl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.odps.data.Record;
|
|
|
import com.tzld.piaoquan.recommend.server.common.base.Constant;
|
|
|
import com.tzld.piaoquan.recommend.server.service.odps.ODPSManager;
|
|
|
+import com.xxl.job.core.biz.model.ReturnT;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import com.xxl.job.core.log.XxlJobLogger;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
@@ -28,17 +30,19 @@ public class SyncFlowPoolRecentTopVideoJob {
|
|
|
@Autowired
|
|
|
private RedisTemplate<String, String> redisTemplate;
|
|
|
|
|
|
-
|
|
|
- @Scheduled(cron = "0 20 * * * ? ")
|
|
|
- public void syncFlowPoolRecentTopVideo() {
|
|
|
+ @XxlJob("syncFlowPoolRecentTopVideo")
|
|
|
+ public ReturnT<String> syncFlowPoolRecentTopVideo(String params) {
|
|
|
|
|
|
List<Long> videoIds = queryTopVideoIdsByLast6Hour(100);
|
|
|
if (CollectionUtils.isEmpty(videoIds)) {
|
|
|
- return;
|
|
|
+ XxlJobLogger.log("syncFlowPoolRecentTopVideo, videoIds is empty");
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
}
|
|
|
+ XxlJobLogger.log("syncFlowPoolRecentTopVideo, videoIds:{}", videoIds);
|
|
|
|
|
|
redisTemplate.opsForValue().set(Constant.FLOW_POOL_LAST_24_HOUR_VIDEO_REDIS_KEY,
|
|
|
JSONObject.toJSONString(videoIds), 2, TimeUnit.DAYS);
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
private List<Long> queryTopVideoIdsByLast6Hour(Integer topNum) {
|