|  | @@ -31,7 +31,6 @@ import javax.annotation.PostConstruct;
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.time.LocalDate;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  | -import java.util.Map.Entry;
 | 
	
		
			
				|  |  |  import java.util.concurrent.atomic.AtomicInteger;
 | 
	
		
			
				|  |  |  import java.util.function.BiFunction;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
	
		
			
				|  | @@ -50,8 +49,6 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentRegistrationDao studentRegistrationDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private StudentStatisticsDao studentStatisticsDao;
 | 
	
		
			
				|  |  | -    @Autowired
 | 
	
		
			
				|  |  |      private MusicGroupDao musicGroupDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private PracticeGroupDao practiceGroupDao;
 | 
	
	
		
			
				|  | @@ -964,81 +961,10 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public CloudStudyStudentDataDto getCloudStudyStudentOverView(List<Integer> organIds) {
 | 
	
		
			
				|  |  |          CloudStudyStudentDataDto result = new CloudStudyStudentDataDto();
 | 
	
		
			
				|  |  | -//        result.setCloudStudyUseStudentNum(studentDao.getOrgansTotalCloudStudyStudentNum(organIds));
 | 
	
		
			
				|  |  |          result.setCloudStudyTodayUseStudentNum(studentDao.getOrgansTodayTotalCloudStudyStudentNum(organIds));
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    @Override
 | 
	
		
			
				|  |  | -	public List<IndexCloudStudyListDto> getCloudStudyStudentOverViewList(List<Integer> organIds) {
 | 
	
		
			
				|  |  | -    	
 | 
	
		
			
				|  |  | -    	List<IndexCloudStudyListDto> list = studentDao.getCloudStudyStudentOverViewList(organIds);
 | 
	
		
			
				|  |  | -    	
 | 
	
		
			
				|  |  | -    	Calendar cal = Calendar.getInstance();    
 | 
	
		
			
				|  |  | -        cal.setTime(new Date());    
 | 
	
		
			
				|  |  | -        //cal.add(Calendar.WEEK_OF_YEAR, -1);// 一周    
 | 
	
		
			
				|  |  | -        cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
 | 
	
		
			
				|  |  | -        Date endTime = cal.getTime();
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        cal.setTime(new Date());    
 | 
	
		
			
				|  |  | -        cal.add(Calendar.WEEK_OF_YEAR, -4);// 一周    
 | 
	
		
			
				|  |  | -        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
 | 
	
		
			
				|  |  | -        Date startTime = cal.getTime();
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        List<Mapper> mapperList = studentDao.getOrganActiveCloudStudyStudentNum(organIds, startTime, endTime);
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        Map<Integer, Integer> organActiveNum = new HashMap<Integer, Integer>();
 | 
	
		
			
				|  |  | -        for(Mapper mapper : mapperList){
 | 
	
		
			
				|  |  | -        	organActiveNum.put(Integer.parseInt(mapper.getKey().toString()), Integer.parseInt(mapper.getValue().toString()));
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        List<Mapper> organCloudTeacherStudentNum = studentDao.getOrganCloudTeacherStudentNum(organIds);
 | 
	
		
			
				|  |  | -        Map<Integer, Integer> organCloudTeacherStudentNumMap = new HashMap<Integer, Integer>();
 | 
	
		
			
				|  |  | -        for(Mapper mapper : organCloudTeacherStudentNum){
 | 
	
		
			
				|  |  | -        	organCloudTeacherStudentNumMap.put(Integer.parseInt(mapper.getKey().toString()), Integer.parseInt(mapper.getValue().toString()));
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        List<StudentOrganDto> set1 = studentRegistrationDao.queryEffectiveStudent(organIds);
 | 
	
		
			
				|  |  | -        List<StudentOrganDto> set2 = courseScheduleStudentPaymentDao.queryRemainCourseStudent(organIds);
 | 
	
		
			
				|  |  | -        List<StudentOrganDto> set3 = studentStatisticsDao.queryNoScheduleNumStudent(organIds);
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        Map<Integer,Set<Integer>> map1= set1.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
 | 
	
		
			
				|  |  | -        Map<Integer,Set<Integer>> map2= set2.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
 | 
	
		
			
				|  |  | -        Map<Integer,Set<Integer>> map3= set3.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        Map<Integer,Set<Integer>> organStudentMap = new HashMap<Integer, Set<Integer>>(map1);
 | 
	
		
			
				|  |  | -        Set<Integer> temp = null;
 | 
	
		
			
				|  |  | -        for(Entry<Integer, Set<Integer>> entry : map2.entrySet()){
 | 
	
		
			
				|  |  | -        	temp = organStudentMap.get(entry.getKey());
 | 
	
		
			
				|  |  | -        	if(temp == null){
 | 
	
		
			
				|  |  | -        		organStudentMap.put(entry.getKey(), entry.getValue());
 | 
	
		
			
				|  |  | -        	}else{
 | 
	
		
			
				|  |  | -        		temp.addAll(entry.getValue());
 | 
	
		
			
				|  |  | -        		organStudentMap.put(entry.getKey(), temp);
 | 
	
		
			
				|  |  | -        	}
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        for(Entry<Integer, Set<Integer>> entry : map3.entrySet()){
 | 
	
		
			
				|  |  | -        	temp = organStudentMap.get(entry.getKey());
 | 
	
		
			
				|  |  | -        	if(temp == null){
 | 
	
		
			
				|  |  | -        		organStudentMap.put(entry.getKey(), entry.getValue());
 | 
	
		
			
				|  |  | -        	}else{
 | 
	
		
			
				|  |  | -        		temp.addAll(entry.getValue());
 | 
	
		
			
				|  |  | -        		organStudentMap.put(entry.getKey(), temp);
 | 
	
		
			
				|  |  | -        	}
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        for(IndexCloudStudyListDto ics : list){
 | 
	
		
			
				|  |  | -        	ics.setActiveStudentNum(organActiveNum.get(ics.getOrganId()) == null ? 0 : organActiveNum.get(ics.getOrganId()));
 | 
	
		
			
				|  |  | -        	ics.setVipStudentNum(organCloudTeacherStudentNumMap.get(ics.getOrganId()) == null ? 0 : organCloudTeacherStudentNumMap.get(ics.getOrganId()));
 | 
	
		
			
				|  |  | -        	ics.setEffectiveStudentNum(organStudentMap.get(ics.getOrganId()) == null ? 0 : organStudentMap.get(ics.getOrganId()).size());
 | 
	
		
			
				|  |  | -        	if(ics.getEffectiveStudentNum() > 0){
 | 
	
		
			
				|  |  | -        		ics.setVipStudentRate(ics.getVipStudentNum() * 100d / ics.getEffectiveStudentNum());
 | 
	
		
			
				|  |  | -        	}
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -		return list;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |      public void cleanStudentCloudStudySequenceDays() {
 | 
	
		
			
				|  |  |          studentDao.cleanStudentCloudStudySequenceDays();
 | 
	
	
		
			
				|  | @@ -1056,17 +982,9 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          List<CloudTeacherActiveTargetDto> targetDtoList = JSONArray.parseArray(cloudTeacherActiveTarget, CloudTeacherActiveTargetDto.class);
 | 
	
		
			
				|  |  |          Map<Integer, List<CloudTeacherActiveTargetDto>> targetMap = targetDtoList.stream().collect(Collectors.groupingBy(e -> e.getOrganId()));
 | 
	
		
			
				|  |  | -        //获取各分部总人数
 | 
	
		
			
				|  |  | -//        List<Map<String, Long>> maps = indexBaseMonthDataDao.countTotalStudentNum();
 | 
	
		
			
				|  |  | -//        Map<String, Long> organStudentNumMap = new HashMap<>(20);
 | 
	
		
			
				|  |  | -//        if(maps != null && maps.size() > 0){
 | 
	
		
			
				|  |  | -//            organStudentNumMap = MapUtil.convertIntegerMap(maps);
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  |          params.put("organIdList",organIdList);
 | 
	
		
			
				|  |  |          List<CloudTeacherActiveTargetDto> resultList = indexBaseMonthDataDao.countCloudTeacherActive(params);
 | 
	
		
			
				|  |  |          for (CloudTeacherActiveTargetDto dto : resultList) {
 | 
	
		
			
				|  |  | -//            Long aLong = organStudentNumMap.get(dto.getOrganId().toString());
 | 
	
		
			
				|  |  | -//            dto.setTotalNum(aLong==null?0:aLong.intValue());
 | 
	
		
			
				|  |  |              List<CloudTeacherActiveTargetDto> targetDtos = targetMap.get(dto.getOrganId());
 | 
	
		
			
				|  |  |              if(targetDtos != null && targetDtos.size() > 0){
 | 
	
		
			
				|  |  |                  CloudTeacherActiveTargetDto target = targetDtos.get(0);
 | 
	
	
		
			
				|  | @@ -1097,22 +1015,15 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 | 
	
		
			
				|  |  |          resultMap.put("buyAmount",buyAmount);
 | 
	
		
			
				|  |  |          Integer buyNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getBuyNum).sum();
 | 
	
		
			
				|  |  |          resultMap.put("buyNum",buyNum);
 | 
	
		
			
				|  |  | -//        Integer totalNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getTotalNum).sum();
 | 
	
		
			
				|  |  | -//        resultMap.put("totalNum",totalNum);
 | 
	
		
			
				|  |  |          Integer targetNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getTargetNum).sum();
 | 
	
		
			
				|  |  |          resultMap.put("targetNum",targetNum);
 | 
	
		
			
				|  |  |          resultMap.put("avgBuyAmount",0);
 | 
	
		
			
				|  |  | -//        resultMap.put("buyScale",0);
 | 
	
		
			
				|  |  |          resultMap.put("targetFinishScale",0);
 | 
	
		
			
				|  |  |          resultMap.put("targetAmountFinishScale",0);
 | 
	
		
			
				|  |  |          if(buyAmount.doubleValue() > 0d && buyNum > 0){
 | 
	
		
			
				|  |  |              BigDecimal avgBuyAmount = buyAmount.divide(new BigDecimal(buyNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 | 
	
		
			
				|  |  |              resultMap.put("avgBuyAmount",avgBuyAmount);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -//        if(totalNum > 0 && buyNum > 0){
 | 
	
		
			
				|  |  | -//            BigDecimal buyScale = new BigDecimal(buyNum).divide(new BigDecimal(totalNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
 | 
	
		
			
				|  |  | -//            resultMap.put("buyScale",buyScale);
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  |          if(targetNum > 0 && buyNum > 0){
 | 
	
		
			
				|  |  |              BigDecimal targetFinishScale = new BigDecimal(buyNum).divide(new BigDecimal(targetNum), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
 | 
	
		
			
				|  |  |              resultMap.put("targetFinishScale",targetFinishScale);
 | 
	
	
		
			
				|  | @@ -1150,20 +1061,6 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 | 
	
		
			
				|  |  |                      resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getAvgBuyAmount)).collect(Collectors.toList());
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  break;
 | 
	
		
			
				|  |  | -//            case "totalNum":
 | 
	
		
			
				|  |  | -//                if("DESC".equalsIgnoreCase(order)){
 | 
	
		
			
				|  |  | -//                    resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTotalNum,Comparator.reverseOrder())).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -//                }else {
 | 
	
		
			
				|  |  | -//                    resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTotalNum)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -//                }
 | 
	
		
			
				|  |  | -//                break;
 | 
	
		
			
				|  |  | -//            case "buyScale":
 | 
	
		
			
				|  |  | -//                if("DESC".equalsIgnoreCase(order)){
 | 
	
		
			
				|  |  | -//                    resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyScale,Comparator.reverseOrder())).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -//                }else {
 | 
	
		
			
				|  |  | -//                    resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyScale)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -//                }
 | 
	
		
			
				|  |  | -//                break;
 | 
	
		
			
				|  |  |              case "targetNum":
 | 
	
		
			
				|  |  |                  if("DESC".equalsIgnoreCase(order)){
 | 
	
		
			
				|  |  |                      resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTargetNum,Comparator.reverseOrder())).collect(Collectors.toList());
 | 
	
	
		
			
				|  | @@ -1314,8 +1211,42 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<IndexCloudStudySumDto> getCloudStudyStudentOverViewList1(List<Integer> organIdsList) {
 | 
	
		
			
				|  |  | -        List<IndexCloudStudySumDto> list = studentDao.getCloudStudyStudentOverViewList1(organIdsList);
 | 
	
		
			
				|  |  | +    public PageInfo<CloudTeacherSumDto> cloudTeacherSumDetail(StudentCourseConsumerQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +        PageInfo<CloudTeacherSumDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  | +        Date date = DateUtil.stringToDate(queryInfo.getStartDate(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
 | 
	
		
			
				|  |  | +        Date date2 = DateUtil.stringToDate(queryInfo.getEndDate(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
 | 
	
		
			
				|  |  | +        long weekBetween = DateUtil.weekBetween(date, date2);
 | 
	
		
			
				|  |  | +        queryInfo.setWeekBetween(weekBetween);
 | 
	
		
			
				|  |  | +        Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | +        MapUtil.populateMap(params, queryInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<CloudTeacherSumDto> dataList = null;
 | 
	
		
			
				|  |  | +        int count = studentDao.countCloudTeacherSumDetail(params);
 | 
	
		
			
				|  |  | +        if (count > 0) {
 | 
	
		
			
				|  |  | +            pageInfo.setTotal(count);
 | 
	
		
			
				|  |  | +            params.put("offset", pageInfo.getOffset());
 | 
	
		
			
				|  |  | +            dataList = studentDao.queryCloudTeacherSumDetail(params);
 | 
	
		
			
				|  |  | +            BigDecimal decimal = new BigDecimal(100);
 | 
	
		
			
				|  |  | +            for (CloudTeacherSumDto dto : dataList) {
 | 
	
		
			
				|  |  | +                if(dto.getNormalNum().compareTo(BigDecimal.ZERO) == 0){
 | 
	
		
			
				|  |  | +                    continue;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                BigDecimal normalNum = dto.getNormalNum();
 | 
	
		
			
				|  |  | +                dto.setAvgTrainTime(dto.getTrainTotalTime().divide(normalNum,2, BigDecimal.ROUND_DOWN));
 | 
	
		
			
				|  |  | +                dto.setTrainRate(dto.getTrainStudentNum().divide(normalNum,2, BigDecimal.ROUND_DOWN).multiply(decimal));
 | 
	
		
			
				|  |  | +                dto.setTrainStandRate(dto.getTrain0().divide(normalNum,2, BigDecimal.ROUND_DOWN).multiply(decimal));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (count == 0) {
 | 
	
		
			
				|  |  | +            dataList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  | +        return pageInfo;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public List<IndexCloudStudySumDto> getCloudStudyStudentOverViewList(List<Integer> organIdsList) {
 | 
	
		
			
				|  |  | +        List<IndexCloudStudySumDto> list = studentDao.getCloudStudyStudentOverViewList(organIdsList);
 | 
	
		
			
				|  |  |          Set<Integer> organIds = list.stream().map(e -> e.getOrganId()).collect(Collectors.toSet());
 | 
	
		
			
				|  |  |          Map<Integer,String> organMap = MapUtil.convertMybatisMap(organizationDao.findOrganNameMapList(organIds));
 | 
	
		
			
				|  |  |          //获取待激活学员数
 | 
	
	
		
			
				|  | @@ -1332,7 +1263,7 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 | 
	
		
			
				|  |  |          cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
 | 
	
		
			
				|  |  |          Date startTime = cal.getTime();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        Map<Integer,Long> activeMap = MapUtil.convertIntegerMap(studentDao.getOrganActiveCloudStudyStudentNum1(organIdsList, startTime, endTime));
 | 
	
		
			
				|  |  | +        Map<Integer,Long> activeMap = MapUtil.convertIntegerMap(studentDao.getOrganActiveCloudStudyStudentNum(organIdsList, startTime, endTime));
 | 
	
		
			
				|  |  |          //获取重复购买人数
 | 
	
		
			
				|  |  |          Map<Integer,Long> againBuyMap = MapUtil.convertIntegerMap(studentDao.getAgainBuyNum(organIdsList));
 | 
	
		
			
				|  |  |          for (IndexCloudStudySumDto dto : list) {
 | 
	
	
		
			
				|  | @@ -1344,9 +1275,12 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 | 
	
		
			
				|  |  |              Long integer = activeMap.get(dto.getOrganId());
 | 
	
		
			
				|  |  |              dto.setActiveStudentNum(integer==null?0:integer.intValue());
 | 
	
		
			
				|  |  |              dto.setVipStudentNum(dto.getEffectiveVipStudentNum() + dto.getWaitActivateVipStudentNum());
 | 
	
		
			
				|  |  | -            double studentNum = (double)dto.getVipStudentNum();
 | 
	
		
			
				|  |  | -            dto.setVipStudentRate(studentNum / dto.getTotalStudentNum() * 100d);
 | 
	
		
			
				|  |  | -//            dto.setAgainBuyRate(dto.getAgainBuyNum() / studentNum);
 | 
	
		
			
				|  |  | +            if(dto.getVipStudentNum() != 0){
 | 
	
		
			
				|  |  | +                double studentNum = (double)dto.getVipStudentNum();
 | 
	
		
			
				|  |  | +                dto.setBuyRate(studentNum / dto.getTotalStudentNum() * 100);
 | 
	
		
			
				|  |  | +                dto.setAgainBuyRate(dto.getAgainBuyNum() / studentNum * 100);
 | 
	
		
			
				|  |  | +                dto.setVipStudentRate(studentNum / dto.getTotalStudentNum() * 100d);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return list;
 | 
	
		
			
				|  |  |      }
 |