wangyunpeng 11 months ago
parent
commit
dc35e8658a

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

@@ -15,7 +15,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 
@@ -74,7 +77,10 @@ public class FlowCtlDecreaseStrategy implements ScoreStrategy {
         }
         Map<String, Integer> indexWeight = getColdStartScoreDecreaseWeight(accountName);
         Map<String, Integer> indexTotalAvgReadCountBase = getAvgReadCountBase(accountName);
-        if (Objects.isNull(indexWeight) || Objects.isNull(indexTotalAvgReadCountBase)) {
+        if (Objects.isNull(indexWeight)
+                || Objects.isNull(indexTotalAvgReadCountBase)
+                || !indexWeight.containsKey(String.valueOf(index))
+                || !indexTotalAvgReadCountBase.containsKey(String.valueOf(index))) {
             return 0;
         }
         if (hisPublishedContentMap.containsKey(content.getTitle())) {