| 
					
				 | 
			
			
				@@ -7,6 +7,7 @@ import com.yonge.cooleshow.biz.dal.dao.MusicSheetDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.dao.UserAccountRecordDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.dto.SubjectHomeSearch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.dto.req.TotalReq; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.entity.SysUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.TeacherTagEnum; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -58,6 +59,10 @@ public class HomeServiceImpl implements HomeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private SysMusicCompareRecordService sysMusicCompareRecordService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private UserOrderDetailService userOrderDetailService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysUserService sysUserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private StudentService studentService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public HomeUserToDoNum getUserToDoNum() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -453,30 +458,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 +491,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); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -511,19 +506,11 @@ public class HomeServiceImpl implements HomeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             groupBy = "%Y"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return exposureFillData(exposureRecordService.getDao().courseExposureTotal(search, groupBy),dateList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public Map<String,List<TeacherIndexWrapper.CourseExposureTotal>> courseBuyTotal(TeacherIndexWrapper.CourseExposureSearch search) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<TeacherIndexWrapper.CourseExposureTotal> courseBuyTotal(TeacherIndexWrapper.CourseExposureSearch search) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取学员练习时长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取分组条件,如果所选时间段只有一天,则按小时分组,超过一个月按天分组,超过一年按月分组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String groupBy; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -541,21 +528,56 @@ 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()})); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result.put("COURSE",exposureFillData(liveSummer,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,new String[]{GoodTypeEnum.MUSIC.getCode()})); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public PageInfo<TeacherIndexWrapper.TeacherIncome> teacherIncomeList(IPage<TeacherIndexWrapper.TeacherIncome> page,TeacherIndexWrapper.CourseExposureSearch query) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        IPage<TeacherIndexWrapper.TeacherIncome> record = baserMapper.teacherIncomeList(page,query); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TeacherIndexWrapper.TeacherIncome> records = record.getRecords(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isNotEmpty(records)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Long> userIds = records.stream().map(TeacherIndexWrapper.TeacherIncome::getUserId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获取用户声部信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            studentService.querySubject() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<SysUser> sysUsers = sysUserService.getDao().selectBatchIds(userIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<Long, SysUser> sysUserMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getId, Function.identity())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (TeacherIndexWrapper.TeacherIncome teacherIncome : records) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                SysUser sysUser = sysUserMap.get(teacherIncome.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (sysUser != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    teacherIncome.setUserName(sysUser.getUsername()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    teacherIncome.setUserAvatar(sysUser.getAvatar()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return PageUtil.pageInfo(record); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |