Pārlūkot izejas kodu

小程序标题审核重新匹配

wangyunpeng 6 mēneši atpakaļ
vecāks
revīzija
6149612fad

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/ArticleReMatchRecordRepository.java

@@ -4,6 +4,9 @@ import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleReM
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Repository
 public interface ArticleReMatchRecordRepository extends JpaRepository<ArticleReMatchRecord, Integer> {
+    List<ArticleReMatchRecord> getByContentIdIn(List<String> contentIds);
 }

+ 5 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleTitleAuditRepository.java

@@ -4,8 +4,13 @@ import com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticl
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Repository
 public interface LongArticleTitleAuditRepository extends JpaRepository<LongArticleTitleAudit, String> {
 
     LongArticleTitleAudit getByContentId(String contentId);
+
+    List<LongArticleTitleAudit> getByStatus(Integer status);
+
 }

+ 36 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleVideoAuditService.java

@@ -17,16 +17,15 @@ import com.tzld.longarticle.recommend.server.model.param.videoAudit.VideoAuditPa
 import com.tzld.longarticle.recommend.server.model.vo.ArticleVideoAuditListVO;
 import com.tzld.longarticle.recommend.server.repository.longArticle.*;
 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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -180,4 +179,37 @@ public class ArticleVideoAuditService {
     public List<String> getFilterValue(AuditFilterParam param) {
         return articleAuditMapper.searchFilterValueByItemName(param.getItemName(), param.getSearchKeyword());
     }
+
+    @XxlJob("rematchVideoAudit")
+    public ReturnT<String> rematchVideoAudit(String param) {
+        List<LongArticleTitleAudit> rejectList = titleAuditRepository.getByStatus(ArticleVideoAuditStatusEnum.REJECT.getCode());
+        if (CollectionUtils.isEmpty(rejectList)) {
+            return ReturnT.SUCCESS;
+        }
+        List<String> contentIds = rejectList.stream().map(LongArticleTitleAudit::getContentId).collect(Collectors.toList());
+        List<ArticleReMatchRecord> reMatchRecordList = articleReMatchRecordRepository.getByContentIdIn(contentIds);
+        if (CollectionUtils.isEmpty(reMatchRecordList)) {
+            return ReturnT.SUCCESS;
+        }
+        Map<String, List<ArticleReMatchRecord>> reMatchRecordMap = reMatchRecordList.stream()
+               .collect(Collectors.groupingBy(ArticleReMatchRecord::getContentId));
+        for (LongArticleTitleAudit audit : rejectList) {
+            List<ArticleReMatchRecord> records = reMatchRecordMap.get(audit.getContentId());
+            if (CollectionUtils.isEmpty(records)) {
+                continue;
+            }
+            records = records.stream().filter(o -> Objects.isNull(o.getTraceId())).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(records)) {
+                continue;
+            }
+            List<ArticleReMatchRecord> failList = records.stream()
+                    .filter(o -> o.getStatus().equals(2) || o.getStatus().equals(0)).collect(Collectors.toList());
+            if (CollectionUtils.isNotEmpty(failList)) {
+                continue;
+            }
+            audit.setStatus(ArticleVideoAuditStatusEnum.WAITING.getCode());
+            titleAuditRepository.save(audit);
+        }
+        return ReturnT.SUCCESS;
+    }
 }

+ 8 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/recommend/ArticleVideoAuditController.java

@@ -10,10 +10,7 @@ import com.tzld.longarticle.recommend.server.service.recommend.ArticleVideoAudit
 import com.tzld.longarticle.recommend.server.util.page.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -47,4 +44,11 @@ public class ArticleVideoAuditController {
         return CommonResponse.success(service.getFilterValue(param));
     }
 
+
+    @GetMapping("/rematchVideoAudit")
+    public CommonResponse<Void> rematchVideoAudit(String contentId) {
+        service.rematchVideoAudit(contentId);
+        return CommonResponse.success();
+    }
+
 }