wangyunpeng пре 4 месеци
родитељ
комит
e42925faf8

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java

@@ -809,6 +809,7 @@ public class XxlJobService {
                         cache.setCategory(JSONObject.toJSONString(content.getCategory()));
                     }
                     cache.setKimiSafeScore(content.getKimiSafeScore());
+                    cache.setPlanId(content.getProducePlanId());
                     cache.setUpdateTimestamp(System.currentTimeMillis());
                     articleTitleHisCacheRepository.save(cache);
                 }

+ 13 - 11
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV15Strategy.java

@@ -131,17 +131,19 @@ public class RankV15Strategy implements RankStrategy {
         // 3-8
         // RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
         List<Content> pool = contentMap.get(contentPools[2]);
-        Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
-        Queue<Content> videoPoolQueue = pool.stream().filter(o -> Objects.equals(o.getSourceType(), videoSourceType))
-                .collect(Collectors.toCollection(LinkedList::new));
-        Queue<Content> otherPoolQueue = pool.stream().filter(o -> !Objects.equals(o.getSourceType(), videoSourceType))
-                .collect(Collectors.toCollection(LinkedList::new));
-        for (int i = 3; i < param.getSize() + 1; i++) {
-            Integer sourceType = RankService.getStrategyPoolSourceType(param.getStrategy(), i);
-            if (Objects.equals(sourceType, videoSourceType) && !videoPoolQueue.isEmpty()) {
-                result.add(videoPoolQueue.poll());
-            } else if (!otherPoolQueue.isEmpty()) {
-                result.add(otherPoolQueue.poll());
+        if (CollectionUtils.isNotEmpty(pool)) {
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            Queue<Content> videoPoolQueue = pool.stream().filter(o -> Objects.equals(o.getSourceType(), videoSourceType))
+                    .collect(Collectors.toCollection(LinkedList::new));
+            Queue<Content> otherPoolQueue = pool.stream().filter(o -> !Objects.equals(o.getSourceType(), videoSourceType))
+                    .collect(Collectors.toCollection(LinkedList::new));
+            for (int i = 3; i < param.getSize() + 1; i++) {
+                Integer sourceType = RankService.getStrategyPoolSourceType(param.getStrategy(), i);
+                if (Objects.equals(sourceType, videoSourceType) && !videoPoolQueue.isEmpty()) {
+                    result.add(videoPoolQueue.poll());
+                } else if (!otherPoolQueue.isEmpty()) {
+                    result.add(otherPoolQueue.poll());
+                }
             }
         }
 

+ 16 - 14
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV16Strategy.java

@@ -122,11 +122,11 @@ public class RankV16Strategy implements RankStrategy {
         }
         RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
-            if (pool1.get(0).getProducePlanId().equals(topProducePlanId)) {
-                int i = RandomUtils.nextInt(0, 1);
+            if (topProducePlanId.equals(pool1.get(0).getProducePlanId())) {
+                int i = RandomUtils.nextInt(0, 2);
                 if (i == 0) {
                     for (Content content : pool1) {
-                        if (!content.getProducePlanId().equals(topProducePlanId)) {
+                        if (!topProducePlanId.equals(content.getProducePlanId())) {
                             result.add(content);
                             break;
                         }
@@ -148,17 +148,19 @@ public class RankV16Strategy implements RankStrategy {
         // 3-8
         // RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
         List<Content> pool = contentMap.get(contentPools[2]);
-        Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
-        Queue<Content> videoPoolQueue = pool.stream().filter(o -> Objects.equals(o.getSourceType(), videoSourceType))
-                .collect(Collectors.toCollection(LinkedList::new));
-        Queue<Content> otherPoolQueue = pool.stream().filter(o -> !Objects.equals(o.getSourceType(), videoSourceType))
-                .collect(Collectors.toCollection(LinkedList::new));
-        for (int i = 3; i < param.getSize() + 1; i++) {
-            Integer sourceType = RankService.getStrategyPoolSourceType(param.getStrategy(), i);
-            if (Objects.equals(sourceType, videoSourceType) && !videoPoolQueue.isEmpty()) {
-                result.add(videoPoolQueue.poll());
-            } else if (!otherPoolQueue.isEmpty()) {
-                result.add(otherPoolQueue.poll());
+        if (CollectionUtils.isNotEmpty(pool)) {
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            Queue<Content> videoPoolQueue = pool.stream().filter(o -> Objects.equals(o.getSourceType(), videoSourceType))
+                    .collect(Collectors.toCollection(LinkedList::new));
+            Queue<Content> otherPoolQueue = pool.stream().filter(o -> !Objects.equals(o.getSourceType(), videoSourceType))
+                    .collect(Collectors.toCollection(LinkedList::new));
+            for (int i = 3; i < param.getSize() + 1; i++) {
+                Integer sourceType = RankService.getStrategyPoolSourceType(param.getStrategy(), i);
+                if (Objects.equals(sourceType, videoSourceType) && !videoPoolQueue.isEmpty()) {
+                    result.add(videoPoolQueue.poll());
+                } else if (!otherPoolQueue.isEmpty()) {
+                    result.add(otherPoolQueue.poll());
+                }
             }
         }