Przeglądaj źródła

Merge branch 'wyp/0123-videoAuditExport' of Server/long-article-recommend into master

wangyunpeng 5 miesięcy temu
rodzic
commit
5c7868ee25

+ 3 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/ContentPoolEnum.java

@@ -8,9 +8,9 @@ import java.util.Objects;
 
 @Getter
 public enum ContentPoolEnum {
-    autoArticlePoolLevel1("autoArticlePoolLevel1", 1, "内容池1层"),
-    autoArticlePoolLevel2("autoArticlePoolLevel2", 2, "内容池2层"),
-    autoArticlePoolLevel3("autoArticlePoolLevel3", 3, "内容池3层"),
+    autoArticlePoolLevel1("autoArticlePoolLevel1", 1, "头条"),
+    autoArticlePoolLevel2("autoArticlePoolLevel2", 2, "头条"),
+    autoArticlePoolLevel3("autoArticlePoolLevel3", 3, "次条"),
     autoArticlePoolLevel4("autoArticlePoolLevel4", 4, "冷启层"),
 
     ;

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java

@@ -1,5 +1,6 @@
 package com.tzld.longarticle.recommend.server.mapper.aigc;
 
+import com.tzld.longarticle.recommend.server.model.dto.ContentPoolTypeDTO;
 import com.tzld.longarticle.recommend.server.model.dto.CrawlerContent;
 import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
 import com.tzld.longarticle.recommend.server.model.dto.ProducePlanAuditCheckDTO;
@@ -35,4 +36,6 @@ public interface AigcBaseMapper {
     List<ProduceTaskAtom> getProduceScoreGreaterThan(Long startTimeStamp, Long endTimeStamp);
 
     List<ProduceTaskAtom> getProduceScoreByContentId(List<String> planExeIds);
+
+    List<ContentPoolTypeDTO> getContentPoolType(List<String> contentIds);
 }

+ 10 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/ContentPoolTypeDTO.java

@@ -0,0 +1,10 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Data;
+
+@Data
+public class ContentPoolTypeDTO {
+    private String planId;
+    private String poolType;
+    private String contentId;
+}

+ 5 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/VideoAuditExport.java

@@ -6,9 +6,10 @@ import lombok.Data;
 public class VideoAuditExport {
 
     private String dateStr;
-    private Long articleAuditCount;
-    private Long articleAuditPassCount;
-    private Long videoAuditCount;
-    private Long videoAuditPassCount;
+    private String poolType;
+    private Long articleAuditCount = 0L;
+    private Long articleAuditPassCount = 0L;
+    private Long videoAuditCount = 0L;
+    private Long videoAuditPassCount = 0L;
 
 }

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

@@ -22,5 +22,7 @@ public interface LongArticleCrawlerVideoRepository extends JpaRepository<LongArt
 
     long countByAuditTimestampBetween(Long start, Long end);
 
+    List<LongArticleCrawlerVideo> getByAuditTimestampBetween(Long start, Long end);
+
     long countByStatusAndAuditTimestampBetween(Integer status, Long start, Long end);
 }

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

@@ -18,4 +18,6 @@ public interface LongArticleTitleAuditRepository extends JpaRepository<LongArtic
     long countByStatusAndAuditTimestampBetween(Integer status, Long start, Long end);
 
     List<LongArticleTitleAudit> getByContentIdIn(List<String> sourceIds);
+
+    List<LongArticleTitleAudit> getByAuditTimestampBetween(Long start, Long end);
 }

+ 57 - 17
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/DataDashboardService.java

@@ -15,6 +15,7 @@ import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategy
 import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
 import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
 import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
+import com.tzld.longarticle.recommend.server.model.dto.ContentPoolTypeDTO;
 import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
 import com.tzld.longarticle.recommend.server.model.dto.ProducePlanAuditCheckDTO;
 import com.tzld.longarticle.recommend.server.model.dto.PublishContentDTO;
@@ -23,9 +24,7 @@ import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleDetailInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.PublishSortLog;
-import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
-import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatScore;
-import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.*;
 import com.tzld.longarticle.recommend.server.model.param.MiniprogramTaskParam;
 import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
 import com.tzld.longarticle.recommend.server.model.vo.*;
@@ -1976,7 +1975,7 @@ public class DataDashboardService {
         List<VideoAuditExport> exportList = new ArrayList<>();
         dateStrList = Lists.reverse(dateStrList);
         for (String dateStr : dateStrList) {
-            exportList.add(buildVideoAuditExport(dateStr));
+            exportList.addAll(buildVideoAuditExport(dateStr));
         }
         if (CollectionUtil.isEmpty(exportList)) {
             return;
@@ -2004,20 +2003,61 @@ public class DataDashboardService {
                 2, null, null);
     }
 
-    private VideoAuditExport buildVideoAuditExport(String dateStr) {
-        VideoAuditExport result = new VideoAuditExport();
+    private List<VideoAuditExport> buildVideoAuditExport(String dateStr) {
+        List<VideoAuditExport> result = new ArrayList<>();
         long timestamp = DateUtils.getStartOfDay(dateStr, "yyyyMMdd") * 1000;
-        long articleAuditCount = titleAuditRepository.countByAuditTimestampBetween(timestamp, timestamp + 86400000);
-        long articleAuditPassCount = titleAuditRepository.countByStatusAndAuditTimestampBetween(
-                ProduceContentAuditStatusEnum.pass.getVal(), timestamp, timestamp + 86400000);
-        long videoAuditCount = crawlerVideoRepository.countByAuditTimestampBetween(timestamp, timestamp + 86400000);
-        long videoAuditPassCount = crawlerVideoRepository.countByStatusAndAuditTimestampBetween(
-                ProduceContentAuditStatusEnum.pass.getVal(), timestamp, timestamp + 86400000);
-        result.setDateStr(dateStr);
-        result.setArticleAuditCount(articleAuditCount);
-        result.setArticleAuditPassCount(articleAuditPassCount);
-        result.setVideoAuditCount(videoAuditCount);
-        result.setVideoAuditPassCount(videoAuditPassCount);
+        // 按内容池区分
+        List<LongArticleTitleAudit> auditList = titleAuditRepository.getByAuditTimestampBetween(timestamp, timestamp + 86400000);
+        List<LongArticleCrawlerVideo> crawlerVideoList = crawlerVideoRepository.getByAuditTimestampBetween(timestamp, timestamp + 86400000);
+        Map<String, List<LongArticleCrawlerVideo>> crawlerVideoMap = crawlerVideoList.stream()
+               .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
+        List<String> contentIds = auditList.stream().map(LongArticleTitleAudit::getContentId).collect(Collectors.toList());
+        List<ContentPoolTypeDTO> poolTypeDTOS = aigcBaseMapper.getContentPoolType(contentIds);
+        Map<String, ContentPoolTypeDTO> poolTypeMap = poolTypeDTOS.stream().collect(Collectors.toMap(ContentPoolTypeDTO::getContentId, o -> o));
+        Map<String, VideoAuditExport> map = new HashMap<>();
+        for (LongArticleTitleAudit titleAudit : auditList) {
+            ContentPoolTypeDTO poolTypeDTO = poolTypeMap.get(titleAudit.getContentId());
+            if (!map.containsKey(poolTypeDTO.getPoolType())) {
+                VideoAuditExport videoAuditExport = new VideoAuditExport();
+                videoAuditExport.setDateStr(dateStr);
+                videoAuditExport.setPoolType(poolTypeDTO.getPoolType());
+                map.put(poolTypeDTO.getPoolType(), videoAuditExport);
+            }
+            VideoAuditExport videoAuditExport = map.get(poolTypeDTO.getPoolType());
+            videoAuditExport.setArticleAuditCount(videoAuditExport.getArticleAuditCount() + 1);
+            if (titleAudit.getStatus().equals(ProduceContentAuditStatusEnum.pass.getVal())) {
+                videoAuditExport.setArticleAuditPassCount(videoAuditExport.getArticleAuditPassCount() + 1);
+            }
+            List<LongArticleCrawlerVideo> videoList = crawlerVideoMap.get(titleAudit.getContentId());
+            if (CollectionUtils.isEmpty(videoList)) {
+                continue;
+            }
+            videoAuditExport.setVideoAuditCount(videoAuditExport.getVideoAuditCount() + videoList.size());
+            long videoAuditPassCount = videoList.stream()
+                   .filter(o -> o.getStatus().equals(ProduceContentAuditStatusEnum.pass.getVal())).count();
+            videoAuditExport.setVideoAuditPassCount(videoAuditExport.getVideoAuditPassCount() + videoAuditPassCount);
+        }
+        for (Map.Entry<String, VideoAuditExport> entry : map.entrySet()) {
+            VideoAuditExport videoAuditExport = entry.getValue();
+            videoAuditExport.setPoolType(ContentPoolEnum.from(videoAuditExport.getPoolType()).getDescription());
+            result.add(videoAuditExport);
+        }
+        // sum
+        long articleAuditCount = auditList.size();
+        long articleAuditPassCount = auditList.stream()
+                .filter(o -> o.getStatus().equals(ProduceContentAuditStatusEnum.pass.getVal())).count();
+        long videoAuditCount = crawlerVideoList.size();
+        long videoAuditPassCount = crawlerVideoList.stream()
+                .filter(o -> o.getStatus().equals(ProduceContentAuditStatusEnum.pass.getVal())).count();
+        VideoAuditExport sum = new VideoAuditExport();
+        sum.setDateStr(dateStr);
+        sum.setPoolType("SUM");
+        sum.setArticleAuditCount(articleAuditCount);
+        sum.setArticleAuditPassCount(articleAuditPassCount);
+        sum.setVideoAuditCount(videoAuditCount);
+        sum.setVideoAuditPassCount(videoAuditPassCount);
+        result.add(sum);
+        result.sort(Comparator.comparing(VideoAuditExport::getPoolType));
         return result;
     }
 

+ 11 - 0
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -128,4 +128,15 @@
         order by record.audit_timestamp desc
     </select>
 
+    <select id="getContentPoolType"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.ContentPoolTypeDTO">
+        select plan.id as planId, plan.plan_tag as poolType, pper.plan_exe_id as contentId
+        from produce_plan plan
+        join produce_plan_exe_record pper on plan.id = pper.plan_id
+        where pper.plan_exe_id in
+        <foreach collection="contentIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>