Browse Source

票圈视频审核 使用ossPath去重

wangyunpeng 7 months ago
parent
commit
43c93b6e84

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/longArticle/LongArticleBaseMapper.java

@@ -67,4 +67,6 @@ public interface LongArticleBaseMapper {
     List<PublishSingleVideoSource> getPublishSingleVideoSource(ArticleVideoPoolSourceParam param);
 
     List<String> getFilterColdLongArticleTitle();
+
+    List<String> getExistsOssPath();
 }

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/pq/PQVideoAuditResultService.java

@@ -73,7 +73,7 @@ public class PQVideoAuditResultService {
                 }
             }
         } catch (IOException e) {
-            log.error("articleGetProducePlanDetail error", e);
+            log.error("PQVideoAuditResultService error", e);
         }
         return null;
     }

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/pq/PQVideoAuditStartProcessService.java

@@ -70,7 +70,7 @@ public class PQVideoAuditStartProcessService {
                 }
             }
         } catch (IOException e) {
-            log.error("articleGetProducePlanDetail error", e);
+            log.error("PQVideoAuditStartProcessService error", e);
         }
         return null;
     }

+ 27 - 5
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleAuditService.java

@@ -10,6 +10,7 @@ import com.tzld.longarticle.recommend.server.common.enums.cgi.PQVideoSensitiveLe
 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;
@@ -69,6 +70,8 @@ public class ArticleAuditService {
     private PQVideoAuditStartProcessService pqVideoAuditStartProcessService;
     @Autowired
     private PQVideoAuditResultService pqVideoAuditResultService;
+    @Autowired
+    private LongArticleBaseMapper longArticleBaseMapper;
 
 
     @XxlJob("articleVideoAudit")
@@ -85,22 +88,22 @@ 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);
@@ -122,6 +125,25 @@ public class ArticleAuditService {
         return ReturnT.SUCCESS;
     }
 
+    private String getOssPath(String ossUrl) {
+        if (ossUrl == null || ossUrl.isEmpty()) {
+            return "";
+        }
+        // 找到 ".com/" 后面的部分
+        String keyword = ".com/";
+        int startIndex = ossUrl.indexOf(keyword);
+        if (startIndex == -1) {
+            return "";
+        }
+        // 提取从 ".com/" 之后的部分,去掉文件后缀名
+        startIndex += keyword.length();
+        int endIndex = ossUrl.lastIndexOf(".");
+        if (endIndex == -1) {
+            endIndex = ossUrl.length();
+        }
+        return ossUrl.substring(startIndex, endIndex);
+    }
+
     @XxlJob("articleVideoAuditResult")
     public ReturnT<String> articleVideoAuditResult(String param) {
         List<LongArticleVideoAudit> list = longArticleVideoAuditRepository.getByStatusAndTaskIdIsNotNull(StatusEnum.ZERO.getCode());

+ 4 - 0
long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

@@ -256,4 +256,8 @@
         </foreach>
     </insert>
 
+    <select id="getExistsOssPath" resultType="java.lang.String">
+        select distinct oss_path from long_articles_video_audit
+    </select>
+
 </mapper>