|
@@ -174,4 +174,201 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
+ <select id="courseDepartRank" resultType="com.gyee.exam.modules.course.dto.response.CourseDepartRankDTO">
|
|
|
+
|
|
|
+ select
|
|
|
+ cd.dept_code deptCode,
|
|
|
+ sd.dept_name deptName,
|
|
|
+ count(cd .id) total
|
|
|
+ from el_course_depart cd
|
|
|
+ LEFT JOIN sys_depart sd on cd.dept_code = sd.dept_code
|
|
|
+ LEFT JOIN el_course ec on ec.id = cd.course_id
|
|
|
+
|
|
|
+ <where>
|
|
|
+ <if test="query!=null">
|
|
|
+
|
|
|
+ <if test="query.statDateL!=null ">
|
|
|
+ AND ec.create_time >= #{query.statDateL}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.statDateR!=null ">
|
|
|
+ AND ec.create_time < #{query.statDateR}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.q!=null and query.q!=''">
|
|
|
+ AND cd.dept_code = #{query.q}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY cd.dept_code order by count(cd .id) desc
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="courseDepartTotal" resultType="com.gyee.exam.modules.course.dto.response.CourseDepartTotalDTO">
|
|
|
+ SELECT
|
|
|
+ sd.dept_name deptName,
|
|
|
+ dept.dept_code deptCode,
|
|
|
+ COUNT( uc.id) AS ecTotalUser,-- 应培训人数
|
|
|
+ COUNT(DISTINCT cl.user_id) AS ecActualUser,-- 学习人数
|
|
|
+ COUNT(IF( cl.state = 1 ,1, NULL)) AS ecPassUser -- 学完人数
|
|
|
+ FROM el_course ec
|
|
|
+ LEFT JOIN el_course_depart dept on ec.id = dept.course_id
|
|
|
+ LEFT JOIN sys_depart sd on sd.dept_code = dept.dept_code
|
|
|
+ LEFT JOIN sys_user uc ON dept.dept_code=uc.dept_code
|
|
|
+ LEFT JOIN el_course_learn cl ON cl.user_id=uc.id AND cl.course_id=dept.course_id
|
|
|
+ <where>
|
|
|
+ AND uc.id IS NOT NULL
|
|
|
+ <if test="query!=null">
|
|
|
+
|
|
|
+ <if test="query.statDateL!=null ">
|
|
|
+ AND ec.create_time >= #{query.statDateL}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.statDateR!=null ">
|
|
|
+ AND ec.create_time < #{query.statDateR}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.q!=null and query.q!=''">
|
|
|
+ AND dept.dept_code = #{query.q}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY dept.dept_code
|
|
|
+ ORDER BY ecActualUser desc ,ecPassUser desc
|
|
|
+
|
|
|
+
|
|
|
+ </select>
|
|
|
+ <select id="courseDepartIdTotal"
|
|
|
+ resultType="com.gyee.exam.modules.course.dto.response.courseDepartIdTotalDTO">
|
|
|
+ SELECT
|
|
|
+ ec.id,
|
|
|
+ ec.title,
|
|
|
+ ec.periods,
|
|
|
+ ec.create_time,
|
|
|
+ SUM(IF( cl.state = 1 ,1, 0)) passUser,
|
|
|
+ count(uc.id) actualUser,
|
|
|
+ (CASE WHEN SUM(IF( cl.state = 1 ,1, 0))>=count(uc.id) THEN 1 ELSE 0 END) AS passed
|
|
|
+
|
|
|
+ FROM el_course ec
|
|
|
+ LEFT JOIN el_course_depart dept on ec.id = dept.course_id
|
|
|
+ LEFT JOIN sys_user uc ON dept.dept_code=uc.dept_code
|
|
|
+ LEFT JOIN el_course_learn cl ON cl.user_id=uc.id AND cl.course_id=dept.course_id
|
|
|
+ <where>
|
|
|
+
|
|
|
+ <if test="query!=null">
|
|
|
+
|
|
|
+ <if test="query.statDateL!=null ">
|
|
|
+ AND ec.create_time >= #{query.statDateL}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.statDateR!=null ">
|
|
|
+ AND ec.create_time < #{query.statDateR}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.q!=null and query.q!=''">
|
|
|
+ AND dept.dept_code = #{query.q}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </where>
|
|
|
+ GROUP BY ec.id
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="selectCourseUserTotal"
|
|
|
+ resultType="com.gyee.exam.modules.course.dto.response.CourseUserTotalDTO">
|
|
|
+
|
|
|
+ SELECT
|
|
|
+ sd.dept_name deptName,
|
|
|
+ sd.dept_code deptCode,
|
|
|
+ su.user_name userName,
|
|
|
+ su.real_name realName,
|
|
|
+ COUNT(cl.id) courseNum,
|
|
|
+ SUM(IF( cl.state = 1 ,1, 0)) learnCourse
|
|
|
+ FROM el_course_learn cl
|
|
|
+ INNER JOIN el_course ec ON cl.course_id = ec.id
|
|
|
+ INNER JOIN sys_user su ON su.id = cl.user_id
|
|
|
+ INNER JOIN sys_depart sd on sd.dept_code = su.dept_code
|
|
|
+ <where>
|
|
|
+
|
|
|
+ <if test="query!=null">
|
|
|
+
|
|
|
+ <if test="query.statDateL!=null ">
|
|
|
+ AND ec.create_time >= #{query.statDateL}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.statDateR!=null ">
|
|
|
+ AND ec.create_time < #{query.statDateR}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.deptName!=null and query.deptName!=''">
|
|
|
+ AND sd.dept_name LIKE '%${query.deptName}%'
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.deptCode!=null and query.deptCode!=''">
|
|
|
+ AND sd.dept_code = #{query.deptCode}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.realName!=null and query.realName!=''">
|
|
|
+ AND su.real_name LIKE '%${query.realName}%'
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.userName!=null and query.userName!=''">
|
|
|
+ AND su.user_name, = #{query.userName}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </where>
|
|
|
+
|
|
|
+ group by cl.user_id ORDER BY learnCourse desc
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="selectCourseUserIdTotal"
|
|
|
+ resultType="com.gyee.exam.modules.course.dto.response.CourseUserIdTotalDTO">
|
|
|
+
|
|
|
+ select
|
|
|
+ ec.id,
|
|
|
+ ec.title,
|
|
|
+ (CASE WHEN SUM(IF( cl.state = 1 ,1, 0))>=count(rf.id) THEN 1 ELSE 0 END) AS state,
|
|
|
+ SUM(ec.periods) periods,
|
|
|
+ SUM(rf.need_learn) needLearn
|
|
|
+
|
|
|
+ from el_course ec
|
|
|
+ INNER JOIN el_course_ref_file rf ON rf.course_id = ec.id
|
|
|
+ LEFT JOIN el_course_learn cl ON cl.course_id = ec.id
|
|
|
+ LEFT JOIN sys_user su ON su.id = cl.user_id
|
|
|
+ <where>
|
|
|
+
|
|
|
+ <if test="query!=null">
|
|
|
+
|
|
|
+ <if test="query.statDateL!=null ">
|
|
|
+ AND ec.create_time >= #{query.statDateL}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.statDateR!=null ">
|
|
|
+ AND ec.create_time < #{query.statDateR}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="query.userName!=null and query.userName!=''">
|
|
|
+ AND su.user_name = #{query.userName}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ GROUP BY ec.id
|
|
|
+
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
</mapper>
|