LearnExamineeMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.learn.mapper.LearnExamineeMapper">
  6. <resultMap type="LearnExaminee" id="LearnExamineeResult">
  7. <result property="examineeId" column="examinee_id" />
  8. <result property="studentId" column="student_id" />
  9. <result property="paperType" column="paper_type" />
  10. <result property="paperId" column="paper_id" />
  11. <result property="paperKey" column="paper_key" />
  12. <result property="paperInfo" column="paper_info" />
  13. <result property="beginTime" column="begin_time" />
  14. <result property="endTime" column="end_time" />
  15. <result property="duration" column="duration" />
  16. <result property="state" column="state" />
  17. <result property="scoreLevel" column="score_level" />
  18. <result property="score" column="score" />
  19. <result property="scoreRate" column="score_rate" />
  20. <result property="ranking" column="ranking" />
  21. <result property="gradeRanking" column="grade_ranking" />
  22. <result property="wrongCount" column="wrong_count" />
  23. <result property="chooseCount" column="choose_count" />
  24. <result property="chooseTotal" column="choose_total" />
  25. <result property="subjectiveCount" column="subjective_count" />
  26. <result property="subjectiveTotal" column="subjective_total" />
  27. <result property="createTime" column="create_time" />
  28. <result property="updateTime" column="update_time" />
  29. </resultMap>
  30. <sql id="selectLearnExamineeVo">
  31. select examinee_id, student_id, paper_type, paper_id, paper_key, paper_info, begin_time, end_time, duration, stats, state, score_level, score, score_rate, ranking, grade_ranking, wrong_count, choose_count, choose_total, subjective_count, subjective_total, create_time, update_time from learn_examinee
  32. </sql>
  33. <select id="selectLearnExamineeList" parameterType="LearnExaminee" resultMap="LearnExamineeResult">
  34. <include refid="selectLearnExamineeVo"/>
  35. <where>
  36. <if test="studentId != null "> and student_id = #{studentId}</if>
  37. <if test="paperType != null "> and paper_type = #{paperType}</if>
  38. <if test="paperId != null "> and paper_id = #{paperId}</if>
  39. <if test="paperKey != null "> and paper_key = #{paperKey}</if>
  40. <if test="beginTime != null "> and begin_time = #{beginTime}</if>
  41. <if test="endTime != null "> and end_time = #{endTime}</if>
  42. <if test="duration != null "> and duration = #{duration}</if>
  43. <if test="state != null "> and state = #{state}</if>
  44. <if test="scoreLevel != null and scoreLevel != ''"> and score_level = #{scoreLevel}</if>
  45. <if test="score != null "> and score = #{score}</if>
  46. <if test="scoreRate != null "> and score_rate = #{scoreRate}</if>
  47. <if test="ranking != null "> and ranking = #{ranking}</if>
  48. <if test="gradeRanking != null "> and grade_ranking = #{gradeRanking}</if>
  49. <if test="wrongCount != null "> and wrong_count = #{wrongCount}</if>
  50. <if test="chooseCount != null "> and choose_count = #{chooseCount}</if>
  51. <if test="chooseTotal != null "> and choose_total = #{chooseTotal}</if>
  52. <if test="subjectiveCount != null "> and subjective_count = #{subjectiveCount}</if>
  53. <if test="subjectiveTotal != null "> and subjective_total = #{subjectiveTotal}</if>
  54. </where>
  55. order by examinee_id desc
  56. </select>
  57. <select id="selectTestStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
  58. SELECT COUNT(*) total, SUM(IF(ls.`major_plan_id` IS NULL, 1, 0)) undirect, SUM(IF(ls.`major_plan_id` IS NOT NULL AND ts.`id` IS NULL, 1, 0)) unsend, SUM(IF(ts.`status` IN (1,2,3), 1, 0)) undone, SUM(IF(ts.`status` >= 4, 1, 0)) done
  59. FROM `dz_teacher_class` tc
  60. JOIN `learn_student` ls ON ls.`class_id` = tc.`class_id`
  61. JOIN `dz_classes` c ON ls.`class_id` = c.`class_id`
  62. LEFT JOIN `learn_test_student` ts ON ts.`batch_id` = #{batchId} AND ts.`student_id` = ls.`student_id` AND ts.`build_type` = #{buildType} AND ts.`subject_id` = #{subjectId}
  63. WHERE tc.`teacher_id` = #{teacherId} and tc.`class_id` = #{classId}
  64. </select>
  65. <select id="selectTestStudents" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
  66. SELECT ls.`student_id` studentId, c.`name` className, u.`nick_name` nickName,
  67. case when ls.`major_plan_id` is null then '未组卷未定向' when ls.`major_plan_id` IS NOT NULL AND ts.`id` IS NULL then '未组卷定向' when ts.`status` IN (1,2,3) then '组卷未完成' else '组卷完成' end as state
  68. FROM `dz_teacher_class` tc
  69. JOIN `learn_student` ls ON ls.`class_id` = tc.`class_id`
  70. JOIN `dz_classes` c ON ls.`class_id` = c.`class_id`
  71. LEFT JOIN `learn_test_student` ts ON ts.`batch_id` = #{batchId} AND ts.`student_id` = ls.`student_id` AND ts.`build_type` = #{buildType} AND ts.`subject_id` = #{subjectId}
  72. LEFT JOIN `sys_user` u ON u.`user_id` = ls.`student_id`
  73. WHERE tc.`teacher_id` = #{teacherId} and tc.`class_id` = #{classId}
  74. <if test="buildStatus != null"> AND #{buildStatus} = case when ls.`major_plan_id` is null then 10 when ls.`major_plan_id` IS NOT NULL AND ts.`id` IS NULL then 20 when ts.`status` IN (1,2,3) then 30 else 40 end</if>
  75. </select>
  76. <select id="selectSimulatedStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
  77. SELECT ls.`class_id` `id`, c.`name`, COUNT(DISTINCT ls.`student_id`) `total`, COUNT(DISTINCT e2.`student_id`) `value`
  78. FROM `dz_teacher_class` tc
  79. JOIN `learn_student` ls ON ls.`class_id` = tc.`class_id`
  80. JOIN `dz_classes` c ON ls.`class_id` = c.`class_id`
  81. LEFT JOIN `learn_examinee` e2 ON ls.`student_id` = e2.`student_id` AND e2.`paper_type` = 20
  82. WHERE tc.`teacher_id` = #{teacherId}
  83. GROUP BY ls.`class_id`, c.`name`
  84. ORDER BY `value` DESC
  85. </select>
  86. <select id="selectSimulatedStudentStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
  87. SELECT u.`user_id` `id`, u.`nick_name` `name`, COUNT(e2.`student_id`) `total`
  88. FROM `learn_student` ls
  89. JOIN `sys_user` u ON ls.`student_id` = u.`user_id`
  90. left JOIN `learn_examinee` e2 ON ls.`student_id` = e2.`student_id` AND e2.`paper_type` = 20
  91. WHERE ls.`class_id` = #{classId}
  92. GROUP BY u.`user_id`, u.`user_name`
  93. ORDER BY `total` DESC, u.`user_id` desc
  94. </select>
  95. <select id="selectSimulatedStuSubjectStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
  96. SELECT e.`examinee_id` `id`, s.`subject_name` `name`, e.`score` `value`, p.`fenshu` `total`
  97. FROM `learn_examinee` e
  98. JOIN `learn_paper` p ON e.`paper_id` = p.`id`
  99. JOIN `dz_subject` s ON p.`subjectId` = s.`subject_id`
  100. WHERE e.`student_id` = #{studentId} AND e.`paper_type` = 20
  101. </select>
  102. <select id="selectExamRankingStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
  103. SELECT e2.`paper_id`, COUNT(*) totalCount, AVG(e2.`score`) maxScore, AVG(e2.`score`) avgScore, COUNT(IF(e2.`score` &lt; #{stuScore}, 1, 0)) lowCount FROM `learn_examinee` e2
  104. WHERE e2.`paper_type` = #{paperType} and e2.paper_id in <foreach item="id" collection="paperIds" open="(" separator="," close=")">#{id}</foreach>
  105. GROUP BY e2.`paper_id`
  106. </select>
  107. <select id="selectStudentPractices" resultType="com.alibaba.fastjson2.JSONObject">
  108. SELECT e.`examinee_id` examineeId, e.`end_time` endTime, SUBSTRING_INDEX(SUBSTRING_INDEX(p.`paperName`, '-', 2), '-', -1) paperName, LENGTH(SUBSTRING_INDEX(SUBSTRING_INDEX(p.`direct_key`, '_', 2), '_', -1)) > 0 AS directed, SUBSTRING_INDEX(p.`direct_key`, '_', -1) as questionType
  109. FROM `learn_examinee` e
  110. JOIN `learn_paper` p ON e.`paper_id` = p.`id`
  111. WHERE e.student_id = #{studentId} and e.`paper_type` = #{paperType} AND e.`state` &gt;= 4
  112. and SUBSTRING_INDEX(p.`direct_key`, '_', -1) = #{questionType}
  113. ORDER BY e.`end_time` DESC
  114. </select>
  115. <select id="selectLearnExamineeByExamineeId" parameterType="Long" resultMap="LearnExamineeResult">
  116. <include refid="selectLearnExamineeVo"/>
  117. where examinee_id = #{examineeId}
  118. </select>
  119. <insert id="insertLearnExaminee" parameterType="LearnExaminee" useGeneratedKeys="true" keyProperty="examineeId">
  120. insert into learn_examinee
  121. <trim prefix="(" suffix=")" suffixOverrides=",">
  122. <if test="studentId != null">student_id,</if>
  123. <if test="paperType != null">paper_type,</if>
  124. <if test="paperId != null">paper_id,</if>
  125. <if test="paperKey != null ">paper_key,</if>
  126. <if test="paperInfo != null ">paper_info,</if>
  127. <if test="beginTime != null">begin_time,</if>
  128. <if test="endTime != null">end_time,</if>
  129. <if test="duration != null">duration,</if>
  130. <if test="stats != null">stats,</if>
  131. <if test="state != null">state,</if>
  132. <if test="scoreLevel != null">score_level,</if>
  133. <if test="score != null">score,</if>
  134. <if test="scoreRate != null">score_rate,</if>
  135. <if test="ranking != null">ranking,</if>
  136. <if test="gradeRanking != null">grade_ranking,</if>
  137. <if test="wrongCount != null">wrong_count,</if>
  138. <if test="chooseCount != null">choose_count,</if>
  139. <if test="chooseTotal != null">choose_total,</if>
  140. <if test="subjectiveCount != null">subjective_count,</if>
  141. <if test="subjectiveTotal != null">subjective_total,</if>
  142. <if test="createTime != null">create_time,</if>
  143. <if test="updateTime != null">update_time,</if>
  144. </trim>
  145. <trim prefix="values (" suffix=")" suffixOverrides=",">
  146. <if test="studentId != null">#{studentId},</if>
  147. <if test="paperType != null">#{paperType},</if>
  148. <if test="paperId != null">#{paperId},</if>
  149. <if test="paperKey != null">#{paperKey},</if>
  150. <if test="paperInfo != null">#{paperInfo},</if>
  151. <if test="beginTime != null">#{beginTime},</if>
  152. <if test="endTime != null">#{endTime},</if>
  153. <if test="duration != null">#{duration},</if>
  154. <if test="stats != null">#{stats},</if>
  155. <if test="state != null">#{state},</if>
  156. <if test="scoreLevel != null">#{scoreLevel},</if>
  157. <if test="score != null">#{score},</if>
  158. <if test="scoreRate != null">#{scoreRate},</if>
  159. <if test="ranking != null">#{ranking},</if>
  160. <if test="gradeRanking != null">#{gradeRanking},</if>
  161. <if test="wrongCount != null">#{wrongCount},</if>
  162. <if test="chooseCount != null">#{chooseCount},</if>
  163. <if test="chooseTotal != null">#{chooseTotal},</if>
  164. <if test="subjectiveCount != null">#{subjectiveCount},</if>
  165. <if test="subjectiveTotal != null">#{subjectiveTotal},</if>
  166. <if test="createTime != null">#{createTime},</if>
  167. <if test="updateTime != null">#{updateTime},</if>
  168. </trim>
  169. </insert>
  170. <update id="updateLearnExaminee" parameterType="LearnExaminee">
  171. update learn_examinee
  172. <trim prefix="SET" suffixOverrides=",">
  173. <if test="studentId != null">student_id = #{studentId},</if>
  174. <if test="beginTime != null">begin_time = #{beginTime},</if>
  175. <if test="endTime != null">end_time = #{endTime},</if>
  176. <if test="duration != null">duration = #{duration},</if>
  177. <if test="stats != null">stats = #{stats},</if>
  178. <if test="state != null">state = #{state},</if>
  179. <if test="scoreLevel != null">score_level = #{scoreLevel},</if>
  180. <if test="score != null">score = #{score},</if>
  181. <if test="scoreRate != null">score_rate = #{scoreRate},</if>
  182. <if test="ranking != null">ranking = #{ranking},</if>
  183. <if test="gradeRanking != null">grade_ranking = #{gradeRanking},</if>
  184. <if test="wrongCount != null">wrong_count = #{wrongCount},</if>
  185. <if test="chooseCount != null">choose_count = #{chooseCount},</if>
  186. <if test="chooseTotal != null">choose_total = #{chooseTotal},</if>
  187. <if test="subjectiveCount != null">subjective_count = #{subjectiveCount},</if>
  188. <if test="subjectiveTotal != null">subjective_total = #{subjectiveTotal},</if>
  189. <if test="createTime != null">create_time = #{createTime},</if>
  190. <if test="updateTime != null">update_time = #{updateTime},</if>
  191. </trim>
  192. where examinee_id = #{examineeId}
  193. </update>
  194. <delete id="deleteLearnExamineeByExamineeId" parameterType="Long">
  195. delete from learn_examinee where examinee_id = #{examineeId}
  196. </delete>
  197. <delete id="deleteLearnExamineeByExamineeIds" parameterType="String">
  198. delete from learn_examinee where examinee_id in
  199. <foreach item="examineeId" collection="array" open="(" separator="," close=")">
  200. #{examineeId}
  201. </foreach>
  202. </delete>
  203. </mapper>