wangyunpeng 4 tháng trước cách đây
mục cha
commit
d6f2a32141

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

@@ -150,7 +150,7 @@ public class ArticleVideoAuditService {
 
         long now = System.currentTimeMillis();
         String id;
-        String nextListRedisKey = "article-pool-audit-next-list";
+        String inAuditListRedisKey = "article-pool-in-audit-list";
         ArticleVideoAuditListVO item = null;
         try {
             String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
@@ -158,7 +158,7 @@ public class ArticleVideoAuditService {
             // 从待审核队列中获取数据,如未获取到则从数据库查询一条
             Long size = redisTemplate.opsForZSet().size(auditQueueRedisKey);
             if (Objects.isNull(size) || size == 0) {
-                Map<Object, Object> entries = redisTemplate.opsForHash().entries(nextListRedisKey);
+                Map<Object, Object> entries = redisTemplate.opsForHash().entries(inAuditListRedisKey);
                 List<String> excludeContentIds = new ArrayList<>();
                 entries.forEach((k, v) -> {
                     excludeContentIds.add((String) k);
@@ -195,7 +195,7 @@ public class ArticleVideoAuditService {
         JSONObject json = new JSONObject();
         json.put("id", item.getContentId());
         json.put("timestamp", now + (15 * 60 * 1000));
-        redisTemplate.opsForList().rightPush(nextListRedisKey, json.toJSONString());
+        redisTemplate.opsForList().rightPush(inAuditListRedisKey, json.toJSONString());
         List<ArticleVideoAuditListVO> list = Collections.singletonList(item);
         buildArticleVideoAuditListVO(list);
         result.setObjs(list);
@@ -218,7 +218,7 @@ public class ArticleVideoAuditService {
         }
         // 当日审核数+1
         addAuditCount(titleAudit.getFlowPoolLevel());
-        redisTemplate.opsForHash().delete("article-pool-audit-next-list", titleAudit.getContentId());
+        redisTemplate.opsForHash().delete("article-pool-in-audit-list", titleAudit.getContentId());
     }
 
     private void addAuditCount(String poolLevel) {
@@ -426,17 +426,17 @@ public class ArticleVideoAuditService {
         try {
             Long now = System.currentTimeMillis();
             String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
-            String nextListRedisKey = "article-pool-audit-next-list";
+            String inAuditListRedisKey = "article-pool-in-audit-list";
             String auditQueueRedisKey = "article-pool-audit-queue-" + dateStr;
             // 判断是否审核超时,重新加入待审核队列
             while (true) {
-                List<String> nextList = redisTemplate.opsForList().range(nextListRedisKey, 0, 0);
-                if (CollectionUtils.isEmpty(nextList)) {
+                List<String> inAuditList = redisTemplate.opsForList().range(inAuditListRedisKey, 0, 0);
+                if (CollectionUtils.isEmpty(inAuditList)) {
                     break;
                 }
-                JSONObject firstObj = JSONObject.parseObject(nextList.get(0));
+                JSONObject firstObj = JSONObject.parseObject(inAuditList.get(0));
                 if (now > firstObj.getLong("timestamp")) {
-                    redisTemplate.opsForList().leftPop(nextListRedisKey);
+                    redisTemplate.opsForList().leftPop(inAuditListRedisKey);
                     String id = firstObj.getString("id");
                     LongArticleTitleAudit videoAudit = titleAuditRepository.getByContentId(id);
                     ContentPoolEnum poolEnum = ContentPoolEnum.from(videoAudit.getFlowPoolLevel());
@@ -446,14 +446,16 @@ public class ArticleVideoAuditService {
                 }
             }
             List<String> excludeContentIds = new ArrayList<>();
-            List<String> nextList = redisTemplate.opsForList().range(nextListRedisKey, 0, -1);
-            Map<String, List<LongArticleTitleAudit>> nextListPoolCountMap = new HashMap<>();
-            if (CollectionUtils.isNotEmpty(nextList)) {
-                List<String> nextListIds = nextList.stream().map(item -> JSONObject.parseObject(item).getString("id")).collect(Collectors.toList());
-                List<LongArticleTitleAudit> auditQueueList = titleAuditRepository.getByContentIdIn(new ArrayList<>(nextListIds));
-                nextListPoolCountMap = auditQueueList.stream().collect(Collectors.groupingBy(item -> ContentPoolEnum.from(item.getFlowPoolLevel()).getContentPool()));
-                excludeContentIds.addAll(nextListIds);
+            // 审核中列表获取,按内容池分组
+            List<String> inAuditList = redisTemplate.opsForList().range(inAuditListRedisKey, 0, -1);
+            Map<String, List<LongArticleTitleAudit>> inAuditListPoolCountMap = new HashMap<>();
+            if (CollectionUtils.isNotEmpty(inAuditList)) {
+                List<String> inAuditListIds = inAuditList.stream().map(item -> JSONObject.parseObject(item).getString("id")).collect(Collectors.toList());
+                List<LongArticleTitleAudit> auditQueueList = titleAuditRepository.getByContentIdIn(new ArrayList<>(inAuditListIds));
+                inAuditListPoolCountMap = auditQueueList.stream().collect(Collectors.groupingBy(item -> ContentPoolEnum.from(item.getFlowPoolLevel()).getContentPool()));
+                excludeContentIds.addAll(inAuditListIds);
             }
+            // 待审核列表获取,按内容池分组
             Set<String> auditQueueIds = redisTemplate.opsForZSet().rangeByScore(auditQueueRedisKey, 0, 100);
             Map<String, List<LongArticleTitleAudit>> auditQueuePoolCountMap = new HashMap<>();
             if (CollectionUtils.isNotEmpty(auditQueueIds)) {
@@ -468,8 +470,8 @@ public class ArticleVideoAuditService {
                 int totalCount = Integer.parseInt(Optional.ofNullable(redisTemplate.opsForValue().get(key)).orElse("0"));
                 if (totalCount < entry.getValue()) {
                     List<LongArticleTitleAudit> auditQueueList = auditQueuePoolCountMap.getOrDefault(poolEnum.getContentPool(), new ArrayList<>());
-                    List<LongArticleTitleAudit> nextListPool = nextListPoolCountMap.getOrDefault(poolEnum.getContentPool(), new ArrayList<>());
-                    int needCount = entry.getValue() - (totalCount + auditQueueList.size() + nextListPool.size());
+                    List<LongArticleTitleAudit> inAuditListPool = inAuditListPoolCountMap.getOrDefault(poolEnum.getContentPool(), new ArrayList<>());
+                    int needCount = entry.getValue() - (totalCount + auditQueueList.size() + inAuditListPool.size());
                     if (needCount > 0) {
                         List<ArticleVideoAuditListVO> addList = articleAuditMapper.articleVideoWatingAuditList(
                                 Arrays.asList(ArticleVideoAuditStatusEnum.WAITING.getCode()),

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

@@ -123,14 +123,14 @@ public class VideoPoolAuditService {
         long now = System.currentTimeMillis();
         String id;
         PublishSingleVideoSource obj = null;
-        String nextListRedisKey = "video-pool-audit-next-list";
+        String inAuditListRedisKey = "video-pool-in-audit-list";
         try {
             String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
             String auditQueueRedisKey = "video-pool-audit-queue-" + dateStr;
             // 从待审核队列中获取数据,如未获取到则从数据库查询一条
             Long size = redisTemplate.opsForZSet().size(auditQueueRedisKey);
             if (Objects.isNull(size) || size == 0) {
-                Map<Object, Object> entries = redisTemplate.opsForHash().entries(nextListRedisKey);
+                Map<Object, Object> entries = redisTemplate.opsForHash().entries(inAuditListRedisKey);
                 List<String> excludeContentIds = new ArrayList<>();
                 entries.forEach((k, v) -> {
                     excludeContentIds.add((String) k);
@@ -164,7 +164,7 @@ public class VideoPoolAuditService {
         JSONObject json = new JSONObject();
         json.put("id", obj.getContentTraceId());
         json.put("timestamp", now + (10 * 60 * 1000));
-        redisTemplate.opsForList().rightPush(nextListRedisKey, json.toJSONString());
+        redisTemplate.opsForList().rightPush(inAuditListRedisKey, json.toJSONString());
         // 填充数据
         List<VideoPoolAuditListVO> list = buildVideoPoolAuditListVO(Collections.singletonList(obj));
         result.setObjs(list);
@@ -192,7 +192,7 @@ public class VideoPoolAuditService {
         }
         // 当日审核数+1
         addAuditCount(ContentPoolEnum.from(videoAudit.getFlowPoolLevel()).getContentPool());
-        redisTemplate.opsForHash().delete("video-pool-audit-next-list", videoAudit.getContentTraceId());
+        redisTemplate.opsForHash().delete("video-pool-in-audit-list", videoAudit.getContentTraceId());
     }
 
     private void addAuditCount(String poolLevel) {
@@ -260,17 +260,17 @@ public class VideoPoolAuditService {
         try {
             Long now = System.currentTimeMillis();
             String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
-            String nextListRedisKey = "video-pool-audit-next-list";
+            String inAuditListRedisKey = "video-pool-in-audit-list";
             String auditQueueRedisKey = "video-pool-audit-queue-" + dateStr;
             // 判断是否审核超时,重新加入待审核队列
             while (true) {
-                List<String> nextList = redisTemplate.opsForList().range(nextListRedisKey, 0, 0);
-                if (CollectionUtils.isEmpty(nextList)) {
+                List<String> inAuditList = redisTemplate.opsForList().range(inAuditListRedisKey, 0, 0);
+                if (CollectionUtils.isEmpty(inAuditList)) {
                     break;
                 }
-                JSONObject firstObj = JSONObject.parseObject(nextList.get(0));
+                JSONObject firstObj = JSONObject.parseObject(inAuditList.get(0));
                 if (now > firstObj.getLong("timestamp")) {
-                    redisTemplate.opsForList().leftPop(nextListRedisKey);
+                    redisTemplate.opsForList().leftPop(inAuditListRedisKey);
                     String id = firstObj.getString("id");
                     PublishSingleVideoSource videoAudit = videoSourceRepository.getByContentTraceId(id);
                     ContentPoolEnum poolEnum = ContentPoolEnum.from(videoAudit.getFlowPoolLevel());
@@ -280,14 +280,16 @@ public class VideoPoolAuditService {
                 }
             }
             List<String> excludeContentIds = new ArrayList<>();
-            List<String> nextList = redisTemplate.opsForList().range(nextListRedisKey, 0, -1);
-            Map<String, List<PublishSingleVideoSource>> nextListPoolCountMap = new HashMap<>();
-            if (CollectionUtils.isNotEmpty(nextList)) {
-                List<String> nextListIds = nextList.stream().map(item -> JSONObject.parseObject(item).getString("id")).collect(Collectors.toList());
-                List<PublishSingleVideoSource> auditQueueList = videoSourceRepository.getByContentTraceIdIn(new ArrayList<>(nextListIds));
-                nextListPoolCountMap = auditQueueList.stream().collect(Collectors.groupingBy(item -> ContentPoolEnum.from(item.getFlowPoolLevel()).getContentPool()));
-                excludeContentIds.addAll(nextListIds);
+            // 审核中列表获取,按内容池分组
+            List<String> inAuditList = redisTemplate.opsForList().range(inAuditListRedisKey, 0, -1);
+            Map<String, List<PublishSingleVideoSource>> inAuditListPoolCountMap = new HashMap<>();
+            if (CollectionUtils.isNotEmpty(inAuditList)) {
+                List<String> inAuditListIds = inAuditList.stream().map(item -> JSONObject.parseObject(item).getString("id")).collect(Collectors.toList());
+                List<PublishSingleVideoSource> auditQueueList = videoSourceRepository.getByContentTraceIdIn(new ArrayList<>(inAuditListIds));
+                inAuditListPoolCountMap = auditQueueList.stream().collect(Collectors.groupingBy(item -> ContentPoolEnum.from(item.getFlowPoolLevel()).getContentPool()));
+                excludeContentIds.addAll(inAuditListIds);
             }
+            // 待审核列表获取,按内容池分组
             Set<String> auditQueueIds = redisTemplate.opsForZSet().rangeByScore(auditQueueRedisKey, 0, 100);
             Map<String, List<PublishSingleVideoSource>> auditQueuePoolCountMap = new HashMap<>();
             if (CollectionUtils.isNotEmpty(auditQueueIds)) {
@@ -302,8 +304,8 @@ public class VideoPoolAuditService {
                 int totalCount = Integer.parseInt(Optional.ofNullable(redisTemplate.opsForValue().get(key)).orElse("0"));
                 if (totalCount < entry.getValue()) {
                     List<PublishSingleVideoSource> auditQueueList = auditQueuePoolCountMap.getOrDefault(poolEnum.getContentPool(), new ArrayList<>());
-                    List<PublishSingleVideoSource> nextListPool = nextListPoolCountMap.getOrDefault(poolEnum.getContentPool(), new ArrayList<>());
-                    int needCount = entry.getValue() - (totalCount + auditQueueList.size() + nextListPool.size());
+                    List<PublishSingleVideoSource> inAuditListPool = inAuditListPoolCountMap.getOrDefault(poolEnum.getContentPool(), new ArrayList<>());
+                    int needCount = entry.getValue() - (totalCount + auditQueueList.size() + inAuditListPool.size());
                     if (needCount > 0) {
                         List<PublishSingleVideoSource> addList = videoPoolAuditMapper.articleVideoWatingAuditList(
                                 Arrays.asList(ArticleVideoAuditStatusEnum.WAITING.getCode()),