|
@@ -1,5 +1,6 @@
|
|
|
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.longArticle.ArticleVideoAuditStatusEnum;
|
|
|
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.vo.VideoPoolAuditListVO;
|
|
|
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.xxl.job.core.biz.model.ReturnT;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
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.Value;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
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;
|
|
|
|
|
|
@Service
|
|
@@ -36,12 +38,18 @@ public class VideoPoolAuditService {
|
|
|
@Autowired
|
|
|
private PublishSingleVideoSourceRepository videoSourceRepository;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate<String, String> redisTemplate;
|
|
|
+
|
|
|
@Value("${cdnUrl:https://rescdn.piaoquantv.com/}")
|
|
|
private String cdnUrl;
|
|
|
|
|
|
@Value("${videoAudit.poolLevel.sort:}")
|
|
|
private String poolLevelDesc;
|
|
|
|
|
|
+ @ApolloJsonValue("${daily.video.audit.pool.count.config:{}}")
|
|
|
+ private Map<String, Integer> dailyAuditPoolCount;
|
|
|
+
|
|
|
public Page<VideoPoolAuditListVO> list(VideoPoolAuditListParam param) {
|
|
|
int offset = (param.getPageNum() - 1) * param.getPageSize();
|
|
|
int count = videoPoolAuditMapper.articleVideoAuditListCount(param.getContentId(), param.getStatus(),
|
|
@@ -84,6 +92,45 @@ public class VideoPoolAuditService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public VideoPoolAuditListVO next(VideoPoolAuditListParam param) {
|
|
|
+ if (Objects.nonNull(param.getFlowPoolLevel())) {
|
|
|
+ param.setPageSize(1);
|
|
|
+ Page<VideoPoolAuditListVO> page = list(param);
|
|
|
+ if (CollectionUtils.isEmpty(page.getObjs())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return page.getObjs().get(0);
|
|
|
+ }
|
|
|
+ // 根据配置判断当日是否审核完成 并 选择内容池返回
|
|
|
+ Integer poolLevel = getAuditPoolLevel();
|
|
|
+ PublishSingleVideoSource obj = videoPoolAuditMapper.articleVideoAuditNext(param.getContentId(),
|
|
|
+ param.getStatus(), param.getTitle(), param.getAuditAccount(), poolLevel);
|
|
|
+ if (Objects.isNull(obj)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<PublishSingleVideoSource> list = Collections.singletonList(obj);
|
|
|
+ List<VideoPoolAuditListVO> result = buildVideoPoolAuditListVO(list);
|
|
|
+ return result.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getAuditPoolLevel() {
|
|
|
+ if (MapUtils.isEmpty(dailyAuditPoolCount)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
|
|
|
+ for (Map.Entry<String, Integer> entry : dailyAuditPoolCount.entrySet()) {
|
|
|
+ String poolLevel = entry.getKey();
|
|
|
+ int target = entry.getValue();
|
|
|
+ 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) {
|
|
|
PublishSingleVideoSource videoAudit = videoSourceRepository.getByContentTraceId(param.getContentId());
|
|
|
Long now = System.currentTimeMillis();
|
|
@@ -103,7 +150,15 @@ public class VideoPoolAuditService {
|
|
|
// 审核通过
|
|
|
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) {
|