|
@@ -274,9 +274,9 @@ public class RecommendTest {
|
|
|
sortLogList.sort(Comparator.comparing(PublishSortLog::getGhId).thenComparing(PublishSortLog::getDateStr));
|
|
|
List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeGreaterThanAndTypeEquals(ghIds, 1725638400L, "9");
|
|
|
articleList = articleList.stream().filter(o -> o.getItemIndex() == 1).collect(Collectors.toList());
|
|
|
- Map<String, Article> articleMap = articleList.stream().collect(Collectors.toMap(
|
|
|
+ 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));
|
|
|
+ (existing, replacement) -> replacement)));
|
|
|
List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByGhIdIn(new HashSet<>(ghIds));
|
|
|
Map<String, Map<String, AccountAvgInfo>> accountAvgInfoMap = accountAvgInfoList.stream()
|
|
|
.filter(o -> Objects.equals(o.getPosition(), "1")).collect(Collectors.groupingBy(AccountAvgInfo::getGhId,
|
|
@@ -328,7 +328,17 @@ public class RecommendTest {
|
|
|
titleCell.setCellValue("阅读均值倍数");
|
|
|
|
|
|
// 填充数据
|
|
|
+ String title = "";
|
|
|
for (PublishSortLog publishSortLog : sortLogList) {
|
|
|
+ Map<String, Article> dateArticleMap = articleMap.get(publishSortLog.getGhId());
|
|
|
+ Article article = dateArticleMap.get(publishSortLog.getDateStr());
|
|
|
+ if (Objects.isNull(article) || !publishSortLog.getTitle().equals(article.getTitle())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (publishSortLog.getTitle().equals(title)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ title = publishSortLog.getTitle();
|
|
|
rowNum++;
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
Cell cell = row.createCell(0);
|
|
@@ -366,22 +376,21 @@ public class RecommendTest {
|
|
|
cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("ViewCountRateStrategy")).orElse(0.0)));
|
|
|
cell = row.createCell(16);
|
|
|
cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("HisFissionDeWeightAvgReadSumRateStrategy")).orElse(0.0)));
|
|
|
- Article article = articleMap.get(publishSortLog.getDateStr());
|
|
|
- if (Objects.nonNull(article)) {
|
|
|
- cell = row.createCell(17);
|
|
|
- cell.setCellValue(article.getShowViewCount());
|
|
|
- cell = row.createCell(18);
|
|
|
- Map<String, AccountAvgInfo> map = accountAvgInfoMap.get(article.getGhId());
|
|
|
- if (Objects.nonNull(map)) {
|
|
|
- AccountAvgInfo accountAvgInfo = map.get(DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyy-MM-dd"));
|
|
|
- if (Objects.nonNull(accountAvgInfo)) {
|
|
|
- cell.setCellValue(accountAvgInfo.getReadAvg());
|
|
|
- cell = row.createCell(19);
|
|
|
- cell.setCellValue(String.format("%.3f", article.getShowViewCount() / (double) accountAvgInfo.getReadAvg()));
|
|
|
- }
|
|
|
+ cell = row.createCell(17);
|
|
|
+ cell.setCellValue(article.getShowViewCount());
|
|
|
+ cell = row.createCell(18);
|
|
|
+ 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)) {
|
|
|
+ cell.setCellValue(accountAvgInfo.getReadAvg());
|
|
|
+ cell = row.createCell(19);
|
|
|
+ cell.setCellValue(String.format("%.3f", article.getShowViewCount() / (double) accountAvgInfo.getReadAvg()));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
try (FileOutputStream outputStream = new FileOutputStream("/Users/wangyunpeng/Downloads/example.xlsx")) {
|