ExamMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. (SELECT count(*) FROM exam_question WHERE exam_id = e.exam_id)as 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. where 1=1
  99. <if test="status != null and status.size()!=0 ">
  100. AND e.status in
  101. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  102. #{item}
  103. </foreach>
  104. </if>
  105. <if test="examIds != null and examIds.size()!=0 ">
  106. AND e.exam_id in
  107. <foreach collection="examIds" item="item" index="index" open="(" close=")" separator=",">
  108. #{item}
  109. </foreach>
  110. </if>
  111. <if test="paperName != null and paperName != ''">
  112. AND ep.paper_name like concat('%', #{paperName}, '%')
  113. </if>
  114. <if test="educationTypeId != null and educationTypeId != ''">
  115. AND cet.id = #{educationTypeId}
  116. </if>
  117. <if test="examId != null and examId != ''">
  118. AND e.exam_id = #{examId}
  119. </if>
  120. <if test="subjectId != null and subjectId != ''">
  121. AND cs.id = #{subjectId}
  122. </if>
  123. <if test="businessId != null and businessId != ''">
  124. AND cb.id = #{businessId}
  125. </if>
  126. <if test="projectId != null and projectId != ''">
  127. AND cpt.id = #{projectId}
  128. </if>
  129. <if test="examPaperId != null and examPaperId != ''">
  130. AND e.exam_paper_id = #{examPaperId}
  131. </if>
  132. <if test="publishStatus != null ">
  133. AND e.publish_status = #{publishStatus}
  134. </if>
  135. <if test="examName != null and examName != ''">
  136. AND e.exam_name like concat('%', #{examName}, '%')
  137. </if>
  138. <if test="prefixName != null and prefixName != ''">
  139. AND e.prefix_name like concat('%', #{prefixName}, '%')
  140. </if>
  141. <if test="key != null and key != ''">
  142. AND (e.exam_name like concat('%', #{key}, '%') or e.prefix_name like concat('%', #{key}, '%') or e.code = #{key})
  143. </if>
  144. <if test="exclude != null and exclude == 1">
  145. AND ep.paper_name NOT IN('每日一练','随机练习')
  146. </if>
  147. ORDER BY e.exam_id DESC
  148. </select>
  149. <select id="getPaperExamList" parameterType="com.zhongzheng.modules.exam.bo.ExamPaperQueryBo" resultMap="ExamVoResult">
  150. SELECT
  151. e.*,
  152. count( eq.question_id ) question_num,
  153. 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,
  154. 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
  155. FROM
  156. exam e
  157. LEFT JOIN exam_question eq ON e.exam_id = eq.exam_id
  158. WHERE
  159. e.exam_id IN (
  160. SELECT
  161. exam_id
  162. FROM
  163. question_chapter_exam
  164. WHERE
  165. FIND_IN_SET(
  166. chapter_exam_id,
  167. (
  168. SELECT
  169. concat(
  170. IFNULL(( SELECT GROUP_CONCAT( major_id ) eids FROM goods_attached WHERE goods_id = #{goodsId} AND type = 2 ), '' ),
  171. ',',
  172. IFNULL(
  173. (
  174. SELECT
  175. GROUP_CONCAT( chapter_exam_id ) eids2
  176. FROM
  177. question_module_chapter
  178. WHERE
  179. module_exam_id IN ( SELECT major_id FROM goods_attached WHERE goods_id = #{goodsId} AND type = 1 )),
  180. ''
  181. )))) UNION
  182. SELECT
  183. major_id AS exam_id
  184. FROM
  185. goods_attached
  186. WHERE
  187. goods_id = #{goodsId}
  188. AND type = 3
  189. )
  190. AND e.`status` = 1 AND e.exam_paper_id = #{paperId} GROUP BY
  191. e.exam_id
  192. </select>
  193. <select id="getExamByTenant" parameterType="map" resultType="com.zhongzheng.modules.bank.domain.Exam">
  194. select * from exam where `code` = #{code} and tenant_id = #{newTenantId}
  195. </select>
  196. </mapper>