Explorar o código

视频审核分发增加缓存排除

wangyunpeng hai 4 meses
pai
achega
6445b0bbbc

+ 2 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/longArticle/ArticleAuditMapper.java

@@ -23,7 +23,8 @@ public interface ArticleAuditMapper {
 
     ArticleVideoAuditListVO articleVideoAuditNext(List<String> contentId, List<Integer> status,
                                                   List<String> title, List<String> auditAccount,
-                                                  List<String> producePlanIds, String poolLevel);
+                                                  List<String> producePlanIds, String poolLevel,
+                                                  List<String> excludeContentIds);
 
     void updateCrawlerVideoIsIllegal(List<Integer> illegalVideoIds, Integer isIllegal);
 

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/longArticle/VideoPoolAuditMapper.java

@@ -23,7 +23,7 @@ public interface VideoPoolAuditMapper {
 
     PublishSingleVideoSource articleVideoAuditNext(List<String> contentId, List<Integer> status,
                                                          List<String> title, List<String> auditAccount,
-                                                         Integer flowPoolLevel);
+                                                         Integer flowPoolLevel, List<String> excludeContentIds);
 
     List<String> searchFilterValueByItemName(String itemName, String searchKeyword);
 

+ 17 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleVideoAuditService.java

@@ -124,17 +124,31 @@ public class ArticleVideoAuditService {
             return list(param);
         }
         Page<ArticleVideoAuditListVO> result = new Page<>();
+        Long now = System.currentTimeMillis();
+        String redisKey = "article-pool-audit-next-list";
+        Map<Object, Object> entries = redisTemplate.opsForHash().entries(redisKey);
+        List<String> excludeContentIds = new ArrayList<>();
+        entries.forEach((k, v) -> {
+            long timestamp = Long.parseLong((String) v);
+            if (now > timestamp) {
+                redisTemplate.opsForHash().delete(redisKey, k);
+            } else {
+                excludeContentIds.add((String) k);
+            }
+        });
         // 根据配置判断当日是否审核完成 并 选择内容池返回
         ArticleVideoAuditListVO item = null;
         List<String> excludePoolLevel = new ArrayList<>();
         String poolLevel = getAuditPoolLevel(excludePoolLevel);
         if (Objects.isNull(poolLevel)) {
             item = articleAuditMapper.articleVideoAuditNext(param.getContentId(),
-                    param.getStatus(), param.getTitle(), param.getAuditAccount(), param.getSourceProducePlan(), poolLevel);
+                    param.getStatus(), param.getTitle(), param.getAuditAccount(), param.getSourceProducePlan(),
+                    poolLevel, excludeContentIds);
         } else {
             do {
                 item = articleAuditMapper.articleVideoAuditNext(param.getContentId(),
-                        param.getStatus(), param.getTitle(), param.getAuditAccount(), param.getSourceProducePlan(), poolLevel);
+                        param.getStatus(), param.getTitle(), param.getAuditAccount(), param.getSourceProducePlan(),
+                        poolLevel, excludeContentIds);
                 if (Objects.nonNull(item)) {
                     break;
                 }
@@ -145,6 +159,7 @@ public class ArticleVideoAuditService {
         if (Objects.isNull(item)) {
             return result;
         }
+        redisTemplate.opsForHash().put(redisKey, item.getContentId(), String.valueOf(now + 600000));
         List<ArticleVideoAuditListVO> list = Collections.singletonList(item);
         buildArticleVideoAuditListVO(list);
         result.setObjs(list);

+ 16 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/VideoPoolAuditService.java

@@ -98,17 +98,30 @@ public class VideoPoolAuditService {
             return list(param);
         }
         Page<VideoPoolAuditListVO> result = new Page<>();
+        // 排除已分配内容
+        Long now = System.currentTimeMillis();
+        String redisKey = "video-pool-audit-next-list";
+        Map<Object, Object> entries = redisTemplate.opsForHash().entries(redisKey);
+        List<String> excludeContentIds = new ArrayList<>();
+        entries.forEach((k, v) -> {
+            long timestamp = Long.parseLong((String) v);
+            if (now > timestamp) {
+                redisTemplate.opsForHash().delete(redisKey, k);
+            } else {
+                excludeContentIds.add((String) k);
+            }
+        });
         // 根据配置判断当日是否审核完成 并 选择内容池返回
         PublishSingleVideoSource obj = null;
         List<String> excludePoolLevel = new ArrayList<>();
         Integer poolLevel = getAuditPoolLevel(excludePoolLevel);
         if (Objects.isNull(poolLevel)) {
             obj = videoPoolAuditMapper.articleVideoAuditNext(param.getContentId(),
-                    param.getStatus(), param.getTitle(), param.getAuditAccount(), poolLevel);
+                    param.getStatus(), param.getTitle(), param.getAuditAccount(), poolLevel, excludeContentIds);
         } else {
             do {
                 obj = videoPoolAuditMapper.articleVideoAuditNext(param.getContentId(),
-                        param.getStatus(), param.getTitle(), param.getAuditAccount(), poolLevel);
+                        param.getStatus(), param.getTitle(), param.getAuditAccount(), poolLevel, excludeContentIds);
                 if (Objects.nonNull(obj)) {
                     break;
                 }
@@ -119,6 +132,7 @@ public class VideoPoolAuditService {
         if (Objects.isNull(obj)) {
             return result;
         }
+        redisTemplate.opsForHash().put(redisKey, obj.getContentTraceId(), String.valueOf(now + 600000));
         List<VideoPoolAuditListVO> list = buildVideoPoolAuditListVO(Collections.singletonList(obj));
         result.setObjs(list);
         return result;

+ 6 - 0
long-article-recommend-service/src/main/resources/mapper/longArticle/ArticleAuditMapper.xml

@@ -217,6 +217,12 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="excludeContentIds!= null and excludeContentIds.size() > 0">
+                and lata.content_id not in
+                <foreach collection="excludeContentIds" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
             <if test="poolLevel!= null and poolLevel !=''">
                 and lata.flow_pool_level = #{poolLevel}
             </if>

+ 7 - 1
long-article-recommend-service/src/main/resources/mapper/longArticle/VideoPoolAuditMapper.xml

@@ -127,7 +127,7 @@
             resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource">
         select *
         from publish_single_video_source
-        where bad_status = 0 and audit_status = 1
+        where bad_status in (0, 5) and audit_status = 1
         <if test="status!= null and status.size() > 0">
             and `video_pool_audit_status` in
             <foreach collection="status" item="item" separator="," open="(" close=")">
@@ -152,6 +152,12 @@
                 #{item}
             </foreach>
         </if>
+        <if test="excludeContentIds!= null and excludeContentIds.size() > 0">
+            and content_trace_id not in
+            <foreach collection="excludeContentIds" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="flowPoolLevel != null">
             and flow_pool_level = #{flowPoolLevel}
         </if>