|
@@ -4,6 +4,8 @@ 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.tzld.piaoquan.recommend.server.service.recall.strategy.FlowPoolLastDayTopRecallStrategy;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.recall.strategy.TopGoodPerformanceVideoRecallStrategy;
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
import com.xxl.job.core.log.XxlJobLogger;
|
|
@@ -33,15 +35,15 @@ public class SyncFlowPoolRecentTopVideoJob {
|
|
|
@XxlJob("syncFlowPoolRecentTopVideo")
|
|
|
public ReturnT<String> syncFlowPoolRecentTopVideo(String params) {
|
|
|
// 执行 ODPS Sql,获取数据
|
|
|
- List<Long> videoIds = queryTopVideoIdsByLast6Hour(100);
|
|
|
+ List<Long> videoIds = queryTopVideoIdsByLast6Hour(200);
|
|
|
if (CollectionUtils.isEmpty(videoIds)) {
|
|
|
XxlJobLogger.log("syncFlowPoolRecentTopVideo, videoIds is empty");
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
XxlJobLogger.log("syncFlowPoolRecentTopVideo, videoIds:{}", videoIds);
|
|
|
// 将数据写入 Redis
|
|
|
- redisTemplate.opsForValue().set(Constant.FLOW_POOL_LAST_24_HOUR_VIDEO_REDIS_KEY,
|
|
|
- JSONObject.toJSONString(videoIds), 2, TimeUnit.DAYS);
|
|
|
+ redisTemplate.opsForValue().set(Constant.VIDEO_PERFORMANCE_DATA_REDIS_KEY + FlowPoolLastDayTopRecallStrategy.PUSH_FORM,
|
|
|
+ JSONObject.toJSONString(videoIds), 2, TimeUnit.HOURS);
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
@@ -56,5 +58,31 @@ public class SyncFlowPoolRecentTopVideoJob {
|
|
|
return records.stream().map(record -> record.getBigint(0)).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ @XxlJob("syncGoodPerformanceVideo")
|
|
|
+ public ReturnT<String> syncGoodPerformanceVideo(String params) {
|
|
|
+ // 执行 ODPS Sql,获取数据
|
|
|
+ List<Long> videoIds = queryGoodPerformanceVideo(100);
|
|
|
+ if (CollectionUtils.isEmpty(videoIds)) {
|
|
|
+ XxlJobLogger.log("syncGoodPerformanceVideo, videoIds is empty");
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+ XxlJobLogger.log("syncGoodPerformanceVideo, videoIds:{}", videoIds);
|
|
|
+ // 将数据写入 Redis
|
|
|
+ redisTemplate.opsForValue().set(Constant.VIDEO_PERFORMANCE_DATA_REDIS_KEY + TopGoodPerformanceVideoRecallStrategy.PUSH_FORM,
|
|
|
+ JSONObject.toJSONString(videoIds), 2, TimeUnit.HOURS);
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Long> queryGoodPerformanceVideo(int limit) {
|
|
|
+ String sql = "SELECT videoid FROM loghubods.long_period_good_performance_video " +
|
|
|
+ "WHERE dt = '" + odpsManager.getNowHour() + "' " +
|
|
|
+ "ORDER BY rov DESC LIMIT " + limit + ";";
|
|
|
+ List<Record> records = odpsManager.query(sql);
|
|
|
+ if (records == null || records.size() == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return records.stream().map(record -> record.getBigint(0)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|