|
@@ -11,6 +11,7 @@ import com.google.common.collect.Sets;
|
|
|
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.modules.adweb.common.util.DateUtil;
|
|
import org.jeecg.modules.adweb.common.util.DateUtil;
|
|
|
|
+import org.jeecg.modules.adweb.common.util.NumberUtil;
|
|
import org.jeecg.modules.adweb.dmp.entity.GADailyReport;
|
|
import org.jeecg.modules.adweb.dmp.entity.GADailyReport;
|
|
import org.jeecg.modules.adweb.dmp.mapper.GADailyReportMapper;
|
|
import org.jeecg.modules.adweb.dmp.mapper.GADailyReportMapper;
|
|
import org.jeecg.modules.adweb.dmp.service.IGADailyReportService;
|
|
import org.jeecg.modules.adweb.dmp.service.IGADailyReportService;
|
|
@@ -24,6 +25,7 @@ import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -106,11 +108,13 @@ public class GADailyReportServiceImpl extends ServiceImpl<GADailyReportMapper, G
|
|
// 3. 询盘数据补充
|
|
// 3. 询盘数据补充
|
|
List<Pair<String, Integer>> enquiryDailyCounts =
|
|
List<Pair<String, Integer>> enquiryDailyCounts =
|
|
adwebEnquiryMapper.getEnquiryDailyCounts(siteCode, start, end);
|
|
adwebEnquiryMapper.getEnquiryDailyCounts(siteCode, start, end);
|
|
- enquiryDailyCounts.forEach(
|
|
|
|
- enquiryDailyCount ->
|
|
|
|
- dailyStatsVOs
|
|
|
|
- .get(enquiryDailyCount.getKey())
|
|
|
|
- .setEnquires(enquiryDailyCount.getValue()));
|
|
|
|
|
|
+ enquiryDailyCounts.stream()
|
|
|
|
+ .filter(enquiryDailyCount -> dailyStatsVOs.containsKey(enquiryDailyCount.getKey()))
|
|
|
|
+ .forEach(
|
|
|
|
+ enquiryDailyCount ->
|
|
|
|
+ dailyStatsVOs
|
|
|
|
+ .get(enquiryDailyCount.getKey())
|
|
|
|
+ .setEnquires(enquiryDailyCount.getValue())); // 返回值可能为Long型
|
|
|
|
|
|
// 3. 根据日期排序并返回
|
|
// 3. 根据日期排序并返回
|
|
return dailyStatsVOs.values().stream()
|
|
return dailyStatsVOs.values().stream()
|
|
@@ -129,6 +133,33 @@ public class GADailyReportServiceImpl extends ServiceImpl<GADailyReportMapper, G
|
|
cacheNames =
|
|
cacheNames =
|
|
"getPeriodicStats" + TTLCacheManager.TTL_SPLITTER + 60 * 30) // Redis TTL为半小时
|
|
"getPeriodicStats" + TTLCacheManager.TTL_SPLITTER + 60 * 30) // Redis TTL为半小时
|
|
public List<PeriodicStatsVO> getPeriodicStats(String siteCode) {
|
|
public List<PeriodicStatsVO> getPeriodicStats(String siteCode) {
|
|
- return gaDailyReportMapper.getPeriodicStats(siteCode);
|
|
|
|
|
|
+ // 1. 查询GA统计数据 - UV,PV等
|
|
|
|
+ Map<String, PeriodicStatsVO> periodicStatsVOs =
|
|
|
|
+ gaDailyReportMapper.getPeriodicStats(siteCode).stream()
|
|
|
|
+ .collect(
|
|
|
|
+ Collectors.toMap(
|
|
|
|
+ PeriodicStatsVO::getPeriod,
|
|
|
|
+ Function.identity(),
|
|
|
|
+ (x, y) -> y,
|
|
|
|
+ LinkedHashMap::new)); // LinkedHashMap保持原查询顺序
|
|
|
|
+
|
|
|
|
+ // 2. 询盘数据补充
|
|
|
|
+ List<Pair<String, Long>> enquiryPeriodicCounts =
|
|
|
|
+ adwebEnquiryMapper.getEnquiryPeriodicCounts(siteCode);
|
|
|
|
+ for (Pair<String, Long> enquiryPeriodicCount : enquiryPeriodicCounts) {
|
|
|
|
+ if (!periodicStatsVOs.containsKey(enquiryPeriodicCount.getKey())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PeriodicStatsVO periodicStatsVO = periodicStatsVOs.get(enquiryPeriodicCount.getKey());
|
|
|
|
+ periodicStatsVO.setEnquires(enquiryPeriodicCount.getValue().intValue()); // 返回值可能为Long型
|
|
|
|
+ periodicStatsVO.setEnquiryConversionRate(
|
|
|
|
+ NumberUtil.formatPercentage(
|
|
|
|
+ NumberUtil.safeDivide(
|
|
|
|
+ periodicStatsVO.getEnquires(), periodicStatsVO.getTotalUsers()),
|
|
|
|
+ 2));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return periodicStatsVOs.values().stream().collect(Collectors.toList());
|
|
}
|
|
}
|
|
}
|
|
}
|