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