|
@@ -6,9 +6,11 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.FieshuTableColumnDataTypeEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.VideoAuditTypeEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishContentStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.PushTypeEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.cgi.FindFaceStatusEnum;
|
|
|
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;
|
|
@@ -17,6 +19,7 @@ import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotI
|
|
|
import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.crawler.ArticleMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.model.cgi.AlgFaceRecognizeResult;
|
|
|
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;
|
|
@@ -30,11 +33,11 @@ import com.tzld.longarticle.recommend.server.model.vo.ArticleDeleteListVO;
|
|
|
import com.tzld.longarticle.recommend.server.model.vo.FeishuTableDTO;
|
|
|
import com.tzld.longarticle.recommend.server.remote.WxAccessTokenRemoteService;
|
|
|
import com.tzld.longarticle.recommend.server.remote.WxArticleDeleteService;
|
|
|
+import com.tzld.longarticle.recommend.server.remote.alg.DangerFaceRecognizeService;
|
|
|
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.aigc.PublishContentRepository;
|
|
|
-import com.tzld.longarticle.recommend.server.repository.aigc.PublishPlanRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.*;
|
|
|
import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
@@ -91,7 +94,7 @@ public class ArticleAuditService {
|
|
|
@Autowired
|
|
|
private ArticleMapper articleMapper;
|
|
|
@Autowired
|
|
|
- private PublishPlanRepository publishPlanRepository;
|
|
|
+ private DangerFaceRecognizeService dangerFaceRecognizeService;
|
|
|
|
|
|
|
|
|
@XxlJob("articleVideoAudit")
|
|
@@ -110,7 +113,7 @@ 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();
|
|
|
+ List<String> existsOssPath = longArticleBaseMapper.getExistsOssPath(VideoAuditTypeEnum.PQ.getType());
|
|
|
for (String traceId : traceIds) {
|
|
|
try {
|
|
|
LongArticlesMatchVideo longArticlesMatchVideo = longarticlesMatchVideoMap.get(traceId);
|
|
@@ -127,6 +130,7 @@ public class ArticleAuditService {
|
|
|
LongArticleVideoAudit videoAudit = new LongArticleVideoAudit();
|
|
|
videoAudit.setVideoId(response.getVideoID());
|
|
|
videoAudit.setTraceId(traceId);
|
|
|
+ videoAudit.setType(VideoAuditTypeEnum.PQ.getType());
|
|
|
videoAudit.setContentId(longArticlesMatchVideo.getContentId());
|
|
|
videoAudit.setOssPath(ossPath);
|
|
|
videoAudit.setStatus(StatusEnum.ZERO.getCode());
|
|
@@ -153,6 +157,89 @@ public class ArticleAuditService {
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
+ @XxlJob("articleVideoAuditCover")
|
|
|
+ public ReturnT<String> articleVideoAuditCover(String param) {
|
|
|
+ long publishTime = DateUtils.getTodayStart() / 1000;
|
|
|
+ if (StringUtils.hasText(param)) {
|
|
|
+ publishTime = DateUtils.getStartOfDay(param, "yyyyMMdd");
|
|
|
+ }
|
|
|
+ List<GetOffVideoArticle> getOffVideoArticleList = getOffVideoArticleRepository.getByPublishTimeGreaterThanEqual(publishTime);
|
|
|
+ List<String> traceIds = getOffVideoArticleList.stream()
|
|
|
+ .filter(o -> !o.getTraceId().startsWith("direct"))
|
|
|
+ .map(GetOffVideoArticle::getTraceId).distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isEmpty(traceIds)) {
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+ List<LongArticlesMatchVideo> longArticlesMatchVideoList = longArticlesMatchVideoRepository.getByTraceIdIn(traceIds);
|
|
|
+ Map<String, LongArticlesMatchVideo> longarticlesMatchVideoMap = longArticlesMatchVideoList.stream()
|
|
|
+ .collect(Collectors.toMap(LongArticlesMatchVideo::getTraceId, Function.identity()));
|
|
|
+ List<String> existsOssPath = longArticleBaseMapper.getExistsOssPath(VideoAuditTypeEnum.COVER.getType());
|
|
|
+ for (String traceId : traceIds) {
|
|
|
+ try {
|
|
|
+ Long now = System.currentTimeMillis();
|
|
|
+ LongArticlesMatchVideo longArticlesMatchVideo = longarticlesMatchVideoMap.get(traceId);
|
|
|
+ List<LongArticlesMatchVideoResponse> responseList = JSONArray.parseArray(longArticlesMatchVideo.getResponse()
|
|
|
+ , LongArticlesMatchVideoResponse.class);
|
|
|
+ for (LongArticlesMatchVideoResponse response : responseList) {
|
|
|
+ String ossPath = response.getVideoOSS();
|
|
|
+ if (StringUtils.hasText(ossPath)) {
|
|
|
+ if (existsOssPath.contains(ossPath)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ existsOssPath.add(ossPath);
|
|
|
+ }
|
|
|
+ LongArticleVideoAudit videoAudit = new LongArticleVideoAudit();
|
|
|
+ videoAudit.setVideoId(response.getVideoID());
|
|
|
+ videoAudit.setTraceId(traceId);
|
|
|
+ videoAudit.setType(VideoAuditTypeEnum.COVER.getType());
|
|
|
+ videoAudit.setContentId(longArticlesMatchVideo.getContentId());
|
|
|
+ videoAudit.setOssPath(ossPath);
|
|
|
+ videoAudit.setStatus(StatusEnum.ZERO.getCode());
|
|
|
+ videoAudit.setCreateTimestamp(now);
|
|
|
+ longArticleVideoAuditRepository.save(videoAudit);
|
|
|
+ try {
|
|
|
+ // 调用封面检测
|
|
|
+ AlgFaceRecognizeResult result = dangerFaceRecognizeService.getResult(response.getVideoCover());
|
|
|
+
|
|
|
+ if (Objects.equals(result.getFind_face_status(), FindFaceStatusEnum.NOT_EXIST.getStatus())) {
|
|
|
+ // 审核通过,更新文章状态
|
|
|
+ videoAudit.setStatus(PQVideoAuditResultEnum.PASS.getStatus());
|
|
|
+ videoAudit.setFinishTimestamp(now);
|
|
|
+ longArticleVideoAuditRepository.save(videoAudit);
|
|
|
+ } else if (Objects.equals(result.getFind_face_status(), FindFaceStatusEnum.EXIST.getStatus())) {
|
|
|
+ // 审核不通过,删除文章
|
|
|
+ videoAudit.setStatus(PQVideoAuditResultEnum.REJECT.getStatus());
|
|
|
+ videoAudit.setFailReason("封面存在敏感");
|
|
|
+ videoAudit.setFinishTimestamp(now);
|
|
|
+ longArticleVideoAuditRepository.save(videoAudit);
|
|
|
+ // 构建删除文章记录 并保存
|
|
|
+ // saveDeleteRecord(longArticleVideoAudit.getOssPath());
|
|
|
+ // 暂时不做删除 先发送通知
|
|
|
+ if (videoAudit.getStatus().equals(PQVideoAuditResultEnum.REJECT.getStatus())) {
|
|
|
+ log.info("视频封面识别不通过【存在敏感】 traceId:{} videoId:{} time:{}",
|
|
|
+ videoAudit.getTraceId(), videoAudit.getVideoId(),
|
|
|
+ DateUtils.getDateString(now, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.ARTICLE_DELETE.getRobotId(),
|
|
|
+ "视频封面识别不通过【存在敏感】\n" +
|
|
|
+ "traceId:" + videoAudit.getTraceId() + "\n" +
|
|
|
+ "视频id:" + videoAudit.getVideoId() + "\n" +
|
|
|
+ "管理后台地址:https://admin.piaoquantv.com/cms/post-detail/" + videoAudit.getVideoId() + "/detail\n" +
|
|
|
+ "操作删除视频及文章(慎点):" +
|
|
|
+ "http://192.168.203.83:30081/articleAudit/saveDeleteRecord?videoId=" + videoAudit.getVideoId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("PQVideoAuditStartProcess start process videoId:{} error:{}", response.getVideoID(), e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("articleVideoAudit traceId:{} error:{}", traceId, e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
private String getOssPath(String ossUrl) {
|
|
|
String result = "";
|
|
|
if (ossUrl == null || ossUrl.isEmpty()) {
|
|
@@ -177,7 +264,8 @@ public class ArticleAuditService {
|
|
|
|
|
|
@XxlJob("articleVideoAuditResult")
|
|
|
public ReturnT<String> articleVideoAuditResult(String param) {
|
|
|
- List<LongArticleVideoAudit> list = longArticleVideoAuditRepository.getByStatusAndTaskIdIsNotNull(StatusEnum.ZERO.getCode());
|
|
|
+ List<LongArticleVideoAudit> list = longArticleVideoAuditRepository.getByStatusAndTypeAndTaskIdIsNotNull(
|
|
|
+ StatusEnum.ZERO.getCode(), VideoAuditTypeEnum.PQ.getType());
|
|
|
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()));
|