Jelajahi Sumber

Merge branch 'wyp/1217-fwhBugFix' of Server/long-article-recommend into master

wangyunpeng 7 bulan lalu
induk
melakukan
b5e715c654

+ 7 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/recall/RecallService.java

@@ -305,10 +305,10 @@ public class RecallService implements ApplicationContextAware {
                     article.setCorrelation(Optional.ofNullable(accountCorrelationMap.get(article.getGhId())).orElse(0.0));
                 }
                 setT0Data(content);
-            }
-            if (!newCacheSourceIdSet.contains(content.getSourceId())) {
-                newCacheSaveList.add(content);
-                newCacheSourceIdSet.add(content.getSourceId());
+                if (!newCacheSourceIdSet.contains(content.getSourceId())) {
+                    newCacheSaveList.add(content);
+                    newCacheSourceIdSet.add(content.getSourceId());
+                }
             }
         }
         // 写入缓存
@@ -356,6 +356,9 @@ public class RecallService implements ApplicationContextAware {
         for (List<String> titleMd5s : titleMd5Partition) {
             hisArticleList.addAll(crawlerBaseMapper.getByTitleMd5InAndTypeEqualsAndStatusEquals(titleMd5s, type, 1));
         }
+        if (CollectionUtils.isEmpty(hisArticleList)) {
+            return result;
+        }
         Map<String, Map<Integer, List<Article>>> map = hisArticleList.stream()
                 .collect(Collectors.groupingBy(Article::getTitle, Collectors.groupingBy(Article::getItemIndex)));
         Set<String> snList = hisArticleList.stream().map(Article::getWxSn).collect(Collectors.toSet());

+ 8 - 5
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/strategy/FlowCtlDecreaseStrategy.java

@@ -12,9 +12,9 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -95,10 +95,13 @@ public class FlowCtlDecreaseStrategy implements ScoreStrategy {
                 sumViewCount = publishContents.stream().filter(o -> !filterCalGhId.contains(o.getGhId()))
                         .mapToDouble(PublishSortLog::getIndexAvgCount).sum();
             }
-            int hisViewCountSum = content.getHisPublishArticleList().stream()
-                    .filter(ContentHisPublishArticle::isInnerAccount)
-                    .filter(o -> !filterCalGhId.contains(o.getGhId()))
-                    .mapToInt(ContentHisPublishArticle::getAvgViewCount).sum();
+            int hisViewCountSum = 0;
+            if (CollectionUtils.isNotEmpty(content.getHisPublishArticleList())) {
+                hisViewCountSum = content.getHisPublishArticleList().stream()
+                        .filter(ContentHisPublishArticle::isInnerAccount)
+                        .filter(o -> !filterCalGhId.contains(o.getGhId()))
+                        .mapToInt(ContentHisPublishArticle::getAvgViewCount).sum();
+            }
             if ((sumViewCount + hisViewCountSum) > indexTotalAvgReadCountBase.get(String.valueOf(index))) {
                 return indexWeight.get(String.valueOf(index));
             }

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/strategy/ViewCountRateCorrelationStrategy.java

@@ -11,6 +11,7 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.MathUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -67,6 +68,9 @@ public class ViewCountRateCorrelationStrategy implements ScoreStrategy {
                 double showViewCountSumSecond = 0D;
                 double avgViewCountSumSecond = 0D;
                 double maxAvgViewCount = 0D;
+                if (CollectionUtils.isEmpty(content.getHisPublishArticleList())) {
+                    continue;
+                }
                 for (ContentHisPublishArticle hisItem : content.getHisPublishArticleList()) {
                     // 过滤掉发布时间晚于19点数据
                     if (ScoreStrategy.hisContentLateFilter(hisItem.getPublishTimestamp())) {

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/strategy/ViewCountRateStrategy.java

@@ -11,6 +11,7 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.MathUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -67,6 +68,9 @@ public class ViewCountRateStrategy implements ScoreStrategy {
                 double showViewCountSumSecond = 0D;
                 double avgViewCountSumSecond = 0D;
                 double maxAvgViewCount = 0D;
+                if (CollectionUtils.isEmpty(content.getHisPublishArticleList())) {
+                    continue;
+                }
                 for (ContentHisPublishArticle hisItem : content.getHisPublishArticleList()) {
                     // 过滤掉发布时间晚于19点数据
                     if (ScoreStrategy.hisContentLateFilter(hisItem.getPublishTimestamp())) {