| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- <?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="preCourseFee" property="preCourseFee" />
- <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.no_schedule_num_ > 0 OR ss.sub_course_num_ > 0) AND (ss.lately_year_course_consumer_ > 0 OR ss.over_course_num_ <= 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>
- <if test="organId != null and organId != ''">
- AND FIND_IN_SET(sbi.organ_id_,#{organId})
- </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 *,ss.not_start_course_fee_ + ss.no_course_fee_ preCourseFee 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.no_schedule_num_ > 0 OR ss.sub_course_num_ > 0) AND (ss.lately_year_course_consumer_ > 0 OR ss.over_course_num_ <= 0) THEN 1 ELSE NULL END) 'normalStudentNum',
- COUNT(CASE WHEN ((ss.no_schedule_num_ > 0 OR ss.sub_course_num_ > 0) AND (ss.lately_year_course_consumer_ > 0 OR ss.over_course_num_ <= 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.no_schedule_num_ > 0 OR ss.sub_course_num_ > 0) AND (ss.lately_year_course_consumer_ > 0 OR ss.over_course_num_ <= 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>
- <select id="countAddStudentNum" resultType="java.lang.Integer">
- SELECT COUNT(extend_info_) FROM (
- SELECT extend_info_ FROM index_base_month_data
- WHERE data_type_ =
- <if test="groupType == 'VIP'">
- 'STUDENT_VIP_ORDER_NUM'
- </if>
- <if test="groupType == 'THEORY'">
- 'STUDENT_THEORY_ORDER_NUM'
- </if>
- <if test="groupType == 'PRACTICE'">
- 'STUDENT_PRACTICE_ORDER_NUM'
- </if>
- AND extend_info_ IS NOT NULL
- GROUP BY extend_info_
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- HAVING COUNT(CASE WHEN month_ < #{startDate} THEN 1 ELSE NULL END) < 1
- AND COUNT(CASE WHEN month_ BETWEEN #{startDate} AND #{endDate} THEN 1 ELSE NULL END) > 0
- </if>
- )a
- </select>
- <select id="countRenewStudentNum" resultType="java.lang.Integer">
- SELECT COUNT(extend_info_) FROM (
- SELECT extend_info_ FROM index_base_month_data
- <include refid="dateTypeSql"/>
- AND extend_info_ IS NOT NULL
- <if test="endDate != null and endDate != ''">
- AND month_ <= #{endDate}
- </if>
- GROUP BY extend_info_
- HAVING SUM(total_num_) > 1)a
- </select>
- <select id="countVisitNum" resultType="java.lang.Integer">
- SELECT COUNT(DISTINCT student_id_) FROM student_visit
- WHERE type_ = '小课回访' AND purpose_ =
- <if test="groupType == 'VIP'">
- 'VIP课回访'
- </if>
- <if test="groupType == 'THEORY'">
- '乐理课回访'
- </if>
- <if test="groupType == 'PRACTICE'">
- '网管课回访'
- </if>
- </select>
- <select id="countLostStudentNum" resultType="java.lang.Integer">
- SELECT SUM(total_num_) FROM index_base_month_data
- <include refid="lostDateTypeSql"/>
- <if test="startDate != null and startDate != ''">
- AND month_ >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- AND month_ <= #{startDate}
- </if>
- </select>
- <select id="queryTeacherIds" resultType="java.lang.Integer">
- SELECT DISTINCT teacher_id_ FROM student_statistics WHERE group_type_ = #{groupType} AND teacher_id_ IS NOT NULL
- </select>
- <select id="queryDirectorList" resultType="java.lang.Integer">
- SELECT DISTINCT music_director_id_ FROM student_statistics WHERE group_type_ = #{groupType} AND music_director_id_ IS NOT NULL
- </select>
- <sql id="dateTypeSql">
- WHERE data_type_ =
- <if test="groupType == 'VIP'">
- 'STUDENT_VIP_ORDER_NUM'
- </if>
- <if test="groupType == 'THEORY'">
- 'STUDENT_THEORY_ORDER_NUM'
- </if>
- <if test="groupType == 'PRACTICE'">
- 'STUDENT_PRACTICE_ORDER_NUM'
- </if>
- </sql>
- <sql id="lostDateTypeSql">
- WHERE data_type_ =
- <if test="groupType == 'VIP'">
- 'STUDENT_VIP_LOST_NUM'
- </if>
- <if test="groupType == 'THEORY'">
- 'STUDENT_THEORY_LOST_NUM'
- </if>
- <if test="groupType == 'PRACTICE'">
- 'STUDENT_PRACTICE_LOST_NUM'
- </if>
- </sql>
- </mapper>
|