Sfoglia il codice sorgente

Merge branch 'wyp/0206-videoAudit' of Server/long-article-recommend into master

wangyunpeng 4 mesi fa
parent
commit
094c0bf836

+ 3 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/longArticle/ArticleAuditMapper.java

@@ -15,7 +15,7 @@ public interface ArticleAuditMapper {
 
     List<ArticleVideoAuditListVO> articleVideoAuditList(List<String> contentId, List<Integer> status,
                                                         List<String> title, List<String> auditAccount,
-                                                        int offset, Integer pageSize);
+                                                        int offset, Integer pageSize, String poolLevelDesc);
 
     void updateCrawlerVideoIsIllegal(List<Integer> illegalVideoIds, Integer isIllegal);
 
@@ -24,4 +24,6 @@ public interface ArticleAuditMapper {
     void updateArticleTitle(ArticleTitleUpdateParam param, Long updateTime);
 
     void updateVideoTitle(VideoTitleUpdateParam param, Long updateTime);
+
+    void updateTitleAuditFlowPoolLevel();
 }

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticleTitleAudit.java

@@ -23,6 +23,9 @@ public class LongArticleTitleAudit {
     @Column(name = "status")
     private Integer status;
 
+    @Column(name = "flow_pool_level")
+    private String flowPoolLevel;
+
     @Column(name = "create_timestamp")
     private Long createTimestamp;
 

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/ArticleVideoAuditListVO.java

@@ -10,6 +10,7 @@ public class ArticleVideoAuditListVO {
     private String contentId;
     private String title;
     private String kimiTitle;
+    private String flowPoolLevel;
     private Integer videoCount;
     private Integer waitingAuditVideoCount;
     private Integer status;

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

@@ -20,4 +20,6 @@ public interface LongArticleTitleAuditRepository extends JpaRepository<LongArtic
     List<LongArticleTitleAudit> getByContentIdIn(List<String> sourceIds);
 
     List<LongArticleTitleAudit> getByAuditTimestampBetween(Long start, Long end);
+
+    List<LongArticleTitleAudit> getByFlowPoolLevelIsNull();
 }

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

@@ -22,10 +22,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -54,12 +51,15 @@ public class ArticleVideoAuditService {
     @Value("${cdnUrl:https://rescdn.piaoquantv.com/}")
     private String cdnUrl;
 
+    @Value("${videoAudit.poolLevel.sort:}")
+    private String poolLevelDesc;
+
     public Page<ArticleVideoAuditListVO> list(ArticleVideoAuditListParam param) {
         int offset = (param.getPageNum() - 1) * param.getPageSize();
         int count = articleAuditMapper.articleVideoAuditListCount(param.getContentId(), param.getStatus(),
                 param.getTitle(), param.getAuditAccount());
         List<ArticleVideoAuditListVO> list = articleAuditMapper.articleVideoAuditList(param.getContentId(),
-                param.getStatus(), param.getTitle(), param.getAuditAccount(), offset, param.getPageSize());
+                param.getStatus(), param.getTitle(), param.getAuditAccount(), offset, param.getPageSize(), poolLevelDesc);
         buildArticleVideoAuditListVO(list);
         Page<ArticleVideoAuditListVO> page = new Page<>(param.getPageNum(), param.getPageSize());
         page.setTotalSize(count);
@@ -253,4 +253,17 @@ public class ArticleVideoAuditService {
         long now = System.currentTimeMillis();
         articleAuditMapper.updateVideoTitle(param, now);
     }
+
+    @XxlJob("shuffleAuditGroup")
+    public ReturnT<String> shuffleAuditGroup(String param) {
+        List<String> auditUser = Arrays.asList("a","b","c","d","e","f","g","h","i","j");
+        List<LongArticleTitleAudit> contentIds = titleAuditRepository.getByStatus(ArticleVideoAuditStatusEnum.WAITING.getCode());
+        for (int i = 0; i < contentIds.size(); i++) {
+            int per = i % auditUser.size();
+            LongArticleTitleAudit audit = contentIds.get(i);
+            audit.setAuditAccount(auditUser.get(per));
+            titleAuditRepository.save(audit);
+        }
+        return ReturnT.SUCCESS;
+    }
 }

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

@@ -62,4 +62,11 @@ public class ArticleVideoAuditController {
         return CommonResponse.success();
     }
 
+
+    @GetMapping("/shuffleAuditGroup")
+    public CommonResponse<Void> shuffleAuditGroup() {
+        service.shuffleAuditGroup(null);
+        return CommonResponse.success();
+    }
+
 }

+ 33 - 17
long-article-recommend-service/src/main/resources/mapper/longArticle/ArticleAuditMapper.xml

@@ -3,30 +3,30 @@
 <mapper namespace="com.tzld.longarticle.recommend.server.mapper.longArticle.ArticleAuditMapper">
 
     <select id="articleVideoAuditListCount" resultType="java.lang.Integer">
-        select count(long_articles_title_audit.content_id)
-        from long_articles_title_audit
-        left join long_articles_text on long_articles_title_audit.content_id = long_articles_text.content_id
+        select count(lata.content_id)
+        from long_articles_title_audit lata
+        left join long_articles_text lat on lata.content_id = lat.content_id
         <where>
             <if test="status!= null and status.size() > 0">
-                and long_articles_title_audit.status in
+                and lata.status in
                 <foreach collection="status" item="item" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="contentId!= null and contentId.size() > 0">
-                and long_articles_title_audit.content_id in
+                and lata.content_id in
                 <foreach collection="contentId" item="item" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="title!= null and title.size() > 0">
-                and long_articles_text.article_title in
+                and lat.article_title in
                 <foreach collection="title" item="item" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="auditAccount!= null and auditAccount.size() > 0">
-                and long_articles_title_audit.audit_account in
+                and lata.audit_account in
                 <foreach collection="auditAccount" item="item" separator="," open="(" close=")">
                     #{item}
                 </foreach>
@@ -36,38 +36,44 @@
 
     <select id="articleVideoAuditList"
             resultType="com.tzld.longarticle.recommend.server.model.vo.ArticleVideoAuditListVO">
-        select long_articles_title_audit.content_id, long_articles_title_audit.status,
-        long_articles_text.article_title as title, long_articles_text.kimi_title,
-        long_articles_title_audit.audit_account, long_articles_title_audit.audit_timestamp
-        from long_articles_title_audit
-        left join long_articles_text on long_articles_title_audit.content_id = long_articles_text.content_id
+        select lata.content_id, lata.status, lat.article_title as title, lat.kimi_title,
+        lata.audit_account, lata.audit_timestamp, lata.flow_pool_level
+        from long_articles_title_audit lata
+        left join long_articles_text lat on lata.content_id = lat.content_id
         <where>
             <if test="status!= null and status.size() > 0">
-                and long_articles_title_audit.status in
+                and lata.status in
                 <foreach collection="status" item="item" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="contentId!= null and contentId.size() > 0">
-                and long_articles_title_audit.content_id in
+                and lata.content_id in
                 <foreach collection="contentId" item="item" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="title!= null and title.size() > 0">
-                and long_articles_text.article_title in
+                and lat.article_title in
                 <foreach collection="title" item="item" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="auditAccount!= null and auditAccount.size() > 0">
-                and long_articles_title_audit.audit_account in
+                and lata.audit_account in
                 <foreach collection="auditAccount" item="item" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </if>
         </where>
-        order by long_articles_title_audit.content_id desc
+        <choose>
+            <when test="poolLevelDesc != null and poolLevelDesc != ''">
+                order by lata.flow_pool_level ${poolLevelDesc}, lata.content_id desc
+            </when>
+            <otherwise>
+                order by lata.content_id desc
+            </otherwise>
+        </choose>
         limit #{offset}, #{pageSize}
     </select>
 
@@ -137,4 +143,14 @@
         where content_id = #{param.contentId}
     </update>
 
+    <update id="updateTitleAuditFlowPoolLevel">
+        update long_articles_title_audit lat
+        join ( SELECT DISTINCT lamv.content_id, lamv.flow_pool_level
+               FROM long_articles_match_videos lamv
+                JOIN long_articles_title_audit lata ON lamv.content_id = lata.content_id
+               where lata.flow_pool_level is null) lamv ON lat.content_id = lamv.content_id
+        set lat.flow_pool_level = lamv.flow_pool_level
+        where lat.flow_pool_level is null
+    </update>
+
 </mapper>

+ 54 - 0
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/ArticleVideoAuditTest.java

@@ -0,0 +1,54 @@
+package com.tzld.longarticle.recommend.server;
+
+import com.tzld.longarticle.recommend.server.mapper.longArticle.ArticleAuditMapper;
+import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlan;
+import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlanExeRecord;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticleTitleAudit;
+import com.tzld.longarticle.recommend.server.repository.aigc.ProducePlanExeRecordRepository;
+import com.tzld.longarticle.recommend.server.repository.aigc.ProducePlanRepository;
+import com.tzld.longarticle.recommend.server.repository.longArticle.LongArticleTitleAuditRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@SpringBootTest(classes = Application.class)
+@Slf4j
+public class ArticleVideoAuditTest {
+
+    @Resource
+    private ArticleAuditMapper articleAuditMapper;
+    @Resource
+    private LongArticleTitleAuditRepository titleAuditRepository;
+    @Resource
+    private ProducePlanExeRecordRepository exeRecordRepository;
+    @Resource
+    private ProducePlanRepository producePlanRepository;
+
+    @Test
+    public void updateTitleAuditFlowPoolLevel() {
+        List<LongArticleTitleAudit> list = titleAuditRepository.getByFlowPoolLevelIsNull();
+        List<String> contentIds = list.stream().map(LongArticleTitleAudit::getContentId).collect(Collectors.toList());
+        List<ProducePlanExeRecord> contentList = exeRecordRepository.findByPlanExeIdIn(contentIds);
+        Map<String, String> contentPlanMap = contentList.stream().collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, ProducePlanExeRecord::getPlanId));
+        List<String> planIds = contentList.stream().map(ProducePlanExeRecord::getPlanId).collect(Collectors.toList());
+        List<ProducePlan> planList = producePlanRepository.findByIdIn(planIds);
+        Map<String, String> planMap = planList.stream().collect(Collectors.toMap(ProducePlan::getId, ProducePlan::getPlanTag));
+        for (LongArticleTitleAudit titleAudit : list) {
+            String contentId = titleAudit.getContentId();
+            String planId = contentPlanMap.get(contentId);
+            String tag = planMap.get(planId);
+            if (!StringUtils.hasText(tag)) {
+                continue;
+            }
+            titleAudit.setFlowPoolLevel(tag);
+            titleAuditRepository.save(titleAudit);
+        }
+        articleAuditMapper.updateTitleAuditFlowPoolLevel();
+    }
+}