Ver código fonte

学员小课数据统计

zouxuan 3 anos atrás
pai
commit
fcae8cd162

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentStatisticsDao.java

@@ -1,8 +1,13 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.StudentStatisticsDto;
+import com.ym.mec.biz.dal.dto.StudentStatisticsSumDto;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.biz.dal.entity.StudentStatistics;
 
+import java.util.List;
+import java.util.Map;
+
 public interface StudentStatisticsDao extends BaseDAO<Integer, StudentStatistics> {
 
     //更新乐团主管、指导老师
@@ -22,4 +27,14 @@ public interface StudentStatisticsDao extends BaseDAO<Integer, StudentStatistics
 
     //更新第一次课的时间\最近一次课时间
     void updateFirstAndLastCourseTime();
+
+    int countStatistics(Map<String, Object> params);
+
+    List<StudentStatisticsDto> queryStatistics(Map<String, Object> params);
+
+    //更新进行中课程组数量
+    void updateNormalGroupNum();
+
+    //汇总小课数据
+    StudentStatisticsSumDto studentSmallClassStatisticsSum(String groupType);
 }

+ 160 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentStatisticsSumDto.java

@@ -0,0 +1,160 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class StudentStatisticsSumDto {
+
+    @ApiModelProperty(value = "沉睡学员总数:有课耗且有【未开始】课程的学生中,近一年无课耗学生总数",required = false)
+    private Integer sleepStudentNum;
+
+    @ApiModelProperty(value = "有未排课:沉睡学员中,有未排课资格的学数量",required = false)
+    private Integer sleepStudentHasNotSchedule;
+
+    @ApiModelProperty(value = "无未排课:沉睡学员中,无未排课资格的学数量",required = false)
+    private Integer sleepStudentNoNotSchedule;
+
+    @ApiModelProperty(value = "在读学员总数:有【未开始】+【未排课】+ 近一年有课耗学生总数",required = false)
+    private Integer normalStudentNum;
+
+    @ApiModelProperty(value = "进行中:【在读学员总数】中有【进行中】状态课程组的学生数量",required = false)
+    private Integer normalStudentHasNormalGroupNum;
+
+    @ApiModelProperty(value = "暂停:有课程余额且没有剩余课时",required = false)
+    private Integer hasCourseBalanceAndNotSubCourseNum;
+
+    @ApiModelProperty(value = "未排课:【在读学员总数】中有未排课资格的学员数量",required = false)
+    private Integer normalStudentHasNoScheduleNum;
+
+    @ApiModelProperty(value = "待续费人数:【未开始】+【未排课】课时数≤3节",required = false)
+    private Integer waitRenewNum;
+
+    @ApiModelProperty(value = "未开始课时:【未开始】课程总数",required = false)
+    private Integer subCourseNum;
+
+    @ApiModelProperty(value = "未排课课时:活动资格【未排课】课程总数(1v多不去重)",required = false)
+    private Integer noScheduleNum;
+
+    @ApiModelProperty(value = "流失人数",required = false)
+    private Integer lostNum;
+
+    @ApiModelProperty(value = "新增人数:以前没课,所选时间段内新增课程或排课资格的学员",required = false)
+    private Integer addNum;
+
+    @ApiModelProperty(value = "续费人数:所选结束时间之前有多笔大于0元的付费订单(活动赠送不算)",required = false)
+    private Integer renewNum;
+
+    @ApiModelProperty(value = "回访人数",required = false)
+    private Integer visitNum;
+
+    public Integer getSleepStudentNum() {
+        return sleepStudentNum;
+    }
+
+    public void setSleepStudentNum(Integer sleepStudentNum) {
+        this.sleepStudentNum = sleepStudentNum;
+    }
+
+    public Integer getSleepStudentHasNotSchedule() {
+        return sleepStudentHasNotSchedule;
+    }
+
+    public void setSleepStudentHasNotSchedule(Integer sleepStudentHasNotSchedule) {
+        this.sleepStudentHasNotSchedule = sleepStudentHasNotSchedule;
+    }
+
+    public Integer getSleepStudentNoNotSchedule() {
+        return sleepStudentNoNotSchedule;
+    }
+
+    public void setSleepStudentNoNotSchedule(Integer sleepStudentNoNotSchedule) {
+        this.sleepStudentNoNotSchedule = sleepStudentNoNotSchedule;
+    }
+
+    public Integer getNormalStudentNum() {
+        return normalStudentNum;
+    }
+
+    public void setNormalStudentNum(Integer normalStudentNum) {
+        this.normalStudentNum = normalStudentNum;
+    }
+
+    public Integer getNormalStudentHasNormalGroupNum() {
+        return normalStudentHasNormalGroupNum;
+    }
+
+    public void setNormalStudentHasNormalGroupNum(Integer normalStudentHasNormalGroupNum) {
+        this.normalStudentHasNormalGroupNum = normalStudentHasNormalGroupNum;
+    }
+
+    public Integer getHasCourseBalanceAndNotSubCourseNum() {
+        return hasCourseBalanceAndNotSubCourseNum;
+    }
+
+    public void setHasCourseBalanceAndNotSubCourseNum(Integer hasCourseBalanceAndNotSubCourseNum) {
+        this.hasCourseBalanceAndNotSubCourseNum = hasCourseBalanceAndNotSubCourseNum;
+    }
+
+    public Integer getNormalStudentHasNoScheduleNum() {
+        return normalStudentHasNoScheduleNum;
+    }
+
+    public void setNormalStudentHasNoScheduleNum(Integer normalStudentHasNoScheduleNum) {
+        this.normalStudentHasNoScheduleNum = normalStudentHasNoScheduleNum;
+    }
+
+    public Integer getWaitRenewNum() {
+        return waitRenewNum;
+    }
+
+    public void setWaitRenewNum(Integer waitRenewNum) {
+        this.waitRenewNum = waitRenewNum;
+    }
+
+    public Integer getSubCourseNum() {
+        return subCourseNum;
+    }
+
+    public void setSubCourseNum(Integer subCourseNum) {
+        this.subCourseNum = subCourseNum;
+    }
+
+    public Integer getNoScheduleNum() {
+        return noScheduleNum;
+    }
+
+    public void setNoScheduleNum(Integer noScheduleNum) {
+        this.noScheduleNum = noScheduleNum;
+    }
+
+    public Integer getLostNum() {
+        return lostNum;
+    }
+
+    public void setLostNum(Integer lostNum) {
+        this.lostNum = lostNum;
+    }
+
+    public Integer getAddNum() {
+        return addNum;
+    }
+
+    public void setAddNum(Integer addNum) {
+        this.addNum = addNum;
+    }
+
+    public Integer getRenewNum() {
+        return renewNum;
+    }
+
+    public void setRenewNum(Integer renewNum) {
+        this.renewNum = renewNum;
+    }
+
+    public Integer getVisitNum() {
+        return visitNum;
+    }
+
+    public void setVisitNum(Integer visitNum) {
+        this.visitNum = visitNum;
+    }
+}

+ 12 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentStatistics.java

@@ -47,6 +47,9 @@ public class StudentStatistics {
 	
 	/** 最近30天课耗(已结束的课程数量) */
 	private Integer latelyCourseConsumer;
+
+	/** 最近1年课耗(已结束的课程数量) */
+	private Integer latelyYearCourseConsumer;
 	
 	/** 回访次数 */
 	private Integer visitNum;
@@ -77,7 +80,15 @@ public class StudentStatistics {
 	
 	/** 课程组类型(VIP乐理网管) */
 	private String groupType;
-	
+
+	public Integer getLatelyYearCourseConsumer() {
+		return latelyYearCourseConsumer;
+	}
+
+	public void setLatelyYearCourseConsumer(Integer latelyYearCourseConsumer) {
+		this.latelyYearCourseConsumer = latelyYearCourseConsumer;
+	}
+
 	public void setId(Integer id){
 		this.id = id;
 	}

+ 154 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentStatisticsQueryInfo.java

@@ -0,0 +1,154 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+* @author zx
+* @date 2021/9/26 15:52
+*/
+public class StudentStatisticsQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "小课类型 VIP、PRACTICE、THEORY 默认VIP",required = true)
+    private String groupType = "VIP";
+
+    @ApiModelProperty(value = "声部编号",required = false)
+    private Integer subjectId;
+
+    @ApiModelProperty(value = "学员状态,在读(NORMAL)、沉睡(SLEEPY)",required = false)
+    private String studentStatus;
+
+    @ApiModelProperty(value = "回访状态,THINKING(考虑中), PENDING_PAYMENT(确认缴费待缴费),LOST(流失), PAUSE(暂停),OTHER(其他)",required = false)
+    private String feedbackType;
+
+    @ApiModelProperty(value = "30天课耗",required = false)
+    private Integer latelyCourseConsumer;
+
+    @ApiModelProperty(value = "一年课耗",required = false)
+    private Integer latelyYearCourseConsumer;
+
+    @ApiModelProperty(value = "回访次数",required = false)
+    private Integer visitNum;
+
+    @ApiModelProperty(value = "指导老师",required = false)
+    private Integer teacherId;
+
+    @ApiModelProperty(value = "声部课老师",required = false)
+    private Integer subjectTeacherId;
+
+    @ApiModelProperty(value = "乐团主管",required = false)
+    private Integer musicDirectorId;
+
+    @ApiModelProperty(value = "是否查询课耗异常",required = false)
+    private boolean courseConsumerError = false;
+
+    @ApiModelProperty(value = "第一次课开始时间(年月日)",required = false)
+    private String firstCourseStartTime;
+
+    @ApiModelProperty(value = "第一次课截止时间(年月日)",required = false)
+    private String firstCourseEndTime;
+
+    public String getGroupType() {
+        return groupType;
+    }
+
+    public void setGroupType(String groupType) {
+        this.groupType = groupType;
+    }
+
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getStudentStatus() {
+        return studentStatus;
+    }
+
+    public void setStudentStatus(String studentStatus) {
+        this.studentStatus = studentStatus;
+    }
+
+    public String getFeedbackType() {
+        return feedbackType;
+    }
+
+    public void setFeedbackType(String feedbackType) {
+        this.feedbackType = feedbackType;
+    }
+
+    public Integer getLatelyCourseConsumer() {
+        return latelyCourseConsumer;
+    }
+
+    public void setLatelyCourseConsumer(Integer latelyCourseConsumer) {
+        this.latelyCourseConsumer = latelyCourseConsumer;
+    }
+
+    public Integer getLatelyYearCourseConsumer() {
+        return latelyYearCourseConsumer;
+    }
+
+    public void setLatelyYearCourseConsumer(Integer latelyYearCourseConsumer) {
+        this.latelyYearCourseConsumer = latelyYearCourseConsumer;
+    }
+
+    public Integer getVisitNum() {
+        return visitNum;
+    }
+
+    public void setVisitNum(Integer visitNum) {
+        this.visitNum = visitNum;
+    }
+
+    public Integer getTeacherId() {
+        return teacherId;
+    }
+
+    public void setTeacherId(Integer teacherId) {
+        this.teacherId = teacherId;
+    }
+
+    public Integer getSubjectTeacherId() {
+        return subjectTeacherId;
+    }
+
+    public void setSubjectTeacherId(Integer subjectTeacherId) {
+        this.subjectTeacherId = subjectTeacherId;
+    }
+
+    public Integer getMusicDirectorId() {
+        return musicDirectorId;
+    }
+
+    public void setMusicDirectorId(Integer musicDirectorId) {
+        this.musicDirectorId = musicDirectorId;
+    }
+
+    public boolean isCourseConsumerError() {
+        return courseConsumerError;
+    }
+
+    public void setCourseConsumerError(boolean courseConsumerError) {
+        this.courseConsumerError = courseConsumerError;
+    }
+
+    public String getFirstCourseStartTime() {
+        return firstCourseStartTime;
+    }
+
+    public void setFirstCourseStartTime(String firstCourseStartTime) {
+        this.firstCourseStartTime = firstCourseStartTime;
+    }
+
+    public String getFirstCourseEndTime() {
+        return firstCourseEndTime;
+    }
+
+    public void setFirstCourseEndTime(String firstCourseEndTime) {
+        this.firstCourseEndTime = firstCourseEndTime;
+    }
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentStatisticsService.java

@@ -1,10 +1,18 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.dto.StudentStatisticsDto;
+import com.ym.mec.biz.dal.dto.StudentStatisticsSumDto;
 import com.ym.mec.biz.dal.entity.StudentStatistics;
+import com.ym.mec.biz.dal.page.StudentStatisticsQueryInfo;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface StudentStatisticsService extends BaseService<Integer, StudentStatistics> {
 
     void updateStudentStatistics();
 
+    PageInfo<StudentStatisticsDto> queryStatisticsPage(StudentStatisticsQueryInfo queryInfo);
+
+    StudentStatisticsSumDto studentSmallClassStatisticsSum(String groupType);
 }

+ 36 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentStatisticsServiceImpl.java

@@ -1,19 +1,24 @@
 package com.ym.mec.biz.service.impl;
 
-import com.google.common.collect.Lists;
 import com.ym.mec.biz.dal.dao.StudentBasicInfoDao;
 import com.ym.mec.biz.dal.dao.StudentStatisticsDao;
-import com.ym.mec.biz.dal.entity.StudentBasicInfo;
+import com.ym.mec.biz.dal.dto.StudentStatisticsDto;
+import com.ym.mec.biz.dal.dto.StudentStatisticsSumDto;
 import com.ym.mec.biz.dal.entity.StudentStatistics;
+import com.ym.mec.biz.dal.page.StudentStatisticsQueryInfo;
 import com.ym.mec.biz.service.StudentStatisticsService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.stream.Collectors;
+import java.util.Map;
 
 @Service
 public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, StudentStatistics>  implements StudentStatisticsService {
@@ -34,7 +39,7 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
 		studentBasicInfoDao.updateSubjectTeacher();
 		//更新乐团主管、指导老师
 		studentStatisticsDao.updateTeacherAndEdu();
-		//更新总课时数、已完成、剩余课时数、最近30天课耗
+		//更新总课时数、已完成、剩余课时数、最近30天课耗、最近1年课耗
 		studentStatisticsDao.updateCourseNum();
 		//更新未排课总数
 		studentStatisticsDao.updateNoCourseNum();
@@ -44,5 +49,32 @@ public class StudentStatisticsServiceImpl extends BaseServiceImpl<Integer, Stude
 		studentStatisticsDao.updateNoCourseFee();
 		//更新第一次课的时间\最近一次课时间
 		studentStatisticsDao.updateFirstAndLastCourseTime();
+		//更新进行中课程组数量
+		studentStatisticsDao.updateNormalGroupNum();
 	}
+
+	@Override
+	public PageInfo<StudentStatisticsDto> queryStatisticsPage(StudentStatisticsQueryInfo queryInfo) {
+		PageInfo<StudentStatisticsDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<StudentStatisticsDto> dataList = null;
+		int count = studentStatisticsDao.countStatistics(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = studentStatisticsDao.queryStatistics(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+
+    @Override
+    public StudentStatisticsSumDto studentSmallClassStatisticsSum(String groupType) {
+		return studentStatisticsDao.studentSmallClassStatisticsSum(groupType);
+    }
 }

+ 112 - 2
mec-biz/src/main/resources/config/mybatis/StudentStatisticsMapper.xml

@@ -20,6 +20,7 @@
 		<result column="first_course_time_" property="firstCourseTime" />
 		<result column="last_course_time_" property="lastCourseTime" />
 		<result column="lately_course_consumer_" property="latelyCourseConsumer" />
+		<result column="lately_year_course_consumer_" property="latelyYearCourseConsumer" />
 		<result column="visit_num_" property="visitNum" />
 		<result column="last_visit_status_" property="lastVisitStatus" />
 		<result column="visit_reason_" property="visitReason" />
@@ -41,7 +42,7 @@
 	<select id="findAll" resultMap="StudentStatistics">
 		SELECT * FROM student_statistics ORDER BY id_
 	</select>
-	
+
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentStatistics" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO student_statistics (id_,user_id_,teacher_id_,teacher_name_,music_director_id_,
@@ -54,7 +55,7 @@
 		       #{latelyCourseConsumer},#{visitNum},#{lastVisitStatus},#{visitReason},#{lastVisitTime},#{notStartCourseFee},#{noCourseFee},#{firstOrderTime},
 		       #{lastOrderTime},#{orderNum},#{groupType})
 	</insert>
-	
+
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentStatistics">
 		UPDATE student_statistics <set>
@@ -141,6 +142,9 @@
 	<update id="updateFirstAndLastCourseTime">
 		SELECT updateFirstAndLastCourseTime()
 	</update>
+	<update id="updateNormalGroupNum">
+		SELECT updateNormalGroupNum()
+	</update>
 
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
@@ -156,4 +160,110 @@
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM student_statistics
 	</select>
+	<resultMap id="StudentStatisticsDto" type="com.ym.mec.biz.dal.dto.StudentStatisticsDto" extends="StudentStatistics">
+		<association property="studentBasicInfo" javaType="com.ym.mec.biz.dal.entity.StudentBasicInfo">
+			<result column="user_id_" property="userId" />
+			<result column="user_name_" property="userName" />
+			<result column="phone_" property="phone" />
+			<result column="subject_id_" property="subjectId" />
+			<result column="subject_name_" property="subjectName" />
+			<result column="grade_" property="grade" />
+			<result column="organ_id_" property="organId" />
+			<result column="organ_name_" property="organName" />
+			<result column="cooperation_organ_id_" property="cooperationOrganId" />
+			<result column="cooperation_organ_name_" property="cooperationOrganName" />
+			<result column="subject_teacher_id_" property="subjectTeacherId" />
+			<result column="subject_teacher_name_" property="subjectTeacherName" />
+		</association>
+	</resultMap>
+	<sql id="queryStatisticsSql">
+		<where>
+			<if test="search != null and search != ''">
+				AND (sbi.user_id_ = #{search} OR sbi.user_name_ LIKE CONCAT('%',#{search},'%'))
+			</if>
+			<if test="subjectId != null">
+				AND sbi.subject_id_ = #{subjectId}
+			</if>
+			<if test="studentStatus != null and studentStatus != ''">
+				<if test="studentStatus == 'NORMAL'">
+					AND ss.over_course_num_ > 0 AND ss.sub_course_num_ > 0 AND ss.lately_year_course_consumer_ > 0
+				</if>
+				<if test="studentStatus == 'SLEEPY'">
+					AND ss.over_course_num_ > 0 AND ss.sub_course_num_ > 0 AND ss.lately_year_course_consumer_ &lt;= 0
+				</if>
+			</if>
+			<if test="feedbackType != null and feedbackType != ''">
+				AND ss.last_visit_status_ = #{feedbackType}
+			</if>
+			<if test="latelyCourseConsumer != null">
+				AND ss.lately_course_consumer_ = #{latelyCourseConsumer}
+			</if>
+			<if test="latelyYearCourseConsumer != null">
+				AND ss.lately_year_course_consumer_ = #{latelyYearCourseConsumer}
+			</if>
+			<if test="visitNum != null">
+				AND ss.visit_num_ = #{visitNum}
+			</if>
+			<if test="teacherId != null">
+				AND ss.teacher_id_ = #{teacherId}
+			</if>
+			<if test="subjectTeacherId != null">
+				AND sbi.subject_teacher_id_ = #{subjectTeacherId}
+			</if>
+			<if test="musicDirectorId != null">
+				AND ss.music_director_id_ = #{musicDirectorId}
+			</if>
+			<if test="courseConsumerError != null and courseConsumerError == 'true'">
+				AND ss.lately_course_consumer_ &lt; 4
+			</if>
+			<if test="firstCourseStartTime != null">
+				AND ss.first_course_time_ >= #{firstCourseStartTime}
+			</if>
+			<if test="firstCourseEndTime != null">
+				AND ss.first_course_time_ &lt;= #{firstCourseEndTime}
+			</if>
+			<if test="groupType != null and groupType != ''">
+				AND ss.group_type_ = #{groupType}
+			</if>
+		</where>
+	</sql>
+	<select id="countStatistics" resultType="java.lang.Integer">
+		SELECT COUNT(sbi.id_) FROM student_basic_info sbi
+		LEFT JOIN student_statistics ss ON ss.user_id_ = sbi.user_id_
+		<include refid="queryStatisticsSql"/>
+	</select>
+	<select id="queryStatistics" resultMap="StudentStatisticsDto">
+		SELECT * FROM student_basic_info sbi
+		LEFT JOIN student_statistics ss ON ss.user_id_ = sbi.user_id_
+		<include refid="queryStatisticsSql"/>
+		<include refid="global.limit"/>
+	</select>
+	<resultMap id="StudentStatisticsSumDto" type="com.ym.mec.biz.dal.dto.StudentStatisticsSumDto">
+		<result property="sleepStudentNum" column="sleepStudentNum"/>
+		<result property="sleepStudentHasNotSchedule" column="sleepStudentHasNotSchedule"/>
+		<result property="sleepStudentNoNotSchedule" column="sleepStudentNoNotSchedule"/>
+		<result property="normalStudentNum" column="normalStudentNum"/>
+		<result property="normalStudentHasNormalGroupNum" column="normalStudentHasNormalGroupNum"/>
+		<result property="hasCourseBalanceAndNotSubCourseNum" column="hasCourseBalanceAndNotSubCourseNum"/>
+		<result property="normalStudentHasNoScheduleNum" column="normalStudentHasNoScheduleNum"/>
+		<result property="waitRenewNum" column="waitRenewNum"/>
+		<result property="subCourseNum" column="subCourseNum"/>
+		<result property="noScheduleNum" column="noScheduleNum"/>
+	</resultMap>
+	<select id="studentSmallClassStatisticsSum" resultMap="StudentStatisticsSumDto">
+		SELECT
+		COUNT(CASE WHEN ss.over_course_num_ > 0 AND ss.sub_course_num_ > 0 AND ss.lately_year_course_consumer_ &lt;= 0 THEN 1 ELSE NULL END) 'sleepStudentNum',
+		COUNT(CASE WHEN ss.over_course_num_ > 0 AND ss.sub_course_num_ > 0 AND ss.lately_year_course_consumer_ &lt;= 0 AND ss.no_schedule_num_ > 0 THEN 1 ELSE NULL END) 'sleepStudentHasNotSchedule',
+		COUNT(CASE WHEN ss.over_course_num_ > 0 AND ss.sub_course_num_ > 0 AND ss.lately_year_course_consumer_ &lt;= 0 AND ss.no_schedule_num_ &lt;= 0 THEN 1 ELSE NULL END) 'sleepStudentNoNotSchedule',
+		COUNT(CASE WHEN ss.over_course_num_ > 0 AND ss.sub_course_num_ > 0 AND ss.lately_year_course_consumer_ > 0 THEN 1 ELSE NULL END) 'normalStudentNum',
+		COUNT(CASE WHEN ss.over_course_num_ > 0 AND ss.sub_course_num_ > 0 AND ss.lately_year_course_consumer_ > 0 AND ss.normal_group_num_ > 0 THEN 1 ELSE NULL END) 'normalStudentHasNormalGroupNum',
+		COUNT(CASE WHEN suca.course_balance_ > 0 AND ss.sub_course_num_ &lt;= 0 THEN 1 ELSE NULL END) 'hasCourseBalanceAndNotSubCourseNum',
+		COUNT(CASE WHEN ss.over_course_num_ > 0 AND ss.sub_course_num_ > 0 AND ss.lately_year_course_consumer_ > 0 AND ss.no_schedule_num_ > 0 THEN 1 ELSE NULL END) 'normalStudentHasNoScheduleNum',
+		COUNT(CASE WHEN (ss.no_schedule_num_ + ss.no_schedule_num_) &lt; 4 THEN 1 ELSE NULL END) 'waitRenewNum',
+		SUM(ss.sub_course_num_) 'subCourseNum',
+		SUM(ss.no_schedule_num_) 'noScheduleNum'
+		FROM student_statistics ss
+		LEFT JOIN sys_user_cash_account suca ON ss.user_id_ = suca.user_id_
+		WHERE ss.group_type_ = #{groupType}
+	</select>
 </mapper>

+ 6 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -254,4 +254,10 @@ public interface TaskRemoteService {
      */
     @GetMapping("task/destroyExpiredLiveRoom")
     void destroyExpiredLiveRoom();
+
+    /**
+     * 学员小课统计
+     */
+    @GetMapping("task/studentSmallClassStatistics")
+    void studentSmallClassStatistics();
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -304,4 +304,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
     public void destroyExpiredLiveRoom() {
         logger.error("销毁直播间失败");
     }
+
+    @Override
+    public void studentSmallClassStatistics() {
+        logger.error("学员小课统计失败");
+    }
 }

+ 19 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/StudentSmallClassStatisticsTask.java

@@ -0,0 +1,19 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class StudentSmallClassStatisticsTask extends BaseTask {
+
+	@Autowired
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.studentSmallClassStatistics();
+	}
+}

+ 16 - 5
mec-web/src/main/java/com/ym/mec/web/controller/StudentStatisticsController.java

@@ -1,13 +1,18 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.dto.StudentStatisticsDto;
+import com.ym.mec.biz.dal.dto.StudentStatisticsSumDto;
+import com.ym.mec.biz.dal.page.StudentStatisticsQueryInfo;
 import com.ym.mec.biz.service.StudentStatisticsService;
 import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -20,10 +25,16 @@ public class StudentStatisticsController extends BaseController {
     private StudentStatisticsService studentStatisticsService;
 
     @ApiOperation(value = "分页查询收费类型列表")
-    @GetMapping("/queryPage")
+    @PostMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('studentStatistics/queryPage')")
-    public Object queryPage(QueryInfo queryInfo) {
-//        return succeed(chargeTypeService.queryPage(queryInfo));
-        return succeed();
+    public HttpResponseResult<PageInfo<StudentStatisticsDto>> queryPage(StudentStatisticsQueryInfo queryInfo) {
+        return succeed(studentStatisticsService.queryStatisticsPage(queryInfo));
+    }
+
+    @ApiOperation(value = "小课学员管理汇总")
+    @GetMapping("/studentSmallClassStatisticsSum")
+    @PreAuthorize("@pcs.hasPermissions('studentStatistics/studentSmallClassStatisticsSum')")
+    public HttpResponseResult<StudentStatisticsSumDto> studentSmallClassStatisticsSum(String groupType) {
+        return succeed(studentStatisticsService.studentSmallClassStatisticsSum(groupType));
     }
 }

+ 8 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -118,6 +118,8 @@ public class TaskController extends BaseController {
 	private TeacherContractsService teacherContractsService;
     @Autowired
     private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
+	@Autowired
+	private StudentStatisticsService studentStatisticsService;
 
 	@GetMapping(value = "/syncImHistoryMessageTask")
 	// 同步即时通讯聊天记录
@@ -577,4 +579,10 @@ public class TaskController extends BaseController {
     public void destroyExpiredLiveRoom(){
         imLiveBroadcastRoomService.destroyExpiredLiveRoom();
     }
+
+    @ApiOperation("学员小课统计")
+    @GetMapping(value = "/studentSmallClassStatistics")
+    public void studentSmallClassStatistics(){
+		studentStatisticsService.updateStudentStatistics();
+    }
 }