|
@@ -5,18 +5,23 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.PushTypeEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.cgi.PQVideoAuditResultEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.cgi.PQVideoSensitiveLevelEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleDeleteStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.model.cgi.PQVideoAuditResult;
|
|
|
import com.tzld.longarticle.recommend.server.model.dto.*;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.*;
|
|
|
import com.tzld.longarticle.recommend.server.model.param.ArticleDangerFindDeleteParam;
|
|
|
-import com.tzld.longarticle.recommend.server.model.param.ArticleVideoAuditResultParam;
|
|
|
import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
|
|
|
import com.tzld.longarticle.recommend.server.remote.WxAccessTokenRemoteService;
|
|
|
import com.tzld.longarticle.recommend.server.remote.WxArticleDeleteService;
|
|
|
+import com.tzld.longarticle.recommend.server.remote.pq.PQVideoAuditResultService;
|
|
|
+import com.tzld.longarticle.recommend.server.remote.pq.PQVideoAuditStartProcessService;
|
|
|
import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.*;
|
|
@@ -31,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.net.URL;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -61,11 +67,17 @@ public class ArticleAuditService {
|
|
|
private ArticleRepository articleRepository;
|
|
|
@Autowired
|
|
|
private ArticleUnsafeTitleRepository articleUnsafeTitleRepository;
|
|
|
+ @Autowired
|
|
|
+ private PQVideoAuditStartProcessService pqVideoAuditStartProcessService;
|
|
|
+ @Autowired
|
|
|
+ private PQVideoAuditResultService pqVideoAuditResultService;
|
|
|
+ @Autowired
|
|
|
+ private LongArticleBaseMapper longArticleBaseMapper;
|
|
|
|
|
|
|
|
|
@XxlJob("articleVideoAudit")
|
|
|
public ReturnT<String> articleVideoAudit(String param) {
|
|
|
- long publishTime = DateUtils.getTodayStart();
|
|
|
+ long publishTime = DateUtils.getTodayStart() / 1000;
|
|
|
if (StringUtils.hasText(param)) {
|
|
|
publishTime = DateUtils.getStartOfDay(param, "yyyyMMdd");
|
|
|
}
|
|
@@ -77,50 +89,102 @@ public class ArticleAuditService {
|
|
|
List<LongArticlesMatchVideo> longArticlesMatchVideoList = longArticlesMatchVideoRepository.getByTraceIdIn(traceIds);
|
|
|
Map<String, LongArticlesMatchVideo> longarticlesMatchVideoMap = longArticlesMatchVideoList.stream()
|
|
|
.collect(Collectors.toMap(LongArticlesMatchVideo::getTraceId, Function.identity()));
|
|
|
+ List<String> existsOssPath = longArticleBaseMapper.getExistsOssPath();
|
|
|
for (String traceId : traceIds) {
|
|
|
LongArticlesMatchVideo longArticlesMatchVideo = longarticlesMatchVideoMap.get(traceId);
|
|
|
List<LongArticlesMatchVideoResponse> responseList = JSONArray.parseArray(longArticlesMatchVideo.getResponse()
|
|
|
, LongArticlesMatchVideoResponse.class);
|
|
|
- List<Long> videoIds = responseList.stream().map(LongArticlesMatchVideoResponse::getVideoID).collect(Collectors.toList());
|
|
|
- List<LongArticleVideoAudit> existsList = longArticleVideoAuditRepository.getByVideoIdIn(videoIds);
|
|
|
- List<Long> existsVideoIds = existsList.stream().map(LongArticleVideoAudit::getVideoId).collect(Collectors.toList());
|
|
|
for (LongArticlesMatchVideoResponse response : responseList) {
|
|
|
- if (existsVideoIds.contains(response.getVideoID())) {
|
|
|
+ String ossPath = getOssPath(response.getVideoPath());
|
|
|
+ if (existsOssPath.contains(ossPath)) {
|
|
|
continue;
|
|
|
}
|
|
|
+ existsOssPath.add(ossPath);
|
|
|
LongArticleVideoAudit videoAudit = new LongArticleVideoAudit();
|
|
|
videoAudit.setVideoId(response.getVideoID());
|
|
|
videoAudit.setTraceId(traceId);
|
|
|
videoAudit.setContentId(longArticlesMatchVideo.getContentId());
|
|
|
- videoAudit.setOssPath(response.getVideoOSS());
|
|
|
+ videoAudit.setOssPath(ossPath);
|
|
|
videoAudit.setStatus(StatusEnum.ZERO.getCode());
|
|
|
videoAudit.setCreateTimestamp(System.currentTimeMillis());
|
|
|
longArticleVideoAuditRepository.save(videoAudit);
|
|
|
- // todo 调用PQ 审核视频
|
|
|
+ // 调用PQ 审核视频
|
|
|
+ try {
|
|
|
+ Long taskId = pqVideoAuditStartProcessService.startProcess(response.getVideoID());
|
|
|
+ if (Objects.nonNull(taskId)) {
|
|
|
+ videoAudit.setTaskId(taskId);
|
|
|
+ longArticleVideoAuditRepository.save(videoAudit);
|
|
|
+ } else {
|
|
|
+ log.error("PQVideoAuditStartProcess start process error videoId:{} ", response.getVideoID());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("PQVideoAuditStartProcess start process videoId:{} error:{}", response.getVideoID(), e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 视频审核结果处理
|
|
|
- */
|
|
|
- public void articleVideoAuditResult(ArticleVideoAuditResultParam param) {
|
|
|
- LongArticleVideoAudit longArticleVideoAudit = longArticleVideoAuditRepository.getByVideoId(param.getVideoId());
|
|
|
- if (param.getResult() == 1) {
|
|
|
+ private String getOssPath(String ossUrl) {
|
|
|
+ String result = "";
|
|
|
+ if (ossUrl == null || ossUrl.isEmpty()) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ URL url = new URL(ossUrl);
|
|
|
+ // 去除域名
|
|
|
+ result = url.getPath();
|
|
|
+ // 获取后缀.位置
|
|
|
+ int endIndex = result.lastIndexOf(".");
|
|
|
+ if (endIndex == -1) {
|
|
|
+ endIndex = result.length();
|
|
|
+ }
|
|
|
+ // 去除 / 及 文件后缀
|
|
|
+ result = result.substring(1, endIndex);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("getOssPath error:{}", e.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @XxlJob("articleVideoAuditResult")
|
|
|
+ public ReturnT<String> articleVideoAuditResult(String param) {
|
|
|
+ List<LongArticleVideoAudit> list = longArticleVideoAuditRepository.getByStatusAndTaskIdIsNotNull(StatusEnum.ZERO.getCode());
|
|
|
+ for (List<LongArticleVideoAudit> partition : Lists.partition(list, 10)) {
|
|
|
+ List<Long> taskIds = partition.stream().map(LongArticleVideoAudit::getTaskId).collect(Collectors.toList());
|
|
|
+ Map<Long, LongArticleVideoAudit> map = partition.stream().collect(Collectors.toMap(LongArticleVideoAudit::getTaskId, Function.identity()));
|
|
|
+ List<PQVideoAuditResult> resultList = pqVideoAuditResultService.getResult(taskIds);
|
|
|
+ resultList.forEach(result -> saveVideoAuditResult(map.get(result.getTaskId()), result));
|
|
|
+ }
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void saveVideoAuditResult(LongArticleVideoAudit longArticleVideoAudit, PQVideoAuditResult result) {
|
|
|
+
|
|
|
+ if (Objects.equals(result.getAuditResult(), PQVideoAuditResultEnum.PASS.getStatus())) {
|
|
|
// 审核通过,更新文章状态
|
|
|
- longArticleVideoAudit.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
|
|
|
+ longArticleVideoAudit.setStatus(PQVideoAuditResultEnum.PASS.getStatus());
|
|
|
longArticleVideoAudit.setFinishTimestamp(System.currentTimeMillis());
|
|
|
longArticleVideoAuditRepository.save(longArticleVideoAudit);
|
|
|
- } else {
|
|
|
+ } else if (Objects.equals(result.getAuditResult(), PQVideoAuditResultEnum.REJECT.getStatus())) {
|
|
|
// 审核不通过,删除文章
|
|
|
- longArticleVideoAudit.setStatus(ArticleDeleteStatusEnum.FAIL.getCode());
|
|
|
- longArticleVideoAudit.setFailReason(param.getFailReason());
|
|
|
+ longArticleVideoAudit.setStatus(PQVideoAuditResultEnum.REJECT.getStatus());
|
|
|
+ PQVideoSensitiveLevelEnum sensitiveLevelEnum = PQVideoSensitiveLevelEnum.from(result.getSensitiveLevel());
|
|
|
+ longArticleVideoAudit.setFailReason(sensitiveLevelEnum.getDescription());
|
|
|
longArticleVideoAudit.setFinishTimestamp(System.currentTimeMillis());
|
|
|
longArticleVideoAuditRepository.save(longArticleVideoAudit);
|
|
|
// 构建删除文章记录 并保存
|
|
|
- saveDeleteRecord(longArticleVideoAudit.getOssPath());
|
|
|
+ // saveDeleteRecord(longArticleVideoAudit.getOssPath());
|
|
|
+ // 暂时不做删除 先发送通知
|
|
|
+ FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.ARTICLE_DELETE.getRobotId(),
|
|
|
+ "视频审核不通过\n" +
|
|
|
+ "traceId:" + longArticleVideoAudit.getTraceId() + "\n" +
|
|
|
+ "视频id:" + longArticleVideoAudit.getVideoId() + "\n" +
|
|
|
+ "视频path:" + longArticleVideoAudit.getOssPath() + "\n" +
|
|
|
+ "敏感等级:" + sensitiveLevelEnum.getDescription() + "\n" +
|
|
|
+ "管理后台地址:https://admin.piaoquantv.com/cms/post-detail/" + longArticleVideoAudit.getVideoId() + "/detail");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -150,7 +214,7 @@ public class ArticleAuditService {
|
|
|
Map<String, String> publishPushIdMap = pushContentRelList.stream()
|
|
|
.collect(Collectors.toMap(PublishGzhPushContentRelDTO::getPublishContentId,
|
|
|
PublishGzhPushContentRelDTO::getPushId,
|
|
|
- (o1, o2) -> o2));
|
|
|
+ (o1, o2) -> o2));
|
|
|
List<PublishGzhPushDTO> pushList = aigcBaseMapper.getPushByPushIdIn(pushIds);
|
|
|
Map<String, PublishGzhPushDTO> pushDTOMap = pushList.stream()
|
|
|
.collect(Collectors.toMap(PublishGzhPushDTO::getPushId, Function.identity()));
|