|
@@ -12,6 +12,7 @@ import com.tzld.longarticle.recommend.server.mapper.longArticle.VideoPoolAuditMa
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource;
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource;
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.VideoTitleReWrite;
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.VideoTitleReWrite;
|
|
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.VideoPoolAuditDataVO;
|
|
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.repository.longArticle.VideoTitleReWriteRepository;
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.VideoTitleReWriteRepository;
|
|
@@ -60,6 +61,10 @@ public class VideoPoolAuditService {
|
|
private Map<String, Integer> dailyAuditPoolCount;
|
|
private Map<String, Integer> dailyAuditPoolCount;
|
|
|
|
|
|
public Page<VideoPoolAuditListVO> list(VideoPoolAuditListParam param) {
|
|
public Page<VideoPoolAuditListVO> list(VideoPoolAuditListParam param) {
|
|
|
|
+ if (Objects.isNull(param.getPageNum()) || Objects.isNull(param.getPageSize())) {
|
|
|
|
+ param.setPageNum(1);
|
|
|
|
+ param.setPageSize(50);
|
|
|
|
+ }
|
|
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(),
|
|
param.getTitle(), param.getAuditAccount(), param.getFlowPoolLevel(), param.getAuditTimestamp());
|
|
param.getTitle(), param.getAuditAccount(), param.getFlowPoolLevel(), param.getAuditTimestamp());
|
|
@@ -139,55 +144,80 @@ public class VideoPoolAuditService {
|
|
return result; // 返回空结果
|
|
return result; // 返回空结果
|
|
}
|
|
}
|
|
long now = System.currentTimeMillis();
|
|
long now = System.currentTimeMillis();
|
|
- String id;
|
|
|
|
- PublishSingleVideoSource obj = null;
|
|
|
|
- String inAuditListRedisKey = "video-pool-in-audit-list";
|
|
|
|
|
|
+ if (Objects.isNull(param.getPageSize())) {
|
|
|
|
+ param.setPageSize(1);
|
|
|
|
+ }
|
|
|
|
+ int limit = param.getPageSize();
|
|
|
|
+ List<PublishSingleVideoSource> objs = new ArrayList<>();
|
|
|
|
+ String inAuditListRedisKey = "video-pool-in-audit-list-" + param.getAuditAccountName();
|
|
try {
|
|
try {
|
|
String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
|
|
String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
|
|
String auditQueueRedisKey = "video-pool-audit-queue-" + dateStr;
|
|
String auditQueueRedisKey = "video-pool-audit-queue-" + dateStr;
|
|
// 从待审核队列中获取数据,如未获取到则从数据库查询一条
|
|
// 从待审核队列中获取数据,如未获取到则从数据库查询一条
|
|
Long size = redisTemplate.opsForZSet().size(auditQueueRedisKey);
|
|
Long size = redisTemplate.opsForZSet().size(auditQueueRedisKey);
|
|
- if (Objects.isNull(size) || size == 0) {
|
|
|
|
- List<String> entries = redisTemplate.opsForList().range(inAuditListRedisKey, 0, -1);
|
|
|
|
- List<String> excludeContentIds = new ArrayList<>();
|
|
|
|
- if (CollectionUtils.isNotEmpty(entries)) {
|
|
|
|
- excludeContentIds = entries.stream().map(o -> {
|
|
|
|
- JSONObject json = JSONObject.parseObject(o);
|
|
|
|
- return json.getString("id");
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
- }
|
|
|
|
- obj = videoPoolAuditMapper.articleVideoAuditNext(param.getContentId(),
|
|
|
|
- param.getStatus(), param.getTitle(), param.getAuditAccount(), null, excludeContentIds);
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (Objects.nonNull(size) && size > 0) {
|
|
// 从待审核队列中获取数据, 如获取到的内容已审核,则重新获取
|
|
// 从待审核队列中获取数据, 如获取到的内容已审核,则重新获取
|
|
- while (true) {
|
|
|
|
- Set<String> ids = redisTemplate.opsForZSet().reverseRangeByScore(auditQueueRedisKey, 0, 100, 0, 1);
|
|
|
|
- if (CollectionUtils.isNotEmpty(ids)) {
|
|
|
|
- id = ids.iterator().next();
|
|
|
|
- redisTemplate.opsForZSet().remove(auditQueueRedisKey, id);
|
|
|
|
- obj = videoSourceRepository.getByContentTraceId(id);
|
|
|
|
- if (obj.getVideoPoolAuditStatus() == ArticleVideoAuditStatusEnum.WAITING.getCode()) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
|
|
+ while (limit > 0) {
|
|
|
|
+ Set<String> ids = redisTemplate.opsForZSet().reverseRangeByScore(auditQueueRedisKey, 0, 100, 0, limit);
|
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ List<String> contentTraceIdList = new ArrayList<>(ids);
|
|
|
|
+ List<PublishSingleVideoSource> checkList = videoSourceRepository.getByContentTraceIdIn(contentTraceIdList);
|
|
|
|
+ if (CollectionUtils.isEmpty(checkList)) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ for (PublishSingleVideoSource videoSource : checkList) {
|
|
|
|
+ redisTemplate.opsForZSet().remove(auditQueueRedisKey, videoSource.getContentTraceId());
|
|
|
|
+ if (videoSource.getVideoPoolAuditStatus() == ArticleVideoAuditStatusEnum.WAITING.getCode()) {
|
|
|
|
+ objs.add(videoSource);
|
|
|
|
+ limit--;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (limit > 0) {
|
|
|
|
+ List<String> excludeContentIds = new ArrayList<>();
|
|
|
|
+ String auditAccountListKey = "video-pool-audit-account-list-" + dateStr;
|
|
|
|
+ Set<String> auditAccountList = redisTemplate.opsForSet().members(auditAccountListKey);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(auditAccountList)) {
|
|
|
|
+ for (String auditAccount : auditAccountList) {
|
|
|
|
+ String inAuditAccountListRedisKey = "video-pool-in-audit-list-" + auditAccount;
|
|
|
|
+ List<String> entries = redisTemplate.opsForList().range(inAuditAccountListRedisKey, 0, -1);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(entries)) {
|
|
|
|
+ excludeContentIds.addAll(entries.stream().map(o -> {
|
|
|
|
+ JSONObject json = JSONObject.parseObject(o);
|
|
|
|
+ return json.getString("id");
|
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ objs.addAll(videoPoolAuditMapper.articleVideoAuditNext(param.getContentId(),
|
|
|
|
+ param.getStatus(), param.getTitle(), param.getAuditAccount(), null,
|
|
|
|
+ excludeContentIds, limit));
|
|
|
|
+ }
|
|
|
|
+ // 添加到超时队列
|
|
|
|
+ if (CollectionUtils.isNotEmpty(objs)) {
|
|
|
|
+ for (PublishSingleVideoSource obj : objs) {
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("id", obj.getContentTraceId());
|
|
|
|
+ json.put("timestamp", now + (120 * 60 * 1000));
|
|
|
|
+ redisTemplate.opsForList().rightPush(inAuditListRedisKey, json.toJSONString());
|
|
|
|
+ redisTemplate.expire(inAuditListRedisKey, 12, TimeUnit.HOURS);
|
|
}
|
|
}
|
|
|
|
+ String auditAccountListKey = "video-pool-audit-account-list-" + dateStr;
|
|
|
|
+ redisTemplate.opsForSet().add(auditAccountListKey, param.getAuditAccountName());
|
|
|
|
+ redisTemplate.expire(auditAccountListKey, 12, TimeUnit.HOURS);
|
|
}
|
|
}
|
|
} finally {
|
|
} finally {
|
|
// 释放锁
|
|
// 释放锁
|
|
redisUtil.releaseLock(lockKey, requestId);
|
|
redisUtil.releaseLock(lockKey, requestId);
|
|
}
|
|
}
|
|
- if (Objects.isNull(obj)) {
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(objs)) {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
- // 添加到超时队列
|
|
|
|
- JSONObject json = new JSONObject();
|
|
|
|
- json.put("id", obj.getContentTraceId());
|
|
|
|
- json.put("timestamp", now + (10 * 60 * 1000));
|
|
|
|
- redisTemplate.opsForList().rightPush(inAuditListRedisKey, json.toJSONString());
|
|
|
|
// 填充数据
|
|
// 填充数据
|
|
- List<VideoPoolAuditListVO> list = buildVideoPoolAuditListVO(Collections.singletonList(obj));
|
|
|
|
|
|
+ List<VideoPoolAuditListVO> list = buildVideoPoolAuditListVO(objs);
|
|
result.setObjs(list);
|
|
result.setObjs(list);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -280,36 +310,42 @@ public class VideoPoolAuditService {
|
|
try {
|
|
try {
|
|
Long now = System.currentTimeMillis();
|
|
Long now = System.currentTimeMillis();
|
|
String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
|
|
String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
|
|
- String inAuditListRedisKey = "video-pool-in-audit-list";
|
|
|
|
String auditQueueRedisKey = "video-pool-audit-queue-" + dateStr;
|
|
String auditQueueRedisKey = "video-pool-audit-queue-" + dateStr;
|
|
// 判断是否审核超时,重新加入待审核队列
|
|
// 判断是否审核超时,重新加入待审核队列
|
|
- while (true) {
|
|
|
|
- List<String> inAuditList = redisTemplate.opsForList().range(inAuditListRedisKey, 0, 0);
|
|
|
|
- if (CollectionUtils.isEmpty(inAuditList)) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- JSONObject firstObj = JSONObject.parseObject(inAuditList.get(0));
|
|
|
|
- if (now > firstObj.getLong("timestamp")) {
|
|
|
|
- redisTemplate.opsForList().leftPop(inAuditListRedisKey);
|
|
|
|
- String id = firstObj.getString("id");
|
|
|
|
- PublishSingleVideoSource videoAudit = videoSourceRepository.getByContentTraceId(id);
|
|
|
|
- if (videoAudit.getVideoPoolAuditStatus() == ArticleVideoAuditStatusEnum.WAITING.getCode()) {
|
|
|
|
- ContentPoolEnum poolEnum = ContentPoolEnum.from(videoAudit.getFlowPoolLevel());
|
|
|
|
- redisTemplate.opsForZSet().add(auditQueueRedisKey, id, poolEnum.getWeight());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ String auditAccountListKey = "video-pool-audit-account-list-" + dateStr;
|
|
|
|
+ Set<String> auditAccountList = redisTemplate.opsForSet().members(auditAccountListKey);
|
|
List<String> excludeContentIds = new ArrayList<>();
|
|
List<String> excludeContentIds = new ArrayList<>();
|
|
- // 审核中列表获取,按内容池分组
|
|
|
|
- List<String> inAuditList = redisTemplate.opsForList().range(inAuditListRedisKey, 0, -1);
|
|
|
|
Map<String, List<PublishSingleVideoSource>> inAuditListPoolCountMap = new HashMap<>();
|
|
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);
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(auditAccountList)) {
|
|
|
|
+ for (String auditAccount : auditAccountList) {
|
|
|
|
+ String inAuditListRedisKey = "video-pool-in-audit-list-" + auditAccount;
|
|
|
|
+ while (true) {
|
|
|
|
+ List<String> inAuditList = redisTemplate.opsForList().range(inAuditListRedisKey, 0, 0);
|
|
|
|
+ if (CollectionUtils.isEmpty(inAuditList)) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ JSONObject firstObj = JSONObject.parseObject(inAuditList.get(0));
|
|
|
|
+ if (now > firstObj.getLong("timestamp")) {
|
|
|
|
+ redisTemplate.opsForList().leftPop(inAuditListRedisKey);
|
|
|
|
+ String id = firstObj.getString("id");
|
|
|
|
+ PublishSingleVideoSource videoAudit = videoSourceRepository.getByContentTraceId(id);
|
|
|
|
+ if (videoAudit.getVideoPoolAuditStatus() == ArticleVideoAuditStatusEnum.WAITING.getCode()) {
|
|
|
|
+ ContentPoolEnum poolEnum = ContentPoolEnum.from(videoAudit.getFlowPoolLevel());
|
|
|
|
+ redisTemplate.opsForZSet().add(auditQueueRedisKey, id, poolEnum.getWeight());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 审核中列表获取,按内容池分组
|
|
|
|
+ List<String> inAuditList = redisTemplate.opsForList().range(inAuditListRedisKey, 0, -1);
|
|
|
|
+ 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);
|
|
Set<String> auditQueueIds = redisTemplate.opsForZSet().rangeByScore(auditQueueRedisKey, 0, 100);
|
|
@@ -329,7 +365,7 @@ public class VideoPoolAuditService {
|
|
List<PublishSingleVideoSource> inAuditListPool = inAuditListPoolCountMap.getOrDefault(poolEnum.getContentPool(), new ArrayList<>());
|
|
List<PublishSingleVideoSource> inAuditListPool = inAuditListPoolCountMap.getOrDefault(poolEnum.getContentPool(), new ArrayList<>());
|
|
int needCount = entry.getValue() - (totalCount + auditQueueList.size() + inAuditListPool.size());
|
|
int needCount = entry.getValue() - (totalCount + auditQueueList.size() + inAuditListPool.size());
|
|
if (needCount > 0) {
|
|
if (needCount > 0) {
|
|
- List<PublishSingleVideoSource> addList = videoPoolAuditMapper.articleVideoWatingAuditList(
|
|
|
|
|
|
+ List<PublishSingleVideoSource> addList = videoPoolAuditMapper.articleVideoWaitingAuditList(
|
|
Arrays.asList(ArticleVideoAuditStatusEnum.WAITING.getCode()),
|
|
Arrays.asList(ArticleVideoAuditStatusEnum.WAITING.getCode()),
|
|
Arrays.asList(poolEnum.getValue()), excludeContentIds, needCount);
|
|
Arrays.asList(poolEnum.getValue()), excludeContentIds, needCount);
|
|
if (CollectionUtils.isNotEmpty(addList)) {
|
|
if (CollectionUtils.isNotEmpty(addList)) {
|
|
@@ -343,9 +379,9 @@ public class VideoPoolAuditService {
|
|
}
|
|
}
|
|
// 待发布内容不足添加
|
|
// 待发布内容不足添加
|
|
Long auditQueueSize = redisTemplate.opsForZSet().size(auditQueueRedisKey);
|
|
Long auditQueueSize = redisTemplate.opsForZSet().size(auditQueueRedisKey);
|
|
- if (Objects.isNull(auditQueueSize) || auditQueueSize < 20) {
|
|
|
|
- List<PublishSingleVideoSource> list = videoPoolAuditMapper.articleVideoWatingAuditList(
|
|
|
|
- Arrays.asList(ArticleVideoAuditStatusEnum.WAITING.getCode()), null, excludeContentIds, 40);
|
|
|
|
|
|
+ if (Objects.isNull(auditQueueSize) || auditQueueSize < 100) {
|
|
|
|
+ List<PublishSingleVideoSource> list = videoPoolAuditMapper.articleVideoWaitingAuditList(
|
|
|
|
+ Arrays.asList(ArticleVideoAuditStatusEnum.WAITING.getCode()), null, excludeContentIds, 100);
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
for (PublishSingleVideoSource item : list) {
|
|
for (PublishSingleVideoSource item : list) {
|
|
ContentPoolEnum poolEnum = ContentPoolEnum.from(item.getFlowPoolLevel());
|
|
ContentPoolEnum poolEnum = ContentPoolEnum.from(item.getFlowPoolLevel());
|
|
@@ -359,4 +395,26 @@ public class VideoPoolAuditService {
|
|
}
|
|
}
|
|
return ReturnT.SUCCESS;
|
|
return ReturnT.SUCCESS;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public VideoPoolAuditDataVO auditData(VideoPoolAuditDataParam param) {
|
|
|
|
+ String accountName = param.getAuditAccountName();
|
|
|
|
+ Long start = DateUtils.getTodayStart();
|
|
|
|
+ Long end = System.currentTimeMillis();
|
|
|
|
+ List<PublishSingleVideoSource> auditCount = videoPoolAuditMapper.articleVideoAuditCount(accountName, start, end);
|
|
|
|
+ int auditPassCount = auditCount.stream()
|
|
|
|
+ .filter(item -> item.getVideoPoolAuditStatus() == ArticleVideoAuditStatusEnum.PASS.getCode())
|
|
|
|
+ .collect(Collectors.toList()).size();
|
|
|
|
+ int waitingAuditCount = videoPoolAuditMapper.articleVideoWaitingAuditCount();
|
|
|
|
+ VideoPoolAuditDataVO result = new VideoPoolAuditDataVO();
|
|
|
|
+ result.setAuditAccount(accountName);
|
|
|
|
+ result.setAuditCount(auditCount.size());
|
|
|
|
+ result.setAuditPassCount(auditPassCount);
|
|
|
|
+ result.setWaitingAuditCount(waitingAuditCount);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void getOff(VideoPoolAuditDataParam param) {
|
|
|
|
+ String inAuditListRedisKey = "video-pool-in-audit-list-" + param.getAuditAccountName();
|
|
|
|
+ redisTemplate.delete(inAuditListRedisKey);
|
|
|
|
+ }
|
|
}
|
|
}
|