|
@@ -0,0 +1,59 @@
|
|
|
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
|
|
|
+
|
|
|
+import com.tzld.piaoquan.recommend.server.model.Video;
|
|
|
+import com.tzld.piaoquan.recommend.server.repository.VideoDemandAnalysisRepository;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.filter.FilterParam;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.filter.FilterResult;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.filter.FilterService;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.recall.FilterParamFactory;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.recall.RecallStrategy;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author dyp
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class VideoInsightRecallStrategy implements RecallStrategy {
|
|
|
+
|
|
|
+ public static final String PUSH_FORM = "video_insight";
|
|
|
+ @Autowired
|
|
|
+ private VideoDemandAnalysisRepository videoDemandAnalysisRepository;
|
|
|
+ @Autowired
|
|
|
+ private FilterService filterService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Video> recall(RecallParam param) {
|
|
|
+
|
|
|
+ List<Video> results = new ArrayList<>();
|
|
|
+ Pageable pageable = PageRequest.of(0, 5000);
|
|
|
+ List<Long> videoIds = videoDemandAnalysisRepository.findDistinctVideoId(pageable);
|
|
|
+ FilterParam filterParam = FilterParamFactory.create(param, videoIds);
|
|
|
+
|
|
|
+ FilterResult filterResult = filterService.filter(filterParam);
|
|
|
+
|
|
|
+ if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
|
|
|
+ filterResult.getVideoIds().stream().forEach(vid -> {
|
|
|
+ Video video = new Video();
|
|
|
+ video.setVideoId(vid);
|
|
|
+ video.setRovScore(0);
|
|
|
+ video.setPushFrom(pushFrom());
|
|
|
+ results.add(video);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String pushFrom() {
|
|
|
+ return PUSH_FORM;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|