zouxuan 3 rokov pred
rodič
commit
fff950741b

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java

@@ -353,4 +353,12 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
                                                                      @Param("organId") Integer organId);
 
     List<Map<Integer, String>> getStudentSubjectMapList(@Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 获取新增人数占比(已上乐团课小于等于4)
+     * @return
+     */
+    List<BaseMapDto<Integer,Long>> getOrganCloudNewStudentNum();
+
+    List<Map<Long, Long>> groupOrganId(@Param("organIds") List<Integer> organIds, @Param("userIds") List<Integer> userIds);
 }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/EduOrganStudentDataDto.java

@@ -45,6 +45,28 @@ public class EduOrganStudentDataDto {
     @ApiModelProperty("云教练新增人数")
     private int newCloudStudyStudentNum;
 
+    @ApiModelProperty("新用户人数")
+    private int newStudentNum;
+
+    @ApiModelProperty("新用户占比")
+    private float newStudentDuty;
+
+    public int getNewStudentNum() {
+        return newStudentNum;
+    }
+
+    public void setNewStudentNum(int newStudentNum) {
+        this.newStudentNum = newStudentNum;
+    }
+
+    public float getNewStudentDuty() {
+        return newStudentDuty;
+    }
+
+    public void setNewStudentDuty(float newStudentDuty) {
+        this.newStudentDuty = newStudentDuty;
+    }
+
     public int getIndex() {
         return index;
     }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/OrganCloudStudyStudentDataQueryInfo.java

@@ -39,6 +39,28 @@ public class OrganCloudStudyStudentDataQueryInfo extends QueryInfo {
     @ApiModelProperty("云教练新增人数")
     private String newCloudStudyStudentNum;
 
+    @ApiModelProperty("新用户人数")
+    private String newStudentNum;
+
+    @ApiModelProperty("新用户人数占比")
+    private String newStudentDuty;
+
+    public String getNewStudentNum() {
+        return newStudentNum;
+    }
+
+    public void setNewStudentNum(String newStudentNum) {
+        this.newStudentNum = newStudentNum;
+    }
+
+    public String getNewStudentDuty() {
+        return newStudentDuty;
+    }
+
+    public void setNewStudentDuty(String newStudentDuty) {
+        this.newStudentDuty = newStudentDuty;
+    }
+
     public String getDate() {
         return date;
     }

+ 43 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServiceImpl.java

@@ -472,7 +472,7 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
                 if(studentGroupNamesMap.containsKey(eduOrganStudentListDto.getStudentId())){
                     eduOrganStudentListDto.setMusicGroupNames(studentGroupNamesMap.get(eduOrganStudentListDto.getStudentId()));
                 }
-                if(hasVipCourseStudentIds.contains(eduOrganStudentListDto.getStudentId())){
+                if(hasVipCourseStudentIds.contains(eduOrganStudentListDto.getSubjectId())){
                     eduOrganStudentListDto.setHasVipGroup(1);
                 }
                 if(eduOrganStudentListDto.getCloudStudyUseNum()>0 && eduOrganStudentListDto.getCloudStudyUseTime()>0){
@@ -541,6 +541,15 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         if(!CollectionUtils.isEmpty(organsNewCloudStudyNumMapList)){
             organsNewCloudStudyNumMap = MapUtil.convertIntegerMap(organsNewCloudStudyNumMapList);
         }
+        //获取新增人数占比(已上乐团课小于等于4)
+        List<BaseMapDto<Integer, Long>> studentMusicCourseNum = studentDao.getOrganCloudNewStudentNum();
+        Map<String, Long> organsNewCloudNewStudentNumMap = new HashMap<>();
+        if(!CollectionUtils.isEmpty(studentMusicCourseNum)){
+            List<BaseMapDto<Integer, Long>> collect = studentMusicCourseNum.stream().filter(e -> e.getValue() < 5).collect(Collectors.toList());
+            List<Integer> userIdList = collect.stream().map(e -> e.getKey()).collect(Collectors.toList());
+            List<Map<Long, Long>> organsNewCloudNewStudentNumMapList = studentDao.groupOrganId(organIds,userIdList);
+            organsNewCloudNewStudentNumMap = MapUtil.convertIntegerMap(organsNewCloudNewStudentNumMapList);
+        }
 
         List<EduOrganStudentDataDto> result = new ArrayList<>();
 
@@ -572,6 +581,10 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
             if(organsNewCloudStudyNumMap.containsKey(organ.getId().toString())){
                 organStudentVipData.setNewCloudStudyStudentNum(organsNewCloudStudyNumMap.get(organ.getId().toString()).intValue());
             }
+            if(organsNewCloudNewStudentNumMap.containsKey(organ.getId().toString())){
+                organStudentVipData.setNewStudentNum(organsNewCloudNewStudentNumMap.get(organ.getId().toString()).intValue());
+                organStudentVipData.setNewStudentDuty(new BigDecimal(organStudentVipData.getNewStudentNum()).divide(new BigDecimal(organStudentVipData.getTotalStudentNum()), 4, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).floatValue());
+            }
             result.add(organStudentVipData);
         }
         return result;
@@ -623,6 +636,16 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
             organsNewCloudStudyNumMap = MapUtil.convertIntegerMap(organsNewCloudStudyNumMapList);
         }
 
+        //获取新增人数占比(已上乐团课小于等于4)
+        List<BaseMapDto<Integer, Long>> studentMusicCourseNum = studentDao.getOrganCloudNewStudentNum();
+        Map<String, Long> organsNewCloudNewStudentNumMap = new HashMap<>();
+        if(!CollectionUtils.isEmpty(studentMusicCourseNum)){
+            List<BaseMapDto<Integer, Long>> collect = studentMusicCourseNum.stream().filter(e -> e.getValue() < 5).collect(Collectors.toList());
+            List<Integer> userIdList = collect.stream().map(e -> e.getKey()).collect(Collectors.toList());
+            List<Map<Long, Long>> organsNewCloudNewStudentNumMapList = studentDao.groupOrganId(organIds,userIdList);
+            organsNewCloudNewStudentNumMap = MapUtil.convertIntegerMap(organsNewCloudNewStudentNumMapList);
+        }
+
         List<EduOrganStudentDataDto> result = new ArrayList<>();
 
         for (Organization organ : organs) {
@@ -653,6 +676,10 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
             if(organsNewCloudStudyNumMap.containsKey(organ.getId().toString())){
                 organStudentVipData.setNewCloudStudyStudentNum(organsNewCloudStudyNumMap.get(organ.getId().toString()).intValue());
             }
+            if(organsNewCloudNewStudentNumMap.containsKey(organ.getId().toString())){
+                organStudentVipData.setNewStudentNum(organsNewCloudNewStudentNumMap.get(organ.getId().toString()).intValue());
+                organStudentVipData.setNewStudentDuty(new BigDecimal(organStudentVipData.getNewStudentNum()).divide(new BigDecimal(organStudentVipData.getTotalStudentNum()), 4, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).floatValue());
+            }
             result.add(organStudentVipData);
         }
         Comparator<EduOrganStudentDataDto> comparing = null;
@@ -712,12 +739,26 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
                 comparing.thenComparing(EduOrganStudentDataDto::getCloudStudyLivelyStudentDuty, "ASC".equals(queryInfo.getCloudStudyLivelyStudentDuty())?Comparator.naturalOrder():Comparator.reverseOrder());
             }
         }
+        if(StringUtils.isNotBlank(queryInfo.getNewStudentNum())){
+            if(Objects.isNull(comparing)){
+                comparing = Comparator.comparing(EduOrganStudentDataDto::getNewStudentNum, "ASC".equals(queryInfo.getNewStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+            }else{
+                comparing.thenComparing(EduOrganStudentDataDto::getNewStudentNum, "ASC".equals(queryInfo.getNewStudentNum())?Comparator.naturalOrder():Comparator.reverseOrder());
+            }
+        }
+        if(StringUtils.isNotBlank(queryInfo.getNewStudentDuty())){
+            if(Objects.isNull(comparing)){
+                comparing = Comparator.comparing(EduOrganStudentDataDto::getNewStudentDuty, "ASC".equals(queryInfo.getNewStudentDuty())?Comparator.naturalOrder():Comparator.reverseOrder());
+            }else{
+                comparing.thenComparing(EduOrganStudentDataDto::getNewStudentDuty, "ASC".equals(queryInfo.getNewStudentDuty())?Comparator.naturalOrder():Comparator.reverseOrder());
+            }
+        }
 
         if(Objects.isNull(comparing)){
             comparing = Comparator.comparing(EduOrganStudentDataDto::getOrganId);
         }
 
-        result = result.stream().sorted(comparing).skip(pageInfo.getOffset()).limit(pageInfo.getLimit()).collect(Collectors.toList());
+        result = result.stream().skip(pageInfo.getOffset()).limit(pageInfo.getLimit()).sorted(comparing).collect(Collectors.toList());
         pageInfo.setRows(result);
         return pageInfo;
     }

+ 23 - 0
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -1189,6 +1189,29 @@
             #{studentId}
         </foreach>
     </select>
+    <select id="getOrganCloudNewStudentNum" resultType="com.ym.mec.biz.dal.dto.BaseMapDto">
+        SELECT cssp.`user_id_` 'key',count(cs.`id_`) 'value' FROM `course_schedule_student_payment` cssp
+        STRAIGHT_JOIN `course_schedule` cs on cssp.`course_schedule_id_` = cs.`id_`
+        WHERE cs.`status_` = 'OVER' AND cs.`group_type_` = 'MUSIC' AND cs.`del_flag_` = 0
+        GROUP BY cssp.`user_id_`
+    </select>
+    <select id="groupOrganId" resultType="java.util.Map">
+        SELECT su.organ_id_ 'key',COUNT(DISTINCT su.id_) 'value' FROM sys_user su
+        WHERE 1 = 1
+        <if test="userIds!=null and userIds.size() > 0">
+            AND su.id_ IN
+            <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
+                #{userId}
+            </foreach>
+        </if>
+        <if test="organIds!=null and organIds.size() > 0">
+            AND su.organ_id_ IN
+            <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+                #{organId}
+            </foreach>
+        </if>
+        GROUP BY su.organ_id_
+    </select>
 
     <update id="updateGrade"><![CDATA[
         UPDATE student SET current_grade_num_=current_grade_num_+1