|
@@ -1,8 +1,12 @@
|
|
|
package com.fs.course.service.impl;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.BigInteger;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -14,8 +18,14 @@ import com.fs.common.utils.date.TimeTypeEnum;
|
|
|
import com.fs.course.domain.FsUserCoursePeriod;
|
|
|
import com.fs.course.mapper.FsUserCoursePeriodMapper;
|
|
|
import com.fs.course.param.CompanyRedPacketParam;
|
|
|
+import com.fs.course.param.PeriodCountParam;
|
|
|
import com.fs.course.param.PeriodRedPacketParam;
|
|
|
+import com.fs.course.vo.FsPeriodCountVO;
|
|
|
+import com.fs.course.vo.newfs.FsCourseAnalysisCountVO;
|
|
|
+import com.fs.store.mapper.FsUserMapper;
|
|
|
+import com.fs.store.param.h5.CourseAnalysisParam;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.fs.course.mapper.FsUserCoursePeriodDaysMapper;
|
|
|
import com.fs.course.domain.FsUserCoursePeriodDays;
|
|
@@ -32,6 +42,9 @@ import com.fs.course.service.IFsUserCoursePeriodDaysService;
|
|
|
public class FsUserCoursePeriodDaysServiceImpl extends ServiceImpl<FsUserCoursePeriodDaysMapper, FsUserCoursePeriodDays> implements IFsUserCoursePeriodDaysService {
|
|
|
|
|
|
private final FsUserCoursePeriodMapper fsUserCoursePeriodMapper;
|
|
|
+
|
|
|
+ private final FsUserMapper fsUserMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询营期课程
|
|
|
*
|
|
@@ -157,4 +170,67 @@ public class FsUserCoursePeriodDaysServiceImpl extends ServiceImpl<FsUserCourseP
|
|
|
public List<PeriodRedPacketParam> getPeriodRedPacketList(Long periodId, Long companyId) {
|
|
|
return fsUserCoursePeriodMapper.selectPeriodRedPacket(periodId, companyId);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FsPeriodCountVO> periodCourseCount(PeriodCountParam param) {
|
|
|
+ //1、查询课程视频信息
|
|
|
+ FsUserCoursePeriodDays fsUserCoursePeriodDays = new FsUserCoursePeriodDays();
|
|
|
+ fsUserCoursePeriodDays.setPeriodId(param.getPeriodId());
|
|
|
+ fsUserCoursePeriodDays.setVideoIds(param.getVideoIdList());
|
|
|
+
|
|
|
+ List<FsUserCoursePeriodDays> videoList = baseMapper.selectFsUserCoursePeriodDaysList(fsUserCoursePeriodDays);
|
|
|
+
|
|
|
+ //2、查询统计
|
|
|
+ CourseAnalysisParam courseAnalysisParam = new CourseAnalysisParam();
|
|
|
+ courseAnalysisParam.setPeriodId(param.getPeriodId());
|
|
|
+ courseAnalysisParam.setVideoIdList(param.getVideoIdList());
|
|
|
+ List<FsCourseAnalysisCountVO> courseCountList = fsUserMapper.courseAnalysisWatchLog(courseAnalysisParam);
|
|
|
+ List<FsCourseAnalysisCountVO> redPacketCountList = fsUserMapper.courseAnalysisRedPacketCount(courseAnalysisParam);
|
|
|
+ List<FsCourseAnalysisCountVO> answerCountList = fsUserMapper.courseAnalysisAnswerCount(courseAnalysisParam);
|
|
|
+
|
|
|
+ //3、转化为map
|
|
|
+ Map<Long, FsCourseAnalysisCountVO> courseMap = courseCountList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ FsCourseAnalysisCountVO::getVideoId,
|
|
|
+ Function.identity()
|
|
|
+ ));
|
|
|
+ Map<Long, FsCourseAnalysisCountVO> redPacketMap = redPacketCountList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ FsCourseAnalysisCountVO::getVideoId,
|
|
|
+ Function.identity()
|
|
|
+ ));
|
|
|
+ Map<Long, FsCourseAnalysisCountVO> answerMap = answerCountList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ FsCourseAnalysisCountVO::getVideoId,
|
|
|
+ Function.identity()
|
|
|
+ ));
|
|
|
+
|
|
|
+ //4、处理数据
|
|
|
+ return videoList.stream().map(v -> {
|
|
|
+ FsPeriodCountVO allVO = new FsPeriodCountVO();
|
|
|
+ BeanUtils.copyProperties(v, allVO);
|
|
|
+ allVO.setTitle(v.getVideoName());
|
|
|
+
|
|
|
+ FsCourseAnalysisCountVO countVO = getCourseAnalysisCountVO(v, courseMap, redPacketMap, answerMap);
|
|
|
+ allVO.setCountDetailsVO(countVO);
|
|
|
+ return allVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private static FsCourseAnalysisCountVO getCourseAnalysisCountVO(FsUserCoursePeriodDays v, Map<Long, FsCourseAnalysisCountVO> courseMap, Map<Long, FsCourseAnalysisCountVO> redPacketMap, Map<Long, FsCourseAnalysisCountVO> answerMap) {
|
|
|
+ FsCourseAnalysisCountVO countVO = new FsCourseAnalysisCountVO();
|
|
|
+ FsCourseAnalysisCountVO courseVO = courseMap.getOrDefault(v.getVideoId(), countVO);
|
|
|
+ FsCourseAnalysisCountVO redPacketVO = redPacketMap.getOrDefault(v.getVideoId(), countVO);
|
|
|
+ FsCourseAnalysisCountVO answerVO = answerMap.getOrDefault(v.getVideoId(), countVO);
|
|
|
+ //单独赋值
|
|
|
+ countVO.setVideoId(v.getVideoId()).setCourseWatchNum(courseVO.getCourseWatchNum()).setCourseCompleteNum(courseVO.getCourseWatchNum())
|
|
|
+ .setCompleteRate(courseVO.getCompleteRate() != null ? courseVO.getCompleteRate() : new BigDecimal(BigInteger.ZERO))
|
|
|
+ .setCourseWatchTimes(courseVO.getCourseWatchTimes()).setCourseCompleteTimes(courseVO.getCourseCompleteTimes());
|
|
|
+ countVO.setRedPacketNum(redPacketVO.getRedPacketNum())
|
|
|
+ .setRedPacketAmount(redPacketVO.getRedPacketAmount() != null ? redPacketVO.getRedPacketAmount() : new BigDecimal(BigInteger.ZERO));
|
|
|
+ countVO.setAnswerNum(answerVO.getAnswerNum()).setAnswerRightNum(answerVO.getAnswerRightNum())
|
|
|
+ .setAnswerRightRate(answerVO.getAnswerRightRate()!=null ? answerVO.getAnswerRightRate() : new BigDecimal(BigInteger.ZERO))
|
|
|
+ .setAnswerTimes(answerVO.getAnswerTimes()).setAnswerRightTimes(answerVO.getAnswerRightTimes());
|
|
|
+ return countVO;
|
|
|
+ }
|
|
|
}
|