|
|
@@ -805,9 +805,12 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 先验需求-场景池: demand_strategy='先验需求-场景',直接按 total_rov DESC, score DESC 取 top N,不分组。
|
|
|
+ * 先验需求-场景池: demand_strategy='先验需求-场景'。
|
|
|
* 退化策略: ghName 非空且查不到数据 → 退回渠道粒度(不限 channel_level3)。
|
|
|
- * 行内不过滤 rov<=0(场景型命中数据 rov 通常都有值,且这类数据稀缺,不再二次过滤)。
|
|
|
+ * 后处理:
|
|
|
+ * 1. 同 video_id 仅保留 total_rov 最大的代表行(利用 SQL 已按 total_rov DESC, score DESC 排好,首次即最大)
|
|
|
+ * 2. 过滤 rov 为 null 或 <=0(视频近 7 日无表现)
|
|
|
+ * 3. 输出顺序按 rov DESC,相同 rov 按 total_rov DESC 兜底
|
|
|
*/
|
|
|
private List<VideoContentItemVO> fetchPriorSceneCandidates(VideoContentListParam param, ContentPlatformAccount user, int limit) {
|
|
|
String dt = demandVideoMapperExt.getMaxDt();
|
|
|
@@ -823,13 +826,28 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
rows = demandVideoMapperExt.selectForRecommend(
|
|
|
dt, crowdSegment, DEMAND_STRATEGY_PRIOR_SCENE, null, null, null, null, null, limit, false);
|
|
|
}
|
|
|
- List<ContentPlatformDemandVideo> filtered = new ArrayList<>(rows.size());
|
|
|
- Set<Long> seen = new HashSet<>();
|
|
|
+ // 1. 同 video_id 取 total_rov 最大的代表行(SQL 已排序,putIfAbsent 保留首次)
|
|
|
+ LinkedHashMap<Long, ContentPlatformDemandVideo> bestPerVideo = new LinkedHashMap<>();
|
|
|
for (ContentPlatformDemandVideo r : rows) {
|
|
|
if (r.getVideoId() == null) continue;
|
|
|
- if (!seen.add(r.getVideoId())) continue;
|
|
|
+ bestPerVideo.putIfAbsent(r.getVideoId(), r);
|
|
|
+ }
|
|
|
+ // 2. 过滤 rov<=0/null
|
|
|
+ List<ContentPlatformDemandVideo> filtered = new ArrayList<>(bestPerVideo.size());
|
|
|
+ for (ContentPlatformDemandVideo r : bestPerVideo.values()) {
|
|
|
+ if (r.getRov() == null || r.getRov() <= 0) continue;
|
|
|
filtered.add(r);
|
|
|
}
|
|
|
+ // 3. 按 rov DESC 排序,次级 total_rov DESC
|
|
|
+ filtered.sort((a, b) -> {
|
|
|
+ int c = Double.compare(
|
|
|
+ b.getRov() == null ? 0d : b.getRov(),
|
|
|
+ a.getRov() == null ? 0d : a.getRov());
|
|
|
+ if (c != 0) return c;
|
|
|
+ return Double.compare(
|
|
|
+ b.getTotalRov() == null ? 0d : b.getTotalRov(),
|
|
|
+ a.getTotalRov() == null ? 0d : a.getTotalRov());
|
|
|
+ });
|
|
|
return buildDemandVideoContentItemVOList(filtered);
|
|
|
}
|
|
|
|