ExamMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.zhongzheng.modules.bank.mapper.ExamMapper">
  6. <resultMap type="com.zhongzheng.modules.bank.domain.Exam" id="ExamResult">
  7. <result property="examId" column="exam_id"/>
  8. <result property="status" column="status"/>
  9. <result property="createTime" column="create_time"/>
  10. <result property="updateTime" column="update_time"/>
  11. <result property="prefixName" column="prefix_name"/>
  12. <result property="code" column="code"/>
  13. <result property="examName" column="exam_name"/>
  14. <result property="publishStatus" column="publish_status"/>
  15. <result property="year" column="year"/>
  16. <result property="cityId" column="city_id"/>
  17. <result property="provinceId" column="province_id"/>
  18. <result property="examPaperId" column="exam_paper_id"/>
  19. <result property="answerTime" column="answer_time"/>
  20. <result property="examPaperId" column="exam_paper_id"/>
  21. <result property="answerNum" column="answer_num"/>
  22. <result property="sort" column="sort"/>
  23. <result property="createBy" column="create_by"/>
  24. <result property="doType" column="do_type"/>
  25. <result property="simulateConfigJson" column="simulate_config_json"/>
  26. <result property="simulateStatus" column="simulate_status"/>
  27. </resultMap>
  28. <resultMap type="com.zhongzheng.modules.bank.vo.ExamVo" id="ExamVoResult">
  29. <result property="examId" column="exam_id"/>
  30. <result property="status" column="status"/>
  31. <result property="createTime" column="create_time"/>
  32. <result property="updateTime" column="update_time"/>
  33. <result property="prefixName" column="prefix_name"/>
  34. <result property="code" column="code"/>
  35. <result property="examName" column="exam_name"/>
  36. <result property="publishStatus" column="publish_status"/>
  37. <result property="year" column="year"/>
  38. <result property="cityId" column="city_id"/>
  39. <result property="provinceId" column="province_id"/>
  40. <result property="examPaperId" column="exam_paper_id"/>
  41. <result property="answerTime" column="answer_time"/>
  42. <result property="examPaperId" column="exam_paper_id"/>
  43. <result property="answerNum" column="answer_num"/>
  44. <result property="sort" column="sort"/>
  45. <result property="educationName" column="education_name"/>
  46. <result property="projectName" column="project_name"/>
  47. <result property="businessName" column="business_name"/>
  48. <result property="educationTypeId" column="education_type_id"/>
  49. <result property="businessId" column="business_id"/>
  50. <result property="subjectId" column="subject_id"/>
  51. <result property="projectId" column="project_id"/>
  52. <result property="subjectName" column="subject_name"/>
  53. <result property="doType" column="do_type"/>
  54. <result property="simulateConfigJson" column="simulate_config_json"/>
  55. <result property="simulateStatus" column="simulate_status"/>
  56. <result property="questionNum" column="question_num"/>
  57. <result property="recordStatus" column="record_status"/>
  58. <result property="doQuestionNum" column="do_question_num"/>
  59. <result property="paperName" column="paper_name"/>
  60. <collection property="goodsList" column="exam_id" select="findGoodsList"/>
  61. </resultMap>
  62. <select id="findGoodsList" resultMap="GoodsListResult">
  63. SELECT
  64. g.goods_name,
  65. g.goods_id
  66. FROM
  67. goods_attached ga
  68. LEFT JOIN goods g ON ga.goods_id = g.goods_id
  69. WHERE
  70. ga.major_id =#{exam_id} AND ga.type = 3
  71. </select>
  72. <resultMap type="com.zhongzheng.modules.bank.vo.ExamGoodsVo" id="GoodsListResult">
  73. <result property="goodsName" column="goods_name"/>
  74. <result property="goodsId" column="goods_id"/>
  75. </resultMap>
  76. <select id="getList" parameterType="com.zhongzheng.modules.bank.bo.ExamQueryBo" resultMap="ExamVoResult">
  77. SELECT
  78. e.*,
  79. qb.education_type_id,
  80. qb.business_id,
  81. qb.project_id,
  82. qb.subject_id,
  83. cet.education_name,
  84. cpt.project_name,
  85. cb.business_name,
  86. cs.subject_name,
  87. eq.question_num,
  88. ep.paper_name
  89. FROM
  90. exam e
  91. LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
  92. LEFT JOIN question_business qb ON e.exam_id = qb.major_id
  93. AND qb.type = 2
  94. LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id
  95. LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id
  96. LEFT JOIN course_business cb ON qb.business_id = cb.id
  97. LEFT JOIN course_subject cs ON cs.id = qb.subject_id
  98. LEFT JOIN (SELECT count(*) question_num,exam_id from exam_question GROUP BY exam_id)eq on eq.exam_id = e.exam_id
  99. where 1=1
  100. <if test="status != null and status.size()!=0 ">
  101. AND e.status in
  102. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  103. #{item}
  104. </foreach>
  105. </if>
  106. <if test="examIds != null and examIds.size()!=0 ">
  107. AND e.exam_id in
  108. <foreach collection="examIds" item="item" index="index" open="(" close=")" separator=",">
  109. #{item}
  110. </foreach>
  111. </if>
  112. <if test="paperName != null and paperName != ''">
  113. AND ep.paper_name like concat('%', #{paperName}, '%')
  114. </if>
  115. <if test="educationTypeId != null and educationTypeId != ''">
  116. AND cet.id = #{educationTypeId}
  117. </if>
  118. <if test="examId != null and examId != ''">
  119. AND e.exam_id = #{examId}
  120. </if>
  121. <if test="subjectId != null and subjectId != ''">
  122. AND cs.id = #{subjectId}
  123. </if>
  124. <if test="businessId != null and businessId != ''">
  125. AND cb.id = #{businessId}
  126. </if>
  127. <if test="projectId != null and projectId != ''">
  128. AND cpt.id = #{projectId}
  129. </if>
  130. <if test="examPaperId != null and examPaperId != ''">
  131. AND e.exam_paper_id = #{examPaperId}
  132. </if>
  133. <if test="publishStatus != null ">
  134. AND e.publish_status = #{publishStatus}
  135. </if>
  136. <if test="examName != null and examName != ''">
  137. AND e.exam_name like concat('%', #{examName}, '%')
  138. </if>
  139. <if test="prefixName != null and prefixName != ''">
  140. AND e.prefix_name like concat('%', #{prefixName}, '%')
  141. </if>
  142. <if test="key != null and key != ''">
  143. AND (e.exam_name like concat('%', #{key}, '%') or e.prefix_name like concat('%', #{key}, '%') or e.code = #{key})
  144. </if>
  145. <if test="exclude != null and exclude == 1">
  146. AND ep.paper_name NOT IN('每日一练','随机练习')
  147. </if>
  148. ORDER BY e.exam_id DESC
  149. </select>
  150. <select id="getPaperExamList" parameterType="com.zhongzheng.modules.exam.bo.ExamPaperQueryBo" resultMap="ExamVoResult">
  151. SELECT
  152. e.*,
  153. count( eq.question_id ) question_num,
  154. ifnull( (select `status` from user_exam_record uer where uer.exam_id = e.exam_id and uer.user_id = #{userId} and uer.order_goods_id = #{orderGoodsId} ORDER BY uer.record_id desc limit 1),-1) record_status,
  155. ifnull( (select do_question_num from user_exam_record uer where uer.exam_id = e.exam_id and uer.user_id = #{userId} and uer.order_goods_id = #{orderGoodsId} ORDER BY uer.record_id desc limit 1),0) do_question_num
  156. FROM
  157. exam e
  158. LEFT JOIN exam_question eq ON e.exam_id = eq.exam_id
  159. WHERE
  160. e.exam_id IN (
  161. SELECT
  162. exam_id
  163. FROM
  164. question_chapter_exam
  165. WHERE
  166. FIND_IN_SET(
  167. chapter_exam_id,
  168. (
  169. SELECT
  170. concat(
  171. IFNULL(( SELECT GROUP_CONCAT( major_id ) eids FROM goods_attached WHERE goods_id = #{goodsId} AND type = 2 ), '' ),
  172. ',',
  173. IFNULL(
  174. (
  175. SELECT
  176. GROUP_CONCAT( chapter_exam_id ) eids2
  177. FROM
  178. question_module_chapter
  179. WHERE
  180. module_exam_id IN ( SELECT major_id FROM goods_attached WHERE goods_id = #{goodsId} AND type = 1 )),
  181. ''
  182. )))) UNION
  183. SELECT
  184. major_id AS exam_id
  185. FROM
  186. goods_attached
  187. WHERE
  188. goods_id = #{goodsId}
  189. AND type = 3
  190. )
  191. AND e.`status` = 1 AND e.exam_paper_id = #{paperId} GROUP BY
  192. e.exam_id
  193. </select>
  194. <select id="getExamByTenant" parameterType="map" resultType="com.zhongzheng.modules.bank.domain.Exam">
  195. select * from exam where `code` = #{code} and tenant_id = #{newTenantId}
  196. </select>
  197. </mapper>