Browse Source

首页新增 新增人数占比

zouxuan 3 years ago
parent
commit
8a67fcbf9c

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

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

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

@@ -675,4 +675,12 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
      * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.String>>
      */
     List<Map<Integer, String>> queryStudentMusicGroupNamesMap(@Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 获取在读并且进行中的乐团编号
+     * @return
+     */
+    List<String> findMusicGroupIds();
+
+    List<Integer> findStudentIds();
 }

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

@@ -542,7 +542,11 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
             organsNewCloudStudyNumMap = MapUtil.convertIntegerMap(organsNewCloudStudyNumMapList);
         }
         //获取新增人数占比(已上乐团课小于等于4)
-        List<BaseMapDto<Integer, Long>> studentMusicCourseNum = studentDao.getOrganCloudNewStudentNum();
+        //获取有在读学员的乐团编号
+        //获取有在读学员的学员编号
+        List<String> musicGroupIds = studentRegistrationDao.findMusicGroupIds();
+        List<Integer> studentIdList = studentRegistrationDao.findStudentIds();
+        List<BaseMapDto<Integer, Long>> studentMusicCourseNum = studentDao.getOrganCloudNewStudentNum(musicGroupIds,studentIdList);
         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());
@@ -637,7 +641,11 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         }
 
         //获取新增人数占比(已上乐团课小于等于4)
-        List<BaseMapDto<Integer, Long>> studentMusicCourseNum = studentDao.getOrganCloudNewStudentNum();
+        //获取有在读学员的乐团编号
+        //获取有在读学员的学员编号
+        List<String> musicGroupIds = studentRegistrationDao.findMusicGroupIds();
+        List<Integer> studentIdList = studentRegistrationDao.findStudentIds();
+        List<BaseMapDto<Integer, Long>> studentMusicCourseNum = studentDao.getOrganCloudNewStudentNum(musicGroupIds,studentIdList);
         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());

+ 13 - 2
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -1192,8 +1192,19 @@
     <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_`
-        LEFT JOIN student_registration sr ON cs.music_group_id_ = sr.music_group_id_
-        WHERE cs.`status_` = 'OVER' AND cs.`group_type_` = 'MUSIC' AND cs.`del_flag_` = 0 AND sr.music_group_status_ = 'NORMAL'
+        WHERE cs.`status_` = 'OVER' AND cs.`group_type_` = 'MUSIC' AND cs.`del_flag_` = 0
+        <if test="musicGroupIds != null and musicGroupIds.size() > 0">
+            AND cs.music_group_id_ IN
+            <foreach collection="musicGroupIds" item="musicGroupId" open="(" close=")" separator=",">
+                #{musicGroupId}
+            </foreach>
+        </if>
+        <if test="userIds != null and userIds.size() > 0">
+            AND cssp.user_id_ IN
+            <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
+                #{userId}
+            </foreach>
+        </if>
         GROUP BY cssp.`user_id_`
     </select>
     <select id="groupOrganId" resultType="java.util.Map">

+ 10 - 0
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -1687,4 +1687,14 @@
         </if>
         GROUP BY sr.user_id_
     </select>
+    <select id="findMusicGroupIds" resultType="java.lang.String">
+        SELECT DISTINCT sr.music_group_id_ FROM student_registration sr
+        LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
+        WHERE sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
+    </select>
+    <select id="findStudentIds" resultType="java.lang.Integer">
+        SELECT DISTINCT sr.user_id_ FROM student_registration sr
+        LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
+        WHERE sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
+    </select>
 </mapper>