Browse Source

视频审核导出

wangyunpeng 6 months ago
parent
commit
8c87fcd714

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

@@ -0,0 +1,14 @@
+package com.tzld.longarticle.recommend.server.model.vo;
+
+import lombok.Data;
+
+@Data
+public class VideoAuditExport {
+
+    private String dateStr;
+    private Long articleAuditCount;
+    private Long articleAuditPassCount;
+    private Long videoAuditCount;
+    private Long videoAuditPassCount;
+
+}

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

@@ -19,4 +19,8 @@ public interface LongArticleCrawlerVideoRepository extends JpaRepository<LongArt
     List<LongArticleCrawlerVideo> getByVideoOssPath(String ossPath);
 
     LongArticleCrawlerVideo getById(Long videoId);
+
+    long countByAuditTimestampBetween(Long start, Long end);
+
+    long countByStatusAndAuditTimestampBetween(Integer status, Long start, Long end);
 }

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

@@ -13,4 +13,7 @@ public interface LongArticleTitleAuditRepository extends JpaRepository<LongArtic
 
     List<LongArticleTitleAudit> getByStatus(Integer status);
 
+    long countByAuditTimestampBetween(Long start, Long end);
+
+    long countByStatusAndAuditTimestampBetween(Integer status, Long start, Long end);
 }

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

@@ -35,9 +35,7 @@ import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRe
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleDetailInfoRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.PublishSortLogRepository;
-import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
-import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
-import com.tzld.longarticle.recommend.server.repository.longArticle.DatastatScoreRepository;
+import com.tzld.longarticle.recommend.server.repository.longArticle.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.MapBuilder;
@@ -95,6 +93,10 @@ public class DataDashboardService {
     private ArticleCategoryRepository articleCategoryRepository;
     @Autowired
     private ArticlePoolPromotionSourceRepository articlePoolPromotionSourceRepository;
+    @Autowired
+    private LongArticleTitleAuditRepository titleAuditRepository;
+    @Autowired
+    private LongArticleCrawlerVideoRepository crawlerVideoRepository;
 
     @ApolloJsonValue("${export.account.ghId:[]}")
     private static List<String> ghIdList;
@@ -1952,4 +1954,67 @@ public class DataDashboardService {
         return result;
     }
 
+    @XxlJob("videoAuditExport")
+    public ReturnT<String> videoAuditExportJob(String param) {
+        List<String> dateStrList = DateUtils.getBeforeDays(null, null, 1);
+        videoAuditExport(dateStrList);
+        return ReturnT.SUCCESS;
+    }
+
+    public void videoAuditExport(String dateStr) {
+        if (!StringUtils.hasText(dateStr)) {
+            dateStr = DateUtils.getBeforeDaysDateStr("yyyyMMdd", 1);
+        }
+        videoAuditExport(Collections.singletonList(dateStr));
+    }
+
+    public void videoAuditExport(List<String> dateStrList) {
+        List<VideoAuditExport> exportList = new ArrayList<>();
+        dateStrList = Lists.reverse(dateStrList);
+        for (String dateStr : dateStrList) {
+            exportList.add(buildVideoAuditExport(dateStr));
+        }
+        if (CollectionUtil.isEmpty(exportList)) {
+            return;
+        }
+        int rowNum = exportList.size();
+        List<List<Object>> rows = new ArrayList<>();
+        Field[] fields = VideoAuditExport.class.getDeclaredFields();
+        for (VideoAuditExport datum : exportList) {
+            List<Object> rowDatas = new ArrayList<>();
+            rows.add(rowDatas);
+
+            for (Field field : fields) {
+                field.setAccessible(true);
+                try {
+                    rowDatas.add(field.get(datum));
+                } catch (IllegalAccessException e) {
+                    log.error("获取值出错:{}", field.getName());
+                } catch (Exception e) {
+                    throw new RuntimeException(e.getMessage());
+                }
+            }
+        }
+
+        doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "vddANt", rowNum, rows,
+                2, null, null);
+    }
+
+    private VideoAuditExport buildVideoAuditExport(String dateStr) {
+        VideoAuditExport result = new VideoAuditExport();
+        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);
+        return result;
+    }
+
 }

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

@@ -50,6 +50,13 @@ public class DataDashboardController {
         }).start();
     }
 
+    @GetMapping("/export/videoAudit")
+    public void videoAuditExport(String dateStr) {
+        new Thread(() -> {
+            service.videoAuditExport(dateStr);
+        }).start();
+    }
+
     @GetMapping("/export/dailySafeScore")
     public void dailySafeScore(String dateStr) {
         new Thread(() -> {