|
@@ -283,23 +283,19 @@
|
|
|
<result property="trainDay" column="train_day_"/>
|
|
|
</resultMap>
|
|
|
<select id="queryStudentTrain" resultMap="CountStudentTrainDataDto">
|
|
|
- SELECT su.id_ user_id_,su.avatar_,su.phone_,su.username_,ROUND(SUM(mcr.play_time_) / 60) total_play_time_,
|
|
|
- COUNT(DISTINCT DATE_FORMAT(mcr.create_time_,"%Y-%m-%d")) train_day_,
|
|
|
- COUNT(DISTINCT mcr.behavior_id_) train_num_,
|
|
|
- COUNT(CASE WHEN mcr.feature_ = 'CLOUD_STUDY_EVALUATION' THEN mcr.behavior_id_ ELSE NULL END) record_num_
|
|
|
+ SELECT su.id_ user_id_,su.avatar_,su.phone_,su.username_,mcr.total_play_time_,mcr.train_day_,
|
|
|
+ mcr.train_num_,mcr.record_num_
|
|
|
FROM sys_user su
|
|
|
- LEFT JOIN sys_music_compare_record mcr ON mcr.user_id_ = su.id_
|
|
|
+ LEFT JOIN (select user_id_,ROUND(SUM(play_time_) / 60) total_play_time_,COUNT(DISTINCT behavior_id_) train_num_,
|
|
|
+ COUNT(DISTINCT DATE_FORMAT(create_time_,'%Y-%m-%d')) train_day_,
|
|
|
+ COUNT(CASE WHEN feature_ = 'CLOUD_STUDY_EVALUATION' THEN behavior_id_ END) record_num_
|
|
|
+ from sys_music_compare_record
|
|
|
+ where user_id_ IS NOT NULL
|
|
|
<if test="startTime != null and startTime != ''">
|
|
|
- AND (DATE_FORMAT(mcr.create_time_, '%Y-%m-%d') >= #{startTime} OR mcr.id_ IS NULL)
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND (DATE_FORMAT(mcr.create_time_, '%Y-%m-%d') <= #{endTime} OR mcr.id_ IS NULL)
|
|
|
+ AND DATE_FORMAT(create_time_, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
|
|
|
</if>
|
|
|
+ group by user_id_) mcr ON mcr.user_id_ = su.id_
|
|
|
<include refid="queryStudentTrainSql"/>
|
|
|
- GROUP BY su.id_
|
|
|
- <if test="having == 1">
|
|
|
- HAVING total_play_time_ < ${totalTime} OR train_num_ < ${trainNum}
|
|
|
- </if>
|
|
|
ORDER BY
|
|
|
<if test="sort != null and sort != ''">
|
|
|
${sort}
|
|
@@ -308,7 +304,7 @@
|
|
|
</if>
|
|
|
</if>
|
|
|
<if test="sort == null or sort == ''">
|
|
|
- total_play_time_ DESC
|
|
|
+ mcr.total_play_time_ DESC
|
|
|
</if>
|
|
|
,su.id_
|
|
|
<include refid="global.limit"/>
|
|
@@ -316,23 +312,22 @@
|
|
|
<select id="countStudentTrain" resultType="int">
|
|
|
SELECT COUNT(distinct su.id_)
|
|
|
FROM sys_user su
|
|
|
- LEFT JOIN sys_music_compare_record mcr ON mcr.user_id_ = su.id_
|
|
|
+ LEFT JOIN (select user_id_,ROUND(SUM(play_time_) / 60) total_play_time_,COUNT(DISTINCT behavior_id_) train_num_,
|
|
|
+ COUNT(DISTINCT DATE_FORMAT(create_time_,'%Y-%m-%d')) train_day_,
|
|
|
+ COUNT(CASE WHEN feature_ = 'CLOUD_STUDY_EVALUATION' THEN behavior_id_ END) record_num_
|
|
|
+ from sys_music_compare_record
|
|
|
+ where user_id_ IS NOT NULL
|
|
|
<if test="startTime != null and startTime != ''">
|
|
|
- AND (DATE_FORMAT(mcr.create_time_, '%Y-%m-%d') >= #{startTime} OR mcr.id_ IS NULL)
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND (DATE_FORMAT(mcr.create_time_, '%Y-%m-%d') <= #{endTime} OR mcr.id_ IS NULL)
|
|
|
+ AND DATE_FORMAT(create_time_, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
|
|
|
</if>
|
|
|
+ group by user_id_) mcr ON mcr.user_id_ = su.id_
|
|
|
<include refid="queryStudentTrainSql"/>
|
|
|
- <if test="having == 1">
|
|
|
- AND total_play_time_ < ${totalTime} OR train_num_ < ${trainNum}
|
|
|
- </if>
|
|
|
</select>
|
|
|
|
|
|
<sql id="queryStudentTrainSql">
|
|
|
<where>
|
|
|
<if test="studentIdList != null and studentIdList.size > 0">
|
|
|
- AND su.id_ IN
|
|
|
+ AND mcr.user_id_ IN
|
|
|
<foreach collection="studentIdList" open="(" close=")" item="userId" separator=",">
|
|
|
#{userId}
|
|
|
</foreach>
|
|
@@ -341,17 +336,20 @@
|
|
|
AND (su.phone_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
|
|
|
</if>
|
|
|
<if test="visitStudents != null and visitStudents.size > 0">
|
|
|
- AND su.id_ NOT IN
|
|
|
+ AND mcr.user_id_ NOT IN
|
|
|
<foreach collection="visitStudents" open="(" close=")" item="userId" separator=",">
|
|
|
#{userId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
<if test="hasCourseUserIds != null and hasCourseUserIds.size > 0">
|
|
|
- AND su.id_ IN
|
|
|
+ AND mcr.user_id_ IN
|
|
|
<foreach collection="hasCourseUserIds" open="(" close=")" item="userId" separator=",">
|
|
|
#{userId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ <if test="having == 1">
|
|
|
+ AND mcr.total_play_time_ < ${totalTime} OR mcr.train_num_ < ${trainNum}
|
|
|
+ </if>
|
|
|
</where>
|
|
|
</sql>
|
|
|
|