|
@@ -80,14 +80,14 @@ public class DataDashboardService {
|
|
|
private static List<String> ghIdList;
|
|
|
private static final String sheetToken = "M0pLs3uF6hfL0htn2dMcB9eFn8e";
|
|
|
|
|
|
- public void export(String dateStr) {
|
|
|
- List<String> dateStrList = DateUtils.getBeforeDays(dateStr, 5);
|
|
|
+ public void export(String beginDate, String endDate) {
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(beginDate, endDate, 5);
|
|
|
exportFeishuNewSortStrategy(dateStrList, sheetToken, "7d4e12");
|
|
|
}
|
|
|
|
|
|
@XxlJob("scheduledExport")
|
|
|
public ReturnT<String> scheduledExport(String param) {
|
|
|
- List<String> dateStrList = DateUtils.getBeforeDays(null, 5);
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(null, null, 5);
|
|
|
exportFeishuNewSortStrategy(dateStrList, sheetToken, "7d4e12");
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
@@ -95,7 +95,8 @@ public class DataDashboardService {
|
|
|
|
|
|
private void exportFeishuNewSortStrategy(List<String> dateStrList, String sheetToken, String sheetId) {
|
|
|
String minDate = dateStrList.stream().min(String::compareTo).orElse("");
|
|
|
- List<NewSortStrategyExport> newContentsYesData = newSortStrategyData(minDate);
|
|
|
+ String maxDate = dateStrList.stream().max(String::compareTo).orElse("");
|
|
|
+ List<NewSortStrategyExport> newContentsYesData = newSortStrategyData(minDate, maxDate);
|
|
|
if (CollectionUtil.isEmpty(newContentsYesData)) {
|
|
|
return;
|
|
|
}
|
|
@@ -138,24 +139,28 @@ public class DataDashboardService {
|
|
|
doSendFeishuSheet(dateStrList, sheetToken, sheetId, rowNum, rows, 2, styles);
|
|
|
}
|
|
|
|
|
|
- private List<NewSortStrategyExport> newSortStrategyData(String dateStr) {
|
|
|
- long timestamp = DateUtils.dateStrToTimestamp(dateStr, "yyyyMMdd");
|
|
|
- String dateStrS = DateUtils.timestampToYMDStr(timestamp, "yyyy-MM-dd");
|
|
|
+ private List<NewSortStrategyExport> newSortStrategyData(String beginDate, String endDate) {
|
|
|
+ long beginTimestamp = DateUtils.dateStrToTimestamp(beginDate, "yyyyMMdd");
|
|
|
+ long endTimestamp = DateUtils.dateStrToTimestamp(endDate, "yyyyMMdd") + 86400;
|
|
|
List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.findAll();
|
|
|
+ log.info("newSortStrategyData accountAvgInfoList finish");
|
|
|
List<String> ghIds = accountAvgInfoList.stream().map(AccountAvgInfo::getGhId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
- List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeGreaterThanAndTypeEquals(ghIds, timestamp, ArticleTypeEnum.QUNFA.getVal());
|
|
|
+ List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeBetweenAndTypeEquals(ghIds,
|
|
|
+ beginTimestamp, endTimestamp, ArticleTypeEnum.QUNFA.getVal());
|
|
|
Map<String, Map<String, Map<Integer, Article>>> articleMap = articleList.stream().collect(Collectors.groupingBy(Article::getGhId,
|
|
|
Collectors.groupingBy(Article::getAppMsgId, Collectors.toMap(Article::getItemIndex, o -> o))));
|
|
|
-
|
|
|
+ log.info("newSortStrategyData articleList finish");
|
|
|
Set<String> snList = articleList.stream().map(Article::getWxSn).collect(Collectors.toSet());
|
|
|
List<ArticleDetailInfo> articleDetailInfoList = new ArrayList<>();
|
|
|
for (List<String> partitions : Lists.partition(new ArrayList<>(snList), 1000)) {
|
|
|
articleDetailInfoList.addAll(articleDetailInfoRepository.getAllByWxSnIn(partitions));
|
|
|
}
|
|
|
+ log.info("newSortStrategyData articleDetailInfoList finish");
|
|
|
Map<String, List<ArticleDetailInfo>> articleDetailInfoMap = articleDetailInfoList.stream()
|
|
|
.collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
|
|
|
- List<PublishSortLog> sortLogList = publishSortLogRepository.findByGhIdInAndDateStrGreaterThanEqual(ghIds, dateStr);
|
|
|
+ List<PublishSortLog> sortLogList = publishSortLogRepository.findByGhIdInAndDateStrBetween(ghIds, beginDate, endDate);
|
|
|
+ log.info("newSortStrategyData sortLogList finish");
|
|
|
Map<String, Map<String, String>> sortStrategyMap = sortLogList.stream()
|
|
|
.collect(Collectors.groupingBy(PublishSortLog::getGhId,
|
|
|
Collectors.toMap(PublishSortLog::getDateStr, PublishSortLog::getStrategy, (existing, replacement) -> replacement)));
|
|
@@ -165,6 +170,7 @@ public class DataDashboardService {
|
|
|
Collectors.toMap(AccountAvgInfo::getPosition, o -> o))));
|
|
|
// 获取发布账号
|
|
|
List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
|
|
|
+ log.info("newSortStrategyData publishAccountList finish");
|
|
|
Map<String, PublishAccount> publishAccountMap = publishAccountList.stream().collect(Collectors.toMap(PublishAccount::getGhId, o -> o));
|
|
|
// 获取发布内容
|
|
|
List<PublishContentParam> publishContentParamList = articleList.stream().map(article -> {
|
|
@@ -178,9 +184,10 @@ public class DataDashboardService {
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
List<PublishContent> publishContents = new ArrayList<>();
|
|
|
- for (List<PublishContentParam> partitions : Lists.partition(publishContentParamList, 1000)) {
|
|
|
+ for (List<PublishContentParam> partitions : Lists.partition(publishContentParamList, 100)) {
|
|
|
publishContents.addAll(aigcBaseMapper.getPublishContentByTitle(partitions));
|
|
|
}
|
|
|
+ log.info("newSortStrategyData publishContents finish");
|
|
|
Map<String, Map<String, Map<Long, PublishContent>>> publishContentMap = publishContents.stream()
|
|
|
.sorted(Comparator.comparingLong(PublishContent::getPublishTimestamp)).collect(
|
|
|
Collectors.groupingBy(PublishContent::getPublishAccountId,
|
|
@@ -193,6 +200,7 @@ public class DataDashboardService {
|
|
|
for (List<String> partitions : Lists.partition(publishContentIds, 1000)) {
|
|
|
publishContentLayoutList.addAll(publishContentLayOutRepository.findByPublishContentIdIn(partitions));
|
|
|
}
|
|
|
+ log.info("newSortStrategyData publishContentLayoutList finish");
|
|
|
Map<String, PublishContentLayout> publishContentLayoutMap = publishContentLayoutList.stream()
|
|
|
.collect(Collectors.toMap(PublishContentLayout::getPublishContentId, o -> o,
|
|
|
(existing, replacement) -> replacement));
|
|
@@ -200,6 +208,7 @@ public class DataDashboardService {
|
|
|
List<String> publishPlanIds = publishContents.stream().map(PublishContent::getPlanId).distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
List<PublishPlan> publishPlanList = publishPlanRepository.findByIdIn(publishPlanIds);
|
|
|
+ log.info("newSortStrategyData publishPlanList finish");
|
|
|
Map<String, PublishPlan> publishPlanMap = publishPlanList.stream()
|
|
|
.collect(Collectors.toMap(PublishPlan::getId, o -> o));
|
|
|
// 获取生成记录
|
|
@@ -210,28 +219,33 @@ public class DataDashboardService {
|
|
|
for (List<String> partitions : Lists.partition(contentSourceIds, 1000)) {
|
|
|
planExeRecordList.addAll(producePlanExeRecordRepository.findByPlanExeIdIn(partitions));
|
|
|
}
|
|
|
+ log.info("newSortStrategyData planExeRecordList finish");
|
|
|
Map<String, ProducePlanExeRecord> planExeRecordMap = planExeRecordList.stream()
|
|
|
.collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, o -> o));
|
|
|
// 获取生成计划
|
|
|
List<String> producePlanIds = planExeRecordList.stream().map(ProducePlanExeRecord::getPlanId).distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
List<ProducePlan> producePlanList = producePlanRepository.findByIdIn(producePlanIds);
|
|
|
+ log.info("newSortStrategyData producePlanList finish");
|
|
|
Map<String, ProducePlan> producePlanMap = producePlanList.stream()
|
|
|
.collect(Collectors.toMap(ProducePlan::getId, o -> o));
|
|
|
// 获取生成计划输入
|
|
|
List<ProducePlanInputSource> inputSourceList = producePlanInputSourceRepository.findByPlanIdIn(producePlanIds);
|
|
|
+ log.info("newSortStrategyData inputSourceList finish");
|
|
|
Map<String, List<ProducePlanInputSource>> inputSourceMap = inputSourceList.stream()
|
|
|
.collect(Collectors.groupingBy(ProducePlanInputSource::getPlanId));
|
|
|
// 获取抓取内容关联
|
|
|
List<String> crawlerChannelContentIds = publishContents.stream().map(PublishContent::getCrawlerChannelContentId)
|
|
|
.distinct().collect(Collectors.toList());
|
|
|
List<CrawlerPlanResultRel> resultRelList = aigcBaseMapper.getCrawlerPlanRelByChannelContentIds(crawlerChannelContentIds);
|
|
|
+ log.info("newSortStrategyData resultRelList finish");
|
|
|
Map<String, List<CrawlerPlanResultRel>> resultRelMap = resultRelList.stream()
|
|
|
.collect(Collectors.groupingBy(CrawlerPlanResultRel::getChannelSourceId));
|
|
|
// 获取抓取计划
|
|
|
List<String> crawlerPlanIds = resultRelList.stream().map(CrawlerPlanResultRel::getPlanId).distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
List<CrawlerPlan> crawlerPlanList = aigcBaseMapper.getCrawlerPlanByPlanIds(crawlerPlanIds);
|
|
|
+ log.info("newSortStrategyData crawlerPlanList finish");
|
|
|
Map<String, CrawlerPlan> crawlerPlanMap = crawlerPlanList.stream()
|
|
|
.collect(Collectors.toMap(CrawlerPlan::getId, o -> o));
|
|
|
// 获取小程序任务
|
|
@@ -253,11 +267,13 @@ public class DataDashboardService {
|
|
|
for (List<MiniprogramTaskParam> partitions : Lists.partition(miniprogramTaskParamList, 1000)) {
|
|
|
miniprogramTaskList.addAll(aigcBaseMapper.getMiniProgramTask(partitions));
|
|
|
}
|
|
|
+ log.info("newSortStrategyData miniprogramTaskList finish");
|
|
|
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);
|
|
|
+ log.info("newSortStrategyData sourceTitlePlan finish");
|
|
|
// 历史发布情况
|
|
|
List<String> titleMd5List = articleList.stream().map(Article::getTitleMd5).distinct().collect(Collectors.toList());
|
|
|
List<Article> hisArticleList = new ArrayList<>();
|
|
@@ -265,6 +281,7 @@ public class DataDashboardService {
|
|
|
for (List<String> titleMd5s : titleMd5Partition) {
|
|
|
hisArticleList.addAll(articleRepository.getByTitleMd5InAndTypeEqualsAndStatusEquals(titleMd5s, ArticleTypeEnum.QUNFA.getVal(), 1));
|
|
|
}
|
|
|
+ log.info("newSortStrategyData hisArticleList finish");
|
|
|
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<>();
|
|
@@ -272,6 +289,7 @@ public class DataDashboardService {
|
|
|
for (List<String> sns : hisSnPartition) {
|
|
|
hisArticleDetailInfoList.addAll(articleDetailInfoRepository.getAllByWxSnIn(sns));
|
|
|
}
|
|
|
+ log.info("newSortStrategyData hisArticleDetailInfoList finish");
|
|
|
Map<String, List<ArticleDetailInfo>> hisArticleDetailInfoMap = hisArticleDetailInfoList.stream()
|
|
|
.collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
|
|
|
|
|
@@ -377,10 +395,11 @@ public class DataDashboardService {
|
|
|
obj.setSourceProducePlanName(sourceProducePlan.getName());
|
|
|
}
|
|
|
}
|
|
|
+ log.info("newSortStrategyData buildData finish");
|
|
|
result.sort(Comparator.comparing(NewSortStrategyExport::getDateStr).reversed()
|
|
|
.thenComparing(NewSortStrategyExport::getGhId).thenComparing(NewSortStrategyExport::getPosition));
|
|
|
if (CollectionUtils.isNotEmpty(result)) {
|
|
|
- longArticleBaseMapper.deleteByDateStrGreaterThanEqual(dateStr);
|
|
|
+ longArticleBaseMapper.deleteByDateStrBetween(beginDate, endDate);
|
|
|
List<DatastatSortStrategy> saveList = new ArrayList<>();
|
|
|
for (NewSortStrategyExport newSortStrategyExport : result) {
|
|
|
DatastatSortStrategy item = new DatastatSortStrategy();
|
|
@@ -391,6 +410,7 @@ public class DataDashboardService {
|
|
|
longArticleBaseMapper.batchInsertDatastatSortStrategy(saveListPartition);
|
|
|
}
|
|
|
}
|
|
|
+ log.info("newSortStrategyData finish");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -697,15 +717,15 @@ public class DataDashboardService {
|
|
|
|
|
|
@XxlJob("scheduleExportIntermediateIndicators")
|
|
|
public ReturnT<String> scheduleIntermediateIndicatorsExport(String param) {
|
|
|
- List<String> dateStrList = DateUtils.getBeforeDays(null, 3);
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(null, null, 3);
|
|
|
for (String date : dateStrList) {
|
|
|
exportFeishuIntermediateIndicators(date, dateStrList, sheetToken, "OuaLWV");
|
|
|
}
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
- public void intermediateIndicatorsExport(String dateStr) {
|
|
|
- List<String> dateStrList = DateUtils.getBeforeDays(dateStr, 3);
|
|
|
+ public void intermediateIndicatorsExport(String beginDate, String endDate) {
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(beginDate, endDate, 3);
|
|
|
for (String date : dateStrList) {
|
|
|
exportFeishuIntermediateIndicators(date, dateStrList, sheetToken, "OuaLWV");
|
|
|
}
|
|
@@ -1265,13 +1285,13 @@ public class DataDashboardService {
|
|
|
|
|
|
@XxlJob("scheduleExportFirstContentScore")
|
|
|
public ReturnT<String> scheduleExportFirstContentScore(String param) {
|
|
|
- List<String> dateStrList = DateUtils.getBeforeDays(null, 1);
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(null, null, 1);
|
|
|
exportFeishuFirstContentScore(dateStrList, sheetToken, "XBFd16");
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
- public void firstContentScoreExport(String dateStr) {
|
|
|
- List<String> dateStrList = DateUtils.getBeforeDays(dateStr, 1);
|
|
|
+ public void firstContentScoreExport(String beginDate, String endDate) {
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(beginDate, endDate, 1);
|
|
|
exportFeishuFirstContentScore(dateStrList, sheetToken, "XBFd16");
|
|
|
}
|
|
|
|