MxjbWrongBookMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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.mxjb.mapper.MxjbWrongBookMapper">
  6. <resultMap type="MxjbWrongBook" id="MxjbWrongBookResult">
  7. <result property="wrongId" column="wrong_id" />
  8. <result property="customerCode" column="customer_code" />
  9. <result property="name" column="name" />
  10. <result property="subjectId" column="subject_id" />
  11. <result property="knownledgeId" column="knownledge_id" />
  12. <result property="knownledgeName" column="knownledge_name" />
  13. <result property="paperType" column="paper_type" />
  14. <result property="paperId" column="paper_id" />
  15. <result property="questionId" column="question_id" />
  16. <result property="source" column="source" />
  17. <result property="answers" column="answers" />
  18. <result property="answer1" column="answer1" />
  19. <result property="answer2" column="answer2" />
  20. <result property="wrongCount" column="wrong_count" />
  21. <result property="rightCount" column="right_count" />
  22. <result property="totalCount" column="total_count" />
  23. <result property="state" column="state" />
  24. <result property="scoreTotal" column="score_total" />
  25. <result property="score" column="score" />
  26. <result property="duration" column="duration" />
  27. <result property="comment" column="comment" />
  28. <result property="createdTime" column="created_time" />
  29. <result property="updatedTime" column="updated_time" />
  30. <result property="qtpye" column="qtpye" />
  31. <result property="title" column="title" />
  32. <result property="title0" column="title0" />
  33. <result property="optionA" column="option_a" />
  34. <result property="optionB" column="option_b" />
  35. <result property="optionC" column="option_c" />
  36. <result property="optionD" column="option_d" />
  37. <result property="optionE" column="option_e" />
  38. <result property="optionF" column="option_f" />
  39. <result property="optionG" column="option_g" />
  40. <result property="collect" column="collect" />
  41. <result property="examineeId" column="examinee_id" />
  42. </resultMap>
  43. <sql id="selectMxjbWrongBookVo">
  44. select wrong_id, customer_code, subject_id, knownledge_id, knownledge_name, paper_type, paper_id, question_id, source, answers, answer1, answer2, wrong_count, right_count, total_count, score_total, score, duration, comment, state, created_time, updated_time from mxjb_wrong_book
  45. </sql>
  46. <select id="findWrongExaminees" parameterType="Long" resultMap="MxjbWrongBookResult">
  47. SELECT wd.`examinee_id`, wd.paper_id, p.`paperName`, p.`paperType` paper_type, e.`begin_time` created_time
  48. FROM `mxjb_wrong_detail` wd
  49. JOIN `papers` p ON wd.`paper_id` = p.`id`
  50. JOIN `mxjb_paper_examinee` e ON e.`examinee_id` = wd.`examinee_id`
  51. WHERE wd.wrong_id = #{wrongId}
  52. </select>
  53. <select id="findWrongQuestions" parameterType="map" resultMap="MxjbWrongBookResult">
  54. SELECT wb.`wrong_id`, wb.`question_id`, q.`title`, q.parse, wb.`knownledge_id`, k.`name` knownledge_name, wb.`wrong_count`, q.qtpye
  55. ,q.option_a,q.option_b,q.option_c,q.option_d,q.option_e,q.option_f,q.option_g,q.answer1,q.answer2,q.title0,wb.answers, qc.question_id &gt; 0 collect
  56. FROM `mxjb_wrong_book` wb
  57. JOIN `questions` q ON wb.`question_id` = q.`id`
  58. LEFT JOIN `knowledge_tree` k ON wb.`knownledge_id` = k.`id`
  59. LEFT JOIN mxjb_question_collection qc on qc.question_id = q.id and qc.user_id = #{creatorId}
  60. <where> wb.`customer_code` = #{creatorId} AND q.`qtpye` IN ('判断题', '单选题', '选择题','单项选择','单项选择题','多选题')
  61. <if test="subjectId != null "> and wb.`subject_id` = #{subjectId}</if>
  62. </where>
  63. </select>
  64. <select id="selectMxjbWrongStudentKnownledgeStats" parameterType="map" resultMap="MxjbWrongBookResult">
  65. SELECT k.id knownledge_id, IF(k.knowledgeName IS NULL, t.knownledge_name, k.knowledgeName) knownledge_name, SUM(IF(t.state = 0, 1, 0)) wrong_count, COUNT(*) total_count
  66. FROM mxjb_wrong_book t
  67. LEFT JOIN knowledge_basic k ON k.id = t.knownledge_id
  68. WHERE t.customer_code = #{customerCode} AND t.subject_id = #{subjectId} AND t.updated_time &gt;= #{beginTime} AND t.updated_time &lt;= #{endTime}
  69. and (t.knownledge_name is not null and t.knownledge_name != '' or k.knowledgeName is not null and t.knownledge_name != '')
  70. GROUP BY k.id, IF(k.knowledgeName IS NULL, t.knownledge_name, k.knowledgeName)
  71. ORDER BY COUNT(*) DESC
  72. </select>
  73. <select id="selectMxjbWrongStudentQuestions" parameterType="map" resultMap="MxjbWrongBookResult">
  74. SELECT DISTINCT t.paper_type, t.question_id, q.title `name`, t.state, t.source, t.answers, t.answer1, t.answer2, t.score_total, t.score, t.duration, t.comment, t.created_time, t.updated_time, q.qtpye
  75. FROM mxjb_wrong_book t
  76. JOIN questions q ON q.id = t.question_id
  77. JOIN b_customer_basic b ON b.code = t.customer_code
  78. JOIN b_customer_class c ON c.customerCode = b.code
  79. <where> t.updated_time &gt;= #{beginTime} AND t.updated_time &lt;= #{endTime}
  80. <if test="studentGradeId != null "> and c.gradeId = #{studentGradeId}</if>
  81. <if test="subjectId != null "> and t.subject_id = #{subjectId}</if>
  82. <if test="customerCode != null "> and t.customer_code = #{customerCode}</if>
  83. <if test="knownledgeName != null ">AND t.knownledge_name = #{knownledgeName} </if>
  84. <if test="state != null "> and t.state = #{state}</if>
  85. </where>
  86. </select>
  87. <select id="selectMxjbWrongClassKnownledgeStats" parameterType="map" resultMap="MxjbWrongBookResult">
  88. SELECT k.id knownledge_id, IF(k.knowledgeName IS NULL, t.knownledge_name, k.knowledgeName) knownledge_name, SUM(IF(t.state = 0, 1, 0)) wrong_count, COUNT(*) total_count
  89. FROM mxjb_wrong_book t
  90. <if test="customerCode != null">
  91. JOIN b_customer_subject cs ON cs.subjectId = t.subject_id AND cs.customerCode = #{customerCode}
  92. </if>
  93. JOIN b_customer_basic b ON b.code = t.customer_code
  94. JOIN b_customer_class c ON c.customerCode = b.code
  95. LEFT JOIN knowledge_basic k ON k.id = t.knownledge_id
  96. <where> t.updated_time &gt;= #{beginTime} AND t.updated_time &lt;= #{endTime}
  97. and (t.knownledge_name is not null and t.knownledge_name != '' or k.knowledgeName is not null and t.knownledge_name != '')
  98. <if test="studentGradeId != null "> and c.gradeId = #{studentGradeId}</if>
  99. <if test="subjectId != null "> and t.subject_id = #{subjectId}</if>
  100. <if test="classId != null "> and c.classId = #{classId}</if>
  101. <if test="classIds != null "> and c.classId in <foreach item="id" collection="classIds" open="(" separator="," close=")">#{id}</foreach></if>
  102. </where>
  103. GROUP BY k.id, IF(k.knowledgeName IS NULL, t.knownledge_name, k.knowledgeName)
  104. ORDER BY COUNT(*) DESC
  105. </select>
  106. <select id="selectMxjbWrongClassStudentStats" parameterType="map" resultMap="MxjbWrongBookResult">
  107. SELECT t.customer_code, b.name name, SUM(IF(t.state = 0, 1, 0)) wrong_count
  108. FROM mxjb_wrong_book t
  109. JOIN b_customer_basic b ON b.code = t.customer_code
  110. JOIN b_customer_class c ON c.customerCode = b.code
  111. <where> t.updated_time &gt;= #{beginTime} AND t.updated_time &lt;= #{endTime}
  112. <if test="studentGradeId != null "> and c.gradeId = #{studentGradeId}</if>
  113. <if test="subjectId != null "> and t.subject_id = #{subjectId}</if>
  114. <if test="classId != null "> and c.classId = #{classId}</if>
  115. <if test="classIds != null "> and c.classId in <foreach item="id" collection="classIds" open="(" separator="," close=")">#{id}</foreach></if>
  116. <if test="knownledgeName != null ">AND t.knownledge_name = #{knownledgeName} </if>
  117. </where>
  118. GROUP BY t.customer_code, b.name
  119. ORDER BY wrong_count DESC
  120. </select>
  121. <select id="selectMxjbWrongClassStudentQuestions" parameterType="map" resultMap="MxjbWrongBookResult">
  122. SELECT t.paper_type, t.question_id, q.title name, t.state, t.source, t.answers, t.answer1, t.answer2, t.score_total, t.score, t.duration, t.comment, t.created_time, t.updated_time
  123. FROM mxjb_wrong_book t
  124. JOIN b_customer_basic b ON b.code = t.customer_code
  125. JOIN b_customer_class c ON c.customerCode = b.code
  126. JOIN questions q ON q.id = t.question_id
  127. <where> t.customer_code = #{customerCode} AND t.updated_time &gt;= #{beginTime} AND t.updated_time &lt;= #{endTime}
  128. <if test="classId != null "> and c.classId = #{classId}</if>
  129. <if test="studentGradeId != null "> and c.gradeId = #{studentGradeId}</if>
  130. <if test="subjectId != null "> and t.subject_id = #{subjectId}</if>
  131. <if test="classIds != null "> and c.classId in <foreach item="id" collection="classIds" open="(" separator="," close=")">#{id}</foreach></if>
  132. <if test="knownledgeName != null ">AND t.knownledge_name = #{knownledgeName} </if>
  133. <if test="state != null "> and t.state = #{state}</if>
  134. </where>
  135. </select>
  136. <select id="selectSubjects" parameterType="MxjbWrongBook" resultMap="MxjbWrongBookResult">
  137. select distinct s.subjectname subjectName,s.subjectId subject_id from mxjb_wrong_book b
  138. left join subject s on s.subjectid = b.subject_id
  139. where b.customer_code = #{customerCode} and s.subjectname is not null
  140. order by s.subjectId asc
  141. </select>
  142. <select id="selectQTypes" parameterType="MxjbWrongBook" resultMap="MxjbWrongBookResult">
  143. select distinct q.qtpye subjectName from mxjb_wrong_book b
  144. left join questions q on q.id = b.question_id
  145. where b.customer_code = #{customerCode} and q.qtpye is not null
  146. <if test="subjectId != null "> and q.subjectId = #{subjectId}</if>
  147. </select>
  148. <select id="selectMxjbWrongBookList" parameterType="MxjbWrongBook" resultMap="MxjbWrongBookResult">
  149. <include refid="selectMxjbWrongBookVo"/>
  150. <where>
  151. <if test="customerCode != null and customerCode != ''"> and customer_code = #{customerCode}</if>
  152. <if test="questionId != null "> and question_id = #{questionId}</if>
  153. <if test="source != null and source != ''"> and source = #{source}</if>
  154. <if test="answers != null and answers != ''"> and answers = #{answers}</if>
  155. <if test="answer1 != null and answer1 != ''"> and answer1 = #{answer1}</if>
  156. <if test="answer2 != null and answer2 != ''"> and answer2 = #{answer2}</if>
  157. <if test="wrongCount != null "> and wrong_count = #{wrongCount}</if>
  158. <if test="rightCount != null "> and right_count = #{rightCount}</if>
  159. <if test="totalCount != null "> and total_count = #{totalCount}</if>
  160. <if test="state != null "> and state = #{state}</if>
  161. <if test="duration != null "> and duration = #{duration}</if>
  162. <if test="comment != null "> and comment = #{comment}</if>
  163. <if test="createdTime != null "> and created_time = #{createdTime}</if>
  164. <if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
  165. </where>
  166. </select>
  167. <select id="selectMxjbWrongBookById" parameterType="Long" resultMap="MxjbWrongBookResult">
  168. <include refid="selectMxjbWrongBookVo"/>
  169. where wrong_id = #{wrongId}
  170. </select>
  171. <insert id="insertMxjbWrongBook" parameterType="MxjbWrongBook" useGeneratedKeys="true" keyProperty="wrongId" keyColumn="wrong_id">
  172. insert into mxjb_wrong_book
  173. <trim prefix="(" suffix=")" suffixOverrides=",">
  174. <if test="wrongId != null">wrong_id,</if>
  175. <if test="customerCode != null">customer_code,</if>
  176. <if test="subjectId != null">subject_id,</if>
  177. <if test="knownledgeId != null">knownledge_id,</if>
  178. <if test="knownledgeName != null">knownledge_name,</if>
  179. <if test="paperType != null">paper_type,</if>
  180. <if test="paperId != null">paper_id,</if>
  181. <if test="questionId != null">question_id,</if>
  182. <if test="source != null">source,</if>
  183. <if test="answers != null">answers,</if>
  184. <if test="answer1 != null">answer1,</if>
  185. <if test="answer2 != null">answer2,</if>
  186. <if test="wrongCount != null">wrong_count,</if>
  187. <if test="rightCount != null">right_count,</if>
  188. <if test="totalCount != null">total_count,</if>
  189. <if test="scoreTotal != null">score_total,</if>
  190. <if test="score != null">score,</if>
  191. <if test="state != null">state,</if>
  192. <if test="duration != null">duration,</if>
  193. <if test="comment != null">comment,</if>
  194. <if test="createdTime != null">created_time,</if>
  195. <if test="updatedTime != null">updated_time,</if>
  196. </trim>
  197. <trim prefix="values (" suffix=")" suffixOverrides=",">
  198. <if test="wrongId != null">#{wrongId},</if>
  199. <if test="customerCode != null">#{customerCode},</if>
  200. <if test="subjectId != null">#{subjectId},</if>
  201. <if test="knownledgeId != null">#{knownledgeId},</if>
  202. <if test="knownledgeName != null">#{knownledgeName},</if>
  203. <if test="paperType != null">#{paperType},</if>
  204. <if test="paperId != null">#{paperId},</if>
  205. <if test="questionId != null">#{questionId},</if>
  206. <if test="source != null">#{source},</if>
  207. <if test="answers != null">#{answers},</if>
  208. <if test="answer1 != null">#{answer1},</if>
  209. <if test="answer2 != null">#{answer2},</if>
  210. <if test="wrongCount != null">#{wrongCount},</if>
  211. <if test="rightCount != null">#{rightCount},</if>
  212. <if test="totalCount != null">#{totalCount},</if>
  213. <if test="scoreTotal != null">#{scoreTotal},</if>
  214. <if test="score != null">#{score},</if>
  215. <if test="state != null">#{state},</if>
  216. <if test="duration != null">#{duration},</if>
  217. <if test="comment != null">#{comment},</if>
  218. <if test="createdTime != null">#{createdTime},</if>
  219. <if test="updatedTime != null">#{updatedTime},</if>
  220. </trim>
  221. </insert>
  222. <update id="updateMxjbWrongBook" parameterType="MxjbWrongBook">
  223. update mxjb_wrong_book
  224. <trim prefix="SET" suffixOverrides=",">
  225. <if test="customerCode != null">customer_code = #{customerCode},</if>
  226. <if test="subjectId != null">subject_id = #{subjectId},</if>
  227. <if test="knownledgeId != null">knownledge_id = #{knownledgeId},</if>
  228. <if test="knownledgeName != null">knownledge_name = #{knownledgeName},</if>
  229. <if test="paperType != null">paper_type = #{paperType},</if>
  230. <if test="paperId != null">paper_id = #{paperId},</if>
  231. <if test="questionId != null">question_id = #{questionId},</if>
  232. <if test="source != null">source = #{source},</if>
  233. <if test="answers != null">answers = #{answers},</if>
  234. <if test="answer1 != null">answer1 = #{answer1},</if>
  235. <if test="answer2 != null">answer2 = #{answer2},</if>
  236. <if test="wrongCount != null">wrong_count = #{wrongCount},</if>
  237. <if test="rightCount != null">right_count = #{rightCount},</if>
  238. <if test="totalCount != null">total_count = #{totalCount},</if>
  239. <if test="scoreTotal != null">score_total = #{scoreTotal},</if>
  240. <if test="score != null">score = #{score},</if>
  241. <if test="state != null">state = #{state},</if>
  242. <if test="duration != null">duration = #{duration},</if>
  243. <if test="comment != null">comment = #{comment},</if>
  244. <if test="createdTime != null">created_time = #{createdTime},</if>
  245. <if test="updatedTime != null">updated_time = #{updatedTime},</if>
  246. </trim>
  247. where wrong_id = #{wrongId}
  248. </update>
  249. <delete id="deleteMxjbWrongBookById" parameterType="Long">
  250. delete from mxjb_wrong_book where wrong_id = #{wrongId}
  251. </delete>
  252. <delete id="deleteMxjbWrongBookByIds" parameterType="String">
  253. delete from mxjb_wrong_book where wrong_id in
  254. <foreach item="wrongId" collection="array" open="(" separator="," close=")">
  255. #{wrongId}
  256. </foreach>
  257. </delete>
  258. <delete id="deleteByQuestion" parameterType="MxjbWrongBook">
  259. delete from mxjb_wrong_book where customer_code = #{customerCode} and question_id = #{questionId}
  260. </delete>
  261. </mapper>