Explorar el Código

Merge branch 'wyp/0108-similarStatusFilter' of Server/long-article-recommend into master

wangyunpeng hace 6 meses
padre
commit
c8e8c2840b

+ 30 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/LongArticleTextSimilarityStatusEnum.java

@@ -0,0 +1,30 @@
+package com.tzld.longarticle.recommend.server.common.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum LongArticleTextSimilarityStatusEnum {
+
+    WAITING(0, "未判断"),
+    AVAILABLE(1, "可用"),
+    UNAVAILABLE(2, "不可用"),
+    ;
+
+    //0-未判断 1-可用 2-不可用
+    private int code;
+    private String msg;
+
+    LongArticleTextSimilarityStatusEnum(int code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public static LongArticleTextSimilarityStatusEnum getByCode(int code) {
+        for (LongArticleTextSimilarityStatusEnum statusEnum : LongArticleTextSimilarityStatusEnum.values()) {
+            if (statusEnum.getCode() == code) {
+                return statusEnum;
+            }
+        }
+        return null;
+    }
+}

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

@@ -7,6 +7,7 @@ import com.google.common.cache.CacheBuilder;
 import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.CostMonitor;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
+import com.tzld.longarticle.recommend.server.common.enums.LongArticleTextSimilarityStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.*;
@@ -204,19 +205,22 @@ public class RecallService implements ApplicationContextAware {
         if (CollectionUtils.isEmpty(content)) {
             return;
         }
+        List<String> sourceIds = content.stream().map(Content::getSourceId).collect(Collectors.toList());
+        Map<String, Integer> textStatusMap = new HashMap<>(textCache.getAllPresent(sourceIds));
         List<String> searchIds = content.stream()
-                .filter(o ->!Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal()))
-                .map(Content::getSourceId).filter(o -> Objects.isNull(textCache.getIfPresent(o)))
+                .filter(o -> !Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal()))
+                .map(Content::getSourceId).filter(o -> Objects.isNull(textStatusMap.get(o)))
                 .collect(Collectors.toList());
         if (CollectionUtils.isNotEmpty(searchIds)) {
             List<LongArticlesText> textList = longArticlesTextRepository.getByContentIdIn(searchIds);
             Map<String, Integer> textMap = textList.stream()
                     .collect(Collectors.toMap(LongArticlesText::getContentId, LongArticlesText::getSimilarityStatus));
+            textStatusMap.putAll(textMap);
             textCache.putAll(textMap);
         }
         content.removeIf(o -> !Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal())
-                && (Objects.isNull(textCache.getIfPresent(o.getSourceId()))
-                || textCache.getIfPresent(o.getSourceId()) == 0));
+                && (Objects.isNull(textStatusMap.get(o.getSourceId()))
+                || textStatusMap.get(o.getSourceId()) != LongArticleTextSimilarityStatusEnum.AVAILABLE.getCode()));
     }
 
     private void setVideoContent(List<Content> contentList) {