|
@@ -1,7 +1,6 @@
|
|
|
package com.tzld.piaoquan.api.job;
|
|
|
|
|
|
import com.aliyun.odps.data.Record;
|
|
|
-import com.tzld.piaoquan.api.common.enums.contentplatform.ContentPlatformGzhPlanTypeEnum;
|
|
|
import com.tzld.piaoquan.api.component.AigcApiService;
|
|
|
import com.tzld.piaoquan.api.dao.mapper.contentplatform.*;
|
|
|
import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformDataStatMapperExt;
|
|
@@ -45,9 +44,6 @@ public class ContentPlatformDatastatJob {
|
|
|
@Autowired
|
|
|
private ContentPlatformQwPlanMapper qwPlanMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ContentPlatformQwPlanVideoMapper qwPlanVideoMapper;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ContentPlatformDataStatMapperExt dataStatMapperExt;
|
|
|
|
|
@@ -70,39 +66,30 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
// 公众号自动回复数据统计
|
|
|
- String sql = String.format("SELECT 合作方, 公众号id, 访问人数, 首层访问人数, dt " +
|
|
|
- "FROM loghubods.loghubods.gzh_autoreply_behavior_uv_total WHERE dt=%s;", dt);
|
|
|
+ String sql = String.format("SELECT first_level.channel_shortname, first_level.subchannel, first_level.first_uv, fission.split_uv " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ "left join loghubods.out_channel_mid_split_total fission " +
|
|
|
+ "on first_level.channel_shortname = fission.channel_shortname and first_level.subchannel = fission.subchannel and first_level.dt = fission.dt " +
|
|
|
+ "and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '公众号即时回复' and first_level.tag = '投放渠道内分客户分账号去重';", dt);
|
|
|
List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
// 所有公众号
|
|
|
List<ContentPlatformGzhAccount> accountList = getAllGzhAccount();
|
|
|
Map<String, ContentPlatformGzhAccount> accountMap = accountList.stream()
|
|
|
.collect(Collectors.toMap(ContentPlatformGzhAccount::getGhId, account -> account));
|
|
|
- List<Long> accountIds = accountList.stream().map(ContentPlatformGzhAccount::getId).collect(Collectors.toList());
|
|
|
List<String> ghIds = accountList.stream().map(ContentPlatformGzhAccount::getGhId).collect(Collectors.toList());
|
|
|
List<String> accountExternalIds = accountList.stream().map(ContentPlatformGzhAccount::getExternalId).collect(Collectors.toList());
|
|
|
String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
|
|
|
List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
|
|
|
Map<String, WxAccountDatastatVO> wxAccountDatastatMap = wxAccountDatastatVOList.stream()
|
|
|
.collect(Collectors.toMap(WxAccountDatastatVO::getAccountId, wxAccountDatastatVO -> wxAccountDatastatVO));
|
|
|
- List<ContentPlatformGzhPlan> gzhPlanList = planService.getGzhPlanListByCooperateAccountIds(accountIds,
|
|
|
- ContentPlatformGzhPlanTypeEnum.AUTO_REPLY.getVal());
|
|
|
- List<Long> planIds = gzhPlanList.stream().map(ContentPlatformGzhPlan::getId).collect(Collectors.toList());
|
|
|
- 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<ContentPlatformVideoAgg> contentPlatformVideoList = planService.getVideoContentAggListByVideoIds(videoIds);
|
|
|
- Map<Long, ContentPlatformVideoAgg> videoMap = contentPlatformVideoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformVideoAgg::getVideoId, video -> video, (a, b) -> a));
|
|
|
if (CollectionUtils.isNotEmpty(dataList)) {
|
|
|
List<ContentPlatformGzhDataStat> saveList = new ArrayList<>();
|
|
|
for (Record record : dataList) {
|
|
|
ContentPlatformGzhDataStat item = new ContentPlatformGzhDataStat();
|
|
|
String ghId = (String) record.get(1);
|
|
|
- Integer firstLevelCount = Integer.valueOf((String) record.get(3));
|
|
|
+ Integer firstLevelCount = Integer.valueOf((String) record.get(2));
|
|
|
+ Integer fissionCount = parseInteger(record.get(3));
|
|
|
item.setDateStr(dt);
|
|
|
if (!ghIds.contains(ghId)) {
|
|
|
continue;
|
|
@@ -114,26 +101,9 @@ public class ContentPlatformDatastatJob {
|
|
|
if (Objects.nonNull(wxAccountDatastatVO)) {
|
|
|
item.setFansIncreaseCount(wxAccountDatastatVO.getFansIncreaseCount());
|
|
|
}
|
|
|
- List<Long> planIdList = gzhPlanMap.get(gzhAccount.getId());
|
|
|
- if (CollectionUtils.isEmpty(planIdList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- 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) {
|
|
|
- if (Objects.nonNull(videoMap.get(videoId))) {
|
|
|
- score += videoMap.get(videoId).getScore();
|
|
|
- }
|
|
|
- }
|
|
|
- size += videoList.size();
|
|
|
- }
|
|
|
- }
|
|
|
- if (size > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(score / size);
|
|
|
+
|
|
|
+ if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
}
|
|
@@ -155,8 +125,12 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
// 公众号自动回复数据统计
|
|
|
- String sql = String.format("SELECT channel_shortname, first_uv, dt " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total WHERE tag = '投放渠道内去重' and type = '公众号即时回复' and dt=%s;", dt);
|
|
|
+ String sql = String.format("SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ "left join loghubods.out_channel_mid_split_total fission " +
|
|
|
+ "on first_level.channel_shortname = fission.channel_shortname and first_level.dt = fission.dt " +
|
|
|
+ "and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '公众号即时回复' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
// 所有公众号
|
|
|
List<ContentPlatformAccount> accountList = getAllAccount();
|
|
@@ -165,31 +139,18 @@ public class ContentPlatformDatastatJob {
|
|
|
List<ContentPlatformGzhAccount> gzhAccountList = getAllGzhAccount();
|
|
|
Map<Long, List<ContentPlatformGzhAccount>> gzhAccountMap = gzhAccountList.stream()
|
|
|
.collect(Collectors.groupingBy(ContentPlatformGzhAccount::getCreateAccountId));
|
|
|
- List<Long> accountIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getId).collect(Collectors.toList());
|
|
|
List<String> accountExternalIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getExternalId).collect(Collectors.toList());
|
|
|
String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
|
|
|
List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
|
|
|
Map<String, WxAccountDatastatVO> wxAccountDatastatMap = wxAccountDatastatVOList.stream()
|
|
|
.collect(Collectors.toMap(WxAccountDatastatVO::getAccountId, wxAccountDatastatVO -> wxAccountDatastatVO));
|
|
|
- List<ContentPlatformGzhPlan> gzhPlanList = planService.getGzhPlanListByCooperateAccountIds(accountIds,
|
|
|
- ContentPlatformGzhPlanTypeEnum.AUTO_REPLY.getVal());
|
|
|
- List<Long> planIds = gzhPlanList.stream().map(ContentPlatformGzhPlan::getId).collect(Collectors.toList());
|
|
|
- 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<ContentPlatformVideoAgg> contentPlatformVideoList = planService.getVideoContentAggListByVideoIds(videoIds);
|
|
|
- Map<Long, ContentPlatformVideoAgg> videoMap = contentPlatformVideoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformVideoAgg::getVideoId, video -> video, (a, b) -> a));
|
|
|
if (CollectionUtils.isNotEmpty(dataList)) {
|
|
|
List<ContentPlatformGzhDataStatTotal> saveList = new ArrayList<>();
|
|
|
for (Record record : dataList) {
|
|
|
ContentPlatformGzhDataStatTotal item = new ContentPlatformGzhDataStatTotal();
|
|
|
String channel = record.getString(0);
|
|
|
Integer firstLevelCount = Integer.valueOf((String) record.get(1));
|
|
|
+ Integer fissionCount = parseInteger(record.get(2));
|
|
|
item.setDateStr(dt);
|
|
|
item.setChannel(channel);
|
|
|
item.setFirstLevelCount(firstLevelCount);
|
|
@@ -199,33 +160,16 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
List<ContentPlatformGzhAccount> gzhAccounts = gzhAccountMap.get(account.getId());
|
|
|
int fansIncreaseCount = 0;
|
|
|
- Double score = 0.0;
|
|
|
- int size = 0;
|
|
|
for (ContentPlatformGzhAccount gzhAccount : gzhAccounts) {
|
|
|
WxAccountDatastatVO wxAccountDatastatVO = wxAccountDatastatMap.get(gzhAccount.getExternalId());
|
|
|
if (Objects.nonNull(wxAccountDatastatVO)) {
|
|
|
fansIncreaseCount += wxAccountDatastatVO.getFansIncreaseCount();
|
|
|
}
|
|
|
- List<Long> planIdList = gzhPlanMap.get(gzhAccount.getId());
|
|
|
- if (CollectionUtils.isEmpty(planIdList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- 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) {
|
|
|
- if (Objects.nonNull(videoMap.get(videoId))) {
|
|
|
- score += videoMap.get(videoId).getScore();
|
|
|
- }
|
|
|
- }
|
|
|
- size += videoList.size();
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
item.setFansIncreaseCount(fansIncreaseCount);
|
|
|
- if (size > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(score / size);
|
|
|
+
|
|
|
+ if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
}
|
|
@@ -252,39 +196,30 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
// 公众号自动回复数据统计
|
|
|
- String sql = String.format("SELECT ghid, 首层访问人数, dt " +
|
|
|
- "FROM loghubods.loghubods.fwhhzdyy_data_per_ghid WHERE dt=%s;", dt);
|
|
|
+ String sql = String.format("SELECT first_level.subchannel, first_level.first_uv, fission.split_uv " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ "left join loghubods.out_channel_mid_split_total fission " +
|
|
|
+ "on first_level.subchannel = fission.subchannel and first_level.dt = fission.dt " +
|
|
|
+ "and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '服务号代运营' and first_level.tag = '投放渠道内分客户分账号去重' ;", dt);
|
|
|
List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
// 所有公众号
|
|
|
List<ContentPlatformGzhAccount> accountList = getAllGzhAccount();
|
|
|
Map<String, ContentPlatformGzhAccount> accountMap = accountList.stream()
|
|
|
.collect(Collectors.toMap(ContentPlatformGzhAccount::getGhId, account -> account));
|
|
|
- List<Long> accountIds = accountList.stream().map(ContentPlatformGzhAccount::getId).collect(Collectors.toList());
|
|
|
List<String> ghIds = accountList.stream().map(ContentPlatformGzhAccount::getGhId).collect(Collectors.toList());
|
|
|
List<String> accountExternalIds = accountList.stream().map(ContentPlatformGzhAccount::getExternalId).collect(Collectors.toList());
|
|
|
String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
|
|
|
List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
|
|
|
Map<String, WxAccountDatastatVO> wxAccountDatastatMap = wxAccountDatastatVOList.stream()
|
|
|
.collect(Collectors.toMap(WxAccountDatastatVO::getAccountId, wxAccountDatastatVO -> wxAccountDatastatVO));
|
|
|
- List<ContentPlatformGzhPlan> gzhPlanList = planService.getGzhPlanListByCooperateAccountIds(accountIds,
|
|
|
- ContentPlatformGzhPlanTypeEnum.FWH_PUSH.getVal());
|
|
|
- List<Long> planIds = gzhPlanList.stream().map(ContentPlatformGzhPlan::getId).collect(Collectors.toList());
|
|
|
- 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<ContentPlatformVideoAgg> contentPlatformVideoList = planService.getVideoContentAggListByVideoIds(videoIds);
|
|
|
- Map<Long, ContentPlatformVideoAgg> videoMap = contentPlatformVideoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformVideoAgg::getVideoId, video -> video, (a, b) -> a));
|
|
|
if (CollectionUtils.isNotEmpty(dataList)) {
|
|
|
List<ContentPlatformFwhDataStat> saveList = new ArrayList<>();
|
|
|
for (Record record : dataList) {
|
|
|
ContentPlatformFwhDataStat item = new ContentPlatformFwhDataStat();
|
|
|
String ghId = (String) record.get(0);
|
|
|
Integer firstLevelCount = Integer.valueOf((String) record.get(1));
|
|
|
+ Integer fissionCount = parseInteger(record.get(2));
|
|
|
item.setDateStr(dt);
|
|
|
if (!ghIds.contains(ghId)) {
|
|
|
continue;
|
|
@@ -296,26 +231,9 @@ public class ContentPlatformDatastatJob {
|
|
|
if (Objects.nonNull(wxAccountDatastatVO)) {
|
|
|
item.setFansIncreaseCount(wxAccountDatastatVO.getFansIncreaseCount());
|
|
|
}
|
|
|
- List<Long> planIdList = gzhPlanMap.get(gzhAccount.getId());
|
|
|
- if (CollectionUtils.isEmpty(planIdList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- 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) {
|
|
|
- if (Objects.nonNull(videoMap.get(videoId))) {
|
|
|
- score += videoMap.get(videoId).getScore();
|
|
|
- }
|
|
|
- }
|
|
|
- size += videoList.size();
|
|
|
- }
|
|
|
- }
|
|
|
- if (size > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(score / size);
|
|
|
+
|
|
|
+ if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
}
|
|
@@ -337,8 +255,12 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
// 公众号自动回复数据统计
|
|
|
- String sql = String.format("SELECT channel_shortname, first_uv, dt " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total WHERE tag = '投放渠道内去重' and type = '服务号代运营' and dt=%s;", dt);
|
|
|
+ String sql = String.format("SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ "left join loghubods.out_channel_mid_split_total fission " +
|
|
|
+ "on first_level.channel_shortname = fission.channel_shortname and first_level.dt = fission.dt " +
|
|
|
+ "and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '服务号代运营' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
// 所有公众号
|
|
|
List<ContentPlatformAccount> accountList = getAllAccount();
|
|
@@ -347,31 +269,18 @@ public class ContentPlatformDatastatJob {
|
|
|
List<ContentPlatformGzhAccount> gzhAccountList = getAllGzhAccount();
|
|
|
Map<Long, List<ContentPlatformGzhAccount>> gzhAccountMap = gzhAccountList.stream()
|
|
|
.collect(Collectors.groupingBy(ContentPlatformGzhAccount::getCreateAccountId));
|
|
|
- List<Long> accountIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getId).collect(Collectors.toList());
|
|
|
List<String> accountExternalIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getExternalId).collect(Collectors.toList());
|
|
|
String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
|
|
|
List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
|
|
|
Map<String, WxAccountDatastatVO> wxAccountDatastatMap = wxAccountDatastatVOList.stream()
|
|
|
.collect(Collectors.toMap(WxAccountDatastatVO::getAccountId, wxAccountDatastatVO -> wxAccountDatastatVO));
|
|
|
- List<ContentPlatformGzhPlan> gzhPlanList = planService.getGzhPlanListByCooperateAccountIds(accountIds,
|
|
|
- ContentPlatformGzhPlanTypeEnum.FWH_PUSH.getVal());
|
|
|
- List<Long> planIds = gzhPlanList.stream().map(ContentPlatformGzhPlan::getId).collect(Collectors.toList());
|
|
|
- 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<ContentPlatformVideoAgg> contentPlatformVideoList = planService.getVideoContentAggListByVideoIds(videoIds);
|
|
|
- Map<Long, ContentPlatformVideoAgg> videoMap = contentPlatformVideoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformVideoAgg::getVideoId, video -> video, (a, b) -> a));
|
|
|
if (CollectionUtils.isNotEmpty(dataList)) {
|
|
|
List<ContentPlatformFwhDataStatTotal> saveList = new ArrayList<>();
|
|
|
for (Record record : dataList) {
|
|
|
ContentPlatformFwhDataStatTotal item = new ContentPlatformFwhDataStatTotal();
|
|
|
String channel = record.getString(0);
|
|
|
Integer firstLevelCount = Integer.valueOf((String) record.get(1));
|
|
|
+ Integer fissionCount = parseInteger(record.get(2));
|
|
|
item.setDateStr(dt);
|
|
|
item.setChannel(channel);
|
|
|
item.setFirstLevelCount(firstLevelCount);
|
|
@@ -381,33 +290,16 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
List<ContentPlatformGzhAccount> gzhAccounts = gzhAccountMap.get(account.getId());
|
|
|
int fansIncreaseCount = 0;
|
|
|
- Double score = 0.0;
|
|
|
- int size = 0;
|
|
|
for (ContentPlatformGzhAccount gzhAccount : gzhAccounts) {
|
|
|
WxAccountDatastatVO wxAccountDatastatVO = wxAccountDatastatMap.get(gzhAccount.getExternalId());
|
|
|
if (Objects.nonNull(wxAccountDatastatVO)) {
|
|
|
fansIncreaseCount += wxAccountDatastatVO.getFansIncreaseCount();
|
|
|
}
|
|
|
- List<Long> planIdList = gzhPlanMap.get(gzhAccount.getId());
|
|
|
- if (CollectionUtils.isEmpty(planIdList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- 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) {
|
|
|
- if (Objects.nonNull(videoMap.get(videoId))) {
|
|
|
- score += videoMap.get(videoId).getScore();
|
|
|
- }
|
|
|
- }
|
|
|
- size += videoList.size();
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
item.setFansIncreaseCount(fansIncreaseCount);
|
|
|
- if (size > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(score / size);
|
|
|
+
|
|
|
+ if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
}
|
|
@@ -556,21 +448,20 @@ public class ContentPlatformDatastatJob {
|
|
|
if (StringUtils.hasText(param)) {
|
|
|
dt = param;
|
|
|
}
|
|
|
- dataStatMapperExt.deleteQwDatastatTotal(dt);
|
|
|
Map<String, ContentPlatformQwDataStatTotal> saveMap = new HashMap<>();
|
|
|
- String outSql = String.format("SELECT channel_shortname, first_uv, dt " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total WHERE tag = '投放渠道内去重' and type = '企微外部' and dt=%s;", dt);
|
|
|
-// String outSql = String.format("SELECT * FROM loghubods.qw_out_touliu_behavior_total WHERE dt=%s;", dt);
|
|
|
+ String outSql = String.format("SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ "left join loghubods.out_channel_mid_split_total fission " +
|
|
|
+ "on first_level.channel_shortname = fission.channel_shortname and first_level.dt = fission.dt " +
|
|
|
+ "and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '企微外部' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
List<Record> outDataList = OdpsUtil.getOdpsData(outSql);
|
|
|
Long now = System.currentTimeMillis();
|
|
|
if (CollectionUtils.isNotEmpty(outDataList)) {
|
|
|
for (Record record : outDataList) {
|
|
|
-// String type = (String) record.get(1);
|
|
|
-// if (!"社群".equals(type) && !"自动回复".equals(type)) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
String channel = (String) record.get(0);
|
|
|
int firstLevelCount = Integer.parseInt((String) record.get(1));
|
|
|
+ Integer fissionCount = parseInteger(record.get(2));
|
|
|
if (firstLevelCount == 0) {
|
|
|
continue;
|
|
|
}
|
|
@@ -580,50 +471,20 @@ public class ContentPlatformDatastatJob {
|
|
|
if (item.getFirstLevelCount() == null) {
|
|
|
item.setFirstLevelCount(0);
|
|
|
}
|
|
|
+
|
|
|
+ if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
+ BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setScore(rounded.doubleValue());
|
|
|
+ }
|
|
|
item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
|
|
|
item.setCreateTimestamp(now);
|
|
|
saveMap.put(channel, item);
|
|
|
}
|
|
|
}
|
|
|
-// String out2Sql = String.format("SELECT * FROM loghubods.qw_out2_touliu_behavior_total WHERE dt=%s;", dt);
|
|
|
-// List<Record> out2DataList = OdpsUtil.getOdpsData(out2Sql);
|
|
|
-// if (CollectionUtils.isNotEmpty(out2DataList)) {
|
|
|
-// List<String> out2Channels = new ArrayList<>();
|
|
|
-// for (Record record : out2DataList) {
|
|
|
-// String type = (String) record.get(1);
|
|
|
-// if (!"社群".equals(type) && !"自动回复".equals(type)) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// String channel = (String) record.get(33);
|
|
|
-// int firstLevelCount = Integer.parseInt((String) record.get(6));
|
|
|
-// if (firstLevelCount == 0) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// if (saveMap.containsKey(channel) && !out2Channels.contains(channel)) {
|
|
|
-// saveMap.remove(channel);
|
|
|
-// }
|
|
|
-// ContentPlatformQwDataStatTotal item = saveMap.getOrDefault(channel, new ContentPlatformQwDataStatTotal());
|
|
|
-// item.setDateStr(dt);
|
|
|
-// item.setChannel(channel);
|
|
|
-// if (item.getFirstLevelCount() == null) {
|
|
|
-// item.setFirstLevelCount(0);
|
|
|
-// }
|
|
|
-// item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
|
|
|
-// item.setCreateTimestamp(now);
|
|
|
-// out2Channels.add(channel);
|
|
|
-// saveMap.put(channel, item);
|
|
|
-// }
|
|
|
-// }
|
|
|
List<ContentPlatformQwDataStatTotal> saveList = new ArrayList<>(saveMap.values());
|
|
|
if (CollectionUtils.isNotEmpty(saveList)) {
|
|
|
- List<String> channels = saveList.stream().map(ContentPlatformQwDataStatTotal::getChannel).distinct().collect(Collectors.toList());
|
|
|
- List<ContentPlatformQwDataStatTotal> channelScoreList = dataStatMapperExt.getQwTotalDatastatScoreList(dt, channels);
|
|
|
- Map<String, Double> channelScoreMap = channelScoreList.stream()
|
|
|
- .filter(o -> Objects.nonNull(o.getChannel()) && Objects.nonNull(o.getScore()))
|
|
|
- .collect(Collectors.toMap(ContentPlatformQwDataStatTotal::getChannel, ContentPlatformQwDataStatTotal::getScore, (a, b) -> a));
|
|
|
- for (ContentPlatformQwDataStatTotal item : saveList) {
|
|
|
- item.setScore(channelScoreMap.get(item.getChannel()));
|
|
|
- }
|
|
|
+ dataStatMapperExt.deleteQwDatastatTotal(dt);
|
|
|
dataStatMapperExt.batchInsertQwDatastatTotal(saveList);
|
|
|
}
|
|
|
return ReturnT.SUCCESS;
|
|
@@ -635,7 +496,6 @@ public class ContentPlatformDatastatJob {
|
|
|
if (StringUtils.hasText(param)) {
|
|
|
dt = param;
|
|
|
}
|
|
|
- dataStatMapperExt.deleteQwDatastatReplyTotal(dt);
|
|
|
Map<String, ContentPlatformQwDataStatReplyTotal> saveMap = new HashMap<>();
|
|
|
String outSql = String.format("SELECT * FROM loghubods.qw_out_touliu_behavior_total WHERE dt=%s and 推送方式 = '自动回复';", dt);
|
|
|
List<Record> outDataList = OdpsUtil.getOdpsData(outSql);
|
|
@@ -669,6 +529,7 @@ public class ContentPlatformDatastatJob {
|
|
|
continue;
|
|
|
}
|
|
|
if (saveMap.containsKey(channel) && !out2Channels.contains(channel)) {
|
|
|
+
|
|
|
saveMap.remove(channel);
|
|
|
}
|
|
|
ContentPlatformQwDataStatReplyTotal item = saveMap.getOrDefault(channel, new ContentPlatformQwDataStatReplyTotal());
|
|
@@ -692,6 +553,7 @@ public class ContentPlatformDatastatJob {
|
|
|
for (ContentPlatformQwDataStatReplyTotal item : saveList) {
|
|
|
item.setScore(channelScoreMap.get(item.getChannel()));
|
|
|
}
|
|
|
+ dataStatMapperExt.deleteQwDatastatReplyTotal(dt);
|
|
|
dataStatMapperExt.batchInsertQwDatastatReplyTotal(saveList);
|
|
|
}
|
|
|
return ReturnT.SUCCESS;
|
|
@@ -704,7 +566,12 @@ public class ContentPlatformDatastatJob {
|
|
|
dt = param;
|
|
|
}
|
|
|
List<ContentPlatformQwDataStatSubChannel> saveList = new ArrayList<>();
|
|
|
- String outSql = String.format("SELECT channel, subchannel, first_uv FROM loghubods.qw_out_channel_mid_first_total WHERE dt=%s;", dt);
|
|
|
+ String outSql = String.format("SELECT first_level.channel_shortname, first_level.subchannel, first_level.first_uv, fission.split_uv " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ "left join loghubods.out_channel_mid_split_total fission " +
|
|
|
+ "on first_level.channel_shortname = fission.channel_shortname and first_level.subchannel = fission.subchannel and first_level.dt = fission.dt " +
|
|
|
+ "and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '企微外部' and first_level.tag = '投放渠道内分客户分账号去重' ;", dt);
|
|
|
List<Record> outDataList = OdpsUtil.getOdpsData(outSql);
|
|
|
List<ContentPlatformAccount> accountList = getAllAccount();
|
|
|
Map<String, ContentPlatformAccount> accountMap = accountList.stream()
|
|
@@ -712,20 +579,6 @@ public class ContentPlatformDatastatJob {
|
|
|
List<ContentPlatformQwPlan> qwPlanList = getSubChannelQwPlanList();
|
|
|
Map<Long, List<ContentPlatformQwPlan>> qwPlanMap = qwPlanList.stream().collect(
|
|
|
Collectors.groupingBy(ContentPlatformQwPlan::getCreateAccountId));
|
|
|
- List<Long> qwPlanIds = qwPlanList.stream().map(ContentPlatformQwPlan::getId).collect(Collectors.toList());
|
|
|
- List<ContentPlatformQwPlanVideo> qwPlanVideoList = new ArrayList<>();
|
|
|
- if (CollectionUtils.isNotEmpty(qwPlanIds)) {
|
|
|
- qwPlanVideoList = getSubChannelQwPlanVideoList(qwPlanIds);
|
|
|
- }
|
|
|
- Map<Long, List<ContentPlatformQwPlanVideo>> qwPlanVideoMap = qwPlanVideoList.stream()
|
|
|
- .collect(Collectors.groupingBy(ContentPlatformQwPlanVideo::getPlanId));
|
|
|
- List<Long> videoIdList = qwPlanVideoList.stream().map(ContentPlatformQwPlanVideo::getVideoId).collect(Collectors.toList());
|
|
|
- List<ContentPlatformVideo> videoList = new ArrayList<>();
|
|
|
- if (CollectionUtils.isNotEmpty(videoIdList)) {
|
|
|
- videoList = planService.getVideoContentListByVideoIds(videoIdList);
|
|
|
- }
|
|
|
- Map<Long, Double> videoScoreMap = videoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformVideo::getVideoId, ContentPlatformVideo::getScore, (a, b) -> a));
|
|
|
Long now = System.currentTimeMillis();
|
|
|
if (CollectionUtils.isNotEmpty(outDataList)) {
|
|
|
List<Record> noSubChannelRecordList = new ArrayList<>();
|
|
@@ -733,6 +586,7 @@ public class ContentPlatformDatastatJob {
|
|
|
String channel = (String) record.get(0);
|
|
|
String subChannel = (String) record.get(1);
|
|
|
int firstLevelCount = Integer.parseInt((String) record.get(2));
|
|
|
+ Integer fissionCount = parseInteger(record.get(3));
|
|
|
if (firstLevelCount == 0) {
|
|
|
continue;
|
|
|
}
|
|
@@ -753,23 +607,9 @@ public class ContentPlatformDatastatJob {
|
|
|
if (item.getFirstLevelCount() == null) {
|
|
|
item.setFirstLevelCount(0);
|
|
|
}
|
|
|
- Double score = 0.0;
|
|
|
- int size = 0;
|
|
|
- for (ContentPlatformQwPlan qwPlan : qwPlans) {
|
|
|
- List<ContentPlatformQwPlanVideo> planVideoList = qwPlanVideoMap.get(qwPlan.getId());
|
|
|
- if (CollectionUtils.isEmpty(planVideoList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<Long> videoIds = planVideoList.stream().map(ContentPlatformQwPlanVideo::getVideoId).collect(Collectors.toList());
|
|
|
- size += videoIds.size();
|
|
|
- for (Long videoId : videoIds) {
|
|
|
- if (Objects.nonNull(videoScoreMap.get(videoId))) {
|
|
|
- score += videoScoreMap.get(videoId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (size > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(score / size);
|
|
|
+
|
|
|
+ if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
}
|
|
@@ -780,6 +620,7 @@ public class ContentPlatformDatastatJob {
|
|
|
for (Record record : noSubChannelRecordList) {
|
|
|
String channel = (String) record.get(0);
|
|
|
int firstLevelCount = Integer.parseInt((String) record.get(2));
|
|
|
+ Integer fissionCount = parseInteger(record.get(3));
|
|
|
ContentPlatformQwDataStatSubChannel item = new ContentPlatformQwDataStatSubChannel();
|
|
|
item.setDateStr(dt);
|
|
|
ContentPlatformAccount account = accountMap.get(channel);
|
|
@@ -792,6 +633,12 @@ public class ContentPlatformDatastatJob {
|
|
|
item.setFirstLevelCount(0);
|
|
|
}
|
|
|
item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
|
|
|
+
|
|
|
+ if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
+ BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setScore(rounded.doubleValue());
|
|
|
+ }
|
|
|
item.setCreateTimestamp(now);
|
|
|
saveList.add(item);
|
|
|
}
|
|
@@ -808,11 +655,13 @@ public class ContentPlatformDatastatJob {
|
|
|
example.createCriteria().andSubChannelIsNotNull();
|
|
|
return qwPlanMapper.selectByExample(example);
|
|
|
}
|
|
|
-
|
|
|
- private List<ContentPlatformQwPlanVideo> getSubChannelQwPlanVideoList(List<Long> qwPlanIds) {
|
|
|
- ContentPlatformQwPlanVideoExample example = new ContentPlatformQwPlanVideoExample();
|
|
|
- example.createCriteria().andPlanIdIn(qwPlanIds);
|
|
|
- return qwPlanVideoMapper.selectByExample(example);
|
|
|
+
|
|
|
+ private Integer parseInteger(Object value) {
|
|
|
+ try {
|
|
|
+ return Integer.parseInt((String) value);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|