|
@@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.AccountBusinessTypeEnum;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.aigc.*;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
|
|
@@ -25,6 +26,7 @@ import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRe
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.ArticleDetailInfoRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.PublishSortLogRepository;
|
|
|
+import com.tzld.longarticle.recommend.server.service.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.feishu.FeiShu;
|
|
@@ -123,9 +125,12 @@ public class DataDashboardService {
|
|
|
Pair.of("AD", "0.00%"),
|
|
|
Pair.of("AE", "0.00%"),
|
|
|
Pair.of("AF", "0.00%"),
|
|
|
- Pair.of("AL", "0.00%"),
|
|
|
- Pair.of("AM", "0.00%"),
|
|
|
- Pair.of("AN", "0.00%")
|
|
|
+ Pair.of("AG", "0.00%"),
|
|
|
+ Pair.of("AH", "0.00%"),
|
|
|
+ Pair.of("AI", "0.00%"),
|
|
|
+ Pair.of("AO", "0.00%"),
|
|
|
+ Pair.of("AP", "0.00%"),
|
|
|
+ Pair.of("AQ", "0.00%")
|
|
|
);
|
|
|
|
|
|
doSendFeishuSheet(dateStrList, sheetToken, sheetId, rowNum, rows, 2, styles);
|
|
@@ -134,7 +139,7 @@ public class DataDashboardService {
|
|
|
private List<NewSortStrategyExport> newSortStrategyData(String dateStr) {
|
|
|
long timestamp = DateUtils.dateStrToTimestamp(dateStr, "yyyyMMdd");
|
|
|
String dateStrS = DateUtils.timestampToYMDStr(timestamp, "yyyy-MM-dd");
|
|
|
- List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByUpdateTimeGreaterThanEqual(dateStrS);
|
|
|
+ List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.findAll();
|
|
|
List<String> ghIds = accountAvgInfoList.stream().map(AccountAvgInfo::getGhId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeGreaterThanAndTypeEquals(ghIds, timestamp, "9");
|
|
@@ -176,9 +181,10 @@ public class DataDashboardService {
|
|
|
}
|
|
|
Map<String, Map<String, Map<Long, PublishContent>>> publishContentMap = publishContents.stream()
|
|
|
.sorted(Comparator.comparingLong(PublishContent::getPublishTimestamp)).collect(
|
|
|
- Collectors.groupingBy(PublishContent::getPublishAccountId,
|
|
|
- Collectors.groupingBy(PublishContent::getTitle,
|
|
|
- Collectors.toMap(PublishContent::getPublishTimestamp, o -> o, (existing, replacement) -> replacement))));
|
|
|
+ Collectors.groupingBy(PublishContent::getPublishAccountId,
|
|
|
+ Collectors.groupingBy(PublishContent::getTitle,
|
|
|
+ Collectors.toMap(PublishContent::getPublishTimestamp, o -> o,
|
|
|
+ (existing, replacement) -> replacement))));
|
|
|
// 获取发布内容排版
|
|
|
List<String> publishContentIds = publishContents.stream().map(PublishContent::getId).collect(Collectors.toList());
|
|
|
List<PublishContentLayout> publishContentLayoutList = new ArrayList<>();
|
|
@@ -247,6 +253,26 @@ public class DataDashboardService {
|
|
|
}
|
|
|
Map<String, List<PublishPlanMiniprogramTask>> miniprogramTaskMap = miniprogramTaskList.stream()
|
|
|
.collect(Collectors.groupingBy(PublishPlanMiniprogramTask::getPlanId));
|
|
|
+ // 源生成计划
|
|
|
+ List<String> titleList = articleList.stream().map(Article::getTitle).distinct().collect(Collectors.toList());
|
|
|
+ Map<String, ProducePlan> sourceTitlePlanMap = getTitleSourceProducePlanMap(titleList);
|
|
|
+ // 历史发布情况
|
|
|
+ List<String> titleMd5List = articleList.stream().map(Article::getTitleMd5).distinct().collect(Collectors.toList());
|
|
|
+ List<Article> hisArticleList = new ArrayList<>();
|
|
|
+ List<List<String>> titleMd5Partition = Lists.partition(new ArrayList<>(titleMd5List), 1000);
|
|
|
+ for (List<String> titleMd5s : titleMd5Partition) {
|
|
|
+ hisArticleList.addAll(articleRepository.getByTitleMd5InAndTypeEqualsAndStatusEquals(titleMd5s, "9", 1));
|
|
|
+ }
|
|
|
+ Map<String, List<Article>> hisArticleMap = hisArticleList.stream().collect(Collectors.groupingBy(Article::getTitle));
|
|
|
+ Set<String> hisWxSnList = hisArticleList.stream().map(Article::getWxSn).collect(Collectors.toSet());
|
|
|
+ List<ArticleDetailInfo> hisArticleDetailInfoList = new ArrayList<>();
|
|
|
+ List<List<String>> hisSnPartition = Lists.partition(new ArrayList<>(hisWxSnList), 1000);
|
|
|
+ for (List<String> sns : hisSnPartition) {
|
|
|
+ hisArticleDetailInfoList.addAll(articleDetailInfoRepository.getAllByWxSnIn(sns));
|
|
|
+ }
|
|
|
+ Map<String, List<ArticleDetailInfo>> hisArticleDetailInfoMap = hisArticleDetailInfoList.stream()
|
|
|
+ .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
|
|
|
+
|
|
|
// result
|
|
|
List<NewSortStrategyExport> result = new ArrayList<>();
|
|
|
for (Article article : articleList) {
|
|
@@ -427,6 +453,49 @@ public class DataDashboardService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ ProducePlan sourceProducePlan = sourceTitlePlanMap.get(article.getTitle());
|
|
|
+ if (Objects.nonNull(sourceProducePlan)) {
|
|
|
+ obj.setSourceProducePlanName(sourceProducePlan.getName());
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ Integer readCount = 0;
|
|
|
+ Double readAvgCount = 0.0;
|
|
|
+ int firstCount = 0;
|
|
|
+ int fission0Count = 0;
|
|
|
+ for (Article hisArticle : hisArticles) {
|
|
|
+ readCount += hisArticle.getShowViewCount();
|
|
|
+ AccountAvgInfo accountAvgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, hisArticle.getGhId(),
|
|
|
+ hisArticle.getUpdateTime(), hisArticle.getItemIndex());
|
|
|
+ if (Objects.nonNull(accountAvgInfo)) {
|
|
|
+ readAvgCount += accountAvgInfo.getReadAvg();
|
|
|
+ }
|
|
|
+ List<ArticleDetailInfo> hisADIList = hisArticleDetailInfoMap.get(hisArticle.getWxSn());
|
|
|
+ if (CollectionUtil.isNotEmpty(hisADIList)) {
|
|
|
+ Date hisMinDate = hisADIList.stream().map(ArticleDetailInfo::getRecallDt).min(Date::compareTo).orElse(new Date());
|
|
|
+ for (ArticleDetailInfo articleDetailInfo : hisADIList) {
|
|
|
+ if (articleDetailInfo.getRecallDt().equals(hisMinDate)) {
|
|
|
+ if (Objects.nonNull(articleDetailInfo.getFirstLevel())) {
|
|
|
+ firstCount += articleDetailInfo.getFirstLevel();
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(articleDetailInfo.getFission0())) {
|
|
|
+ fission0Count += articleDetailInfo.getFission0();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (readAvgCount > 0) {
|
|
|
+ obj.setHisReadRate(readCount / readAvgCount);
|
|
|
+ }
|
|
|
+ if (readCount > 0) {
|
|
|
+ obj.setHisFirstReadRate(firstCount / (double) readCount);
|
|
|
+ }
|
|
|
+ if (firstCount > 0) {
|
|
|
+ obj.setHisFission0FirstRate(fission0Count / (double) firstCount);
|
|
|
+ }
|
|
|
}
|
|
|
result.sort(Comparator.comparing(NewSortStrategyExport::getDateStr).reversed()
|
|
|
.thenComparing(NewSortStrategyExport::getGhId).thenComparing(NewSortStrategyExport::getPosition));
|
|
@@ -445,6 +514,35 @@ public class DataDashboardService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private Map<String, ProducePlan> getTitleSourceProducePlanMap(List<String> titleList) {
|
|
|
+ List<ProduceContentDTO> sourceProduceContentList = new ArrayList<>();
|
|
|
+ for (List<String> partitions : Lists.partition(titleList, 1000)) {
|
|
|
+ sourceProduceContentList.addAll(aigcBaseMapper.getSourceProduceContentByTitles(partitions));
|
|
|
+ }
|
|
|
+ Map<String, List<ProduceContentDTO>> sourceProduceContentMap = sourceProduceContentList.stream()
|
|
|
+ .collect(Collectors.groupingBy(ProduceContentDTO::getTitle));
|
|
|
+ Map<String, String> sourceTitlePlanIdMap = new HashMap<>();
|
|
|
+ List<String> sourceProducePlanIds = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<ProduceContentDTO>> entry : sourceProduceContentMap.entrySet()) {
|
|
|
+ String title = entry.getKey();
|
|
|
+ List<ProduceContentDTO> contentList = entry.getValue();
|
|
|
+ contentList.sort(Comparator.comparing(ProduceContentDTO::getProduceTimestamp));
|
|
|
+ sourceTitlePlanIdMap.put(title, contentList.get(0).getProducePlanId());
|
|
|
+ sourceProducePlanIds.add(contentList.get(0).getProducePlanId());
|
|
|
+ }
|
|
|
+ List<ProducePlan> sourceProducePlanList = producePlanRepository.findByIdIn(sourceProducePlanIds);
|
|
|
+ Map<String, ProducePlan> sourceProducePlanMap = sourceProducePlanList.stream()
|
|
|
+ .collect(Collectors.toMap(ProducePlan::getId, o -> o));
|
|
|
+ Map<String, ProducePlan> sourceTitlePlanMap = new HashMap<>();
|
|
|
+ for (Map.Entry<String, String> entry : sourceTitlePlanIdMap.entrySet()) {
|
|
|
+ String title = entry.getKey();
|
|
|
+ String planId = entry.getValue();
|
|
|
+ ProducePlan plan = sourceProducePlanMap.get(planId);
|
|
|
+ sourceTitlePlanMap.put(title, plan);
|
|
|
+ }
|
|
|
+ return sourceTitlePlanMap;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private static void doSendFeishuSheet(List<String> dateStrList, String sheetToken, String sheetId,
|
|
|
int rowNum, List<List<Object>> rows, Integer startRowIndex,
|
|
@@ -515,6 +613,10 @@ public class DataDashboardService {
|
|
|
ResponseEntity<String> response = restTemplate.exchange(String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/values_prepend",
|
|
|
sheetToken),
|
|
|
HttpMethod.POST, postEntity, String.class);
|
|
|
+ JSONObject responseJSON = JSONObject.parseObject(response.getBody());
|
|
|
+ if (0 != responseJSON.getInteger("code")) {
|
|
|
+ log.error("doSendFeishuSheet write error :{}", responseJSON.getString("msg"));
|
|
|
+ }
|
|
|
startRow += partition.size();
|
|
|
}
|
|
|
// // 合并单元格
|