From 54a6c048c97011cd2a99fbef2065afe0a167fcfc Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期一, 22 七月 2024 13:46:05 +0800
Subject: [PATCH] fix:成绩统计导出完善
---
src/main/resources/mapper/UserMapper.xml | 92 +++++++++++++++++++++++++++++++---------------
1 files changed, 62 insertions(+), 30 deletions(-)
diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml
index 7b36ba1..1a1de5d 100644
--- a/src/main/resources/mapper/UserMapper.xml
+++ b/src/main/resources/mapper/UserMapper.xml
@@ -341,13 +341,13 @@
WHERE
a.deleted=0
<if test="departmentId != null and departmentId.size() > 0">
- AND b.department_id IN <foreach collection="departmentId" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach>
+ AND b.department_id IN <foreach collection="departmentId" item="item" open="(" separator="," close=")"> #{item} </foreach>
</if>
<if test="userName != null and userName != ''">
AND real_name LIKE concat('%',#{userName},'%')
</if>
- <if test="role != null and role.size() > 0">
- AND role IN <foreach collection="role" item="item" open="(" separator="," close=")"> #{item} </foreach>
+ <if test="roles != null and roles.size() > 0">
+ AND role IN <foreach collection="roles" item="item" open="(" separator="," close=")"> #{item} </foreach>
</if>
GROUP BY a.id
</select>
@@ -523,46 +523,78 @@
</update>
<update id="cancelUserDeptAdmin">
- update t_user set role = 1 where id in(
- select user_id from t_user_department where department_id = #{id} and user_id not in
- <foreach collection="adminIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- and user_id not in
- (select user_id from t_user_department where dept_admin = 1 and user_id in
- (select user_id from t_user_department where department_id = #{id} and user_id not in
- <foreach collection="adminIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- )))
+ update t_user set role = 1 where id in
+ <foreach collection="userIds" item="id" open="(" separator="," close=")">
+ #{id}
+ </foreach>
</update>
<select id="getDeptAdminIds" resultType="java.lang.Integer" parameterType="java.lang.Integer">
- select department_id from t_user_department where dept_admin = 1 and user_id = #{id}
+ select department_id from t_user_department where dept_admin = 1 and user_id = #{userId}
</select>
- <select id="getDeptAdmins" resultType="com.mindskip.xzs.domain.Department" parameterType="java.lang.Integer">
- <if test="id != null">
- select a.id, a.name from t_department a inner join t_user_department b on a.id = b.department_id where a.deleted = 0 and b.dept_admin = 1 and b.user_id = #{id} order by a.id desc
+ <select id="getDeptAdminIdAndInfo" resultType="com.mindskip.xzs.domain.Department">
+ select
+ d.id, d.name, d.special
+ from
+ t_user_department ud
+ INNER JOIN t_department d ON ud.department_id = d.id
+ WHERE
+ dept_admin = 1 and user_id = #{userId}
+ </select>
+
+ <select id="getDeptAdmins" resultType="com.mindskip.xzs.domain.Department">
+ <if test="ids != null and ids.size() != 0">
+ WITH RECURSIVE temp_table AS (
+ select a.id, a.name, a.parent_id from t_department a WHERE id IN <foreach collection="ids" item="id" open="(" separator="," close=")"> #{id} </foreach>
+ UNION ALL
+ SELECT
+ so.id, so.name, so.parent_id FROM t_department so INNER JOIN temp_table tb ON so.parent_id = tb.id
+ )
+ SELECT
+ id, name, parent_id
+ FROM
+ temp_table
</if>
- <if test="id == null">
- select a.id, a.name from t_department a where a.deleted = 0 order by a.id desc
+ <if test="ids == null or ids.size() == 0">
+ select a.id, a.name, a.parent_id from t_department a where a.deleted = 0 order by a.id
</if>
</select>
<select id="getUserByExamByTemplateId" resultType="com.mindskip.xzs.domain.User" parameterType="com.mindskip.xzs.domain.ExamPaper">
+ select *
+ from t_user
+ where id in
+ (select user_id from t_exam_templates_user WHERE templates_id = #{id} and user_id not in
+ (SELECT create_user from t_exam_paper_answer where (user_score / paper_score) > 0.6 and (invalid = 0 or invalid is null) and exam_paper_id in
+ (select exam_paper_id from t_exam_templates_user_count WHERE exam_templates_id = #{id})))
+ and id = #{createUser}
+ </select>
+
+ <select id="getDeptIds" resultType="integer">
+ SELECT department_id FROM t_user_department WHERE user_id = #{userId} AND dept_admin != 1
+ </select>
+
+ <select id="getFailExamUser" resultType="com.mindskip.xzs.domain.User">
<![CDATA[
- SELECT DISTINCT
- d.*
- FROM
- t_exam_templates a
- INNER JOIN t_exam_templates_user_count b ON a.id = b.exam_templates_id and a.id = ${id}
- LEFT JOIN t_exam_paper_answer c ON b.exam_paper_id = c.exam_paper_id AND c.create_user = b.user_id and invalid = 0
+ SELECT
+ DISTINCT d.id, d.real_name
+ FROM t_exam_paper a
+ LEFT JOIN t_exam_paper_user b ON a.id = b.exam_paper_id AND b.deleted = 0
+ LEFT JOIN t_exam_paper_answer c ON a.id = c.exam_paper_id AND c.create_user = b.user_id
LEFT JOIN t_user d ON b.user_id = d.id
- WHERE
- ( c.id IS NULL OR ( user_score / paper_score ) < 0.6 )
- AND b.user_id = #{createUser}
+ WHERE a.id = #{examPaperId}
+ AND (c.id IS NULL OR (user_score / paper_score) < 0.6)
]]>
</select>
+ <select id="getFailTemplateUser" resultType="com.mindskip.xzs.domain.User">
+ SELECT id, real_name
+ FROM t_user
+ WHERE id IN
+ (SELECT user_id FROM t_exam_templates_user WHERE templates_id = #{id} AND user_id NOT IN
+ (SELECT create_user FROM t_exam_paper_answer WHERE (user_score / paper_score) > 0.6 AND (invalid = 0 OR invalid IS NULL) AND exam_paper_id IN
+ (SELECT exam_paper_id FROM t_exam_templates_user_count WHERE exam_templates_id = #{templateId})))
+ </select>
+
</mapper>
--
Gitblit v1.8.0