Просмотр исходного кода

Merge branch 'master' into cooperation_video_candidate_pool_improved_lld_0509

刘立冬 4 часов назад
Родитель
Сommit
ee1108f245

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/contentplatform/ext/ContentPlatformDemandVideoMapperExt.java

@@ -27,7 +27,7 @@ public interface ContentPlatformDemandVideoMapperExt {
                          @Param("title") String title,
                          @Param("title") String title,
                          @Param("crowdSegment") String crowdSegment);
                          @Param("crowdSegment") String crowdSegment);
 
 
-    String getMaxDt();
+    String getMaxDt(@Param("channelName") String channelName);
 
 
     /**
     /**
      * 推荐场景候选池查询:按 demand_strategy 取指定 crowd_segment 的候选行,
      * 推荐场景候选池查询:按 demand_strategy 取指定 crowd_segment 的候选行,

+ 8 - 1
api-module/src/main/java/com/tzld/piaoquan/api/job/contentplatform/ContentPlatformDemandVideoJob.java

@@ -80,8 +80,15 @@ public class ContentPlatformDemandVideoJob {
     /**
     /**
      * 写入三条默认记录:仅含匹配实验id及三个匹配相关字段,其它字段为空。
      * 写入三条默认记录:仅含匹配实验id及三个匹配相关字段,其它字段为空。
      * 用 channel_name=DEFAULT_RECORD_CHANNEL 与正常渠道数据隔离,先按 (dt, channel_name) 删除后批量插入,保证幂等。
      * 用 channel_name=DEFAULT_RECORD_CHANNEL 与正常渠道数据隔离,先按 (dt, channel_name) 删除后批量插入,保证幂等。
+     * 仅当该 dt 已存在数据时才执行,避免在无任何渠道数据的日期下凭空插入默认记录。
      */
      */
     private void insertDefaultRecords(String dt) {
     private void insertDefaultRecords(String dt) {
+        int existCount = demandVideoMapperExt.countByCondition(dt, null, null, null, null);
+        if (existCount <= 0) {
+            log.info("insertDefaultRecords skip, dt={} has no data", dt);
+            return;
+        }
+
         Long now = System.currentTimeMillis();
         Long now = System.currentTimeMillis();
         List<ContentPlatformDemandVideo> defaults = new ArrayList<>();
         List<ContentPlatformDemandVideo> defaults = new ArrayList<>();
         defaults.add(buildDefaultRecord(dt, now,
         defaults.add(buildDefaultRecord(dt, now,
@@ -349,7 +356,7 @@ public class ContentPlatformDemandVideoJob {
 
 
     @XxlJob("checkContentPlatformDemandVideoStatusJob")
     @XxlJob("checkContentPlatformDemandVideoStatusJob")
     public ReturnT<String> checkContentPlatformDemandVideoStatusJob(String param) {
     public ReturnT<String> checkContentPlatformDemandVideoStatusJob(String param) {
-        String dt = demandVideoMapperExt.getMaxDt();
+        String dt = demandVideoMapperExt.getMaxDt(null);
         if (!StringUtils.hasText(dt)) {
         if (!StringUtils.hasText(dt)) {
             log.info("checkContentPlatformDemandVideoStatusJob no data");
             log.info("checkContentPlatformDemandVideoStatusJob no data");
             return ReturnT.SUCCESS;
             return ReturnT.SUCCESS;

+ 7 - 7
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -876,13 +876,13 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
      *   3. 输出顺序按 rov DESC,相同 rov 按 total_rov DESC 兜底
      *   3. 输出顺序按 rov DESC,相同 rov 按 total_rov DESC 兜底
      */
      */
     private List<VideoContentItemVO> fetchPriorSceneCandidates(VideoContentListParam param, ContentPlatformAccount user, int limit) {
     private List<VideoContentItemVO> fetchPriorSceneCandidates(VideoContentListParam param, ContentPlatformAccount user, int limit) {
-        String dt = demandVideoMapperExt.getMaxDt();
+        String channelName = resolveChannelName(param);
+        String dt = demandVideoMapperExt.getMaxDt(channelName);
         if (!StringUtils.hasText(dt)) {
         if (!StringUtils.hasText(dt)) {
             return new ArrayList<>();
             return new ArrayList<>();
         }
         }
         String crowdSegment = user.getChannel();
         String crowdSegment = user.getChannel();
         String ghName = StringUtils.hasText(param.getGhName()) ? param.getGhName() : null;
         String ghName = StringUtils.hasText(param.getGhName()) ? param.getGhName() : null;
-        String channelName = resolveChannelName(param);
 
 
         String category = StringUtils.hasText(param.getCategory()) ? param.getCategory() : null;
         String category = StringUtils.hasText(param.getCategory()) ? param.getCategory() : null;
         // priorScene 池新识别:demand_strategy='人群需求' AND match_method='场景已看视频'(0519+ 起,旧 demand_strategy='人群需求-场景' 已迁走)
         // priorScene 池新识别:demand_strategy='人群需求' AND match_method='场景已看视频'(0519+ 起,旧 demand_strategy='人群需求-场景' 已迁走)
@@ -931,13 +931,13 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
      * 结果按 limit 截断。
      * 结果按 limit 截断。
      */
      */
     private List<VideoContentItemVO> fetchPriorCandidates(VideoContentListParam param, ContentPlatformAccount user, int limit) {
     private List<VideoContentItemVO> fetchPriorCandidates(VideoContentListParam param, ContentPlatformAccount user, int limit) {
-        String dt = demandVideoMapperExt.getMaxDt();
+        String channelName = resolveChannelName(param);
+        String dt = demandVideoMapperExt.getMaxDt(channelName);
         if (!StringUtils.hasText(dt)) {
         if (!StringUtils.hasText(dt)) {
             return new ArrayList<>();
             return new ArrayList<>();
         }
         }
         String crowdSegment = user.getChannel();
         String crowdSegment = user.getChannel();
         String ghName = StringUtils.hasText(param.getGhName()) ? param.getGhName() : null;
         String ghName = StringUtils.hasText(param.getGhName()) ? param.getGhName() : null;
-        String channelName = resolveChannelName(param);
         int fetchLimit = Math.max(limit * 3, DEMAND_CANDIDATE_LIMIT);
         int fetchLimit = Math.max(limit * 3, DEMAND_CANDIDATE_LIMIT);
 
 
         String category = StringUtils.hasText(param.getCategory()) ? param.getCategory() : null;
         String category = StringUtils.hasText(param.getCategory()) ? param.getCategory() : null;
@@ -1013,13 +1013,13 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
      * 跨组用 video_id + 归一化标题去重,截到 limit。
      * 跨组用 video_id + 归一化标题去重,截到 limit。
      */
      */
     private List<VideoContentItemVO> fetchPosteriorCandidates(VideoContentListParam param, ContentPlatformAccount user, int limit) {
     private List<VideoContentItemVO> fetchPosteriorCandidates(VideoContentListParam param, ContentPlatformAccount user, int limit) {
-        String dt = demandVideoMapperExt.getMaxDt();
+        String channelName = resolveChannelName(param);
+        String dt = demandVideoMapperExt.getMaxDt(channelName);
         if (!StringUtils.hasText(dt)) {
         if (!StringUtils.hasText(dt)) {
             return new ArrayList<>();
             return new ArrayList<>();
         }
         }
         String crowdSegment = user.getChannel();
         String crowdSegment = user.getChannel();
         String ghName = StringUtils.hasText(param.getGhName()) ? param.getGhName() : null;
         String ghName = StringUtils.hasText(param.getGhName()) ? param.getGhName() : null;
-        String channelName = resolveChannelName(param);
         int fetchLimit = Math.max(limit * 3, DEMAND_CANDIDATE_LIMIT);
         int fetchLimit = Math.max(limit * 3, DEMAND_CANDIDATE_LIMIT);
 
 
         String category = StringUtils.hasText(param.getCategory()) ? param.getCategory() : null;
         String category = StringUtils.hasText(param.getCategory()) ? param.getCategory() : null;
@@ -1851,7 +1851,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         ContentPlatformAccount loginAccount = LoginUserContext.getUser();
         ContentPlatformAccount loginAccount = LoginUserContext.getUser();
         String crowdSegment = loginAccount.getChannel();
         String crowdSegment = loginAccount.getChannel();
         int offset = (param.getPageNum() - 1) * param.getPageSize();
         int offset = (param.getPageNum() - 1) * param.getPageSize();
-        String dt = demandVideoMapperExt.getMaxDt();
+        String dt = demandVideoMapperExt.getMaxDt(null);
         if (!StringUtils.hasText(dt)) {
         if (!StringUtils.hasText(dt)) {
             result.setTotalSize(0);
             result.setTotalSize(0);
             result.setObjs(new ArrayList<>());
             result.setObjs(new ArrayList<>());

+ 6 - 1
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformDemandVideoMapperExt.xml

@@ -78,7 +78,12 @@
     </select>
     </select>
 
 
     <select id="getMaxDt" resultType="java.lang.String">
     <select id="getMaxDt" resultType="java.lang.String">
-        SELECT MAX(dt) FROM content_platform_demand_video WHERE status = 1
+        SELECT MAX(dt)
+        FROM content_platform_demand_video
+        WHERE status = 1
+        <if test="channelName != null and channelName != ''">
+            AND channel_name = #{channelName}
+        </if>
     </select>
     </select>
 
 
     <select id="selectForRecommend" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformDemandVideo">
     <select id="selectForRecommend" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformDemandVideo">