|
@@ -28,7 +28,6 @@ import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
@@ -88,7 +87,7 @@ public class DataDashboardService {
|
|
|
|
|
|
private void exportFeishuNewSortStrategy(List<String> dateStrList, String sheetToken, String sheetId) {
|
|
|
String minDate = dateStrList.stream().min(String::compareTo).orElse("");
|
|
|
- List<NewSortStrategyExport> newContentsYesData = newSortStrageData(minDate);
|
|
|
+ List<NewSortStrategyExport> newContentsYesData = newSortStrategyData(minDate);
|
|
|
if (CollectionUtil.isEmpty(newContentsYesData)) {
|
|
|
return;
|
|
|
}
|
|
@@ -114,24 +113,25 @@ public class DataDashboardService {
|
|
|
|
|
|
List<Pair<String, String>> styles = Arrays
|
|
|
.asList(
|
|
|
- Pair.of("O", "0.00%"),
|
|
|
Pair.of("P", "0.00%"),
|
|
|
Pair.of("Q", "0.00%"),
|
|
|
Pair.of("R", "0.00%"),
|
|
|
- Pair.of("S", "0.00%")
|
|
|
+ Pair.of("S", "0.00%"),
|
|
|
+ Pair.of("T", "0.00%"),
|
|
|
+ Pair.of("U", "0.00%")
|
|
|
);
|
|
|
|
|
|
doSendFeishuSheet(dateStrList, sheetToken, sheetId, rowNum, rows, 2, styles);
|
|
|
}
|
|
|
|
|
|
- private List<NewSortStrategyExport> newSortStrageData(String dateStr) {
|
|
|
+ private List<NewSortStrategyExport> newSortStrategyData(String dateStr) {
|
|
|
long timestamp = DateUtils.dateStrToTimestamp(dateStr, "yyyyMMdd");
|
|
|
List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByStatusEquals(1);
|
|
|
Set<String> ghIds = accountAvgInfoList.stream().map(AccountAvgInfo::getGhId).collect(Collectors.toSet());
|
|
|
List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeGreaterThan(ghIds, timestamp);
|
|
|
|
|
|
Set<String> snList = articleList.stream().map(Article::getWxSn).collect(Collectors.toSet());
|
|
|
- List<ArticleDetailInfo> articleDetailInfoList = articleDetailInfoRepository.getAllByWxSnIn(snList);
|
|
|
+ List<ArticleDetailInfo> articleDetailInfoList = articleDetailInfoRepository.getAllByWxSnIn(new ArrayList<>(snList));
|
|
|
Map<String, List<ArticleDetailInfo>> articleDetailInfoMap = articleDetailInfoList.stream()
|
|
|
.collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
|
|
|
List<PublishSortLog> sortLogList = publishSortLogRepository.findByGhIdInAndDateStrGreaterThanEqual(ghIds, dateStr);
|
|
@@ -163,8 +163,7 @@ public class DataDashboardService {
|
|
|
}
|
|
|
Map<String, AccountAvgInfo> accountAvgInfoMap = accountAvgInfoIndexMap.get(article.getGhId());
|
|
|
AccountAvgInfo avgInfo = accountAvgInfoMap.get(article.getItemIndex().toString());
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
- String date = sdf.format(new Date(article.getUpdateTime() * 1000));
|
|
|
+ String date = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyyMMdd");
|
|
|
NewSortStrategyExport obj = new NewSortStrategyExport();
|
|
|
obj.setGhId(article.getGhId());
|
|
|
obj.setAccountName(article.getAccountName());
|
|
@@ -173,7 +172,15 @@ public class DataDashboardService {
|
|
|
obj.setPosition(article.getItemIndex());
|
|
|
obj.setViewCount(article.getShowViewCount());
|
|
|
obj.setDateStr(date);
|
|
|
- obj.setStrategy(dateStrategy.get(date));
|
|
|
+ obj.setPublishTime(DateUtils.timestampToYMDStr(article.getUpdateTime(), "HH:mm:ss"));
|
|
|
+ obj.setFirstLevel(sumfirstLevel);
|
|
|
+ obj.setFission0(sumFission0);
|
|
|
+ obj.setFission1(sumFission1);
|
|
|
+ obj.setFission2(sumFission2);
|
|
|
+ obj.setWxSn(article.getWxSn());
|
|
|
+ if (Objects.nonNull(dateStrategy)) {
|
|
|
+ obj.setStrategy(dateStrategy.get(date));
|
|
|
+ }
|
|
|
if (Objects.nonNull(avgInfo)) {
|
|
|
obj.setAccountMode(avgInfo.getAccountMode());
|
|
|
obj.setAccountSource(avgInfo.getAccountSource());
|
|
@@ -183,17 +190,14 @@ public class DataDashboardService {
|
|
|
obj.setAvgViewCount(avgInfo.getReadAvg());
|
|
|
if (avgInfo.getReadAvg() > 0) {
|
|
|
obj.setReadRate((article.getShowViewCount() * 1.0) / avgInfo.getReadAvg());
|
|
|
+ obj.setFission0ReadAvgRate((sumFission0 * 1.0) / avgInfo.getReadAvg());
|
|
|
}
|
|
|
if (avgInfo.getFans() > 0) {
|
|
|
obj.setReadFansRate((article.getShowViewCount() * 1.0) / avgInfo.getFans());
|
|
|
}
|
|
|
}
|
|
|
- obj.setFirstLevel(sumfirstLevel);
|
|
|
- obj.setFission0(sumFission0);
|
|
|
- obj.setFission1(sumFission1);
|
|
|
- obj.setFission2(sumFission2);
|
|
|
if (sumfirstLevel > 0) {
|
|
|
- obj.setFission0ReadAvgRate((sumFission0 * 1.0) / sumfirstLevel);
|
|
|
+ obj.setFission0FirstRate((sumFission0 * 1.0) / sumfirstLevel);
|
|
|
}
|
|
|
if (article.getShowViewCount() > 0) {
|
|
|
obj.setFirstReadRate((sumfirstLevel * 1.0) / article.getShowViewCount());
|
|
@@ -261,7 +265,7 @@ public class DataDashboardService {
|
|
|
delNum = Math.min(delNum + 4000, count);
|
|
|
} while (delNum < count);
|
|
|
}
|
|
|
- List<List<List<Object>>> partitions = Lists.partition(rows, 4000);
|
|
|
+ List<List<List<Object>>> partitions = Lists.partition(rows, 1000);
|
|
|
int startRow = startRowIndex;
|
|
|
for (List<List<Object>> partition : partitions) {
|
|
|
// 插入数据
|
|
@@ -269,7 +273,7 @@ public class DataDashboardService {
|
|
|
.builder()
|
|
|
.put("valueRange", MapBuilder
|
|
|
.builder()
|
|
|
- .put("range", String.format("%s!A" + startRow + ":W", sheetId) + (partition.size() + startRow - 1))
|
|
|
+ .put("range", String.format("%s!A" + startRow + ":Z", sheetId) + (partition.size() + startRow - 1))
|
|
|
.put("values", partition)
|
|
|
.build())
|
|
|
.build(), httpHeaders);
|