|
@@ -1296,51 +1296,57 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
@Override
|
|
@Override
|
|
|
public List<FsCourseReportVO> selectFsCourseReportVO(FsCourseWatchLogStatisticsListParam param) {
|
|
public List<FsCourseReportVO> selectFsCourseReportVO(FsCourseWatchLogStatisticsListParam param) {
|
|
|
//时间处理
|
|
//时间处理
|
|
|
- if(param.getSTime()!=null||param.getETime()!=null){
|
|
|
|
|
|
|
+ if (param.getSTime() != null || param.getETime() != null) {
|
|
|
Date date = removeTime(param.getSTime());
|
|
Date date = removeTime(param.getSTime());
|
|
|
param.setSTime(date);
|
|
param.setSTime(date);
|
|
|
Date endDate = removeTime(param.getETime());
|
|
Date endDate = removeTime(param.getETime());
|
|
|
param.setETime(endDate);
|
|
param.setETime(endDate);
|
|
|
}
|
|
}
|
|
|
- // 1. 查询公司基础信息
|
|
|
|
|
- List<FsCourseReportVO> companyList = fsCourseWatchLogMapper.selectCompanyBaseInfo(param);
|
|
|
|
|
|
|
+ // 基础信息
|
|
|
|
|
+ List<FsCourseReportVO> companyList = new ArrayList<>();
|
|
|
|
|
+ if ("camp".equals(param.getDimension())) {
|
|
|
|
|
+ companyList = fsCourseWatchLogMapper.selectPeriodInfo(param);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ companyList = fsCourseWatchLogMapper.selectCompanyBaseInfo(param);
|
|
|
|
|
+ }
|
|
|
if (CollectionUtils.isEmpty(companyList)) {
|
|
if (CollectionUtils.isEmpty(companyList)) {
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
|
|
+ if ("camp".equals(param.getDimension())) {
|
|
|
|
|
+ List<Long> periodIds = companyList.stream()
|
|
|
|
|
+ .map(company -> (Long) company.getPeriodId())
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ param.setPeriodIds(periodIds);
|
|
|
|
|
+ }
|
|
|
List<Long> companyIds = companyList.stream()
|
|
List<Long> companyIds = companyList.stream()
|
|
|
.map(company -> (Long) company.getCompanyId())
|
|
.map(company -> (Long) company.getCompanyId())
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
param.setCompanyIds(companyIds);
|
|
param.setCompanyIds(companyIds);
|
|
|
|
|
+
|
|
|
Map<Long, FsCourseReportVO> watchStatistics = getWatchStatistics(param);
|
|
Map<Long, FsCourseReportVO> watchStatistics = getWatchStatistics(param);
|
|
|
Map<Long, FsCourseReportVO> answerStatistics = getAnswerStatistics(param);
|
|
Map<Long, FsCourseReportVO> answerStatistics = getAnswerStatistics(param);
|
|
|
Map<Long, FsCourseReportVO> redPacketStatistics = getRedPacketStatistics(param);
|
|
Map<Long, FsCourseReportVO> redPacketStatistics = getRedPacketStatistics(param);
|
|
|
- Map<Long, FsCourseReportVO> campPeriodMap = new HashMap<>();
|
|
|
|
|
- if ("camp".equals(param.getDimension())) {
|
|
|
|
|
- List<Long> periodIds = watchStatistics.values().stream()
|
|
|
|
|
- .map(stats -> stats.getPeriodId())
|
|
|
|
|
- .filter(Objects::nonNull)
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- if (!periodIds.isEmpty()) {
|
|
|
|
|
- campPeriodMap = getCampPeriodInfo(periodIds);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
// 4. 组装最终结果
|
|
// 4. 组装最终结果
|
|
|
return assembleStatisticsResult(companyList, watchStatistics, answerStatistics,
|
|
return assembleStatisticsResult(companyList, watchStatistics, answerStatistics,
|
|
|
- redPacketStatistics, campPeriodMap, param);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private List<FsCourseReportVO> assembleStatisticsResult(List<FsCourseReportVO> companyList, Map<Long, FsCourseReportVO> watchStatistics, Map<Long, FsCourseReportVO> answerStatistics, Map<Long, FsCourseReportVO> redPacketStatistics, Map<Long, FsCourseReportVO> campPeriodMap, FsCourseWatchLogStatisticsListParam param) {
|
|
|
|
|
- for (FsCourseReportVO company : companyList) {
|
|
|
|
|
- Long companyId = company.getCompanyId();
|
|
|
|
|
-
|
|
|
|
|
- // 获取各类统计数据
|
|
|
|
|
- FsCourseReportVO watchStats = watchStatistics.get(companyId);
|
|
|
|
|
- FsCourseReportVO answerStats = answerStatistics.get(companyId);
|
|
|
|
|
- FsCourseReportVO redPacketStats = redPacketStatistics.get(companyId);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ redPacketStatistics, param);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<FsCourseReportVO> assembleStatisticsResult(List<FsCourseReportVO> companyList, Map<Long, FsCourseReportVO> watchStatistics, Map<Long, FsCourseReportVO> answerStatistics, Map<Long, FsCourseReportVO> redPacketStatistics, FsCourseWatchLogStatisticsListParam param) {
|
|
|
|
|
+ for (FsCourseReportVO company : companyList) {
|
|
|
|
|
+ FsCourseReportVO watchStats;
|
|
|
|
|
+ FsCourseReportVO answerStats;
|
|
|
|
|
+ FsCourseReportVO redPacketStats;
|
|
|
|
|
+ if ("camp".equals(param.getDimension())) {
|
|
|
|
|
+ watchStats = watchStatistics.getOrDefault(company.getPeriodId(), new FsCourseReportVO());
|
|
|
|
|
+ answerStats = answerStatistics.getOrDefault(company.getPeriodId(), new FsCourseReportVO());
|
|
|
|
|
+ redPacketStats = redPacketStatistics.getOrDefault(company.getPeriodId(), new FsCourseReportVO());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ watchStats = watchStatistics.getOrDefault(company.getCompanyId(), new FsCourseReportVO());
|
|
|
|
|
+ answerStats = answerStatistics.getOrDefault(company.getCompanyId(), new FsCourseReportVO());
|
|
|
|
|
+ redPacketStats = redPacketStatistics.getOrDefault(company.getCompanyId(), new FsCourseReportVO());
|
|
|
|
|
+ }
|
|
|
// 设置看课统计数据
|
|
// 设置看课统计数据
|
|
|
- if(watchStats!=null){
|
|
|
|
|
|
|
+ if (watchStats != null) {
|
|
|
company.setPendingCount(watchStats.getPendingCount());
|
|
company.setPendingCount(watchStats.getPendingCount());
|
|
|
company.setWatchingCount(watchStats.getWatchingCount());
|
|
company.setWatchingCount(watchStats.getWatchingCount());
|
|
|
company.setFinishedCount(watchStats.getFinishedCount());
|
|
company.setFinishedCount(watchStats.getFinishedCount());
|
|
@@ -1351,30 +1357,18 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 设置答题统计数据
|
|
// 设置答题统计数据
|
|
|
- if(answerStats!=null){
|
|
|
|
|
|
|
+ if (answerStats != null) {
|
|
|
company.setAnswerUserCount(answerStats.getAnswerUserCount());
|
|
company.setAnswerUserCount(answerStats.getAnswerUserCount());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 设置红包统计数据
|
|
// 设置红包统计数据
|
|
|
- if(redPacketStats!=null){
|
|
|
|
|
- company.setPacketUserCount(redPacketStats.getPacketUserCount());
|
|
|
|
|
- company.setPacketAmount(redPacketStats.getPacketAmount());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 设置营期信息(如果维度是camp)
|
|
|
|
|
- if ("camp".equals(param.getDimension()) && watchStats != null) {
|
|
|
|
|
- Long samplePeriodId = watchStats.getPeriodId();
|
|
|
|
|
- if (samplePeriodId != null) {
|
|
|
|
|
- FsCourseReportVO campPeriod = campPeriodMap.get(samplePeriodId);
|
|
|
|
|
- if (campPeriod != null) {
|
|
|
|
|
- company.setTrainingCampName(campPeriod.getTrainingCampName());
|
|
|
|
|
- company.setPeriodName(campPeriod.getPeriodName());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (redPacketStats != null) {
|
|
|
|
|
+ company.setPacketUserCount(redPacketStats.getPacketUserCount());
|
|
|
|
|
+ company.setPacketAmount(redPacketStats.getPacketAmount());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- return companyList;
|
|
|
|
|
|
|
+ return companyList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1403,32 +1397,65 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
|
|
|
|
|
private Map<Long, FsCourseReportVO> getWatchStatistics(FsCourseWatchLogStatisticsListParam query) {
|
|
private Map<Long, FsCourseReportVO> getWatchStatistics(FsCourseWatchLogStatisticsListParam query) {
|
|
|
List<FsCourseReportVO> watchStatistics = fsCourseWatchLogMapper.selectWatchStatistics(query);
|
|
List<FsCourseReportVO> watchStatistics = fsCourseWatchLogMapper.selectWatchStatistics(query);
|
|
|
- Map<Long, FsCourseReportVO> watchStatisticsMap = watchStatistics.stream()
|
|
|
|
|
- .collect(Collectors.toMap(
|
|
|
|
|
- stats -> stats.getCompanyId(),
|
|
|
|
|
- Function.identity(),
|
|
|
|
|
- (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
- ));
|
|
|
|
|
|
|
+ Map<Long, FsCourseReportVO> watchStatisticsMap = new HashMap<>();
|
|
|
|
|
+ if ("company".equals(query.getDimension())) {
|
|
|
|
|
+ watchStatisticsMap = watchStatistics.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
|
+ stats -> stats.getCompanyId(),
|
|
|
|
|
+ Function.identity(),
|
|
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
+ ));
|
|
|
|
|
+ } else if ("camp".equals(query.getDimension())) {
|
|
|
|
|
+ watchStatisticsMap = watchStatistics.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
|
+ stats -> stats.getPeriodId(),
|
|
|
|
|
+ Function.identity(),
|
|
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return watchStatisticsMap;
|
|
return watchStatisticsMap;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
private Map<Long, FsCourseReportVO> getAnswerStatistics(FsCourseWatchLogStatisticsListParam query) {
|
|
private Map<Long, FsCourseReportVO> getAnswerStatistics(FsCourseWatchLogStatisticsListParam query) {
|
|
|
List<FsCourseReportVO> answerStatistics = fsCourseWatchLogMapper.selectAnswerStatistics(query);
|
|
List<FsCourseReportVO> answerStatistics = fsCourseWatchLogMapper.selectAnswerStatistics(query);
|
|
|
- Map<Long, FsCourseReportVO> answerMap = answerStatistics.stream()
|
|
|
|
|
- .collect(Collectors.toMap(
|
|
|
|
|
- stats -> stats.getCompanyId(),
|
|
|
|
|
- Function.identity(),
|
|
|
|
|
- (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
- ));
|
|
|
|
|
|
|
+ Map<Long, FsCourseReportVO> answerMap = new HashMap<>();
|
|
|
|
|
+ if ("company".equals(query.getDimension())) {
|
|
|
|
|
+ answerMap = answerStatistics.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
|
+ stats -> stats.getCompanyId(),
|
|
|
|
|
+ Function.identity(),
|
|
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
+ ));
|
|
|
|
|
+ } else if ("camp".equals(query.getDimension())) {
|
|
|
|
|
+ answerMap = answerStatistics.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
|
+ stats -> stats.getPeriodId(),
|
|
|
|
|
+ Function.identity(),
|
|
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return answerMap;
|
|
return answerMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Map<Long, FsCourseReportVO> getRedPacketStatistics(FsCourseWatchLogStatisticsListParam query){
|
|
|
|
|
|
|
+ private Map<Long, FsCourseReportVO> getRedPacketStatistics(FsCourseWatchLogStatisticsListParam query) {
|
|
|
List<FsCourseReportVO> redPacketStatistics = fsCourseWatchLogMapper.selectRedPacketStatistics(query);
|
|
List<FsCourseReportVO> redPacketStatistics = fsCourseWatchLogMapper.selectRedPacketStatistics(query);
|
|
|
- Map<Long, FsCourseReportVO> redPacketMap = redPacketStatistics.stream().collect(Collectors.toMap(
|
|
|
|
|
- stats -> stats.getCompanyId(),
|
|
|
|
|
- Function.identity(),
|
|
|
|
|
- (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
- ));
|
|
|
|
|
|
|
+ Map<Long, FsCourseReportVO> redPacketMap = new HashMap<>();
|
|
|
|
|
+ if ("company".equals(query.getDimension())) {
|
|
|
|
|
+ redPacketMap = redPacketStatistics.stream().collect(Collectors.toMap(
|
|
|
|
|
+ stats -> stats.getCompanyId(),
|
|
|
|
|
+ Function.identity(),
|
|
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
+ ));
|
|
|
|
|
+ } else if ("camp".equals(query.getDimension())) {
|
|
|
|
|
+ redPacketMap = redPacketStatistics.stream().collect(Collectors.toMap(
|
|
|
|
|
+ stats -> stats.getPeriodId(),
|
|
|
|
|
+ Function.identity(),
|
|
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return redPacketMap;
|
|
return redPacketMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1440,7 +1467,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
Function.identity(),
|
|
Function.identity(),
|
|
|
(existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
(existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
));
|
|
));
|
|
|
- return campPeriodMap;
|
|
|
|
|
|
|
+ return campPeriodMap;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1468,7 +1495,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
Function.identity()
|
|
Function.identity()
|
|
|
));
|
|
));
|
|
|
|
|
|
|
|
- Map<Long, FsUserReportVO> integralStatsMap = fsCourseWatchLogMapper.selectIntegralStatsByUserIds(userIds,param)
|
|
|
|
|
|
|
+ Map<Long, FsUserReportVO> integralStatsMap = fsCourseWatchLogMapper.selectIntegralStatsByUserIds(userIds, param)
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.toMap(FsUserReportVO::getUserId, Function.identity()));
|
|
.collect(Collectors.toMap(FsUserReportVO::getUserId, Function.identity()));
|
|
|
|
|
|
|
@@ -1479,7 +1506,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
Function.identity()
|
|
Function.identity()
|
|
|
));
|
|
));
|
|
|
|
|
|
|
|
- Map<Long, FsUserReportVO> orderStatsMap = fsCourseWatchLogMapper.selectOrderStatsByUserIds(userIds,param)
|
|
|
|
|
|
|
+ Map<Long, FsUserReportVO> orderStatsMap = fsCourseWatchLogMapper.selectOrderStatsByUserIds(userIds, param)
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.toMap(FsUserReportVO::getUserId, Function.identity()));
|
|
.collect(Collectors.toMap(FsUserReportVO::getUserId, Function.identity()));
|
|
|
userList.forEach(user -> {
|
|
userList.forEach(user -> {
|
|
@@ -1542,6 +1569,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 优化后的公司维度基础数据查询
|
|
* 优化后的公司维度基础数据查询
|
|
|
*/
|
|
*/
|
|
@@ -1590,6 +1618,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
|
|
|
|
|
return deptBaseData;
|
|
return deptBaseData;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 复制参数属性的辅助方法
|
|
* 复制参数属性的辅助方法
|
|
|
*/
|
|
*/
|
|
@@ -1628,7 +1657,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
Map<Long, WatchLogReportVO> orderMap = convertOrderToMap(
|
|
Map<Long, WatchLogReportVO> orderMap = convertOrderToMap(
|
|
|
- fsCourseWatchLogMapper.selectOrderStats(userIds,param)
|
|
|
|
|
|
|
+ fsCourseWatchLogMapper.selectOrderStats(userIds, param)
|
|
|
);
|
|
);
|
|
|
Map<Long, WatchLogReportVO> answerMap = convertAnswerToMap(
|
|
Map<Long, WatchLogReportVO> answerMap = convertAnswerToMap(
|
|
|
fsCourseWatchLogMapper.selectAnswerStats(logIds)
|
|
fsCourseWatchLogMapper.selectAnswerStats(logIds)
|
|
@@ -1637,7 +1666,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
|
|
|
|
|
// 组装数据
|
|
// 组装数据
|
|
|
for (WatchLogReportVO item : baseData) {
|
|
for (WatchLogReportVO item : baseData) {
|
|
|
- if(!"user".equals(param.getDimension())){
|
|
|
|
|
|
|
+ if (!"user".equals(param.getDimension())) {
|
|
|
//完课率
|
|
//完课率
|
|
|
item.setCompletionRate(calculateCompletionRate(item));
|
|
item.setCompletionRate(calculateCompletionRate(item));
|
|
|
}
|
|
}
|
|
@@ -1648,19 +1677,19 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
item.setTrainingCampName(watchStats.getTrainingCampName());
|
|
item.setTrainingCampName(watchStats.getTrainingCampName());
|
|
|
}
|
|
}
|
|
|
// 红包数据
|
|
// 红包数据
|
|
|
- WatchLogReportVO redPacketStats = redPacketMap.getOrDefault(item.getLogId(),null);
|
|
|
|
|
|
|
+ WatchLogReportVO redPacketStats = redPacketMap.getOrDefault(item.getLogId(), null);
|
|
|
if (redPacketStats != null) {
|
|
if (redPacketStats != null) {
|
|
|
item.setRedPacketAmount(redPacketStats.getRedPacketAmount());
|
|
item.setRedPacketAmount(redPacketStats.getRedPacketAmount());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 订单数据
|
|
// 订单数据
|
|
|
- WatchLogReportVO order = orderMap.getOrDefault(item.getUserId(),null);
|
|
|
|
|
|
|
+ WatchLogReportVO order = orderMap.getOrDefault(item.getUserId(), null);
|
|
|
if (order != null) {
|
|
if (order != null) {
|
|
|
item.setHistoryOrderCount(order.getHistoryOrderCount());
|
|
item.setHistoryOrderCount(order.getHistoryOrderCount());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 答题数据
|
|
// 答题数据
|
|
|
- WatchLogReportVO answer = answerMap.getOrDefault(item.getLogId(),null);
|
|
|
|
|
|
|
+ WatchLogReportVO answer = answerMap.getOrDefault(item.getLogId(), null);
|
|
|
if (answer != null) {
|
|
if (answer != null) {
|
|
|
setAnswerData(item, answer, param.getDimension());
|
|
setAnswerData(item, answer, param.getDimension());
|
|
|
}
|
|
}
|
|
@@ -1701,8 +1730,6 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 会员数据转Map
|
|
* 会员数据转Map
|
|
|
*/
|
|
*/
|