|
@@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -196,7 +198,7 @@ public class ContentPlatformVideoJob {
|
|
|
if (StringUtils.hasText(param)) {
|
|
|
aggDt = param;
|
|
|
}
|
|
|
- List<String> dtList = DateUtil.getBeforeDays(aggDt, null, 7);
|
|
|
+ List<String> dtList = DateUtil.getBeforeDays(aggDt, aggDt, 6);
|
|
|
// 轮询查询大数据获取最近14天视频
|
|
|
for (String dt : dtList) {
|
|
|
long videoGroupScoreCount = getVideoGroupScoreCount(dt);
|
|
@@ -212,8 +214,8 @@ public class ContentPlatformVideoJob {
|
|
|
List<ContentPlatformVideoDataStat> saveList = new ArrayList<>();
|
|
|
for (Record record : dataList) {
|
|
|
ContentPlatformVideoDataStat item = new ContentPlatformVideoDataStat();
|
|
|
- String type =(String) record.get(0);
|
|
|
- String channel =(String) record.get(1);
|
|
|
+ String type = (String) record.get(0);
|
|
|
+ String channel = (String) record.get(1);
|
|
|
Long videoId = Long.parseLong((String) record.get(2));
|
|
|
Long firstLevel = Long.parseLong((String) record.get(3));
|
|
|
Long fission0 = Long.parseLong((String) record.get(4));
|
|
@@ -251,14 +253,55 @@ public class ContentPlatformVideoJob {
|
|
|
|
|
|
private List<ContentPlatformVideoDataStatAgg> buildVideoDataStatAggList(String aggDt, List<String> dtList) {
|
|
|
Long now = System.currentTimeMillis();
|
|
|
+ List<ContentPlatformVideoDataStat> dataStatList = getVideoDatastatList(dtList);
|
|
|
+ Map<Long, Map<String, Map<String, List<ContentPlatformVideoDataStat>>>> videoIdMap = dataStatList.stream()
|
|
|
+ .filter(o -> {
|
|
|
+ if ("sum".equals(o.getChannel())) {
|
|
|
+ return o.getFirstLevel() > 300;
|
|
|
+ } else {
|
|
|
+ return o.getFirstLevel() > 100;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .collect(Collectors.groupingBy(ContentPlatformVideoDataStat::getVideoId,
|
|
|
+ Collectors.groupingBy(ContentPlatformVideoDataStat::getType,
|
|
|
+ Collectors.groupingBy(ContentPlatformVideoDataStat::getChannel))));
|
|
|
List<ContentPlatformVideoDataStatAgg> result = new ArrayList<>();
|
|
|
- for (ContentPlatformVideoDataStatAgg item : result) {
|
|
|
- item.setDt(aggDt);
|
|
|
- item.setCreateTimestamp(now);
|
|
|
+ for (Map.Entry<Long, Map<String, Map<String, List<ContentPlatformVideoDataStat>>>> entry : videoIdMap.entrySet()) {
|
|
|
+ Long videoId = entry.getKey();
|
|
|
+ Map<String, Map<String, List<ContentPlatformVideoDataStat>>> typeMap = entry.getValue();
|
|
|
+ for (Map.Entry<String, Map<String, List<ContentPlatformVideoDataStat>>> typeEntry : typeMap.entrySet()) {
|
|
|
+ String type = typeEntry.getKey();
|
|
|
+ Map<String, List<ContentPlatformVideoDataStat>> channelMap = typeEntry.getValue();
|
|
|
+ for (Map.Entry<String, List<ContentPlatformVideoDataStat>> channelEntry : channelMap.entrySet()) {
|
|
|
+ String channel = channelEntry.getKey();
|
|
|
+ List<ContentPlatformVideoDataStat> statList = channelEntry.getValue();
|
|
|
+ Long sumFirstLevel = statList.stream().map(ContentPlatformVideoDataStat::getFirstLevel).reduce(0L, Long::sum);
|
|
|
+ Long sumFission0 = statList.stream().map(ContentPlatformVideoDataStat::getFission0).reduce(0L, Long::sum);
|
|
|
+ ContentPlatformVideoDataStatAgg item = new ContentPlatformVideoDataStatAgg();
|
|
|
+ item.setDt(aggDt);
|
|
|
+ item.setVideoId(videoId);
|
|
|
+ item.setType(type);
|
|
|
+ item.setChannel(channel);
|
|
|
+ item.setFirstLevel(sumFirstLevel);
|
|
|
+ item.setFission0(sumFission0);
|
|
|
+ if (sumFirstLevel > 0) {
|
|
|
+ BigDecimal fissionRate = new BigDecimal(sumFission0).divide(new BigDecimal(sumFirstLevel), 4, RoundingMode.HALF_UP);
|
|
|
+ item.setFissionRate(fissionRate.doubleValue());
|
|
|
+ }
|
|
|
+ item.setCreateTimestamp(now);
|
|
|
+ result.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private List<ContentPlatformVideoDataStat> getVideoDatastatList(List<String> dtList) {
|
|
|
+ ContentPlatformVideoDataStatExample example = new ContentPlatformVideoDataStatExample();
|
|
|
+ example.createCriteria().andDtIn(dtList);
|
|
|
+ return videoDataStatMapper.selectByExample(example);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|