|  | @@ -18,6 +18,7 @@ import com.tzld.longarticle.recommend.server.model.entity.crawler.PublishSortLog
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.model.param.MiniprogramTaskParam;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
 | 
	
		
			
				|  |  | +import com.tzld.longarticle.recommend.server.model.vo.FirstContentScoreExport;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.model.vo.IntermediateIndicatorsExport;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.model.vo.NewSortStrategyExport;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.model.vo.ProduceAuditLayoutContentObjVO;
 | 
	
	
		
			
				|  | @@ -459,8 +460,8 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              List<Article> hisArticles = hisArticleMap.getOrDefault(article.getTitle(), new ArrayList<>());
 | 
	
		
			
				|  |  |              hisArticles = hisArticles.stream().filter(o -> o.getUpdateTime() < (article.getUpdateTime() - 3600 * 8)
 | 
	
		
			
				|  |  | -                            && (1 == o.getItemIndex() || 2 == o.getItemIndex())
 | 
	
		
			
				|  |  | -                            && !ScoreStrategy.hisContentLateFilter(o.getUpdateTime())).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                    && (1 == o.getItemIndex() || 2 == o.getItemIndex())
 | 
	
		
			
				|  |  | +                    && !ScoreStrategy.hisContentLateFilter(o.getUpdateTime())).collect(Collectors.toList());
 | 
	
		
			
				|  |  |              Integer readCount = 0;
 | 
	
		
			
				|  |  |              Double readAvgCount = 0.0;
 | 
	
		
			
				|  |  |              int firstCount = 0;
 | 
	
	
		
			
				|  | @@ -1317,4 +1318,131 @@ public class DataDashboardService {
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @XxlJob("scheduleExportFirstContentScore")
 | 
	
		
			
				|  |  | +    public ReturnT<String> scheduleExportFirstContentScore(String param) {
 | 
	
		
			
				|  |  | +        List<String> dateStrList = DateUtils.getBeforeDays(null, 1);
 | 
	
		
			
				|  |  | +        exportFeishuFirstContentScore(dateStrList, sheetToken, "XBFd16");
 | 
	
		
			
				|  |  | +        return ReturnT.SUCCESS;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void firstContentScoreExport(String dateStr) {
 | 
	
		
			
				|  |  | +        List<String> dateStrList = DateUtils.getBeforeDays(dateStr, 1);
 | 
	
		
			
				|  |  | +        exportFeishuFirstContentScore(dateStrList, sheetToken, "XBFd16");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void exportFeishuFirstContentScore(List<String> dateStrList, String sheetToken, String sheetId) {
 | 
	
		
			
				|  |  | +        List<FirstContentScoreExport> scoreDataList = firstContentScoreData(dateStrList);
 | 
	
		
			
				|  |  | +        if (CollectionUtil.isEmpty(scoreDataList)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        int rowNum = scoreDataList.size();
 | 
	
		
			
				|  |  | +        List<List<Object>> rows = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Field[] fields = FirstContentScoreExport.class.getDeclaredFields();
 | 
	
		
			
				|  |  | +        for (FirstContentScoreExport datum : scoreDataList) {
 | 
	
		
			
				|  |  | +            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("G", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("H", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("I", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("J", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("K", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("L", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("M", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("N", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("O", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("P", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("Q", "#,##0.00"),
 | 
	
		
			
				|  |  | +                        Pair.of("T", "#,##0.00")
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        doSendFeishuSheet(dateStrList, sheetToken, sheetId, rowNum, rows, 2, styles);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<FirstContentScoreExport> firstContentScoreData(List<String> dateStrList) {
 | 
	
		
			
				|  |  | +        List<FirstContentScoreExport> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        List<PublishSortLog> sortLogList = publishSortLogRepository.findByDateStrIn(dateStrList);
 | 
	
		
			
				|  |  | +        sortLogList = sortLogList.stream().filter(o -> o.getIndex() == 1).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        sortLogList.sort(Comparator.comparing(PublishSortLog::getGhId).thenComparing(PublishSortLog::getDateStr));
 | 
	
		
			
				|  |  | +        List<String> ghIds = sortLogList.stream().map(PublishSortLog::getGhId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        long minTimestamp = DateUtils.dateStrToTimestamp(dateStrList.get(0), "yyyyMMdd");
 | 
	
		
			
				|  |  | +        List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeGreaterThanAndTypeEquals(ghIds, minTimestamp, "9");
 | 
	
		
			
				|  |  | +        articleList = articleList.stream().filter(o -> o.getItemIndex() == 1).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        Map<String, Map<String, Article>> articleMap = articleList.stream().collect(
 | 
	
		
			
				|  |  | +                Collectors.groupingBy(Article::getGhId, Collectors.toMap(
 | 
	
		
			
				|  |  | +                        o -> DateUtils.timestampToYMDStr(o.getUpdateTime(), "yyyyMMdd"), o -> o,
 | 
	
		
			
				|  |  | +                        (existing, replacement) -> replacement)));
 | 
	
		
			
				|  |  | +        String ymd = DateUtils.timestampToYMDStr(minTimestamp - 86400 * 7, "yyyy-MM-dd");
 | 
	
		
			
				|  |  | +        List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByUpdateTimeGreaterThanEqual(ymd);
 | 
	
		
			
				|  |  | +        Map<String, Map<String, AccountAvgInfo>> accountAvgInfoMap = accountAvgInfoList.stream()
 | 
	
		
			
				|  |  | +                .filter(o -> Objects.equals(o.getPosition(), "1")).collect(Collectors.groupingBy(AccountAvgInfo::getGhId,
 | 
	
		
			
				|  |  | +                        Collectors.toMap(AccountAvgInfo::getUpdateTime, o -> o)));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String title = "";
 | 
	
		
			
				|  |  | +        for (PublishSortLog publishSortLog : sortLogList) {
 | 
	
		
			
				|  |  | +            Map<String, Article> dateArticleMap = articleMap.get(publishSortLog.getGhId());
 | 
	
		
			
				|  |  | +            if (Objects.isNull(dateArticleMap)) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            Article article = dateArticleMap.get(publishSortLog.getDateStr());
 | 
	
		
			
				|  |  | +            if (Objects.isNull(article) || !publishSortLog.getTitle().equals(article.getTitle())) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (publishSortLog.getTitle().equals(title)) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            FirstContentScoreExport item = new FirstContentScoreExport();
 | 
	
		
			
				|  |  | +            title = publishSortLog.getTitle();
 | 
	
		
			
				|  |  | +            item.setDateStr(publishSortLog.getDateStr());
 | 
	
		
			
				|  |  | +            item.setGhId(publishSortLog.getGhId());
 | 
	
		
			
				|  |  | +            item.setAccountName(publishSortLog.getAccountName());
 | 
	
		
			
				|  |  | +            item.setTitle(publishSortLog.getTitle());
 | 
	
		
			
				|  |  | +            item.setStrategy(publishSortLog.getStrategy());
 | 
	
		
			
				|  |  | +            item.setScore(Double.valueOf(publishSortLog.getScore()));
 | 
	
		
			
				|  |  | +            JSONObject scoreMap = JSONObject.parseObject(publishSortLog.getScoreMap());
 | 
	
		
			
				|  |  | +            item.setHisFissionFansRateRateStrategy(scoreMap.getDoubleValue("HisFissionFansRateRateStrategy"));
 | 
	
		
			
				|  |  | +            item.setHisFissionAvgReadRateRateStrategy(scoreMap.getDoubleValue("HisFissionAvgReadRateRateStrategy"));
 | 
	
		
			
				|  |  | +            item.setPublishTimesStrategy(scoreMap.getDoubleValue("PublishTimesStrategy"));
 | 
	
		
			
				|  |  | +            item.setViewCountRateCorrelationStrategy(scoreMap.getDoubleValue("ViewCountRateCorrelationStrategy"));
 | 
	
		
			
				|  |  | +            item.setHisFissionAvgReadSumRateStrategy(scoreMap.getDoubleValue("HisFissionAvgReadSumRateStrategy"));
 | 
	
		
			
				|  |  | +            item.setHisFissionAvgReadRateCorrelationRateStrategy(scoreMap.getDoubleValue("HisFissionAvgReadRateCorrelationRateStrategy"));
 | 
	
		
			
				|  |  | +            item.setHisFissionFansSumRateStrategy(scoreMap.getDoubleValue("HisFissionFansSumRateStrategy"));
 | 
	
		
			
				|  |  | +            item.setSimilarityStrategy(scoreMap.getDoubleValue("SimilarityStrategy"));
 | 
	
		
			
				|  |  | +            item.setViewCountStrategy(scoreMap.getDoubleValue("ViewCountStrategy"));
 | 
	
		
			
				|  |  | +            item.setViewCountRateStrategy(scoreMap.getDoubleValue("ViewCountRateStrategy"));
 | 
	
		
			
				|  |  | +            item.setHisFissionDeWeightAvgReadSumRateStrategy(scoreMap.getDoubleValue("HisFissionDeWeightAvgReadSumRateStrategy"));
 | 
	
		
			
				|  |  | +            item.setReadCount(article.getShowViewCount());
 | 
	
		
			
				|  |  | +            Map<String, AccountAvgInfo> map = accountAvgInfoMap.get(article.getGhId());
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(map)) {
 | 
	
		
			
				|  |  | +                List<String> avgMapDateList = new ArrayList<>(map.keySet());
 | 
	
		
			
				|  |  | +                String publishDate = DateUtils.findNearestDate(avgMapDateList,
 | 
	
		
			
				|  |  | +                        DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyy-MM-dd"), "yyyy-MM-dd");
 | 
	
		
			
				|  |  | +                AccountAvgInfo accountAvgInfo = map.get(publishDate);
 | 
	
		
			
				|  |  | +                if (Objects.nonNull(accountAvgInfo)) {
 | 
	
		
			
				|  |  | +                    item.setReadAvg(accountAvgInfo.getReadAvg());
 | 
	
		
			
				|  |  | +                    item.setReadAvgRate(article.getShowViewCount() / (double) accountAvgInfo.getReadAvg());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            result.add(item);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        result.sort(Comparator.comparing(FirstContentScoreExport::getDateStr).reversed()
 | 
	
		
			
				|  |  | +                .thenComparing(FirstContentScoreExport::getGhId));
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |