|  | @@ -1,5 +1,6 @@
 | 
											
												
													
														|  |  package com.tzld.longarticle.recommend.server.service.recommend;
 |  |  package com.tzld.longarticle.recommend.server.service.recommend;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 | 
											
												
													
														|  |  import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishContentStatusEnum;
 |  |  import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishContentStatusEnum;
 | 
											
												
													
														|  |  import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoAuditStatusEnum;
 |  |  import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoAuditStatusEnum;
 | 
											
												
													
														|  |  import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoBadStatusEnum;
 |  |  import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoBadStatusEnum;
 | 
											
										
											
												
													
														|  | @@ -10,19 +11,20 @@ import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSin
 | 
											
												
													
														|  |  import com.tzld.longarticle.recommend.server.model.param.videoAudit.*;
 |  |  import com.tzld.longarticle.recommend.server.model.param.videoAudit.*;
 | 
											
												
													
														|  |  import com.tzld.longarticle.recommend.server.model.vo.VideoPoolAuditListVO;
 |  |  import com.tzld.longarticle.recommend.server.model.vo.VideoPoolAuditListVO;
 | 
											
												
													
														|  |  import com.tzld.longarticle.recommend.server.repository.longArticle.PublishSingleVideoSourceRepository;
 |  |  import com.tzld.longarticle.recommend.server.repository.longArticle.PublishSingleVideoSourceRepository;
 | 
											
												
													
														|  | 
 |  | +import com.tzld.longarticle.recommend.server.util.DateUtils;
 | 
											
												
													
														|  |  import com.tzld.longarticle.recommend.server.util.page.Page;
 |  |  import com.tzld.longarticle.recommend.server.util.page.Page;
 | 
											
												
													
														|  |  import com.xxl.job.core.biz.model.ReturnT;
 |  |  import com.xxl.job.core.biz.model.ReturnT;
 | 
											
												
													
														|  |  import com.xxl.job.core.handler.annotation.XxlJob;
 |  |  import com.xxl.job.core.handler.annotation.XxlJob;
 | 
											
												
													
														|  |  import lombok.extern.slf4j.Slf4j;
 |  |  import lombok.extern.slf4j.Slf4j;
 | 
											
												
													
														|  |  import org.apache.commons.collections4.CollectionUtils;
 |  |  import org.apache.commons.collections4.CollectionUtils;
 | 
											
												
													
														|  | 
 |  | +import org.apache.commons.collections4.MapUtils;
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Autowired;
 |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Value;
 |  |  import org.springframework.beans.factory.annotation.Value;
 | 
											
												
													
														|  | 
 |  | +import org.springframework.data.redis.core.RedisTemplate;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Service;
 |  |  import org.springframework.stereotype.Service;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -import java.util.ArrayList;
 |  | 
 | 
											
												
													
														|  | -import java.util.Arrays;
 |  | 
 | 
											
												
													
														|  | -import java.util.List;
 |  | 
 | 
											
												
													
														|  | -import java.util.Objects;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import java.util.*;
 | 
											
												
													
														|  | 
 |  | +import java.util.concurrent.TimeUnit;
 | 
											
												
													
														|  |  import java.util.stream.Collectors;
 |  |  import java.util.stream.Collectors;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  @Service
 |  |  @Service
 | 
											
										
											
												
													
														|  | @@ -36,12 +38,18 @@ public class VideoPoolAuditService {
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private PublishSingleVideoSourceRepository videoSourceRepository;
 |  |      private PublishSingleVideoSourceRepository videoSourceRepository;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private RedisTemplate<String, String> redisTemplate;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      @Value("${cdnUrl:https://rescdn.piaoquantv.com/}")
 |  |      @Value("${cdnUrl:https://rescdn.piaoquantv.com/}")
 | 
											
												
													
														|  |      private String cdnUrl;
 |  |      private String cdnUrl;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Value("${videoAudit.poolLevel.sort:}")
 |  |      @Value("${videoAudit.poolLevel.sort:}")
 | 
											
												
													
														|  |      private String poolLevelDesc;
 |  |      private String poolLevelDesc;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    @ApolloJsonValue("${daily.video.audit.pool.count.config:{}}")
 | 
											
												
													
														|  | 
 |  | +    private Map<String, Integer> dailyAuditPoolCount;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      public Page<VideoPoolAuditListVO> list(VideoPoolAuditListParam param) {
 |  |      public Page<VideoPoolAuditListVO> list(VideoPoolAuditListParam param) {
 | 
											
												
													
														|  |          int offset = (param.getPageNum() - 1) * param.getPageSize();
 |  |          int offset = (param.getPageNum() - 1) * param.getPageSize();
 | 
											
												
													
														|  |          int count = videoPoolAuditMapper.articleVideoAuditListCount(param.getContentId(), param.getStatus(),
 |  |          int count = videoPoolAuditMapper.articleVideoAuditListCount(param.getContentId(), param.getStatus(),
 | 
											
										
											
												
													
														|  | @@ -84,6 +92,60 @@ public class VideoPoolAuditService {
 | 
											
												
													
														|  |          return result;
 |  |          return result;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    public Page<VideoPoolAuditListVO> next(VideoPoolAuditListParam param) {
 | 
											
												
													
														|  | 
 |  | +        if (Objects.nonNull(param.getFlowPoolLevel())) {
 | 
											
												
													
														|  | 
 |  | +            param.setPageSize(1);
 | 
											
												
													
														|  | 
 |  | +            return list(param);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        Page<VideoPoolAuditListVO> result = new Page<>();
 | 
											
												
													
														|  | 
 |  | +        // 根据配置判断当日是否审核完成 并 选择内容池返回
 | 
											
												
													
														|  | 
 |  | +        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);
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            do {
 | 
											
												
													
														|  | 
 |  | +                obj = videoPoolAuditMapper.articleVideoAuditNext(param.getContentId(),
 | 
											
												
													
														|  | 
 |  | +                        param.getStatus(), param.getTitle(), param.getAuditAccount(), poolLevel);
 | 
											
												
													
														|  | 
 |  | +                if (Objects.nonNull(obj)) {
 | 
											
												
													
														|  | 
 |  | +                    break;
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +                excludePoolLevel.add(ContentPoolEnum.from(poolLevel).getContentPool());
 | 
											
												
													
														|  | 
 |  | +                poolLevel = getAuditPoolLevel(excludePoolLevel);
 | 
											
												
													
														|  | 
 |  | +            } while (Objects.nonNull(poolLevel));
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        if (Objects.isNull(obj)) {
 | 
											
												
													
														|  | 
 |  | +            return result;
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        List<VideoPoolAuditListVO> list = buildVideoPoolAuditListVO(Collections.singletonList(obj));
 | 
											
												
													
														|  | 
 |  | +        result.setObjs(list);
 | 
											
												
													
														|  | 
 |  | +        return result;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private Integer getAuditPoolLevel(List<String> excludePoolLevel) {
 | 
											
												
													
														|  | 
 |  | +        if (MapUtils.isEmpty(dailyAuditPoolCount)) {
 | 
											
												
													
														|  | 
 |  | +            return null;
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
 | 
											
												
													
														|  | 
 |  | +        Set<String> keySet = dailyAuditPoolCount.keySet();
 | 
											
												
													
														|  | 
 |  | +        keySet = keySet.stream().sorted().collect(Collectors.toCollection(LinkedHashSet::new));
 | 
											
												
													
														|  | 
 |  | +        for (String poolLevel : keySet) {
 | 
											
												
													
														|  | 
 |  | +            if (excludePoolLevel.contains(poolLevel)) {
 | 
											
												
													
														|  | 
 |  | +                continue;
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            int target = dailyAuditPoolCount.get(poolLevel);
 | 
											
												
													
														|  | 
 |  | +            String key = "video_audit_count_" + dateStr + "_" + poolLevel;
 | 
											
												
													
														|  | 
 |  | +            int totalCount = Integer.parseInt(Optional.ofNullable(redisTemplate.opsForValue().get(key)).orElse("0"));
 | 
											
												
													
														|  | 
 |  | +            if (target > totalCount) {
 | 
											
												
													
														|  | 
 |  | +                ContentPoolEnum poolEnum = ContentPoolEnum.from(poolLevel);
 | 
											
												
													
														|  | 
 |  | +                return poolEnum.getValue();
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return null;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      public void auditArticle(ArticleAuditParam param) {
 |  |      public void auditArticle(ArticleAuditParam param) {
 | 
											
												
													
														|  |          PublishSingleVideoSource videoAudit = videoSourceRepository.getByContentTraceId(param.getContentId());
 |  |          PublishSingleVideoSource videoAudit = videoSourceRepository.getByContentTraceId(param.getContentId());
 | 
											
												
													
														|  |          Long now = System.currentTimeMillis();
 |  |          Long now = System.currentTimeMillis();
 | 
											
										
											
												
													
														|  | @@ -103,7 +165,15 @@ public class VideoPoolAuditService {
 | 
											
												
													
														|  |              // 审核通过
 |  |              // 审核通过
 | 
											
												
													
														|  |              auditArticlePass(videoAudit);
 |  |              auditArticlePass(videoAudit);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | 
 |  | +        // 当日审核数+1
 | 
											
												
													
														|  | 
 |  | +        addAuditCount(ContentPoolEnum.from(videoAudit.getFlowPoolLevel()).getContentPool());
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    private void addAuditCount(String poolLevel) {
 | 
											
												
													
														|  | 
 |  | +        String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
 | 
											
												
													
														|  | 
 |  | +        String key = "video_audit_count_" + dateStr + "_" + poolLevel;
 | 
											
												
													
														|  | 
 |  | +        int totalCount = Integer.parseInt(Optional.ofNullable(redisTemplate.opsForValue().get(key)).orElse("0"));
 | 
											
												
													
														|  | 
 |  | +        redisTemplate.opsForValue().set(key, String.valueOf(totalCount + 1), 24, TimeUnit.HOURS);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      private void auditArticlePass(PublishSingleVideoSource videoAudit) {
 |  |      private void auditArticlePass(PublishSingleVideoSource videoAudit) {
 | 
											
										
											
												
													
														|  | @@ -142,7 +212,7 @@ public class VideoPoolAuditService {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @XxlJob("shuffleVideoPoolAuditGroup")
 |  |      @XxlJob("shuffleVideoPoolAuditGroup")
 | 
											
												
													
														|  |      public ReturnT<String> shuffleVideoPoolAuditGroup(String param) {
 |  |      public ReturnT<String> shuffleVideoPoolAuditGroup(String param) {
 | 
											
												
													
														|  | -        List<String> auditUser = Arrays.asList("a","b","c","d","e","f","g","h","i","j");
 |  | 
 | 
											
												
													
														|  | 
 |  | +        List<String> auditUser = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j");
 | 
											
												
													
														|  |          List<PublishSingleVideoSource> contentIds = videoSourceRepository.getByVideoPoolAuditStatus(ArticleVideoAuditStatusEnum.WAITING.getCode());
 |  |          List<PublishSingleVideoSource> contentIds = videoSourceRepository.getByVideoPoolAuditStatus(ArticleVideoAuditStatusEnum.WAITING.getCode());
 | 
											
												
													
														|  |          for (int i = 0; i < contentIds.size(); i++) {
 |  |          for (int i = 0; i < contentIds.size(); i++) {
 | 
											
												
													
														|  |              int per = i % auditUser.size();
 |  |              int per = i % auditUser.size();
 |