| | |
| | | #{item} |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <select id="dataByTemplate" resultType="java.util.Map" parameterType="com.mindskip.xzs.domain.vo.ExamPaperDataVO"> |
| | | SELECT |
| | | a.id, |
| | | a.name, |
| | | COUNT(DISTINCT c.create_user) as factPeopleTotal, -- 参考人数 |
| | | IFNULL(ROUND(AVG(c.user_score), 2), 0) as averageScore, -- 平均成绩 |
| | | IFNULL(ROUND((COUNT(DISTINCT c.create_user) * 100.0 / COUNT(DISTINCT d.user_id)), 2), 0) AS referencePercentage -- 参考百分比 |
| | | FROM |
| | | t_department a |
| | | LEFT JOIN t_user_department b ON a.id = b.department_id |
| | | LEFT JOIN t_exam_templates_user d ON d.user_id = b.user_id AND d.templates_id = #{id} |
| | | LEFT JOIN t_exam_templates_user_count e ON d.templates_id = e.exam_templates_id |
| | | LEFT JOIN t_exam_paper_answer c ON d.user_id = c.create_user AND e.exam_paper_id = c.exam_paper_id AND (c.invalid = 0 OR c.invalid IS NULL) |
| | | GROUP BY |
| | | a.id, a.name |
| | | </select> |
| | | |
| | | <select id="totalByTemplate" resultType="java.util.Map" parameterType="com.mindskip.xzs.domain.vo.ExamPaperDataVO"> |
| | | SELECT |
| | | (SELECT (SELECT count(*) FROM t_exam_paper) + (SELECT count(*) FROM t_exam_templates)) as examTotal, -- 总考试次数 |
| | | COUNT(DISTINCT c.create_user) as factPeopleTotal, -- 参考人数 |
| | | IFNULL(ROUND(AVG(c.user_score), 2), 0) as averageScore, -- 平均成绩 |
| | | IFNULL(ROUND((COUNT(DISTINCT c.create_user) * 100.0 / COUNT(DISTINCT d.user_id)), 2), 0) AS referencePercentage -- 参考百分比 |
| | | FROM |
| | | t_exam_templates a |
| | | LEFT JOIN t_exam_templates_user d ON d.templates_id = a.id |
| | | LEFT JOIN t_exam_templates_user_count e ON d.templates_id = e.exam_templates_id |
| | | LEFT JOIN t_exam_paper_answer c ON d.user_id = c.create_user AND e.exam_paper_id = c.exam_paper_id AND (c.invalid = 0 OR c.invalid IS NULL) |
| | | WHERE a.id = #{id} |
| | | GROUP BY |
| | | a.id |
| | | </select> |
| | | |
| | | <select id="dataByPaper" resultType="java.util.Map" parameterType="com.mindskip.xzs.domain.vo.ExamPaperDataVO"> |
| | | SELECT |
| | | a.id, |
| | | a.name, |
| | | COUNT(DISTINCT c.create_user) as factPeopleTotal, -- 参考人数 |
| | | IFNULL(ROUND(AVG(c.user_score), 2), 0) as averageScore, -- 平均成绩 |
| | | IFNULL(ROUND((COUNT(DISTINCT c.create_user) * 100.0 / COUNT(DISTINCT d.user_id)), 2), 0) AS referencePercentage -- 参考百分比 |
| | | FROM |
| | | t_department a |
| | | LEFT JOIN t_user_department b ON a.id = b.department_id |
| | | LEFT JOIN t_exam_paper_answer c ON b.user_id = c.create_user AND (c.invalid = 0 OR c.invalid IS NULL) AND c.exam_paper_id = #{id} |
| | | LEFT JOIN t_exam_paper_user d ON c.exam_paper_id = d.exam_paper_id and b.user_id = d.user_id |
| | | GROUP BY |
| | | a.id, a.name |
| | | </select> |
| | | |
| | | <select id="totalByPaper" resultType="java.util.Map" parameterType="com.mindskip.xzs.domain.vo.ExamPaperDataVO"> |
| | | SELECT |
| | | (SELECT (SELECT count(*) FROM t_exam_paper) + (SELECT count(*) FROM t_exam_templates)) as examTotal, -- 总考试次数 |
| | | count(DISTINCT b.create_user) AS factPeopleTotal, -- 参考数 |
| | | IFNULL(ROUND(avg(user_score), 2), 0) as averageScore, -- 平均分 |
| | | IFNULL(ROUND((COUNT(DISTINCT b.create_user) * 100.0 / COUNT(DISTINCT c.user_id)), 2), 0) AS referencePercentage -- 参考百分比 |
| | | FROM t_exam_paper a |
| | | LEFT JOIN t_exam_paper_answer b ON a.id = b.exam_paper_id AND (b.invalid = 0 OR b.invalid IS NULL) |
| | | LEFT JOIN t_exam_paper_user c ON a.id = c.exam_paper_id |
| | | WHERE a.id = #{id} |
| | | GROUP BY a.id |
| | | </select> |
| | | |
| | | </mapper> |