|
@@ -0,0 +1,269 @@
|
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
+<!--
|
|
|
|
+这个文件是自动生成的。
|
|
|
|
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
|
|
|
|
+-->
|
|
|
|
+<mapper namespace="com.ym.mec.biz.dal.dao.StudentStatisticsDao">
|
|
|
|
+
|
|
|
|
+ <resultMap type="com.ym.mec.biz.dal.entity.StudentStatistics" id="StudentStatistics">
|
|
|
|
+ <result column="id_" property="id" />
|
|
|
|
+ <result column="user_id_" property="userId" />
|
|
|
|
+ <result column="teacher_id_" property="teacherId" />
|
|
|
|
+ <result column="teacher_name_" property="teacherName" />
|
|
|
|
+ <result column="music_director_id_" property="musicDirectorId" />
|
|
|
|
+ <result column="music_director_name_" property="musicDirectorName" />
|
|
|
|
+ <result column="total_course_num_" property="totalCourseNum" />
|
|
|
|
+ <result column="over_course_num_" property="overCourseNum" />
|
|
|
|
+ <result column="sub_course_num_" property="subCourseNum" />
|
|
|
|
+ <result column="no_schedule_num_" property="noScheduleNum" />
|
|
|
|
+ <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" />
|
|
|
|
+ <result column="last_visit_time_" property="lastVisitTime" />
|
|
|
|
+ <result column="not_start_course_fee_" property="notStartCourseFee" />
|
|
|
|
+ <result column="no_course_fee_" property="noCourseFee" />
|
|
|
|
+ <result column="first_order_time_" property="firstOrderTime" />
|
|
|
|
+ <result column="last_order_time_" property="lastOrderTime" />
|
|
|
|
+ <result column="order_num_" property="orderNum" />
|
|
|
|
+ <result column="group_type_" property="groupType" />
|
|
|
|
+ </resultMap>
|
|
|
|
+
|
|
|
|
+ <!-- 根据主键查询一条记录 -->
|
|
|
|
+ <select id="get" resultMap="StudentStatistics" >
|
|
|
|
+ SELECT * FROM student_statistics WHERE id_ = #{id}
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <!-- 全查询 -->
|
|
|
|
+ <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_,
|
|
|
|
+ music_director_name_,total_course_num_,over_course_num_,sub_course_num_,
|
|
|
|
+ no_schedule_num_,first_course_time_,last_course_time_,lately_course_consumer_,
|
|
|
|
+ visit_num_,last_visit_status_,visit_reason_,last_visit_time_,not_start_course_fee_,no_course_fee_,first_order_time_,
|
|
|
|
+ last_order_time_,order_num_,group_type_)
|
|
|
|
+ VALUES(#{id},#{userId},#{teacherId},#{teacherName},#{musicDirectorId},#{musicDirectorName},
|
|
|
|
+ #{totalCourseNum},#{overCourseNum},#{subCourseNum},#{noScheduleNum},#{firstCourseTime},#{lastCourseTime},
|
|
|
|
+ #{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>
|
|
|
|
+ <if test="overCourseNum != null">
|
|
|
|
+ over_course_num_ = #{overCourseNum},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="latelyCourseConsumer != null">
|
|
|
|
+ lately_course_consumer_ = #{latelyCourseConsumer},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="lastCourseTime != null">
|
|
|
|
+ last_course_time_ = #{lastCourseTime},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="totalCourseNum != null">
|
|
|
|
+ total_course_num_ = #{totalCourseNum},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="musicDirectorName != null">
|
|
|
|
+ music_director_name_ = #{musicDirectorName},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="visitNum != null">
|
|
|
|
+ visit_num_ = #{visitNum},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="teacherName != null">
|
|
|
|
+ teacher_name_ = #{teacherName},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="subCourseNum != null">
|
|
|
|
+ sub_course_num_ = #{subCourseNum},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="lastVisitStatus != null">
|
|
|
|
+ last_visit_status_ = #{lastVisitStatus},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="lastVisitTime != null">
|
|
|
|
+ last_visit_time_ = #{lastVisitTime},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="teacherId != null">
|
|
|
|
+ teacher_id_ = #{teacherId},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="musicDirectorId != null">
|
|
|
|
+ music_director_id_ = #{musicDirectorId},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="lastOrderTime != null">
|
|
|
|
+ last_order_time_ = #{lastOrderTime},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="firstOrderTime != null">
|
|
|
|
+ first_order_time_ = #{firstOrderTime},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="orderNum != null">
|
|
|
|
+ order_num_ = #{orderNum},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="groupType != null">
|
|
|
|
+ group_type_ = #{groupType},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="visitReason != null">
|
|
|
|
+ visit_reason_ = #{visitReason},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="notStartCourseFee != null">
|
|
|
|
+ not_start_course_fee_ = #{notStartCourseFee},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="noCourseFee != null">
|
|
|
|
+ no_course_fee_ = #{noCourseFee},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="noScheduleNum != null">
|
|
|
|
+ no_schedule_num_ = #{noScheduleNum},
|
|
|
|
+ </if>
|
|
|
|
+ <if test="firstCourseTime != null">
|
|
|
|
+ first_course_time_ = #{firstCourseTime},
|
|
|
|
+ </if>
|
|
|
|
+ </set> WHERE id_ = #{id}
|
|
|
|
+ </update>
|
|
|
|
+ <update id="updateTeacherAndEdu">
|
|
|
|
+ SELECT updateTeacherAndEdu()
|
|
|
|
+ </update>
|
|
|
|
+ <update id="updateCourseNum">
|
|
|
|
+ SELECT updateCourseNum()
|
|
|
|
+ </update>
|
|
|
|
+ <update id="updateNoCourseNum">
|
|
|
|
+ SELECT updateNoCourseNum()
|
|
|
|
+ </update>
|
|
|
|
+ <update id="updateNotStartCourseFee">
|
|
|
|
+ SELECT updateNotStartCourseFee()
|
|
|
|
+ </update>
|
|
|
|
+ <update id="updateNoCourseFee">
|
|
|
|
+ SELECT updateNoCourseFee()
|
|
|
|
+ </update>
|
|
|
|
+ <update id="updateFirstAndLastCourseTime">
|
|
|
|
+ SELECT updateFirstAndLastCourseTime()
|
|
|
|
+ </update>
|
|
|
|
+ <update id="updateNormalGroupNum">
|
|
|
|
+ SELECT updateNormalGroupNum()
|
|
|
|
+ </update>
|
|
|
|
+
|
|
|
|
+ <!-- 根据主键删除一条记录 -->
|
|
|
|
+ <delete id="delete" >
|
|
|
|
+ DELETE FROM student_statistics WHERE id_ = #{id}
|
|
|
|
+ </delete>
|
|
|
|
+
|
|
|
|
+ <!-- 分页查询 -->
|
|
|
|
+ <select id="queryPage" resultMap="StudentStatistics" parameterType="map">
|
|
|
|
+ SELECT * FROM student_statistics ORDER BY id_ <include refid="global.limit"/>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <!-- 查询当前表的总记录数 -->
|
|
|
|
+ <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_ <= 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_ < 4
|
|
|
|
+ </if>
|
|
|
|
+ <if test="firstCourseStartTime != null">
|
|
|
|
+ AND ss.first_course_time_ >= #{firstCourseStartTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="firstCourseEndTime != null">
|
|
|
|
+ AND ss.first_course_time_ <= #{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_ <= 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_ <= 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_ <= 0 AND ss.no_schedule_num_ <= 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_ <= 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_) < 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>
|