|  | @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 | 
	
		
			
				|  |  |  import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  | +import com.tzld.longarticle.recommend.server.common.enums.ContentPositionEnum;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.common.enums.aigc.ChannelEnum;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.common.enums.aigc.ProduceContentAuditStatusEnum;
 | 
	
	
		
			
				|  | @@ -13,10 +14,7 @@ import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputS
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoAuditStatusEnum;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoBadStatusEnum;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.common.enums.longArticle.VideoPoolPlatformEnum;
 | 
	
		
			
				|  |  | -import com.tzld.longarticle.recommend.server.common.enums.recommend.AccountBusinessTypeEnum;
 | 
	
		
			
				|  |  | -import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleTypeEnum;
 | 
	
		
			
				|  |  | -import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 | 
	
		
			
				|  |  | -import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 | 
	
		
			
				|  |  | +import com.tzld.longarticle.recommend.server.common.enums.recommend.*;
 | 
	
		
			
				|  |  |  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.crawler.CrawlerBaseMapper;
 | 
	
	
		
			
				|  | @@ -46,13 +44,16 @@ 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;
 | 
	
		
			
				|  |  | +import com.tzld.longarticle.recommend.server.util.Md5Util;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.util.feishu.FeiShu;
 | 
	
		
			
				|  |  |  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.apache.commons.collections4.MapUtils;
 | 
	
		
			
				|  |  | +import org.springframework.beans.BeanUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  |  import org.springframework.data.util.Pair;
 | 
	
		
			
				|  |  |  import org.springframework.http.*;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
	
		
			
				|  | @@ -60,6 +61,8 @@ import org.springframework.util.StringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.web.client.RestTemplate;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.lang.reflect.Field;
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  | +import java.math.RoundingMode;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  import java.util.function.Function;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
	
		
			
				|  | @@ -114,11 +117,20 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |      private LongArticlesRootSourceIdRepository rootSourceIdRepository;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private DatastatSortStrategyRepository datastatSortStrategyRepository;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private LongArticlesPublishMiniprogramRepository longArticlesPublishMiniprogramRepository;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private LongArticlesNewVideoCoverRepository longArticlesNewVideoCoverRepository;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private PublishDailyReportRepository publishDailyReportRepository;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApolloJsonValue("${export.account.ghId:[]}")
 | 
	
		
			
				|  |  |      private static List<String> ghIdList;
 | 
	
		
			
				|  |  |      @ApolloJsonValue("${audit.producePlan.list:[]}")
 | 
	
		
			
				|  |  |      private static List<String> auditProducePlanList;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Value("${category.active.version:1}")
 | 
	
		
			
				|  |  | +    private Integer activeVersion;
 | 
	
		
			
				|  |  |      private static final String dailyDetailSheetToken = "M0pLs3uF6hfL0htn2dMcB9eFn8e";
 | 
	
		
			
				|  |  |      private static final String dailySafeSheetToken = "Xoass3ZGYhi9BVtZDoMclGFpnYe";
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -140,6 +152,28 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          return ReturnT.SUCCESS;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @XxlJob("scheduledExportMysql")
 | 
	
		
			
				|  |  | +    public ReturnT<String> scheduledExportMysql(String param) {
 | 
	
		
			
				|  |  | +        if (!StringUtils.hasText(param)) {
 | 
	
		
			
				|  |  | +            return ReturnT.FAIL;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        JSONObject jsonObject = JSONObject.parseObject(param);
 | 
	
		
			
				|  |  | +        String minDate = jsonObject.getString("minDate");
 | 
	
		
			
				|  |  | +        String maxDate = jsonObject.getString("maxDate");
 | 
	
		
			
				|  |  | +        List<NewSortStrategyExport> newContentsYesData = newSortStrategyData(minDate, maxDate,
 | 
	
		
			
				|  |  | +                ArticleTypeEnum.QUNFA.getVal(), StatusEnum.ZERO.getCode());
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(newContentsYesData)) {
 | 
	
		
			
				|  |  | +            List<PublishDailyReport> reports = new ArrayList<>();
 | 
	
		
			
				|  |  | +            for (NewSortStrategyExport newSortStrategyExport : newContentsYesData) {
 | 
	
		
			
				|  |  | +                PublishDailyReport publishDailyReport = new PublishDailyReport();
 | 
	
		
			
				|  |  | +                BeanUtils.copyProperties(newSortStrategyExport, publishDailyReport);
 | 
	
		
			
				|  |  | +                reports.add(publishDailyReport);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            publishDailyReportRepository.saveAll(reports);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return ReturnT.SUCCESS;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      public void exportWuXianLiu(String beginDate, String endDate) {
 | 
	
		
			
				|  |  |          List<String> dateStrList = DateUtils.getBeforeDays(beginDate, endDate, 5);
 | 
	
		
			
				|  |  |          exportFeishuNewSortStrategy(dateStrList, ArticleTypeEnum.WUXIANLIU.getVal(), StatusEnum.ONE.getCode(),
 | 
	
	
		
			
				|  | @@ -284,7 +318,7 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |                  .map(PublishContentDTO::getSourceId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  |          List<ProducePlanExeRecord> planExeRecordList = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (List<String> partitions : Lists.partition(contentSourceIds, 1000)) {
 | 
	
		
			
				|  |  | -            planExeRecordList.addAll(producePlanExeRecordRepository.findByPlanExeIdIn(partitions));
 | 
	
		
			
				|  |  | +            planExeRecordList.addAll(producePlanExeRecordRepository.getByPlanExeIdIn(partitions));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          log.info("newSortStrategyData planExeRecordList finish");
 | 
	
		
			
				|  |  |          List<String> videoPoolSourceIds = publishContents.stream()
 | 
	
	
		
			
				|  | @@ -528,8 +562,8 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |                  ProducePlan producePlan = producePlanMap.get(record.getPlanId());
 | 
	
		
			
				|  |  |                  obj.setProducePlanName(producePlan.getName());
 | 
	
		
			
				|  |  |                  obj.setProducePlanTag(producePlan.getPlanTag());
 | 
	
		
			
				|  |  | +                producePlanInputSourceList = inputSourceMap.get(record.getPlanId());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            producePlanInputSourceList = inputSourceMap.get(record.getPlanId());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (publishContent.getSourceType().equals(PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal())) {
 | 
	
		
			
				|  |  |              PublishSingleVideoSource videoPoolSource = videoPoolSourceMap.get(publishContent.getSourceId());
 | 
	
	
		
			
				|  | @@ -545,18 +579,25 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          List<CrawlerPlanResultRel> crawlerPlanRelList = resultRelMap.get(publishContent.getCrawlerChannelContentId());
 | 
	
		
			
				|  |  | -        if (CollectionUtil.isNotEmpty(crawlerPlanRelList) && CollectionUtil.isNotEmpty(producePlanInputSourceList)) {
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(crawlerPlanRelList) && CollectionUtils.isNotEmpty(producePlanInputSourceList)) {
 | 
	
		
			
				|  |  |              List<String> inputSourceValues = producePlanInputSourceList.stream()
 | 
	
		
			
				|  |  |                      .map(ProducePlanInputSource::getInputSourceValue).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -            List<CrawlerPlan> crawlerPlanItemList = new ArrayList<>();
 | 
	
		
			
				|  |  | -            for (CrawlerPlanResultRel crawlerPlanResultRel : crawlerPlanRelList) {
 | 
	
		
			
				|  |  | -                crawlerPlanItemList.add(crawlerPlanMap.get(crawlerPlanResultRel.getPlanId()));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            for (CrawlerPlan crawlerPlan : crawlerPlanItemList) {
 | 
	
		
			
				|  |  | -                if (inputSourceValues.contains(crawlerPlan.getId())) {
 | 
	
		
			
				|  |  | -                    obj.setCrawlerPlanName(crawlerPlan.getName());
 | 
	
		
			
				|  |  | -                    obj.setCrawlerPlanTag(crawlerPlan.getPlanTag());
 | 
	
		
			
				|  |  | -                    break;
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(inputSourceValues)) {
 | 
	
		
			
				|  |  | +                List<CrawlerPlan> crawlerPlanItemList = new ArrayList<>();
 | 
	
		
			
				|  |  | +                for (CrawlerPlanResultRel crawlerPlanResultRel : crawlerPlanRelList) {
 | 
	
		
			
				|  |  | +                    CrawlerPlan crawlerPlan = crawlerPlanMap.get(crawlerPlanResultRel.getPlanId());
 | 
	
		
			
				|  |  | +                    if (Objects.nonNull(crawlerPlan)) {
 | 
	
		
			
				|  |  | +                        crawlerPlanItemList.add(crawlerPlan);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (CollectionUtils.isNotEmpty(crawlerPlanItemList)) {
 | 
	
		
			
				|  |  | +                    for (CrawlerPlan crawlerPlan : crawlerPlanItemList) {
 | 
	
		
			
				|  |  | +                        if (inputSourceValues.contains(crawlerPlan.getId())) {
 | 
	
		
			
				|  |  | +                            obj.setCrawlerPlanName(crawlerPlan.getName());
 | 
	
		
			
				|  |  | +                            obj.setCrawlerPlanTag(crawlerPlan.getPlanTag());
 | 
	
		
			
				|  |  | +                            break;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -2434,7 +2475,9 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |                                  Pair.of("公众号视频", "#F8E6AB"),
 | 
	
		
			
				|  |  |                                  Pair.of("好看视频", "#A9EFE6"),
 | 
	
		
			
				|  |  |                                  Pair.of("视频号视频", "#FDE2E2"),
 | 
	
		
			
				|  |  | -                                Pair.of("头条视频", "#ECE2FE")))
 | 
	
		
			
				|  |  | +                                Pair.of("头条视频", "#ECE2FE"),
 | 
	
		
			
				|  |  | +                                Pair.of("搜狐视频", "#D9F5D6"),
 | 
	
		
			
				|  |  | +                                Pair.of("票圈视频", "#F8DEF8")))
 | 
	
		
			
				|  |  |                  );
 | 
	
		
			
				|  |  |          doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "6aW60b", rowNum, rows,
 | 
	
		
			
				|  |  |                  3, styles, null, thank);
 | 
	
	
		
			
				|  | @@ -2511,7 +2554,8 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 视频
 | 
	
		
			
				|  |  |          List<VideoPoolPlatformEnum> videoPoolType = Arrays.asList(VideoPoolPlatformEnum.GZH, VideoPoolPlatformEnum.HkSP,
 | 
	
		
			
				|  |  | -                VideoPoolPlatformEnum.SPH, VideoPoolPlatformEnum.TOUTIAO);
 | 
	
		
			
				|  |  | +                VideoPoolPlatformEnum.SPH, VideoPoolPlatformEnum.TOUTIAO, VideoPoolPlatformEnum.SOHU,
 | 
	
		
			
				|  |  | +                VideoPoolPlatformEnum.PQ);
 | 
	
		
			
				|  |  |          for (VideoPoolPlatformEnum videoType : videoPoolType) {
 | 
	
		
			
				|  |  |              ContentGroupFunnelExport item = ContentGroupFunnelExport.getDefault();
 | 
	
		
			
				|  |  |              item.setDateStr(dateStr);
 | 
	
	
		
			
				|  | @@ -2572,38 +2616,48 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |              result.add(item);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // sum
 | 
	
		
			
				|  |  | -        result.add(buildContentFunnelGroupSum(dateStr, result));
 | 
	
		
			
				|  |  | +        result.add(buildContentFunnelGroupSum(dateStr, result, "文章"));
 | 
	
		
			
				|  |  | +        result.add(buildContentFunnelGroupSum(dateStr, result, "视频"));
 | 
	
		
			
				|  |  | +        result.add(buildContentFunnelGroupSum(dateStr, result, "SUM"));
 | 
	
		
			
				|  |  | +        result.removeIf(o -> o.getCrawlerCount() == 0 && o.getProduceCount() == 0 && o.getProduceAuditCount() == 0
 | 
	
		
			
				|  |  | +                && o.getVideoPoolPQAuditCount() == 0 && o.getVideoAuditCount() == 0);
 | 
	
		
			
				|  |  | +        result.sort(Comparator.comparing(ContentGroupFunnelExport::getType));
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private ContentGroupFunnelExport buildContentFunnelGroupSum(String dateStr, List<ContentGroupFunnelExport> result) {
 | 
	
		
			
				|  |  | +    private ContentGroupFunnelExport buildContentFunnelGroupSum(String dateStr, List<ContentGroupFunnelExport> result,
 | 
	
		
			
				|  |  | +                                                                String type) {
 | 
	
		
			
				|  |  |          ContentGroupFunnelExport sum = ContentGroupFunnelExport.getDefault();
 | 
	
		
			
				|  |  | -        sum.setType("SUM");
 | 
	
		
			
				|  |  | +        sum.setType(type);
 | 
	
		
			
				|  |  |          sum.setSource("SUM");
 | 
	
		
			
				|  |  |          sum.setDateStr(dateStr);
 | 
	
		
			
				|  |  | -        for (ContentGroupFunnelExport contentGroupFunnelExport : result) {
 | 
	
		
			
				|  |  | -            sum.setCrawlerCount(sum.getCrawlerCount() + contentGroupFunnelExport.getCrawlerCount());
 | 
	
		
			
				|  |  | -            sum.setProduceCount(sum.getProduceCount() + contentGroupFunnelExport.getProduceCount());
 | 
	
		
			
				|  |  | +        for (ContentGroupFunnelExport export : result) {
 | 
	
		
			
				|  |  | +            if ((!export.getType().equals(type) && !"SUM".equals(type))
 | 
	
		
			
				|  |  | +                    || export.getSource().equals("SUM")) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            sum.setCrawlerCount(sum.getCrawlerCount() + export.getCrawlerCount());
 | 
	
		
			
				|  |  | +            sum.setProduceCount(sum.getProduceCount() + export.getProduceCount());
 | 
	
		
			
				|  |  |              if (sum.getCrawlerCount() > 0) {
 | 
	
		
			
				|  |  |                  sum.setProduceRate(sum.getProduceCount() * 1.0 / sum.getCrawlerCount());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            sum.setProduceAuditCount(sum.getProduceAuditCount() + contentGroupFunnelExport.getProduceAuditCount());
 | 
	
		
			
				|  |  | -            sum.setProduceAuditPassCount(sum.getProduceAuditPassCount() + contentGroupFunnelExport.getProduceAuditPassCount());
 | 
	
		
			
				|  |  | +            sum.setProduceAuditCount(sum.getProduceAuditCount() + export.getProduceAuditCount());
 | 
	
		
			
				|  |  | +            sum.setProduceAuditPassCount(sum.getProduceAuditPassCount() + export.getProduceAuditPassCount());
 | 
	
		
			
				|  |  |              if (sum.getProduceAuditCount() > 0) {
 | 
	
		
			
				|  |  |                  sum.setProduceAuditPassRate(sum.getProduceAuditPassCount() * 1.0 / sum.getProduceAuditCount());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            sum.setMatchCount(sum.getMatchCount() + contentGroupFunnelExport.getMatchCount());
 | 
	
		
			
				|  |  | -            sum.setMatchSuccessCount(sum.getMatchSuccessCount() + contentGroupFunnelExport.getMatchSuccessCount());
 | 
	
		
			
				|  |  | +            sum.setMatchCount(sum.getMatchCount() + export.getMatchCount());
 | 
	
		
			
				|  |  | +            sum.setMatchSuccessCount(sum.getMatchSuccessCount() + export.getMatchSuccessCount());
 | 
	
		
			
				|  |  |              if (sum.getMatchCount() > 0) {
 | 
	
		
			
				|  |  |                  sum.setMatchSuccessRate(sum.getMatchSuccessCount() * 1.0 / sum.getMatchCount());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            sum.setVideoAuditCount(sum.getVideoAuditCount() + contentGroupFunnelExport.getVideoAuditCount());
 | 
	
		
			
				|  |  | -            sum.setVideoAuditPassCount(sum.getVideoAuditPassCount() + contentGroupFunnelExport.getVideoAuditPassCount());
 | 
	
		
			
				|  |  | +            sum.setVideoAuditCount(sum.getVideoAuditCount() + export.getVideoAuditCount());
 | 
	
		
			
				|  |  | +            sum.setVideoAuditPassCount(sum.getVideoAuditPassCount() + export.getVideoAuditPassCount());
 | 
	
		
			
				|  |  |              if (sum.getVideoAuditCount() > 0) {
 | 
	
		
			
				|  |  |                  sum.setVideoAuditPassRate(sum.getVideoAuditPassCount() * 1.0 / sum.getVideoAuditCount());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            sum.setVideoPoolPQAuditCount(sum.getVideoPoolPQAuditCount() + contentGroupFunnelExport.getVideoPoolPQAuditCount());
 | 
	
		
			
				|  |  | -            sum.setVideoPoolPQAuditPassCount(sum.getVideoPoolPQAuditPassCount() + contentGroupFunnelExport.getVideoPoolPQAuditPassCount());
 | 
	
		
			
				|  |  | +            sum.setVideoPoolPQAuditCount(sum.getVideoPoolPQAuditCount() + export.getVideoPoolPQAuditCount());
 | 
	
		
			
				|  |  | +            sum.setVideoPoolPQAuditPassCount(sum.getVideoPoolPQAuditPassCount() + export.getVideoPoolPQAuditPassCount());
 | 
	
		
			
				|  |  |              if (sum.getVideoPoolPQAuditCount() > 0) {
 | 
	
		
			
				|  |  |                  sum.setVideoPoolPQAuditPassRate(sum.getVideoPoolPQAuditPassCount() * 1.0 / sum.getVideoPoolPQAuditCount());
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -2656,13 +2710,13 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<Pair<String, String>> styles = Arrays
 | 
	
		
			
				|  |  |                  .asList(
 | 
	
		
			
				|  |  | -                        Pair.of("H", "0.00%"),
 | 
	
		
			
				|  |  | -                        Pair.of("L", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("I", "0.00%"),
 | 
	
		
			
				|  |  |                          Pair.of("M", "0.00%"),
 | 
	
		
			
				|  |  |                          Pair.of("N", "0.00%"),
 | 
	
		
			
				|  |  | -                        Pair.of("R", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("O", "0.00%"),
 | 
	
		
			
				|  |  |                          Pair.of("S", "0.00%"),
 | 
	
		
			
				|  |  | -                        Pair.of("T", "0.00%")
 | 
	
		
			
				|  |  | +                        Pair.of("T", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("U", "0.00%")
 | 
	
		
			
				|  |  |                  );
 | 
	
		
			
				|  |  |          List<Pair<String, List<Pair<String, String>>>> thank = Arrays
 | 
	
		
			
				|  |  |                  .asList(
 | 
	
	
		
			
				|  | @@ -2681,11 +2735,18 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |                                  Pair.of("视频号视频", "#FDE2E2"),
 | 
	
		
			
				|  |  |                                  Pair.of("头条视频", "#ECE2FE"),
 | 
	
		
			
				|  |  |                                  Pair.of("文章SUM", "#D9F5D6"),
 | 
	
		
			
				|  |  | -                                Pair.of("视频SUM", "#F8DEF8"))),
 | 
	
		
			
				|  |  | +                                Pair.of("视频SUM", "#F8DEF8"),
 | 
	
		
			
				|  |  | +                                Pair.of("搜狐视频", "#EEF6C6"),
 | 
	
		
			
				|  |  | +                                Pair.of("票圈视频", "#BACEFD"))),
 | 
	
		
			
				|  |  |                          Pair.of("D", Arrays.asList(
 | 
	
		
			
				|  |  |                                  Pair.of("SUM", "#BACEFD"),
 | 
	
		
			
				|  |  |                                  Pair.of("相同", "#FED4A4"),
 | 
	
		
			
				|  |  | -                                Pair.of("不同", "#B1E8FC")))
 | 
	
		
			
				|  |  | +                                Pair.of("不同", "#B1E8FC"))),
 | 
	
		
			
				|  |  | +                        Pair.of("E", Arrays.asList(
 | 
	
		
			
				|  |  | +                                Pair.of("SUM", "#BACEFD"),
 | 
	
		
			
				|  |  | +                                Pair.of("头条", "#FED4A4"),
 | 
	
		
			
				|  |  | +                                Pair.of("次条", "#B1E8FC"),
 | 
	
		
			
				|  |  | +                                Pair.of("3-8", "#F8E6AB")))
 | 
	
		
			
				|  |  |                  );
 | 
	
		
			
				|  |  |          doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "qvxJsD", rowNum, rows,
 | 
	
		
			
				|  |  |                  2, styles, null, thank);
 | 
	
	
		
			
				|  | @@ -2711,8 +2772,10 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          List<String> rootSourceIdList = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (Article article : articleList) {
 | 
	
		
			
				|  |  |              List<String> rootSourceIds = JSONArray.parseArray(article.getRootSourceIdList(), String.class);
 | 
	
		
			
				|  |  | -            rootSourceIdMap.put(article.getWxSn(), rootSourceIds);
 | 
	
		
			
				|  |  | -            rootSourceIdList.addAll(rootSourceIds);
 | 
	
		
			
				|  |  | +            if (CollectionUtil.isNotEmpty(rootSourceIds)) {
 | 
	
		
			
				|  |  | +                rootSourceIdMap.put(article.getWxSn(), rootSourceIds);
 | 
	
		
			
				|  |  | +                rootSourceIdList.addAll(rootSourceIds);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          List<LongArticlesRootSourceId> longArticlesRootSourceIdList = rootSourceIdRepository.getByRootSourceIdIn(rootSourceIdList);
 | 
	
		
			
				|  |  |          Map<String, LongArticlesRootSourceId> longArticlesRootSourceIdMap = longArticlesRootSourceIdList.stream()
 | 
	
	
		
			
				|  | @@ -2722,11 +2785,49 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          List<LongArticleCrawlerVideo> longArticleCrawlerVideoList = crawlerVideoRepository.getByContentIdInAndIsIllegal(contentIdList, 0);
 | 
	
		
			
				|  |  |          Map<String, List<LongArticleCrawlerVideo>> longArticleCrawlerVideoMap = longArticleCrawlerVideoList.stream()
 | 
	
		
			
				|  |  |                  .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
 | 
	
		
			
				|  |  | +        List<String> videoOssPathList = longArticleCrawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
 | 
	
		
			
				|  |  | +                .filter(StringUtils::hasText).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<PublishSingleVideoSource> singleVideoSourceList = videoPoolRepository.getByVideoOssPathIn(videoOssPathList);
 | 
	
		
			
				|  |  | +        Map<String, List<PublishSingleVideoSource>> singgleVideoSourceMap = singleVideoSourceList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.groupingBy(PublishSingleVideoSource::getVideoOssPath));
 | 
	
		
			
				|  |  | +        // 获取晋级
 | 
	
		
			
				|  |  | +        List<String> sourceIds = datastatSortStrategyList.stream().map(DatastatSortStrategy::getSourceId).distinct()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<ProducePlanExeRecord> exeRecordList = producePlanExeRecordRepository.getByPlanExeIdIn(sourceIds);
 | 
	
		
			
				|  |  | +        Map<String, String> sourceIdMap = exeRecordList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, ProducePlanExeRecord::getChannelContentId));
 | 
	
		
			
				|  |  | +        List<String> channelContentIds = exeRecordList.stream().map(ProducePlanExeRecord::getChannelContentId)
 | 
	
		
			
				|  |  | +                .collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<ArticlePoolPromotionSource> promotionSourceList = articlePoolPromotionSourceRepository.getByChannelContentIdInAndStatusAndDeleted(
 | 
	
		
			
				|  |  | +                channelContentIds, ArticlePoolPromotionSourceStatusEnum.FINISH.getCode(), 0);
 | 
	
		
			
				|  |  | +        Map<String, String> promotionSourceMap = promotionSourceList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(ArticlePoolPromotionSource::getChannelContentId, ArticlePoolPromotionSource::getRootProduceContentId));
 | 
	
		
			
				|  |  | +        List<String> rootProduceContentIds = promotionSourceList.stream().map(ArticlePoolPromotionSource::getRootProduceContentId)
 | 
	
		
			
				|  |  | +                .collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        // 视频溯源信息
 | 
	
		
			
				|  |  | +        List<LongArticleCrawlerVideo> promotionCrawlerVideoList = crawlerVideoRepository.getByContentIdInAndIsIllegal(rootProduceContentIds, 0);
 | 
	
		
			
				|  |  | +        Map<String, List<LongArticleCrawlerVideo>> promotionCrawlerVideoMap = promotionCrawlerVideoList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
 | 
	
		
			
				|  |  | +        List<String> promotionVideoOssPathList = promotionCrawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
 | 
	
		
			
				|  |  | +                .filter(StringUtils::hasText).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<PublishSingleVideoSource> promotionSingleVideoSourceList = videoPoolRepository.getByVideoOssPathIn(promotionVideoOssPathList);
 | 
	
		
			
				|  |  | +        Map<String, List<PublishSingleVideoSource>> promotionSinggleVideoSourceMap = promotionSingleVideoSourceList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.groupingBy(PublishSingleVideoSource::getVideoOssPath));
 | 
	
		
			
				|  |  | +        // 文章溯源信息
 | 
	
		
			
				|  |  | +        List<ProducePlanExeRecord> rootProduceContentList = producePlanExeRecordRepository.getByPlanExeIdIn(rootProduceContentIds);
 | 
	
		
			
				|  |  | +        Map<String, String> rootProduceContentMap = rootProduceContentList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, ProducePlanExeRecord::getPlanId));
 | 
	
		
			
				|  |  | +        List<String> rootPlanIdList = rootProduceContentList.stream().map(ProducePlanExeRecord::getPlanId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<ProducePlan> producePlanList = producePlanRepository.findByIdIn(rootPlanIdList);
 | 
	
		
			
				|  |  | +        Map<String, ProducePlan> producePlanMap = producePlanList.stream().collect(Collectors.toMap(ProducePlan::getId, Function.identity()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          for (Article article : articleList) {
 | 
	
		
			
				|  |  |              boolean isVideo = false;
 | 
	
		
			
				|  |  |              boolean isSameMiniProgram = false;
 | 
	
		
			
				|  |  |              String source = "";
 | 
	
		
			
				|  |  |              List<String> rootSourceIds = rootSourceIdMap.get(article.getWxSn());
 | 
	
		
			
				|  |  | +            List<ArticleDetailInfo> detailInfoList = articleDetailInfoMap.get(article.getWxSn());
 | 
	
		
			
				|  |  | +            DatastatSortStrategy datastatSortStrategy = datastatSortStrategyMap.get(article.getWxSn());
 | 
	
		
			
				|  |  |              if (CollectionUtil.isNotEmpty(rootSourceIds)) {
 | 
	
		
			
				|  |  |                  List<LongArticlesRootSourceId> rootSourceIdItemList = new ArrayList<>();
 | 
	
		
			
				|  |  |                  for (String rootSourceId : rootSourceIds) {
 | 
	
	
		
			
				|  | @@ -2736,21 +2837,58 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      rootSourceIdItemList.add(longArticlesRootSourceId);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +                if (CollectionUtils.isEmpty(rootSourceIdItemList)) {
 | 
	
		
			
				|  |  | +                    continue;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                // 判断是否冷启视频内容池
 | 
	
		
			
				|  |  |                  String contentId = rootSourceIdItemList.get(0).getContentId();
 | 
	
		
			
				|  |  | -                List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoMap.get(contentId);
 | 
	
		
			
				|  |  | +                List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoMap.getOrDefault(contentId, new ArrayList<>());
 | 
	
		
			
				|  |  |                  List<String> videoOssPaths = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
 | 
	
		
			
				|  |  |                          .filter(StringUtils::hasText).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -                List<PublishSingleVideoSource> singleVideoSources = videoPoolRepository.getByVideoOssPathIn(videoOssPaths);
 | 
	
		
			
				|  |  | +                List<PublishSingleVideoSource> singleVideoSources = new ArrayList<>();
 | 
	
		
			
				|  |  | +                for (String videoOssPath : videoOssPaths) {
 | 
	
		
			
				|  |  | +                    List<PublishSingleVideoSource> item = singgleVideoSourceMap.get(videoOssPath);
 | 
	
		
			
				|  |  | +                    if (CollectionUtil.isEmpty(item)) {
 | 
	
		
			
				|  |  | +                        continue;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    singleVideoSources.addAll(item);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  if (CollectionUtil.isNotEmpty(singleVideoSources)) {
 | 
	
		
			
				|  |  |                      isVideo = true;
 | 
	
		
			
				|  |  |                      source = VideoPoolPlatformEnum.from(singleVideoSources.get(0).getPlatform()).getDescription();
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +                // 判断是否是晋级内容池
 | 
	
		
			
				|  |  | +                String channelContentId = null;
 | 
	
		
			
				|  |  | +                if (Objects.nonNull(datastatSortStrategy)) {
 | 
	
		
			
				|  |  | +                    channelContentId = sourceIdMap.get(datastatSortStrategy.getSourceId());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                String rootProduceContentId = promotionSourceMap.get(channelContentId);
 | 
	
		
			
				|  |  | +                List<LongArticleCrawlerVideo> promotionCrawlerVideos = promotionCrawlerVideoMap.get(rootProduceContentId);
 | 
	
		
			
				|  |  | +                if (!isVideo && CollectionUtil.isNotEmpty(promotionCrawlerVideos)) {
 | 
	
		
			
				|  |  | +                    List<String> promotionVideoOssPaths = promotionCrawlerVideos.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
 | 
	
		
			
				|  |  | +                            .filter(StringUtils::hasText).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                    List<PublishSingleVideoSource> promotionSingleVideoSources = new ArrayList<>();
 | 
	
		
			
				|  |  | +                    for (String videoOssPath : promotionVideoOssPaths) {
 | 
	
		
			
				|  |  | +                        List<PublishSingleVideoSource> item = promotionSinggleVideoSourceMap.get(videoOssPath);
 | 
	
		
			
				|  |  | +                        if (CollectionUtil.isEmpty(item)) {
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        promotionSingleVideoSources.addAll(item);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (CollectionUtil.isNotEmpty(promotionSingleVideoSources)) {
 | 
	
		
			
				|  |  | +                        isVideo = true;
 | 
	
		
			
				|  |  | +                        source = VideoPoolPlatformEnum.from(promotionSingleVideoSources.get(0).getPlatform()).getDescription();
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (!isVideo) {
 | 
	
		
			
				|  |  | +                    String planId = rootProduceContentMap.get(rootProduceContentId);
 | 
	
		
			
				|  |  | +                    ProducePlan producePlan = producePlanMap.get(planId);
 | 
	
		
			
				|  |  | +                    source = getArticleSource(producePlan);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  if (CollectionUtil.isNotEmpty(crawlerVideoList) && crawlerVideoList.size() == 1) {
 | 
	
		
			
				|  |  |                      isSameMiniProgram = true;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            List<ArticleDetailInfo> detailInfoList = articleDetailInfoMap.get(article.getWxSn());
 | 
	
		
			
				|  |  | -            DatastatSortStrategy datastatSortStrategy = datastatSortStrategyMap.get(article.getWxSn());
 | 
	
		
			
				|  |  |              if (isVideo) {
 | 
	
		
			
				|  |  |                  addContentEffectGroupBySourceRate(article, "视频", source, isSameMiniProgram, result, detailInfoList,
 | 
	
		
			
				|  |  |                          datastatSortStrategy);
 | 
	
	
		
			
				|  | @@ -2764,6 +2902,13 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          result.add(buildContentEffectGroupBySourceSum(dateStr, result));
 | 
	
		
			
				|  |  | +        Iterator<ContentEffectGroupBySourceExport> iterator = result.iterator();
 | 
	
		
			
				|  |  | +        while (iterator.hasNext()) {
 | 
	
		
			
				|  |  | +            ContentEffectGroupBySourceExport export = iterator.next();
 | 
	
		
			
				|  |  | +            if (export.getFansCount() == 0) {
 | 
	
		
			
				|  |  | +                iterator.remove();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2775,53 +2920,55 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          if (Objects.isNull(datastatSortStrategy)) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if ("文章".equals(type) && "".equals(source)) {
 | 
	
		
			
				|  |  | -            source = getArticleSource(datastatSortStrategy);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |          for (ContentEffectGroupBySourceExport export : result) {
 | 
	
		
			
				|  |  |              if ((export.getType().contains("SUM") && export.getType().contains(type)) || export.getType().equals(type)) {
 | 
	
		
			
				|  |  |                  if ((export.getIsSameMiniprogram().equals("相同") && isSameMiniProgram)
 | 
	
		
			
				|  |  |                          || (export.getIsSameMiniprogram().equals("不同") && !isSameMiniProgram)
 | 
	
		
			
				|  |  |                          || export.getIsSameMiniprogram().equals("SUM")) {
 | 
	
		
			
				|  |  |                      if (export.getSource().contains("SUM") || export.getSource().equals(source)) {
 | 
	
		
			
				|  |  | -                        if (Objects.nonNull(datastatSortStrategy.getFans())) {
 | 
	
		
			
				|  |  | -                            export.setFansCount(export.getFansCount() + datastatSortStrategy.getFans());
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        export.setPublishContentCount(export.getPublishContentCount() + 1);
 | 
	
		
			
				|  |  | -                        export.setReadCount(export.getReadCount() + article.getShowViewCount());
 | 
	
		
			
				|  |  | -                        if (CollectionUtil.isNotEmpty(detailInfoList)) {
 | 
	
		
			
				|  |  | -                            int totalFirstLevel = 0;
 | 
	
		
			
				|  |  | -                            int totalT0Fission = 0;
 | 
	
		
			
				|  |  | -                            int card1FirstLevel = 0;
 | 
	
		
			
				|  |  | -                            int card1T0Fission = 0;
 | 
	
		
			
				|  |  | -                            int card2FirstLevel = 0;
 | 
	
		
			
				|  |  | -                            int card2T0Fission = 0;
 | 
	
		
			
				|  |  | -                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | -                                if (Objects.isNull(articleDetailInfo.getFirstLevel())) {
 | 
	
		
			
				|  |  | -                                    continue;
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                                if (articleDetailInfo.getVideoIndex() == 1) {
 | 
	
		
			
				|  |  | -                                    card1FirstLevel += articleDetailInfo.getFirstLevel();
 | 
	
		
			
				|  |  | -                                    if (Objects.nonNull(articleDetailInfo.getFission0())) {
 | 
	
		
			
				|  |  | -                                        card1T0Fission += articleDetailInfo.getFission0();
 | 
	
		
			
				|  |  | +                        if ((article.getItemIndex() == 1 && "头条".equals(export.getPosition()))
 | 
	
		
			
				|  |  | +                                || (article.getItemIndex() == 2 && "次条".equals(export.getPosition()))
 | 
	
		
			
				|  |  | +                                || (article.getItemIndex() > 2 && "3-8".equals(export.getPosition()))
 | 
	
		
			
				|  |  | +                                || export.getPosition().equals("SUM")) {
 | 
	
		
			
				|  |  | +                            if (Objects.nonNull(datastatSortStrategy.getFans())) {
 | 
	
		
			
				|  |  | +                                export.setFansCount(export.getFansCount() + datastatSortStrategy.getFans());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            export.setPublishContentCount(export.getPublishContentCount() + 1);
 | 
	
		
			
				|  |  | +                            export.setReadCount(export.getReadCount() + article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            if (CollectionUtil.isNotEmpty(detailInfoList)) {
 | 
	
		
			
				|  |  | +                                int totalFirstLevel = 0;
 | 
	
		
			
				|  |  | +                                int totalT0Fission = 0;
 | 
	
		
			
				|  |  | +                                int card1FirstLevel = 0;
 | 
	
		
			
				|  |  | +                                int card1T0Fission = 0;
 | 
	
		
			
				|  |  | +                                int card2FirstLevel = 0;
 | 
	
		
			
				|  |  | +                                int card2T0Fission = 0;
 | 
	
		
			
				|  |  | +                                for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                    if (Objects.isNull(articleDetailInfo.getFirstLevel())) {
 | 
	
		
			
				|  |  | +                                        continue;
 | 
	
		
			
				|  |  | +                                    }
 | 
	
		
			
				|  |  | +                                    if (articleDetailInfo.getVideoIndex() == 1) {
 | 
	
		
			
				|  |  | +                                        card1FirstLevel += articleDetailInfo.getFirstLevel();
 | 
	
		
			
				|  |  | +                                        if (Objects.nonNull(articleDetailInfo.getFission0())) {
 | 
	
		
			
				|  |  | +                                            card1T0Fission += articleDetailInfo.getFission0();
 | 
	
		
			
				|  |  | +                                        }
 | 
	
		
			
				|  |  | +                                    } else if (articleDetailInfo.getVideoIndex() == 2) {
 | 
	
		
			
				|  |  | +                                        card2FirstLevel += articleDetailInfo.getFirstLevel();
 | 
	
		
			
				|  |  | +                                        if (Objects.nonNull(articleDetailInfo.getFission0())) {
 | 
	
		
			
				|  |  | +                                            card2T0Fission += articleDetailInfo.getFission0();
 | 
	
		
			
				|  |  | +                                        }
 | 
	
		
			
				|  |  |                                      }
 | 
	
		
			
				|  |  | -                                } else if (articleDetailInfo.getVideoIndex() == 2) {
 | 
	
		
			
				|  |  | -                                    card2FirstLevel += articleDetailInfo.getFirstLevel();
 | 
	
		
			
				|  |  | +                                    totalFirstLevel += articleDetailInfo.getFirstLevel();
 | 
	
		
			
				|  |  |                                      if (Objects.nonNull(articleDetailInfo.getFission0())) {
 | 
	
		
			
				|  |  | -                                        card2T0Fission += articleDetailInfo.getFission0();
 | 
	
		
			
				|  |  | +                                        totalT0Fission += articleDetailInfo.getFission0();
 | 
	
		
			
				|  |  |                                      }
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  | -                                totalFirstLevel += articleDetailInfo.getFirstLevel();
 | 
	
		
			
				|  |  | -                                if (Objects.nonNull(articleDetailInfo.getFission0())) {
 | 
	
		
			
				|  |  | -                                    totalT0Fission += articleDetailInfo.getFission0();
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | +                                export.setFirstLevel(export.getFirstLevel() + totalFirstLevel);
 | 
	
		
			
				|  |  | +                                export.setMiniprogram1FirstLevel(export.getMiniprogram1FirstLevel() + card1FirstLevel);
 | 
	
		
			
				|  |  | +                                export.setMiniprogram2FirstLevel(export.getMiniprogram2FirstLevel() + card2FirstLevel);
 | 
	
		
			
				|  |  | +                                export.setT0Fission(export.getT0Fission() + totalT0Fission);
 | 
	
		
			
				|  |  | +                                export.setMiniprogram1T0Fission(export.getMiniprogram1T0Fission() + card1T0Fission);
 | 
	
		
			
				|  |  | +                                export.setMiniprogram2T0Fission(export.getMiniprogram2T0Fission() + card2T0Fission);
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  | -                            export.setFirstLevel(export.getFirstLevel() + totalFirstLevel);
 | 
	
		
			
				|  |  | -                            export.setMiniprogram1FirstLevel(export.getMiniprogram1FirstLevel() + card1FirstLevel);
 | 
	
		
			
				|  |  | -                            export.setMiniprogram2FirstLevel(export.getMiniprogram2FirstLevel() + card2FirstLevel);
 | 
	
		
			
				|  |  | -                            export.setT0Fission(export.getT0Fission() + totalT0Fission);
 | 
	
		
			
				|  |  | -                            export.setMiniprogram1T0Fission(export.getMiniprogram1T0Fission() + card1T0Fission);
 | 
	
		
			
				|  |  | -                            export.setMiniprogram2T0Fission(export.getMiniprogram2T0Fission() + card2T0Fission);
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
	
		
			
				|  | @@ -2829,9 +2976,9 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private String getArticleSource(DatastatSortStrategy datastatSortStrategy) {
 | 
	
		
			
				|  |  | -        if (StringUtils.hasText(datastatSortStrategy.getProducePlanName())
 | 
	
		
			
				|  |  | -                && datastatSortStrategy.getProducePlanName().contains("头条")) {
 | 
	
		
			
				|  |  | +    private String getArticleSource(ProducePlan producePlan) {
 | 
	
		
			
				|  |  | +        if (Objects.nonNull(producePlan)
 | 
	
		
			
				|  |  | +                && producePlan.getName().contains("今日头条")) {
 | 
	
		
			
				|  |  |              return "头条文章";
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              return "公众号文章";
 | 
	
	
		
			
				|  | @@ -2843,15 +2990,19 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          List<ContentEffectGroupBySourceExport> result = new ArrayList<>();
 | 
	
		
			
				|  |  |          List<String> isSameMiniprogram = Arrays.asList("相同", "不同", "SUM");
 | 
	
		
			
				|  |  |          List<String> articleSource = Arrays.asList("公众号文章", "头条文章");
 | 
	
		
			
				|  |  | -        List<String> videoSource = Arrays.asList("公众号视频", "好看视频", "视频号视频", "头条视频");
 | 
	
		
			
				|  |  | +        List<String> videoSource = Arrays.asList("公众号视频", "好看视频", "视频号视频", "头条视频", "搜狐视频", "票圈视频");
 | 
	
		
			
				|  |  | +        List<String> positionList = Arrays.asList("头条", "次条", "3-8");
 | 
	
		
			
				|  |  |          for (String source : articleSource) {
 | 
	
		
			
				|  |  |              for (String same : isSameMiniprogram) {
 | 
	
		
			
				|  |  | -                ContentEffectGroupBySourceExport item = new ContentEffectGroupBySourceExport();
 | 
	
		
			
				|  |  | -                item.setDateStr(dateStr);
 | 
	
		
			
				|  |  | -                item.setType("文章");
 | 
	
		
			
				|  |  | -                item.setSource(source);
 | 
	
		
			
				|  |  | -                item.setIsSameMiniprogram(same);
 | 
	
		
			
				|  |  | -                result.add(item);
 | 
	
		
			
				|  |  | +                for (String position : positionList) {
 | 
	
		
			
				|  |  | +                    ContentEffectGroupBySourceExport item = new ContentEffectGroupBySourceExport();
 | 
	
		
			
				|  |  | +                    item.setDateStr(dateStr);
 | 
	
		
			
				|  |  | +                    item.setType("文章");
 | 
	
		
			
				|  |  | +                    item.setSource(source);
 | 
	
		
			
				|  |  | +                    item.setIsSameMiniprogram(same);
 | 
	
		
			
				|  |  | +                    item.setPosition(position);
 | 
	
		
			
				|  |  | +                    result.add(item);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          for (String same : isSameMiniprogram) {
 | 
	
	
		
			
				|  | @@ -2863,12 +3014,15 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |              result.add(item);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          for (String source : videoSource) {
 | 
	
		
			
				|  |  | -            ContentEffectGroupBySourceExport item = new ContentEffectGroupBySourceExport();
 | 
	
		
			
				|  |  | -            item.setDateStr(dateStr);
 | 
	
		
			
				|  |  | -            item.setType("视频");
 | 
	
		
			
				|  |  | -            item.setSource(source);
 | 
	
		
			
				|  |  | -            item.setIsSameMiniprogram("SUM");
 | 
	
		
			
				|  |  | -            result.add(item);
 | 
	
		
			
				|  |  | +            for (String position : positionList) {
 | 
	
		
			
				|  |  | +                ContentEffectGroupBySourceExport item = new ContentEffectGroupBySourceExport();
 | 
	
		
			
				|  |  | +                item.setDateStr(dateStr);
 | 
	
		
			
				|  |  | +                item.setType("视频");
 | 
	
		
			
				|  |  | +                item.setSource(source);
 | 
	
		
			
				|  |  | +                item.setIsSameMiniprogram("SUM");
 | 
	
		
			
				|  |  | +                item.setPosition(position);
 | 
	
		
			
				|  |  | +                result.add(item);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          ContentEffectGroupBySourceExport item = new ContentEffectGroupBySourceExport();
 | 
	
		
			
				|  |  |          item.setDateStr(dateStr);
 | 
	
	
		
			
				|  | @@ -2924,4 +3078,970 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @XxlJob("buildCoverStatisticDataExportJob")
 | 
	
		
			
				|  |  | +    public ReturnT<String> buildCoverStatisticDataExportJob(String param) {
 | 
	
		
			
				|  |  | +        if (StringUtils.hasText(param)) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport(param);
 | 
	
		
			
				|  |  | +            coverStatisticTestDataExport(param);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            String dateStr = DateUtils.getDateString(System.currentTimeMillis() - 24 * 60 * 60 * 1000, "yyyMMdd");
 | 
	
		
			
				|  |  | +            coverStatisticDataExport(dateStr);
 | 
	
		
			
				|  |  | +            coverStatisticTestDataExport(dateStr);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return ReturnT.SUCCESS;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void coverStatisticDataExport(String dateStr) {
 | 
	
		
			
				|  |  | +        List<String> dateStrList = Arrays.asList(dateStr);
 | 
	
		
			
				|  |  | +        List<CoverStatisticDataExport> exportList = buildCoverStatisticDataExport(dateStr);
 | 
	
		
			
				|  |  | +        if (CollectionUtil.isEmpty(exportList)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        int rowNum = exportList.size();
 | 
	
		
			
				|  |  | +        List<List<Object>> rows = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Field[] fields = CoverStatisticDataExport.class.getDeclaredFields();
 | 
	
		
			
				|  |  | +        for (CoverStatisticDataExport 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, "jwayC4", rowNum, rows,
 | 
	
		
			
				|  |  | +                2, null, null, null);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void coverStatisticTestDataExport(String dateStr) {
 | 
	
		
			
				|  |  | +        List<String> dateStrList = Arrays.asList(dateStr);
 | 
	
		
			
				|  |  | +        List<CoverStatisticOneDataExport> exportList = buildCoverStatisticTestDataExport(dateStr);
 | 
	
		
			
				|  |  | +        if (CollectionUtil.isEmpty(exportList)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        int rowNum = exportList.size();
 | 
	
		
			
				|  |  | +        List<List<Object>> rows = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Field[] fields = CoverStatisticOneDataExport.class.getDeclaredFields();
 | 
	
		
			
				|  |  | +        for (CoverStatisticOneDataExport 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, "QiEZiz", rowNum, rows,
 | 
	
		
			
				|  |  | +                2, null, null, null);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<CoverStatisticDataExport> buildCoverStatisticDataExport(String dateStr) {
 | 
	
		
			
				|  |  | +        List<CoverStatisticDataExport> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleTestFirst = new CoverStatisticDataExport(dateStr, "文章", "实验组", "头条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleTestSecond = new CoverStatisticDataExport(dateStr, "文章", "实验组", "次条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleTestLast = new CoverStatisticDataExport(dateStr, "文章", "实验组", "3-8条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleTestSum = new CoverStatisticDataExport(dateStr, "文章", "实验组", "sum");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleBaseFirst = new CoverStatisticDataExport(dateStr, "文章", "base组", "头条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleBaseSecond = new CoverStatisticDataExport(dateStr, "文章", "base组", "次条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleBaseLast = new CoverStatisticDataExport(dateStr, "文章", "base组", "3-8条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleBaseSum = new CoverStatisticDataExport(dateStr, "文章", "base组", "sum");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleMinimumFirst = new CoverStatisticDataExport(dateStr, "文章", "兜底组", "头条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleMinimumSecond = new CoverStatisticDataExport(dateStr, "文章", "兜底组", "次条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleMinimumLast = new CoverStatisticDataExport(dateStr, "文章", "兜底组", "3-8条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleMinimumSum = new CoverStatisticDataExport(dateStr, "文章", "兜底组", "sum");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport articleSum = new CoverStatisticDataExport(dateStr, "文章", "sum", "sum");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoTestFirst = new CoverStatisticDataExport(dateStr, "视频", "实验组", "头条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoTestSecond = new CoverStatisticDataExport(dateStr, "视频", "实验组", "次条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoTestLast = new CoverStatisticDataExport(dateStr, "视频", "实验组", "3-8条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoTestSum = new CoverStatisticDataExport(dateStr, "视频", "实验组", "sum");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoBaseFirst = new CoverStatisticDataExport(dateStr, "视频", "base组", "头条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoBaseSecond = new CoverStatisticDataExport(dateStr, "视频", "base组", "次条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoBaseLast = new CoverStatisticDataExport(dateStr, "视频", "base组", "3-8条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoBaseSum = new CoverStatisticDataExport(dateStr, "视频", "base组", "sum");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoMinimumFirst = new CoverStatisticDataExport(dateStr, "视频", "兜底组", "头条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoMinimumSecond = new CoverStatisticDataExport(dateStr, "视频", "兜底组", "次条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoMinimumLast = new CoverStatisticDataExport(dateStr, "视频", "兜底组", "3-8条");
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoMinimumSum = new CoverStatisticDataExport(dateStr, "视频", "兜底组", "sum");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        CoverStatisticDataExport videoSum = new CoverStatisticDataExport(dateStr, "视频", "sum", "sum");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Long start = DateUtils.getStartOfDay(dateStr, "yyyyMMdd");
 | 
	
		
			
				|  |  | +        Long end = start + 86400;
 | 
	
		
			
				|  |  | +        Date startDate = new Date(start * 1000);
 | 
	
		
			
				|  |  | +        Date endDate = new Date(end * 1000);
 | 
	
		
			
				|  |  | +        List<Article> articleList = articleRepository.getByPublishTimestampBetweenAndTypeEquals(start, end, ArticleTypeEnum.QUNFA.getVal());
 | 
	
		
			
				|  |  | +        List<String> wxSnList = articleList.stream().map(Article::getWxSn).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<ArticleDetailInfo> articleDetailInfoList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (List<String> partitions : Lists.partition(wxSnList, 1000)) {
 | 
	
		
			
				|  |  | +            articleDetailInfoList.addAll(articleDetailInfoRepository.findByWxSnInAndPublishDtBetween(partitions, startDate, endDate));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<DatastatSortStrategy> datastatSortStrategyList = datastatSortStrategyRepository.getByWxSnIn(wxSnList);
 | 
	
		
			
				|  |  | +        Map<String, DatastatSortStrategy> datastatSortStrategyMap = datastatSortStrategyList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(DatastatSortStrategy::getWxSn, Function.identity()));
 | 
	
		
			
				|  |  | +        Map<String, List<ArticleDetailInfo>> articleDetailInfoMap = articleDetailInfoList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
 | 
	
		
			
				|  |  | +        // 获取rootSourceId
 | 
	
		
			
				|  |  | +        Map<String, List<String>> rootSourceIdMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        List<String> rootSourceIdList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (Article article : articleList) {
 | 
	
		
			
				|  |  | +            List<String> rootSourceIds = JSONArray.parseArray(article.getRootSourceIdList(), String.class);
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isEmpty(rootSourceIds)) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            rootSourceIdMap.put(article.getWxSn(), rootSourceIds);
 | 
	
		
			
				|  |  | +            rootSourceIdList.addAll(rootSourceIds);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<LongArticlesRootSourceId> longArticlesRootSourceIdList = rootSourceIdRepository.getByRootSourceIdIn(rootSourceIdList);
 | 
	
		
			
				|  |  | +        Map<String, LongArticlesRootSourceId> longArticlesRootSourceIdMap = longArticlesRootSourceIdList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(LongArticlesRootSourceId::getRootSourceId, Function.identity()));
 | 
	
		
			
				|  |  | +        // 获取视频
 | 
	
		
			
				|  |  | +        List<String> contentIdList = longArticlesRootSourceIdList.stream().map(LongArticlesRootSourceId::getContentId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<LongArticleCrawlerVideo> longArticleCrawlerVideoList = crawlerVideoRepository.getByContentIdInAndIsIllegal(contentIdList, 0);
 | 
	
		
			
				|  |  | +        Map<String, List<LongArticleCrawlerVideo>> longArticleCrawlerVideoMap = longArticleCrawlerVideoList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
 | 
	
		
			
				|  |  | +        for (Article article : articleList) {
 | 
	
		
			
				|  |  | +            boolean isVideo = false;
 | 
	
		
			
				|  |  | +            boolean isSameMiniProgram = false;
 | 
	
		
			
				|  |  | +            boolean isTest = false;
 | 
	
		
			
				|  |  | +            List<String> rootSourceIds = rootSourceIdMap.get(article.getWxSn());
 | 
	
		
			
				|  |  | +            if (CollectionUtil.isNotEmpty(rootSourceIds)) {
 | 
	
		
			
				|  |  | +                List<LongArticlesRootSourceId> rootSourceIdItemList = new ArrayList<>();
 | 
	
		
			
				|  |  | +                for (String rootSourceId : rootSourceIds) {
 | 
	
		
			
				|  |  | +                    LongArticlesRootSourceId longArticlesRootSourceId = longArticlesRootSourceIdMap.get(rootSourceId);
 | 
	
		
			
				|  |  | +                    if (!Objects.isNull(longArticlesRootSourceId)) {
 | 
	
		
			
				|  |  | +                        rootSourceIdItemList.add(longArticlesRootSourceId);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    LongArticlesPublishMiniprogram longArticlesPublishMiniprogram
 | 
	
		
			
				|  |  | +                            = longArticlesPublishMiniprogramRepository.findByRootSourceIdEquals(rootSourceId);
 | 
	
		
			
				|  |  | +                    if (!Objects.isNull(longArticlesPublishMiniprogram)) {
 | 
	
		
			
				|  |  | +                        if (longArticlesPublishMiniprogram.getNewVideoCoverId() != null) {
 | 
	
		
			
				|  |  | +                            isTest = true;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                String contentId = rootSourceIdItemList.get(0).getContentId();
 | 
	
		
			
				|  |  | +                List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoMap.get(contentId);
 | 
	
		
			
				|  |  | +                List<String> videoOssPaths = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
 | 
	
		
			
				|  |  | +                        .filter(StringUtils::hasText).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                List<PublishSingleVideoSource> singleVideoSources = videoPoolRepository.getByVideoOssPathIn(videoOssPaths);
 | 
	
		
			
				|  |  | +                if (CollectionUtil.isNotEmpty(singleVideoSources)) {
 | 
	
		
			
				|  |  | +                    isVideo = true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (CollectionUtil.isNotEmpty(crawlerVideoList) && crawlerVideoList.size() == 1) {
 | 
	
		
			
				|  |  | +                    isSameMiniProgram = true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<ArticleDetailInfo> detailInfoList = articleDetailInfoMap.get(article.getWxSn());
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isEmpty(detailInfoList)) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByGhIdEqualsAndStatusEquals(article.getGhId(), 1);
 | 
	
		
			
				|  |  | +            Integer fans = 0;
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(accountAvgInfoList)) {
 | 
	
		
			
				|  |  | +                fans = accountAvgInfoList.get(0).getFans();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (isVideo) {
 | 
	
		
			
				|  |  | +                if (isSameMiniProgram) {
 | 
	
		
			
				|  |  | +                    if (isTest) {
 | 
	
		
			
				|  |  | +                        if (article.getItemIndex() == 1) {
 | 
	
		
			
				|  |  | +                            save(videoTestFirst, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(videoTestFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else if (article.getItemIndex() == 2) {
 | 
	
		
			
				|  |  | +                            save(videoTestSecond, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(videoTestSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            save(videoTestLast, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(videoTestLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        if (article.getItemIndex() == 1) {
 | 
	
		
			
				|  |  | +                            save(videoMinimumFirst, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(videoMinimumFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else if (article.getItemIndex() == 2) {
 | 
	
		
			
				|  |  | +                            save(videoMinimumSecond, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(videoMinimumSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            save(videoMinimumLast, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(videoMinimumLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    if (article.getItemIndex() == 1) {
 | 
	
		
			
				|  |  | +                        save(videoBaseFirst, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                            saveMini(videoBaseFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else if (article.getItemIndex() == 2) {
 | 
	
		
			
				|  |  | +                        save(videoBaseSecond, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                            saveMini(videoBaseSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        save(videoBaseLast, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                            saveMini(videoBaseLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                if (isSameMiniProgram) {
 | 
	
		
			
				|  |  | +                    if (isTest) {
 | 
	
		
			
				|  |  | +                        if (article.getItemIndex() == 1) {
 | 
	
		
			
				|  |  | +                            save(articleTestFirst, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(articleTestFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else if (article.getItemIndex() == 2) {
 | 
	
		
			
				|  |  | +                            save(articleTestSecond, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(articleTestSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            save(articleTestLast, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(articleTestLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        if (article.getItemIndex() == 1) {
 | 
	
		
			
				|  |  | +                            save(articleMinimumFirst, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(articleMinimumFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else if (article.getItemIndex() == 2) {
 | 
	
		
			
				|  |  | +                            save(articleMinimumSecond, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(articleMinimumSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            save(articleMinimumLast, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                                saveMini(articleMinimumLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    if (article.getItemIndex() == 1) {
 | 
	
		
			
				|  |  | +                        save(articleBaseFirst, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                            saveMini(articleBaseFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else if (article.getItemIndex() == 2) {
 | 
	
		
			
				|  |  | +                        save(articleBaseSecond, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                            saveMini(articleBaseSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        save(articleBaseLast, fans, article.getShowViewCount());
 | 
	
		
			
				|  |  | +                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                            saveMini(articleBaseLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        sum(articleTestSum, articleTestFirst, articleTestSecond, articleTestLast);
 | 
	
		
			
				|  |  | +        sum(articleBaseSum, articleBaseFirst, articleBaseSecond, articleBaseLast);
 | 
	
		
			
				|  |  | +        sum(articleMinimumSum, articleMinimumFirst, articleMinimumSecond, articleMinimumLast);
 | 
	
		
			
				|  |  | +        sum(articleSum, articleTestSum, articleBaseSum, articleMinimumSum);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        sum(videoTestSum, videoTestFirst, videoTestSecond, videoTestLast);
 | 
	
		
			
				|  |  | +        sum(videoBaseSum, videoBaseFirst, videoBaseSecond, videoBaseLast);
 | 
	
		
			
				|  |  | +        sum(videoMinimumSum, videoMinimumFirst, videoMinimumSecond, videoMinimumLast);
 | 
	
		
			
				|  |  | +        sum(videoSum, videoTestSum, videoBaseSum, videoMinimumSum);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        result.add(rate(articleTestFirst));
 | 
	
		
			
				|  |  | +        result.add(rate(articleTestSecond));
 | 
	
		
			
				|  |  | +        result.add(rate(articleTestLast));
 | 
	
		
			
				|  |  | +        result.add(rate(articleTestSum));
 | 
	
		
			
				|  |  | +        result.add(rate(articleBaseFirst));
 | 
	
		
			
				|  |  | +        result.add(rate(articleBaseSecond));
 | 
	
		
			
				|  |  | +        result.add(rate(articleBaseLast));
 | 
	
		
			
				|  |  | +        result.add(rate(articleBaseSum));
 | 
	
		
			
				|  |  | +        result.add(rate(articleMinimumFirst));
 | 
	
		
			
				|  |  | +        result.add(rate(articleMinimumSecond));
 | 
	
		
			
				|  |  | +        result.add(rate(articleMinimumLast));
 | 
	
		
			
				|  |  | +        result.add(rate(articleMinimumSum));
 | 
	
		
			
				|  |  | +        result.add(rate(articleSum));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        result.add(rate(videoTestFirst));
 | 
	
		
			
				|  |  | +        result.add(rate(videoTestSecond));
 | 
	
		
			
				|  |  | +        result.add(rate(videoTestLast));
 | 
	
		
			
				|  |  | +        result.add(rate(videoTestSum));
 | 
	
		
			
				|  |  | +        result.add(rate(videoBaseFirst));
 | 
	
		
			
				|  |  | +        result.add(rate(videoBaseSecond));
 | 
	
		
			
				|  |  | +        result.add(rate(videoBaseLast));
 | 
	
		
			
				|  |  | +        result.add(rate(videoBaseSum));
 | 
	
		
			
				|  |  | +        result.add(rate(videoMinimumFirst));
 | 
	
		
			
				|  |  | +        result.add(rate(videoMinimumSecond));
 | 
	
		
			
				|  |  | +        result.add(rate(videoMinimumLast));
 | 
	
		
			
				|  |  | +        result.add(rate(videoMinimumSum));
 | 
	
		
			
				|  |  | +        result.add(rate(videoSum));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<CoverStatisticOneDataExport> buildCoverStatisticTestDataExport(String dateStr) {
 | 
	
		
			
				|  |  | +        List<CoverStatisticOneDataExport> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Long start = DateUtils.getStartOfDay(dateStr, "yyyyMMdd");
 | 
	
		
			
				|  |  | +        Long end = start + 86400;
 | 
	
		
			
				|  |  | +        Date startDate = new Date(start * 1000);
 | 
	
		
			
				|  |  | +        Date endDate = new Date(end * 1000);
 | 
	
		
			
				|  |  | +        List<Article> articleList = articleRepository.getByPublishTimestampBetweenAndTypeEquals(start, end, ArticleTypeEnum.QUNFA.getVal());
 | 
	
		
			
				|  |  | +        List<String> wxSnList = articleList.stream().map(Article::getWxSn).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<ArticleDetailInfo> articleDetailInfoList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (List<String> partitions : Lists.partition(wxSnList, 1000)) {
 | 
	
		
			
				|  |  | +            articleDetailInfoList.addAll(articleDetailInfoRepository.findByWxSnInAndPublishDtBetween(partitions, startDate, endDate));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<DatastatSortStrategy> datastatSortStrategyList = datastatSortStrategyRepository.getByWxSnIn(wxSnList);
 | 
	
		
			
				|  |  | +        Map<String, DatastatSortStrategy> datastatSortStrategyMap = datastatSortStrategyList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(DatastatSortStrategy::getWxSn, Function.identity()));
 | 
	
		
			
				|  |  | +        Map<String, List<ArticleDetailInfo>> articleDetailInfoMap = articleDetailInfoList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
 | 
	
		
			
				|  |  | +        // 获取rootSourceId
 | 
	
		
			
				|  |  | +        Map<String, List<String>> rootSourceIdMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        List<String> rootSourceIdList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (Article article : articleList) {
 | 
	
		
			
				|  |  | +            List<String> rootSourceIds = JSONArray.parseArray(article.getRootSourceIdList(), String.class);
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isEmpty(rootSourceIds)) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            rootSourceIdMap.put(article.getWxSn(), rootSourceIds);
 | 
	
		
			
				|  |  | +            rootSourceIdList.addAll(rootSourceIds);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<LongArticlesRootSourceId> longArticlesRootSourceIdList = rootSourceIdRepository.getByRootSourceIdIn(rootSourceIdList);
 | 
	
		
			
				|  |  | +        Map<String, LongArticlesRootSourceId> longArticlesRootSourceIdMap = longArticlesRootSourceIdList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(LongArticlesRootSourceId::getRootSourceId, Function.identity()));
 | 
	
		
			
				|  |  | +        // 获取视频
 | 
	
		
			
				|  |  | +        List<String> contentIdList = longArticlesRootSourceIdList.stream().map(LongArticlesRootSourceId::getContentId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<LongArticleCrawlerVideo> longArticleCrawlerVideoList = crawlerVideoRepository.getByContentIdInAndIsIllegal(contentIdList, 0);
 | 
	
		
			
				|  |  | +        Map<String, List<LongArticleCrawlerVideo>> longArticleCrawlerVideoMap = longArticleCrawlerVideoList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
 | 
	
		
			
				|  |  | +        for (Article article : articleList) {
 | 
	
		
			
				|  |  | +            boolean isVideo = false;
 | 
	
		
			
				|  |  | +            boolean isSameMiniProgram = false;
 | 
	
		
			
				|  |  | +            boolean isTest = false;
 | 
	
		
			
				|  |  | +            List<String> rootSourceIds = rootSourceIdMap.get(article.getWxSn());
 | 
	
		
			
				|  |  | +            if (CollectionUtil.isNotEmpty(rootSourceIds)) {
 | 
	
		
			
				|  |  | +                List<LongArticlesRootSourceId> rootSourceIdItemList = new ArrayList<>();
 | 
	
		
			
				|  |  | +                for (String rootSourceId : rootSourceIds) {
 | 
	
		
			
				|  |  | +                    LongArticlesRootSourceId longArticlesRootSourceId = longArticlesRootSourceIdMap.get(rootSourceId);
 | 
	
		
			
				|  |  | +                    if (!Objects.isNull(longArticlesRootSourceId)) {
 | 
	
		
			
				|  |  | +                        rootSourceIdItemList.add(longArticlesRootSourceId);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    LongArticlesPublishMiniprogram longArticlesPublishMiniprogram
 | 
	
		
			
				|  |  | +                            = longArticlesPublishMiniprogramRepository.findByRootSourceIdEquals(rootSourceId);
 | 
	
		
			
				|  |  | +                    if (!Objects.isNull(longArticlesPublishMiniprogram)) {
 | 
	
		
			
				|  |  | +                        if (longArticlesPublishMiniprogram.getNewVideoCoverId() != null) {
 | 
	
		
			
				|  |  | +                            isTest = true;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                String contentId = rootSourceIdItemList.get(0).getContentId();
 | 
	
		
			
				|  |  | +                List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoMap.get(contentId);
 | 
	
		
			
				|  |  | +                List<String> videoOssPaths = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
 | 
	
		
			
				|  |  | +                        .filter(StringUtils::hasText).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                List<PublishSingleVideoSource> singleVideoSources = videoPoolRepository.getByVideoOssPathIn(videoOssPaths);
 | 
	
		
			
				|  |  | +                if (CollectionUtil.isNotEmpty(singleVideoSources)) {
 | 
	
		
			
				|  |  | +                    isVideo = true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (CollectionUtil.isNotEmpty(crawlerVideoList) && crawlerVideoList.size() == 1) {
 | 
	
		
			
				|  |  | +                    isSameMiniProgram = true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<ArticleDetailInfo> detailInfoList = articleDetailInfoMap.get(article.getWxSn());
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isEmpty(detailInfoList)) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByGhIdEqualsAndStatusEquals(article.getGhId(), 1);
 | 
	
		
			
				|  |  | +            Integer fans = 0;
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(accountAvgInfoList)) {
 | 
	
		
			
				|  |  | +                fans = accountAvgInfoList.get(0).getFans();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (isSameMiniProgram && isTest) {
 | 
	
		
			
				|  |  | +                CoverStatisticOneDataExport coverStatisticOneDataExport = new CoverStatisticOneDataExport();
 | 
	
		
			
				|  |  | +                if (isVideo) {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setChannel("视频");
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setChannel("文章");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                coverStatisticOneDataExport.setDateStr(dateStr);
 | 
	
		
			
				|  |  | +                coverStatisticOneDataExport.setAccountName(article.getAccountName());
 | 
	
		
			
				|  |  | +                coverStatisticOneDataExport.setTitle(article.getTitle());
 | 
	
		
			
				|  |  | +                coverStatisticOneDataExport.setContentUrl(article.getContentUrl());
 | 
	
		
			
				|  |  | +                if (article.getItemIndex() == 1) {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setIndex("头条");
 | 
	
		
			
				|  |  | +                } else if (article.getItemIndex() == 2) {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setIndex("次条");
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setIndex("3-8条");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                coverStatisticOneDataExport.setFans(fans);
 | 
	
		
			
				|  |  | +                coverStatisticOneDataExport.setShowViewCount(article.getShowViewCount());
 | 
	
		
			
				|  |  | +                for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
 | 
	
		
			
				|  |  | +                    if (articleDetailInfo.getFirstLevel() != null) {
 | 
	
		
			
				|  |  | +                        coverStatisticOneDataExport.setAllFirstLevel(coverStatisticOneDataExport.getAllFirstLevel() + articleDetailInfo.getFirstLevel());
 | 
	
		
			
				|  |  | +                        if (articleDetailInfo.getVideoIndex() == 1) {
 | 
	
		
			
				|  |  | +                            coverStatisticOneDataExport.setOneFirstLevel(coverStatisticOneDataExport.getOneFirstLevel() + articleDetailInfo.getFirstLevel());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        if (articleDetailInfo.getVideoIndex() == 2) {
 | 
	
		
			
				|  |  | +                            coverStatisticOneDataExport.setTwoFirstLevel(coverStatisticOneDataExport.getTwoFirstLevel() + articleDetailInfo.getFirstLevel());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (articleDetailInfo.getFission0() != null) {
 | 
	
		
			
				|  |  | +                        coverStatisticOneDataExport.setAllFission0(coverStatisticOneDataExport.getAllFission0() + articleDetailInfo.getFission0());
 | 
	
		
			
				|  |  | +                        if (articleDetailInfo.getVideoIndex() == 1) {
 | 
	
		
			
				|  |  | +                            coverStatisticOneDataExport.setOneFission0(coverStatisticOneDataExport.getOneFission0() + articleDetailInfo.getFission0());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        if (articleDetailInfo.getVideoIndex() == 2) {
 | 
	
		
			
				|  |  | +                            coverStatisticOneDataExport.setTwoFission0(coverStatisticOneDataExport.getTwoFission0() + articleDetailInfo.getFission0());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (coverStatisticOneDataExport.getShowViewCount() != 0 && coverStatisticOneDataExport.getFans() != 0) {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setShowViewRate((double) coverStatisticOneDataExport.getShowViewCount() / coverStatisticOneDataExport.getFans());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (coverStatisticOneDataExport.getShowViewCount() != 0) {
 | 
	
		
			
				|  |  | +                    if (coverStatisticOneDataExport.getAllFirstLevel() != 0) {
 | 
	
		
			
				|  |  | +                        coverStatisticOneDataExport.setAllFirstLevelRate((double) coverStatisticOneDataExport.getAllFirstLevel() / coverStatisticOneDataExport.getShowViewCount());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (coverStatisticOneDataExport.getOneFirstLevel() != 0) {
 | 
	
		
			
				|  |  | +                        coverStatisticOneDataExport.setOneFirstLevelRate((double) coverStatisticOneDataExport.getOneFirstLevel() / coverStatisticOneDataExport.getShowViewCount());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (coverStatisticOneDataExport.getTwoFirstLevel() != 0) {
 | 
	
		
			
				|  |  | +                        coverStatisticOneDataExport.setTwoFirstLevelRate((double) coverStatisticOneDataExport.getTwoFirstLevel() / coverStatisticOneDataExport.getShowViewCount());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (coverStatisticOneDataExport.getAllFirstLevel() != 0 && coverStatisticOneDataExport.getAllFission0() != 0) {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setAllFission0Rate((double) coverStatisticOneDataExport.getAllFission0() / coverStatisticOneDataExport.getAllFirstLevel());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (coverStatisticOneDataExport.getOneFirstLevel() != 0 && coverStatisticOneDataExport.getOneFission0() != 0) {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setOneFission0Rate((double) coverStatisticOneDataExport.getOneFission0() / coverStatisticOneDataExport.getOneFirstLevel());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (coverStatisticOneDataExport.getTwoFirstLevel() != 0 && coverStatisticOneDataExport.getTwoFission0() != 0) {
 | 
	
		
			
				|  |  | +                    coverStatisticOneDataExport.setTwoFission0Rate((double) coverStatisticOneDataExport.getTwoFission0() / coverStatisticOneDataExport.getTwoFirstLevel());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                result.add(coverStatisticOneDataExport);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (!CollectionUtils.isEmpty(result)) {
 | 
	
		
			
				|  |  | +            result = result.stream().sorted(Comparator.comparing(CoverStatisticOneDataExport::getChannel)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void save(CoverStatisticDataExport coverStatisticDataExport, Integer fans, Integer showViewCount) {
 | 
	
		
			
				|  |  | +        if (fans != null) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport.setFans(coverStatisticDataExport.getFans() + fans);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (showViewCount != null) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport.setShowViewCount(coverStatisticDataExport.getShowViewCount() + showViewCount);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        coverStatisticDataExport.setPublishCount(coverStatisticDataExport.getPublishCount() + 1);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void saveMini(CoverStatisticDataExport coverStatisticDataExport, Integer firstLevel, Integer fission0, Integer index) {
 | 
	
		
			
				|  |  | +        if (firstLevel != null) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport.setAllFirstLevel(coverStatisticDataExport.getAllFirstLevel() + firstLevel);
 | 
	
		
			
				|  |  | +            if (index == 1) {
 | 
	
		
			
				|  |  | +                coverStatisticDataExport.setOneFirstLevel(coverStatisticDataExport.getOneFirstLevel() + firstLevel);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (index == 2) {
 | 
	
		
			
				|  |  | +                coverStatisticDataExport.setTwoFirstLevel(coverStatisticDataExport.getTwoFirstLevel() + firstLevel);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (fission0 != null) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport.setAllFission0(coverStatisticDataExport.getAllFission0() + fission0);
 | 
	
		
			
				|  |  | +            if (index == 1) {
 | 
	
		
			
				|  |  | +                coverStatisticDataExport.setOneFission0(coverStatisticDataExport.getOneFission0() + fission0);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (index == 2) {
 | 
	
		
			
				|  |  | +                coverStatisticDataExport.setTwoFission0(coverStatisticDataExport.getTwoFission0() + fission0);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void sum(CoverStatisticDataExport sumCoverStatisticDataExport,
 | 
	
		
			
				|  |  | +                     CoverStatisticDataExport coverStatisticDataExport1,
 | 
	
		
			
				|  |  | +                     CoverStatisticDataExport coverStatisticDataExport2,
 | 
	
		
			
				|  |  | +                     CoverStatisticDataExport coverStatisticDataExport3) {
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setFans(coverStatisticDataExport1.getFans() + coverStatisticDataExport2.getFans() + coverStatisticDataExport3.getFans());
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setPublishCount(coverStatisticDataExport1.getPublishCount() + coverStatisticDataExport2.getPublishCount() + coverStatisticDataExport3.getPublishCount());
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setShowViewCount(coverStatisticDataExport1.getShowViewCount() + coverStatisticDataExport2.getShowViewCount() + coverStatisticDataExport3.getShowViewCount());
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setAllFirstLevel(coverStatisticDataExport1.getAllFirstLevel() + coverStatisticDataExport2.getAllFirstLevel() + coverStatisticDataExport3.getAllFirstLevel());
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setOneFirstLevel(coverStatisticDataExport1.getOneFirstLevel() + coverStatisticDataExport2.getOneFirstLevel() + coverStatisticDataExport3.getOneFirstLevel());
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setTwoFirstLevel(coverStatisticDataExport1.getTwoFirstLevel() + coverStatisticDataExport2.getTwoFirstLevel() + coverStatisticDataExport3.getTwoFirstLevel());
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setAllFission0(coverStatisticDataExport1.getAllFission0() + coverStatisticDataExport2.getAllFission0() + coverStatisticDataExport3.getAllFission0());
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setOneFission0(coverStatisticDataExport1.getOneFission0() + coverStatisticDataExport2.getOneFission0() + coverStatisticDataExport3.getOneFission0());
 | 
	
		
			
				|  |  | +        sumCoverStatisticDataExport.setTwoFission0(coverStatisticDataExport1.getTwoFission0() + coverStatisticDataExport2.getTwoFission0() + coverStatisticDataExport3.getTwoFission0());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private CoverStatisticDataExport rate(CoverStatisticDataExport coverStatisticDataExport) {
 | 
	
		
			
				|  |  | +        if (coverStatisticDataExport.getShowViewCount() != 0 && coverStatisticDataExport.getFans() != 0) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport.setShowViewRate((double) coverStatisticDataExport.getShowViewCount() / coverStatisticDataExport.getFans());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (coverStatisticDataExport.getShowViewCount() != 0) {
 | 
	
		
			
				|  |  | +            if (coverStatisticDataExport.getAllFirstLevel() != 0) {
 | 
	
		
			
				|  |  | +                coverStatisticDataExport.setAllFirstLevelRate((double) coverStatisticDataExport.getAllFirstLevel() / coverStatisticDataExport.getShowViewCount());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (coverStatisticDataExport.getOneFirstLevel() != 0) {
 | 
	
		
			
				|  |  | +                coverStatisticDataExport.setOneFirstLevelRate((double) coverStatisticDataExport.getOneFirstLevel() / coverStatisticDataExport.getShowViewCount());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (coverStatisticDataExport.getTwoFirstLevel() != 0) {
 | 
	
		
			
				|  |  | +                coverStatisticDataExport.setTwoFirstLevelRate((double) coverStatisticDataExport.getTwoFirstLevel() / coverStatisticDataExport.getShowViewCount());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (coverStatisticDataExport.getAllFirstLevel() != 0 && coverStatisticDataExport.getAllFission0() != 0) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport.setAllFission0Rate((double) coverStatisticDataExport.getAllFission0() / coverStatisticDataExport.getAllFirstLevel());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (coverStatisticDataExport.getOneFirstLevel() != 0 && coverStatisticDataExport.getOneFission0() != 0) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport.setOneFission0Rate((double) coverStatisticDataExport.getOneFission0() / coverStatisticDataExport.getOneFirstLevel());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (coverStatisticDataExport.getTwoFirstLevel() != 0 && coverStatisticDataExport.getTwoFission0() != 0) {
 | 
	
		
			
				|  |  | +            coverStatisticDataExport.setTwoFission0Rate((double) coverStatisticDataExport.getTwoFission0() / coverStatisticDataExport.getTwoFirstLevel());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return coverStatisticDataExport;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @XxlJob("dailyAuditProduceExport")
 | 
	
		
			
				|  |  | +    public ReturnT<String> dailyAuditProduceJob(String param) {
 | 
	
		
			
				|  |  | +        List<String> dateStrList = DateUtils.getBeforeDays(null, null, 1);
 | 
	
		
			
				|  |  | +        dailyAuditProduce(dateStrList);
 | 
	
		
			
				|  |  | +        return ReturnT.SUCCESS;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void dailyAuditProduce(String dateStr) {
 | 
	
		
			
				|  |  | +        if (!StringUtils.hasText(dateStr)) {
 | 
	
		
			
				|  |  | +            dateStr = DateUtils.getBeforeDaysDateStr("yyyyMMdd", 1);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        dailyAuditProduce(Collections.singletonList(dateStr));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void dailyAuditProduce(List<String> dateStrList) {
 | 
	
		
			
				|  |  | +        List<DailyAuditProduceExport> exportList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        dateStrList = Lists.reverse(dateStrList);
 | 
	
		
			
				|  |  | +        for (String dateStr : dateStrList) {
 | 
	
		
			
				|  |  | +            exportList.addAll(buildDailyAuditProduceExport(dateStr));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (CollectionUtil.isEmpty(exportList)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        int rowNum = exportList.size();
 | 
	
		
			
				|  |  | +        List<List<Object>> rows = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Field[] fields = DailyAuditProduceExport.class.getDeclaredFields();
 | 
	
		
			
				|  |  | +        for (DailyAuditProduceExport 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());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Pair<String, String>> styles = Arrays
 | 
	
		
			
				|  |  | +                .asList(
 | 
	
		
			
				|  |  | +                        Pair.of("F", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("I", "0.00%")
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +        List<Pair<String, List<Pair<String, String>>>> thank = Arrays
 | 
	
		
			
				|  |  | +                .asList(
 | 
	
		
			
				|  |  | +                        Pair.of("B", Arrays.asList(
 | 
	
		
			
				|  |  | +                                Pair.of("长文审核", "#BACEFD"),
 | 
	
		
			
				|  |  | +                                Pair.of("文章内容池", "#FED4A4")))
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +        doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "Lushkl", rowNum, rows,
 | 
	
		
			
				|  |  | +                3, styles, null, thank);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<DailyAuditProduceExport> buildDailyAuditProduceExport(String dateStr) {
 | 
	
		
			
				|  |  | +        Long startTimeStamp = DateUtils.getStartOfDay(dateStr, "yyyyMMdd") * 1000;
 | 
	
		
			
				|  |  | +        Long endTimeStamp = startTimeStamp + 86400000;
 | 
	
		
			
				|  |  | +        List<DailyAuditProduceExport> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        List<DailyAuditProduceExport> produceAuditList = aigcBaseMapper.getAccountDailyProduceAuditCount(startTimeStamp, endTimeStamp);
 | 
	
		
			
				|  |  | +        List<DailyAuditProduceExport> videoAuditList = longArticleBaseMapper.getAccountDailyVideoAuditCount(startTimeStamp, endTimeStamp);
 | 
	
		
			
				|  |  | +        for (DailyAuditProduceExport dailyAuditProduceExport : produceAuditList) {
 | 
	
		
			
				|  |  | +            dailyAuditProduceExport.setType("长文审核");
 | 
	
		
			
				|  |  | +            result.add(dailyAuditProduceExport);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for (DailyAuditProduceExport dailyAuditProduceExport : videoAuditList) {
 | 
	
		
			
				|  |  | +            dailyAuditProduceExport.setType("文章内容池");
 | 
	
		
			
				|  |  | +            result.add(dailyAuditProduceExport);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for (DailyAuditProduceExport item : result) {
 | 
	
		
			
				|  |  | +            item.setDateStr(dateStr);
 | 
	
		
			
				|  |  | +            if (item.getAuditCount() != null && item.getAuditCount() != 0) {
 | 
	
		
			
				|  |  | +                item.setAuditPassRate((double) item.getAuditPassCount() / item.getAuditCount());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (item.getVideoAuditCount() != null && item.getVideoAuditCount() != 0) {
 | 
	
		
			
				|  |  | +                item.setVideoAuditPassRate((double) item.getVideoAuditPassCount() / item.getVideoAuditCount());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @XxlJob("categoryGroupDataExport")
 | 
	
		
			
				|  |  | +    public ReturnT<String> categoryGroupDataJob(String param) {
 | 
	
		
			
				|  |  | +        List<String> dateStrList = DateUtils.getBeforeDays(null, null, 1);
 | 
	
		
			
				|  |  | +        categoryGroupData(dateStrList);
 | 
	
		
			
				|  |  | +        return ReturnT.SUCCESS;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void categoryGroupData(String dateStr) {
 | 
	
		
			
				|  |  | +        if (!StringUtils.hasText(dateStr)) {
 | 
	
		
			
				|  |  | +            dateStr = DateUtils.getBeforeDaysDateStr("yyyyMMdd", 1);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        categoryGroupData(Collections.singletonList(dateStr));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void categoryGroupData(List<String> dateStrList) {
 | 
	
		
			
				|  |  | +        List<CategoryGroupDataExport> exportList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        dateStrList = Lists.reverse(dateStrList);
 | 
	
		
			
				|  |  | +        for (String dateStr : dateStrList) {
 | 
	
		
			
				|  |  | +            exportList.addAll(buildCategoryGroupDataExport(dateStr));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (CollectionUtil.isEmpty(exportList)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        int rowNum = exportList.size();
 | 
	
		
			
				|  |  | +        List<List<Object>> rows = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Field[] fields = CategoryGroupDataExport.class.getDeclaredFields();
 | 
	
		
			
				|  |  | +        for (CategoryGroupDataExport 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());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Pair<String, String>> styles = Arrays
 | 
	
		
			
				|  |  | +                .asList(
 | 
	
		
			
				|  |  | +                        Pair.of("I", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("J", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("K", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("L", "0.00%")
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +        doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "bl1eL2", rowNum, rows,
 | 
	
		
			
				|  |  | +                2, styles, null, null);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<CategoryGroupDataExport> buildCategoryGroupDataExport(String dateStr) {
 | 
	
		
			
				|  |  | +        List<DatastatSortStrategy> list = datastatSortStrategyRepository.getByDateStr(dateStr);
 | 
	
		
			
				|  |  | +        List<ArticleCategory> articleCategoryList = articleCategoryRepository.getByStatusAndVersion(
 | 
	
		
			
				|  |  | +                ArticleCategoryStatusEnum.SUCCESS.getCode(), activeVersion);
 | 
	
		
			
				|  |  | +        Map<String, ArticleCategory> categoryMap = articleCategoryList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(ArticleCategory::getProduceContentId, Function.identity()));
 | 
	
		
			
				|  |  | +        Map<String, ArticleCategory> titleCategoryMap = articleCategoryList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(ArticleCategory::getTitleMd5, Function.identity(), (a, b) -> a));
 | 
	
		
			
				|  |  | +        Map<String, Map<String, CategoryGroupDataExport>> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        for (DatastatSortStrategy item : list) {
 | 
	
		
			
				|  |  | +            if (Objects.isNull(item.getViewCount()) || Objects.isNull(item.getFirstLevel()) || Objects.isNull(item.getFans())) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            Map<String, CategoryGroupDataExport> positionMap = resultMap.get(ContentPositionEnum.from(item.getPosition()));
 | 
	
		
			
				|  |  | +            if (MapUtils.isEmpty(positionMap)) {
 | 
	
		
			
				|  |  | +                positionMap = new HashMap<>();
 | 
	
		
			
				|  |  | +                resultMap.put(ContentPositionEnum.from(item.getPosition()), positionMap);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            ArticleCategory articleCategory = categoryMap.get(item.getSourceId());
 | 
	
		
			
				|  |  | +            if (Objects.isNull(articleCategory)) {
 | 
	
		
			
				|  |  | +                String titleMd5 = Md5Util.encoderByMd5(item.getTitle());
 | 
	
		
			
				|  |  | +                articleCategory = titleCategoryMap.get(titleMd5);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (Objects.isNull(articleCategory)) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            CategoryGroupDataExport export = positionMap.get(articleCategory.getCategory());
 | 
	
		
			
				|  |  | +            if (Objects.isNull(export)) {
 | 
	
		
			
				|  |  | +                export = new CategoryGroupDataExport();
 | 
	
		
			
				|  |  | +                export.setDateStr(dateStr);
 | 
	
		
			
				|  |  | +                export.setPosition(ContentPositionEnum.from(item.getPosition()));
 | 
	
		
			
				|  |  | +                export.setCategory(articleCategory.getCategory());
 | 
	
		
			
				|  |  | +                positionMap.put(articleCategory.getCategory(), export);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            export.setPublishTimes(export.getPublishTimes() + 1);
 | 
	
		
			
				|  |  | +            export.setViewCount(export.getViewCount() + item.getViewCount());
 | 
	
		
			
				|  |  | +            export.setFirstLevel(export.getFirstLevel() + item.getFirstLevel());
 | 
	
		
			
				|  |  | +            export.setFission0(export.getFission0() + item.getFission0());
 | 
	
		
			
				|  |  | +            export.setFansCount(export.getFansCount() + item.getFans());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<CategoryGroupDataExport> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (Map.Entry<String, Map<String, CategoryGroupDataExport>> entry : resultMap.entrySet()) {
 | 
	
		
			
				|  |  | +            for (Map.Entry<String, CategoryGroupDataExport> item : entry.getValue().entrySet()) {
 | 
	
		
			
				|  |  | +                CategoryGroupDataExport export = item.getValue();
 | 
	
		
			
				|  |  | +                if (export.getFansCount() != null && export.getFansCount() != 0) {
 | 
	
		
			
				|  |  | +                    export.setReadRate((double) export.getViewCount() / export.getFansCount());
 | 
	
		
			
				|  |  | +                    export.setOpenFansRate((double) export.getFirstLevel() / export.getFansCount());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (export.getViewCount() != null && export.getViewCount() != 0) {
 | 
	
		
			
				|  |  | +                    export.setOpenRate(((double) export.getFirstLevel() / export.getViewCount()));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (export.getFirstLevel() != null && export.getFirstLevel() != 0) {
 | 
	
		
			
				|  |  | +                    export.setFissionRate(((double) export.getFission0() / export.getFirstLevel()));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                result.add(export);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        result.addAll(buildCategoryGroupDataSum(dateStr, resultMap));
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<CategoryGroupDataExport> buildCategoryGroupDataSum(String dateStr,
 | 
	
		
			
				|  |  | +                                                                    Map<String, Map<String, CategoryGroupDataExport>> resultMap) {
 | 
	
		
			
				|  |  | +        List<CategoryGroupDataExport> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Map<String, CategoryGroupDataExport> sumMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        for (Map.Entry<String, Map<String, CategoryGroupDataExport>> positionMap : resultMap.entrySet()) {
 | 
	
		
			
				|  |  | +            for (Map.Entry<String, CategoryGroupDataExport> categoryMap : positionMap.getValue().entrySet()) {
 | 
	
		
			
				|  |  | +                String category = categoryMap.getKey();
 | 
	
		
			
				|  |  | +                CategoryGroupDataExport export = sumMap.get(category);
 | 
	
		
			
				|  |  | +                if (Objects.isNull(export)) {
 | 
	
		
			
				|  |  | +                    export = new CategoryGroupDataExport();
 | 
	
		
			
				|  |  | +                    export.setDateStr(dateStr);
 | 
	
		
			
				|  |  | +                    export.setPosition("SUM");
 | 
	
		
			
				|  |  | +                    export.setCategory(category);
 | 
	
		
			
				|  |  | +                    sumMap.put(category, export);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                export.setPublishTimes(export.getPublishTimes() + categoryMap.getValue().getPublishTimes());
 | 
	
		
			
				|  |  | +                export.setViewCount(export.getViewCount() + categoryMap.getValue().getViewCount());
 | 
	
		
			
				|  |  | +                export.setFirstLevel(export.getFirstLevel() + categoryMap.getValue().getFirstLevel());
 | 
	
		
			
				|  |  | +                export.setFission0(export.getFission0() + categoryMap.getValue().getFission0());
 | 
	
		
			
				|  |  | +                export.setFansCount(export.getFansCount() + categoryMap.getValue().getFansCount());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for (Map.Entry<String, CategoryGroupDataExport> item : sumMap.entrySet()) {
 | 
	
		
			
				|  |  | +            CategoryGroupDataExport export = item.getValue();
 | 
	
		
			
				|  |  | +            if (export.getFansCount() != null && export.getFansCount() != 0) {
 | 
	
		
			
				|  |  | +                export.setReadRate((double) export.getViewCount() / export.getFansCount());
 | 
	
		
			
				|  |  | +                export.setOpenFansRate((double) export.getFirstLevel() / export.getFansCount());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (export.getViewCount() != null && export.getViewCount() != 0) {
 | 
	
		
			
				|  |  | +                export.setOpenRate(((double) export.getFirstLevel() / export.getViewCount()));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (export.getFirstLevel() != null && export.getFirstLevel() != 0) {
 | 
	
		
			
				|  |  | +                export.setFissionRate(((double) export.getFission0() / export.getFirstLevel()));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            result.add(export);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @XxlJob("categoryGroupFunnelExport")
 | 
	
		
			
				|  |  | +    public ReturnT<String> categoryGroupFunnelJob(String param) {
 | 
	
		
			
				|  |  | +        List<String> dateStrList = DateUtils.getBeforeDays(null, null, 1);
 | 
	
		
			
				|  |  | +        categoryGroupFunnel(dateStrList);
 | 
	
		
			
				|  |  | +        return ReturnT.SUCCESS;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void categoryGroupFunnel(String dateStr) {
 | 
	
		
			
				|  |  | +        if (!StringUtils.hasText(dateStr)) {
 | 
	
		
			
				|  |  | +            dateStr = DateUtils.getBeforeDaysDateStr("yyyyMMdd", 1);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        categoryGroupFunnel(Collections.singletonList(dateStr));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void categoryGroupFunnel(List<String> dateStrList) {
 | 
	
		
			
				|  |  | +        List<CategoryGroupFunnelExport> exportList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        dateStrList = Lists.reverse(dateStrList);
 | 
	
		
			
				|  |  | +        for (String dateStr : dateStrList) {
 | 
	
		
			
				|  |  | +            exportList.addAll(buildCategoryGroupFunnelExport(dateStr));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (CollectionUtil.isEmpty(exportList)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        int rowNum = exportList.size();
 | 
	
		
			
				|  |  | +        List<List<Object>> rows = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Field[] fields = CategoryGroupFunnelExport.class.getDeclaredFields();
 | 
	
		
			
				|  |  | +        for (CategoryGroupFunnelExport 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());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Pair<String, String>> styles = Arrays
 | 
	
		
			
				|  |  | +                .asList(
 | 
	
		
			
				|  |  | +                        Pair.of("G", "0%"),
 | 
	
		
			
				|  |  | +                        Pair.of("I", "0%"),
 | 
	
		
			
				|  |  | +                        Pair.of("J", "0%"),
 | 
	
		
			
				|  |  | +                        Pair.of("K", "0%"),
 | 
	
		
			
				|  |  | +                        Pair.of("L", "0%"),
 | 
	
		
			
				|  |  | +                        Pair.of("M", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("N", "0%"),
 | 
	
		
			
				|  |  | +                        Pair.of("O", "0%"),
 | 
	
		
			
				|  |  | +                        Pair.of("P", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("Q", "0.00%"),
 | 
	
		
			
				|  |  | +                        Pair.of("R", "0%")
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +        doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "0Lwz8A", rowNum, rows,
 | 
	
		
			
				|  |  | +                2, styles, null, null);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<CategoryGroupFunnelExport> buildCategoryGroupFunnelExport(String dateStr) {
 | 
	
		
			
				|  |  | +        List<CategoryGroupFunnelExport> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Long start = DateUtils.getStartOfDay(dateStr, "yyyyMMdd") * 1000;
 | 
	
		
			
				|  |  | +        Long end = start + 86400000;
 | 
	
		
			
				|  |  | +        Date dateStart = DateUtils.getStartDateOfDay(start / 1000);
 | 
	
		
			
				|  |  | +        Date dateEnd = DateUtils.getStartDateOfDay(end / 1000);
 | 
	
		
			
				|  |  | +        // 匹配
 | 
	
		
			
				|  |  | +        List<CategoryGroupFunnelExport> matchCategoryList = longArticleBaseMapper.getCategoryMatchCount(dateStart, dateEnd);
 | 
	
		
			
				|  |  | +        Map<String, CategoryGroupFunnelExport> categoryMap = matchCategoryList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(CategoryGroupFunnelExport::getCategory, Function.identity()));
 | 
	
		
			
				|  |  | +        for (CategoryGroupFunnelExport item : matchCategoryList) {
 | 
	
		
			
				|  |  | +            item.setDateStr(dateStr);
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(item.getMatchCount()) && item.getMatchCount() > 0) {
 | 
	
		
			
				|  |  | +                item.setMatchSuccessRate(round((double) item.getMatchSuccessCount() / item.getMatchCount(), 2));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            result.add(item);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        // 视频审核
 | 
	
		
			
				|  |  | +        List<CategoryGroupFunnelExport> auditCategoryList = longArticleBaseMapper.getCategoryTitleAuditCount(start, end);
 | 
	
		
			
				|  |  | +        for (CategoryGroupFunnelExport item : auditCategoryList) {
 | 
	
		
			
				|  |  | +            CategoryGroupFunnelExport export = categoryMap.get(item.getCategory());
 | 
	
		
			
				|  |  | +            if (Objects.isNull(export)) {
 | 
	
		
			
				|  |  | +                export = new CategoryGroupFunnelExport();
 | 
	
		
			
				|  |  | +                export.setDateStr(dateStr);
 | 
	
		
			
				|  |  | +                export.setCategory(item.getCategory());
 | 
	
		
			
				|  |  | +                result.add(export);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            export.setVideoAuditPassCount(item.getVideoAuditPassCount());
 | 
	
		
			
				|  |  | +            export.setVideoAuditCount(item.getVideoAuditCount());
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(export.getMatchSuccessCount()) && export.getMatchSuccessCount() > 0
 | 
	
		
			
				|  |  | +                    && Objects.nonNull(export.getVideoAuditCount())) {
 | 
	
		
			
				|  |  | +                export.setAuditRate(round((double) export.getVideoAuditCount() / export.getMatchSuccessCount(), 2));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(export.getVideoAuditCount()) && export.getVideoAuditCount() > 0) {
 | 
	
		
			
				|  |  | +                export.setVideoAuditPassRate(round((double) export.getVideoAuditPassCount() / export.getVideoAuditCount(), 2));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<CategoryGroupDataExport> dataList = buildCategoryGroupDataExport(dateStr);
 | 
	
		
			
				|  |  | +        Map<String, CategoryGroupDataExport> categoryDataMap = dataList.stream().filter(o -> o.getPosition().equals("头条"))
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(CategoryGroupDataExport::getCategory, Function.identity()));
 | 
	
		
			
				|  |  | +        long auditPassTotal = result.stream().filter(o -> Objects.nonNull(o.getVideoAuditPassCount()))
 | 
	
		
			
				|  |  | +                .mapToLong(CategoryGroupFunnelExport::getVideoAuditPassCount).sum();
 | 
	
		
			
				|  |  | +        int viewCountTotal = dataList.stream().filter(o -> o.getPosition().equals("头条"))
 | 
	
		
			
				|  |  | +                .filter(o -> Objects.nonNull(o.getViewCount()))
 | 
	
		
			
				|  |  | +                .mapToInt(CategoryGroupDataExport::getViewCount).sum();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<String> dateStrList = DateUtils.getBeforeDays(null, dateStr, 7);
 | 
	
		
			
				|  |  | +        List<CategoryGroupDataExport> dataSevenDaysList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (String dt : dateStrList) {
 | 
	
		
			
				|  |  | +            dataSevenDaysList.addAll(buildCategoryGroupDataExport(dt));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        int sevenSumViewCount = dataSevenDaysList.stream().filter(o -> o.getPosition().equals("头条"))
 | 
	
		
			
				|  |  | +                .filter(o -> Objects.nonNull(o.getViewCount()))
 | 
	
		
			
				|  |  | +                .mapToInt(CategoryGroupDataExport::getViewCount).sum();
 | 
	
		
			
				|  |  | +        Map<String, List<CategoryGroupDataExport>> categoryDataSevenDaysMap = dataSevenDaysList.stream().filter(o -> o.getPosition().equals("头条"))
 | 
	
		
			
				|  |  | +                .collect(Collectors.groupingBy(CategoryGroupDataExport::getCategory));
 | 
	
		
			
				|  |  | +        double sumReadOpenFissionRate = 0;
 | 
	
		
			
				|  |  | +        for (CategoryGroupFunnelExport export : result) {
 | 
	
		
			
				|  |  | +            CategoryGroupDataExport data = categoryDataMap.get(export.getCategory());
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(data)) {
 | 
	
		
			
				|  |  | +                export.setReadRate(data.getReadRate());
 | 
	
		
			
				|  |  | +                export.setOpenRate(data.getOpenRate());
 | 
	
		
			
				|  |  | +                export.setFissionRate(data.getFissionRate());
 | 
	
		
			
				|  |  | +                if (viewCountTotal > 0 && Objects.nonNull(data.getViewCount())) {
 | 
	
		
			
				|  |  | +                    export.setViewCountProportion(round((double) data.getViewCount() / viewCountTotal, 2));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<CategoryGroupDataExport> sevenDaysCategoryDataList = categoryDataSevenDaysMap.get(export.getCategory());
 | 
	
		
			
				|  |  | +            if (CollectionUtil.isNotEmpty(sevenDaysCategoryDataList)) {
 | 
	
		
			
				|  |  | +                int sevenDaysViewCount = sevenDaysCategoryDataList.stream().filter(o -> Objects.nonNull(o.getViewCount()))
 | 
	
		
			
				|  |  | +                        .mapToInt(CategoryGroupDataExport::getViewCount).sum();
 | 
	
		
			
				|  |  | +                if (sevenSumViewCount > 0) {
 | 
	
		
			
				|  |  | +                    export.setSupplyDemandProportion(round((double) sevenDaysViewCount / sevenSumViewCount, 2));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(export.getVideoAuditPassCount()) && auditPassTotal > 0) {
 | 
	
		
			
				|  |  | +                export.setAuditPassTotalProportion(round((double) export.getVideoAuditPassCount() / auditPassTotal, 2));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(export.getSupplyDemandProportion())
 | 
	
		
			
				|  |  | +                    && export.getSupplyDemandProportion() > 0
 | 
	
		
			
				|  |  | +                    && Objects.nonNull(export.getAuditPassTotalProportion())) {
 | 
	
		
			
				|  |  | +                export.setAuditPassSupplyDemandRate(round(export.getAuditPassTotalProportion() / export.getSupplyDemandProportion(), 2));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(export.getReadRate()) && Objects.nonNull(export.getOpenRate()) && Objects.nonNull(export.getFissionRate())) {
 | 
	
		
			
				|  |  | +                export.setReadOpenFissionRate(export.getReadRate() * export.getOpenRate() * export.getFissionRate());
 | 
	
		
			
				|  |  | +                sumReadOpenFissionRate += export.getReadOpenFissionRate();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for (CategoryGroupFunnelExport item : result) {
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(item.getAuditPassTotalProportion()) && Objects.nonNull(item.getReadOpenFissionRate())
 | 
	
		
			
				|  |  | +                    && item.getReadOpenFissionRate() > 0 && sumReadOpenFissionRate > 0) {
 | 
	
		
			
				|  |  | +                item.setPassReadOpenFissionRate(item.getAuditPassTotalProportion() / (item.getReadOpenFissionRate() / sumReadOpenFissionRate));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        result.sort((o1, o2) -> Double.compare(o2.getReadOpenFissionRate(), o1.getReadOpenFissionRate()));
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private double round(double value, int places) {
 | 
	
		
			
				|  |  | +        BigDecimal bd = BigDecimal.valueOf(value);
 | 
	
		
			
				|  |  | +        bd = bd.setScale(places, RoundingMode.HALF_UP);
 | 
	
		
			
				|  |  | +        return bd.doubleValue();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |