|
@@ -34,12 +34,9 @@ import org.springframework.data.util.Pair;
|
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -77,39 +74,16 @@ public class DataDashboardService {
|
|
|
private static final String sheetToken = "M0pLs3uF6hfL0htn2dMcB9eFn8e";
|
|
|
|
|
|
public void export(String dateStr) {
|
|
|
- List<String> dateStrList = getBeforeThreeDays(dateStr);
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(dateStr, 5);
|
|
|
exportFeishuNewSortStrategy(dateStrList, sheetToken, "7d4e12");
|
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 0 4 * * ?")
|
|
|
public void scheduledExport() {
|
|
|
- List<String> dateStrList = getBeforeThreeDays(null);
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(null, 5);
|
|
|
exportFeishuNewSortStrategy(dateStrList, sheetToken, "7d4e12");
|
|
|
}
|
|
|
|
|
|
- private List<String> getBeforeThreeDays(String dateStr) {
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
- // 获取今天的日期
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
- if (!StringUtils.hasText(dateStr)) {
|
|
|
- dateStr = today.format(formatter);
|
|
|
- }
|
|
|
- // 解析输入的日期字符串为LocalDate对象
|
|
|
- LocalDate date = LocalDate.parse(dateStr, formatter);
|
|
|
- // 获取从输入日期前三天的日期
|
|
|
- LocalDate startDate = date.minusDays(3);
|
|
|
- // 存储所有日期的列表
|
|
|
- List<String> datesList = new ArrayList<>();
|
|
|
- // 从startDate到today遍历日期
|
|
|
- while (!startDate.isAfter(today)) {
|
|
|
- // 将当前日期格式化为"yyyyMMdd"并添加到列表中
|
|
|
- datesList.add(startDate.format(formatter));
|
|
|
- // 日期加1天
|
|
|
- startDate = startDate.plusDays(1);
|
|
|
- }
|
|
|
- return datesList;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
private void exportFeishuNewSortStrategy(List<String> dateStrList, String sheetToken, String sheetId) {
|
|
|
String minDate = dateStrList.stream().min(String::compareTo).orElse("");
|
|
@@ -139,15 +113,15 @@ public class DataDashboardService {
|
|
|
|
|
|
List<Pair<String, String>> styles = Arrays
|
|
|
.asList(
|
|
|
- Pair.of("S", "0.00%"),
|
|
|
- Pair.of("T", "0.00%"),
|
|
|
- Pair.of("U", "0.00%"),
|
|
|
- Pair.of("V", "0.00%"),
|
|
|
- Pair.of("W", "0.00%"),
|
|
|
- Pair.of("X", "0.00%"),
|
|
|
+ Pair.of("AA", "0.00%"),
|
|
|
+ Pair.of("AB", "0.00%"),
|
|
|
+ Pair.of("AC", "0.00%"),
|
|
|
Pair.of("AD", "0.00%"),
|
|
|
Pair.of("AE", "0.00%"),
|
|
|
- Pair.of("AF", "0.00%")
|
|
|
+ Pair.of("AF", "0.00%"),
|
|
|
+ Pair.of("AL", "0.00%"),
|
|
|
+ Pair.of("AM", "0.00%"),
|
|
|
+ Pair.of("AN", "0.00%")
|
|
|
);
|
|
|
|
|
|
doSendFeishuSheet(dateStrList, sheetToken, sheetId, rowNum, rows, 2, styles);
|
|
@@ -277,17 +251,39 @@ public class DataDashboardService {
|
|
|
Article firstArticle = articleMap.get(article.getGhId()).get(article.getAppMsgId()).get(1);
|
|
|
Map<String, String> dateStrategy = sortStrategyMap.get(article.getGhId());
|
|
|
Date minDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).min(Date::compareTo).orElse(new Date());
|
|
|
- int sumfirstLevel = 0;
|
|
|
+ Date secondDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).filter(o -> o.after(minDate)).min(Date::compareTo).orElse(new Date());
|
|
|
+ Date thirdDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).filter(o -> o.after(secondDate)).min(Date::compareTo).orElse(new Date());
|
|
|
+ int sumFirstLevel = 0;
|
|
|
int sumFission0 = 0;
|
|
|
int sumFission1 = 0;
|
|
|
int sumFission2 = 0;
|
|
|
+ int sumSecondFirstLevel = 0;
|
|
|
+ int sumSecondFission0 = 0;
|
|
|
+ int sumSecondFission1 = 0;
|
|
|
+ int sumSecondFission2 = 0;
|
|
|
+ int sumThirdFirstLevel = 0;
|
|
|
+ int sumThirdFission0 = 0;
|
|
|
+ int sumThirdFission1 = 0;
|
|
|
+ int sumThirdFission2 = 0;
|
|
|
for (ArticleDetailInfo articleDetailInfo : articleDetailInfos) {
|
|
|
if (articleDetailInfo.getRecallDt().equals(minDate)) {
|
|
|
- sumfirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
|
|
|
+ sumFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
|
|
|
sumFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
|
|
|
sumFission1 += Optional.ofNullable(articleDetailInfo.getFission1()).orElse(0);
|
|
|
sumFission2 += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
|
|
|
}
|
|
|
+ if (articleDetailInfo.getRecallDt().equals(secondDate)) {
|
|
|
+ sumSecondFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
|
|
|
+ sumSecondFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
|
|
|
+ sumSecondFission1 += Optional.ofNullable(articleDetailInfo.getFission1()).orElse(0);
|
|
|
+ sumSecondFission2 += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
|
|
|
+ }
|
|
|
+ if (articleDetailInfo.getRecallDt().equals(thirdDate)) {
|
|
|
+ sumThirdFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
|
|
|
+ sumThirdFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
|
|
|
+ sumThirdFission1 += Optional.ofNullable(articleDetailInfo.getFission1()).orElse(0);
|
|
|
+ sumThirdFission2 += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
|
|
|
+ }
|
|
|
}
|
|
|
Map<String, Map<String, AccountAvgInfo>> dateAvgMap = accountAvgInfoIndexMap.get(article.getGhId());
|
|
|
String hisPublishDate = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyy-MM-dd");
|
|
@@ -312,10 +308,18 @@ public class DataDashboardService {
|
|
|
obj.setViewCount(article.getShowViewCount());
|
|
|
obj.setDateStr(date);
|
|
|
obj.setPublishTime(DateUtils.timestampToYMDStr(article.getUpdateTime(), "HH:mm:ss"));
|
|
|
- obj.setFirstLevel(sumfirstLevel);
|
|
|
+ obj.setFirstLevel(sumFirstLevel);
|
|
|
obj.setFission0(sumFission0);
|
|
|
obj.setFission1(sumFission1);
|
|
|
obj.setFission2(sumFission2);
|
|
|
+ obj.setSecondFirstLevel(sumSecondFirstLevel);
|
|
|
+ obj.setSecondFission0(sumSecondFission0);
|
|
|
+ obj.setSecondFission1(sumSecondFission1);
|
|
|
+ obj.setSecondFission2(sumSecondFission2);
|
|
|
+ obj.setThirdFirstLevel(sumThirdFirstLevel);
|
|
|
+ obj.setThirdFission0(sumThirdFission0);
|
|
|
+ obj.setThirdFission1(sumThirdFission1);
|
|
|
+ obj.setThirdFission2(sumThirdFission2);
|
|
|
obj.setWxSn(article.getWxSn());
|
|
|
if (Objects.nonNull(firstArticle)) {
|
|
|
obj.setFirstViewCount(firstArticle.getShowViewCount());
|
|
@@ -345,11 +349,11 @@ public class DataDashboardService {
|
|
|
obj.setReadFansRate((article.getShowViewCount() * 1.0) / avgInfo.getFans());
|
|
|
}
|
|
|
}
|
|
|
- if (sumfirstLevel > 0) {
|
|
|
- obj.setFission0FirstRate((sumFission0 * 1.0) / sumfirstLevel);
|
|
|
+ if (sumFirstLevel > 0) {
|
|
|
+ obj.setFission0FirstRate((sumFission0 * 1.0) / sumFirstLevel);
|
|
|
}
|
|
|
if (article.getShowViewCount() > 0) {
|
|
|
- obj.setFirstReadRate((sumfirstLevel * 1.0) / article.getShowViewCount());
|
|
|
+ obj.setFirstReadRate((sumFirstLevel * 1.0) / article.getShowViewCount());
|
|
|
}
|
|
|
if (sumFission0 > 0) {
|
|
|
obj.setFission1Fission0Rate((sumFission1 * 1.0) / sumFission0);
|