|
@@ -453,30 +453,20 @@ public class HomeServiceImpl implements HomeService {
|
|
|
|
|
|
//数据补全,按时间顺序
|
|
|
private List<TeacherIndexWrapper.CourseExposureTotal> exposureFillData(List<TeacherIndexWrapper.CourseExposureTotal> exposureTotals,
|
|
|
- List<String> dateList,
|
|
|
- String[] typeArr) {
|
|
|
- if(exposureTotals == null){
|
|
|
- exposureTotals = new ArrayList<>();
|
|
|
- }
|
|
|
- //按类型分组
|
|
|
- Map<String, List<TeacherIndexWrapper.CourseExposureTotal>> typeMap = exposureTotals.stream()
|
|
|
- .collect(Collectors.groupingBy(TeacherIndexWrapper.CourseExposureTotal::getType));
|
|
|
+ List<String> dateList) {
|
|
|
List<TeacherIndexWrapper.CourseExposureTotal> result = new ArrayList<>();
|
|
|
//按时间段补全数据
|
|
|
for (String s : dateList) {
|
|
|
- for (String type : typeArr) {
|
|
|
- List<TeacherIndexWrapper.CourseExposureTotal> dateMap = typeMap.get(type);
|
|
|
- if(CollectionUtils.isEmpty(dateMap)){
|
|
|
- result.add(new TeacherIndexWrapper.CourseExposureTotal(s,type,0));
|
|
|
+ if(CollectionUtils.isEmpty(exposureTotals)){
|
|
|
+ result.add(new TeacherIndexWrapper.CourseExposureTotal(s,0));
|
|
|
+ }else {
|
|
|
+ Map<String, TeacherIndexWrapper.CourseExposureTotal> dateMapGroup = exposureTotals.stream()
|
|
|
+ .collect(Collectors.toMap(TeacherIndexWrapper.CourseExposureTotal::getDate, o -> o));
|
|
|
+ TeacherIndexWrapper.CourseExposureTotal courseExposureTotal = dateMapGroup.get(s);
|
|
|
+ if(Objects.nonNull(courseExposureTotal)){
|
|
|
+ result.add(courseExposureTotal);
|
|
|
}else {
|
|
|
- Map<String, TeacherIndexWrapper.CourseExposureTotal> dateMapGroup = dateMap.stream()
|
|
|
- .collect(Collectors.toMap(TeacherIndexWrapper.CourseExposureTotal::getDate, o -> o));
|
|
|
- TeacherIndexWrapper.CourseExposureTotal courseExposureTotal = dateMapGroup.get(s);
|
|
|
- if(Objects.nonNull(courseExposureTotal)){
|
|
|
- result.add(courseExposureTotal);
|
|
|
- }else {
|
|
|
- result.add(new TeacherIndexWrapper.CourseExposureTotal(s,type,0));
|
|
|
- }
|
|
|
+ result.add(new TeacherIndexWrapper.CourseExposureTotal(s,0));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -496,7 +486,7 @@ public class HomeServiceImpl implements HomeService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Map<String,List<TeacherIndexWrapper.CourseExposureTotal>> courseExposureTotal(TeacherIndexWrapper.CourseExposureSearch search) {
|
|
|
+ public List<TeacherIndexWrapper.CourseExposureTotal> courseExposureTotal(TeacherIndexWrapper.CourseExposureSearch search) {
|
|
|
String groupBy;
|
|
|
List<String> dateList;
|
|
|
Date startDate = DateUtil.strToDate(search.getStartTime(), DateUtil.DEFAULT_PATTERN);
|
|
@@ -512,18 +502,20 @@ public class HomeServiceImpl implements HomeService {
|
|
|
dateList = DateUtil.getYearList(startDate,endDate);
|
|
|
}
|
|
|
List<TeacherIndexWrapper.CourseExposureTotal> courseExposureTotals = exposureRecordService.getDao().courseExposureTotal(search, groupBy);
|
|
|
- //按分类分组
|
|
|
- Map<String,List<TeacherIndexWrapper.CourseExposureTotal>> typeMap = courseExposureTotals.stream()
|
|
|
- .collect(Collectors.groupingBy(TeacherIndexWrapper.CourseExposureTotal::getType));
|
|
|
- Map<String,List<TeacherIndexWrapper.CourseExposureTotal>> result = new HashMap<>();
|
|
|
- result.put("EXPOSURE_LIVE",exposureFillData(typeMap.get(GoodTypeEnum.LIVE.getCode()),dateList,new String[]{GoodTypeEnum.LIVE.getCode()}));
|
|
|
- result.put("EXPOSURE_VIDEO",exposureFillData(typeMap.get(GoodTypeEnum.VIDEO.getCode()),dateList,new String[]{GoodTypeEnum.VIDEO.getCode()}));
|
|
|
- result.put("EXPOSURE_MUSIC",exposureFillData(typeMap.get(GoodTypeEnum.MUSIC.getCode()),dateList,new String[]{GoodTypeEnum.MUSIC.getCode()}));
|
|
|
- return result;
|
|
|
+// //按分类分组
|
|
|
+// Map<String,List<TeacherIndexWrapper.CourseExposureTotal>> typeMap = courseExposureTotals.stream()
|
|
|
+// .collect(Collectors.groupingBy(TeacherIndexWrapper.CourseExposureTotal::getType));
|
|
|
+// Map<String,List<TeacherIndexWrapper.CourseExposureTotal>> result = new HashMap<>();
|
|
|
+// result.put("EXPOSURE_VIP",exposureFillData(typeMap.get(GoodTypeEnum.VIP_COURSE.getCode()),dateList,new String[]{GoodTypeEnum.VIP_COURSE.getCode()}));
|
|
|
+// result.put("EXPOSURE_PRACTICE",exposureFillData(typeMap.get(GoodTypeEnum.PRACTICE.getCode()),dateList,new String[]{GoodTypeEnum.PRACTICE.getCode()}));
|
|
|
+// result.put("EXPOSURE_LIVE",exposureFillData(typeMap.get(GoodTypeEnum.LIVE.getCode()),dateList,new String[]{GoodTypeEnum.LIVE.getCode()}));
|
|
|
+// result.put("EXPOSURE_VIDEO",exposureFillData(typeMap.get(GoodTypeEnum.VIDEO.getCode()),dateList,new String[]{GoodTypeEnum.VIDEO.getCode()}));
|
|
|
+// result.put("EXPOSURE_MUSIC",exposureFillData(typeMap.get(GoodTypeEnum.MUSIC.getCode()),dateList,new String[]{GoodTypeEnum.MUSIC.getCode()}));
|
|
|
+ return exposureFillData(courseExposureTotals,dateList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String,List<TeacherIndexWrapper.CourseExposureTotal>> courseBuyTotal(TeacherIndexWrapper.CourseExposureSearch search) {
|
|
|
+ public List<TeacherIndexWrapper.CourseExposureTotal> courseBuyTotal(TeacherIndexWrapper.CourseExposureSearch search) {
|
|
|
//获取学员练习时长
|
|
|
//获取分组条件,如果所选时间段只有一天,则按小时分组,超过一个月按天分组,超过一年按月分组
|
|
|
String groupBy;
|
|
@@ -541,21 +533,59 @@ public class HomeServiceImpl implements HomeService {
|
|
|
dateList = DateUtil.getYearList(startDate,endDate);
|
|
|
}
|
|
|
Map<String,List<TeacherIndexWrapper.CourseExposureTotal>> result = new HashMap<>();
|
|
|
- //直播课
|
|
|
- List<TeacherIndexWrapper.CourseExposureTotal> liveSummer = userOrderDetailService.getDao().liveBuyTotal(search,groupBy);
|
|
|
- result.put(GoodTypeEnum.LIVE.getCode(),exposureFillData(liveSummer,dateList,new String[]{GoodTypeEnum.LIVE.getCode()}));
|
|
|
- //视频课
|
|
|
- List<TeacherIndexWrapper.CourseExposureTotal> videoSummer = userOrderDetailService.getDao().videoBuyTotal(search,groupBy);
|
|
|
- result.put(GoodTypeEnum.VIDEO.getCode(),exposureFillData(videoSummer,dateList,new String[]{GoodTypeEnum.VIDEO.getCode()}));
|
|
|
- //获取老师关联的学员
|
|
|
- List<Long> studentIds = teacherService.getDao().getStudentIds(search.getTeacherId(),null);
|
|
|
- if(CollectionUtils.isNotEmpty(studentIds)){
|
|
|
- //曲谱
|
|
|
- search.setStudentIds(studentIds);
|
|
|
- List<TeacherIndexWrapper.CourseExposureTotal> musicSheetSummer = userOrderDetailService.getDao().musicSheetBuyTotal(search,groupBy);
|
|
|
- result.put(GoodTypeEnum.MUSIC.getCode(),exposureFillData(musicSheetSummer,dateList,new String[]{GoodTypeEnum.MUSIC.getCode()}));
|
|
|
+ if(StringUtils.isEmpty(search.getType())){
|
|
|
+ //直播课
|
|
|
+ List<TeacherIndexWrapper.CourseExposureTotal> liveSummer = userOrderDetailService.getDao().liveBuyTotal(search,groupBy);
|
|
|
+ result.put(GoodTypeEnum.LIVE.getCode(),exposureFillData(liveSummer,dateList));
|
|
|
+ //视频课
|
|
|
+ List<TeacherIndexWrapper.CourseExposureTotal> videoSummer = userOrderDetailService.getDao().videoBuyTotal(search,groupBy);
|
|
|
+ result.put(GoodTypeEnum.VIDEO.getCode(),exposureFillData(videoSummer,dateList));
|
|
|
+ //获取老师关联的学员
|
|
|
+ List<Long> studentIds = teacherService.getDao().getStudentIds(search.getTeacherId(),null);
|
|
|
+ if(CollectionUtils.isNotEmpty(studentIds)){
|
|
|
+ //曲谱
|
|
|
+ search.setStudentIds(studentIds);
|
|
|
+ List<TeacherIndexWrapper.CourseExposureTotal> musicSheetSummer = userOrderDetailService.getDao().musicSheetBuyTotal(search,groupBy);
|
|
|
+ result.put(GoodTypeEnum.MUSIC.getCode(),exposureFillData(musicSheetSummer,dateList));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(StringUtils.equals("LIVE",search.getType()) || StringUtils.equals("VIP_COURSE",search.getType()) || StringUtils.equals("PRACTICE",search.getType())){
|
|
|
+ //直播课
|
|
|
+ List<TeacherIndexWrapper.CourseExposureTotal> liveSummer = userOrderDetailService.getDao().liveBuyTotal(search,groupBy);
|
|
|
+ result.put(GoodTypeEnum.LIVE.getCode(),exposureFillData(liveSummer,dateList));
|
|
|
+ }else if (StringUtils.equals("VIDEO",search.getType())){
|
|
|
+ //视频课
|
|
|
+ List<TeacherIndexWrapper.CourseExposureTotal> videoSummer = userOrderDetailService.getDao().videoBuyTotal(search,groupBy);
|
|
|
+ result.put(GoodTypeEnum.VIDEO.getCode(),exposureFillData(videoSummer,dateList));
|
|
|
+ }else if (StringUtils.equals("MUSIC",search.getType())){
|
|
|
+ //获取老师关联的学员
|
|
|
+ List<Long> studentIds = teacherService.getDao().getStudentIds(search.getTeacherId(),null);
|
|
|
+ if(CollectionUtils.isNotEmpty(studentIds)){
|
|
|
+ //曲谱
|
|
|
+ search.setStudentIds(studentIds);
|
|
|
+ List<TeacherIndexWrapper.CourseExposureTotal> musicSheetSummer = userOrderDetailService.getDao().musicSheetBuyTotal(search,groupBy);
|
|
|
+ result.put(GoodTypeEnum.MUSIC.getCode(),exposureFillData(musicSheetSummer,dateList));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return result;
|
|
|
+ //将数据合并,map中所有的数据按时间,将list中的数据相加
|
|
|
+ List<TeacherIndexWrapper.CourseExposureTotal> finalResult = new ArrayList<>();
|
|
|
+ for (String s : dateList) {
|
|
|
+ TeacherIndexWrapper.CourseExposureTotal courseExposureTotal = new TeacherIndexWrapper.CourseExposureTotal();
|
|
|
+ courseExposureTotal.setDate(s);
|
|
|
+ courseExposureTotal.setExposureNum(0);
|
|
|
+ for (Map.Entry<String, List<TeacherIndexWrapper.CourseExposureTotal>> entry : result.entrySet()) {
|
|
|
+ List<TeacherIndexWrapper.CourseExposureTotal> value = entry.getValue();
|
|
|
+ Map<String, TeacherIndexWrapper.CourseExposureTotal> collect = value.stream()
|
|
|
+ .collect(Collectors.toMap(TeacherIndexWrapper.CourseExposureTotal::getDate, o -> o));
|
|
|
+ TeacherIndexWrapper.CourseExposureTotal exposureTotal = collect.get(s);
|
|
|
+ if(Objects.nonNull(exposureTotal)){
|
|
|
+ courseExposureTotal.setExposureNum(courseExposureTotal.getExposureNum() + exposureTotal.getExposureNum());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finalResult.add(courseExposureTotal);
|
|
|
+ }
|
|
|
+ return finalResult;
|
|
|
}
|
|
|
|
|
|
}
|