|
@@ -19,6 +19,8 @@ import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -76,15 +78,16 @@ public class ContentPlatformDatastatJob {
|
|
|
.collect(Collectors.toMap(WxAccountDatastatVO::getAccountId, wxAccountDatastatVO -> wxAccountDatastatVO));
|
|
|
List<ContentPlatformGzhPlan> gzhPlanList = planService.getGzhPlanListByCooperateAccountIds(accountIds);
|
|
|
List<Long> planIds = gzhPlanList.stream().map(ContentPlatformGzhPlan::getId).collect(Collectors.toList());
|
|
|
- Map<Long, Long> gzhPlanMap = gzhPlanList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformGzhPlan::getAccountId, ContentPlatformGzhPlan::getId));
|
|
|
+ Map<Long, List<Long>> gzhPlanMap = gzhPlanList.stream()
|
|
|
+ .collect(Collectors.groupingBy(ContentPlatformGzhPlan::getAccountId,
|
|
|
+ Collectors.mapping(ContentPlatformGzhPlan::getId, Collectors.toList())));
|
|
|
List<ContentPlatformGzhPlanVideo> gzhPlanVideoList = planService.getGzhPlanVideoList(planIds);
|
|
|
Map<Long, List<ContentPlatformGzhPlanVideo>> gzhPlanVideoMap = gzhPlanVideoList.stream()
|
|
|
.collect(Collectors.groupingBy(ContentPlatformGzhPlanVideo::getPlanId));
|
|
|
List<Long> videoIds = gzhPlanVideoList.stream().map(ContentPlatformGzhPlanVideo::getVideoId).collect(Collectors.toList());
|
|
|
List<ContentPlatformVideo> contentPlatformVideoList = planService.getVideoContentListByVideoIds(videoIds);
|
|
|
Map<Long, ContentPlatformVideo> videoMap = contentPlatformVideoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformVideo::getId, video -> video));
|
|
|
+ .collect(Collectors.toMap(ContentPlatformVideo::getVideoId, video -> video, (a, b) -> a));
|
|
|
if (CollectionUtils.isNotEmpty(dataList)) {
|
|
|
List<ContentPlatformGzhDataStat> saveList = new ArrayList<>();
|
|
|
for (Record record : dataList) {
|
|
@@ -102,15 +105,23 @@ public class ContentPlatformDatastatJob {
|
|
|
if (Objects.nonNull(wxAccountDatastatVO)) {
|
|
|
item.setFansIncreaseCount(wxAccountDatastatVO.getFansIncreaseCount());
|
|
|
}
|
|
|
- List<ContentPlatformGzhPlanVideo> videoList = gzhPlanVideoMap.get(gzhPlanMap.get(gzhAccount.getId()));
|
|
|
- if (CollectionUtils.isNotEmpty(videoList)) {
|
|
|
- List<Long> itemVideoIds = videoList.stream().map(ContentPlatformGzhPlanVideo::getVideoId).collect(Collectors.toList());
|
|
|
- Double score = 0.0;
|
|
|
- for (Long videoId : itemVideoIds) {
|
|
|
- score += videoMap.get(videoId).getScore();
|
|
|
+ List<Long> planIdList = gzhPlanMap.get(gzhAccount.getId());
|
|
|
+ Double score = 0.0;
|
|
|
+ int size = 0;
|
|
|
+ for (Long planId : planIdList) {
|
|
|
+ List<ContentPlatformGzhPlanVideo> videoList = gzhPlanVideoMap.get(planId);
|
|
|
+ if (CollectionUtils.isNotEmpty(videoList)) {
|
|
|
+ List<Long> itemVideoIds = videoList.stream().map(ContentPlatformGzhPlanVideo::getVideoId).collect(Collectors.toList());
|
|
|
+ for (Long videoId : itemVideoIds) {
|
|
|
+ score += videoMap.get(videoId).getScore();
|
|
|
+ }
|
|
|
+ size += videoList.size();
|
|
|
}
|
|
|
- item.setScore(score / itemVideoIds.size());
|
|
|
}
|
|
|
+
|
|
|
+ BigDecimal num = BigDecimal.valueOf(score / size);
|
|
|
+ BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setScore(rounded.doubleValue());
|
|
|
item.setCreateTimestamp(now);
|
|
|
saveList.add(item);
|
|
|
}
|
|
@@ -159,9 +170,7 @@ public class ContentPlatformDatastatJob {
|
|
|
List<Long> videoIds = planVideoList.stream().map(ContentPlatformQwPlanVideo::getVideoId).collect(Collectors.toList());
|
|
|
List<ContentPlatformVideo> videoList = planService.getVideoContentListByVideoIds(videoIds);
|
|
|
Map<Long, Double> videoScoreMap = videoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformVideo::getId, ContentPlatformVideo::getScore));
|
|
|
- Map<Long, ContentPlatformVideo> videoMap = videoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformVideo::getId, video -> video));
|
|
|
+ .collect(Collectors.toMap(ContentPlatformVideo::getVideoId, ContentPlatformVideo::getScore, (a, b) -> a));
|
|
|
List<ContentPlatformQwDataStat> saveList = new ArrayList<>();
|
|
|
List<String> rootSourceIds = qwPlanList.stream().map(ContentPlatformQwPlan::getRootSourceId).collect(Collectors.toList());
|
|
|
String outSql = String.format("SELECT * FROM loghubods.qw_out_touliu_behavior_detail WHERE dt=%s;", dt);
|
|
@@ -179,7 +188,9 @@ public class ContentPlatformDatastatJob {
|
|
|
Long planId = rootSourceIdMap.get(rootSourceId);
|
|
|
Long videoId = planVideoMap.get(planId);
|
|
|
Double score = videoScoreMap.get(videoId);
|
|
|
- item.setScore(score);
|
|
|
+ BigDecimal num = BigDecimal.valueOf(score);
|
|
|
+ BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setScore(rounded.doubleValue());
|
|
|
item.setRootSourceId(rootSourceId);
|
|
|
item.setFirstLevelCount(firstLevelCount);
|
|
|
item.setCreateTimestamp(now);
|
|
@@ -200,7 +211,9 @@ public class ContentPlatformDatastatJob {
|
|
|
Long planId = rootSourceIdMap.get(rootSourceId);
|
|
|
Long videoId = planVideoMap.get(planId);
|
|
|
Double score = videoScoreMap.get(videoId);
|
|
|
- item.setScore(score);
|
|
|
+ BigDecimal num = BigDecimal.valueOf(score);
|
|
|
+ BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setScore(rounded.doubleValue());
|
|
|
item.setRootSourceId(rootSourceId);
|
|
|
item.setFirstLevelCount(firstLevelCount);
|
|
|
item.setCreateTimestamp(now);
|