ExamRegistrationMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.keao.edu.user.dao.ExamRegistrationDao">
  8. <resultMap type="com.keao.edu.user.entity.ExamRegistration" id="ExamRegistration">
  9. <id column="id_" property="id" />
  10. <result column="examination_basic_id_" property="examinationBasicId" />
  11. <result column="student_id_" property="studentId" />
  12. <result column="organ_id_" property="organId" />
  13. <result column="subject_id_" property="subjectId" />
  14. <result column="level_" property="level" />
  15. <result column="level_fee_" property="levelFee" />
  16. <result column="song_json_" property="songJson" />
  17. <result column="last_exam_level_" property="lastExamLevel" />
  18. <result column="last_exam_certificate_url_" property="lastExamCertificateUrl" />
  19. <result column="exam_music_theory_level_" property="examMusicTheoryLevel" />
  20. <result column="theory_level_fee_" property="theoryLevelFee" />
  21. <result column="last_music_theory_level_" property="lastMusicTheoryLevel" />
  22. <result column="last_music_theory_certificate_url_" property="lastMusicTheoryCertificateUrl" />
  23. <result column="adviser_name_" property="adviserName" />
  24. <result column="adviser_phone_" property="adviserPhone" />
  25. <result column="card_no_" property="cardNo" />
  26. <result column="status_" property="status" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  27. <result column="create_time_" property="createTime" />
  28. <result column="update_time_" property="updateTime" />
  29. <result column="tenant_id_" property="tenantId" />
  30. <result column="memo_" property="memo" />
  31. <association property="sysUser" columnPrefix="sys_user_" resultMap="com.keao.edu.user.dao.StudentDao.Student"/>
  32. <association property="subject" columnPrefix="subject_" resultMap="com.keao.edu.user.dao.SubjectDao.Subject"/>
  33. <association property="examinationBasic" columnPrefix="examination_basic_" resultMap="com.keao.edu.user.dao.ExaminationBasicDao.ExaminationBasic"/>
  34. </resultMap>
  35. <resultMap id="ExamRegistrationRoomDto" type="com.keao.edu.user.dto.ExamRegistrationRoomDto" extends="ExamRegistration">
  36. <result column="exam_room_id_" property="examRoomId"/>
  37. <result column="exam_start_time_" property="examStartTime"/>
  38. <result column="exam_end_time_" property="examEndTime"/>
  39. </resultMap>
  40. <!-- 根据主键查询一条记录 -->
  41. <select id="get" resultMap="ExamRegistration" >
  42. SELECT * FROM exam_registration WHERE id_ = #{id}
  43. </select>
  44. <!-- 全查询 -->
  45. <select id="findAll" resultMap="ExamRegistration">
  46. SELECT * FROM exam_registration ORDER BY id_
  47. </select>
  48. <!-- 向数据库增加一条记录 -->
  49. <insert id="insert" parameterType="com.keao.edu.user.entity.ExamRegistration" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  50. INSERT INTO exam_registration (examination_basic_id_, student_id_, organ_id_,subject_id_, level_, level_fee_,
  51. song_json_, last_exam_level_, last_exam_certificate_url_,exam_music_theory_level_, theory_level_fee_,
  52. last_music_theory_level_,last_music_theory_certificate_url_, adviser_name_,adviser_phone_, card_no_, status_,
  53. create_time_, update_time_, tenant_id_,memo_)
  54. VALUES (#{examinationBasicId}, #{studentId}, #{organId}, #{subjectId}, #{level}, #{levelFee}, #{songJson},
  55. #{lastExamLevel}, #{lastExamCertificateUrl}, #{examMusicTheoryLevel}, #{theoryLevelFee}, #{lastMusicTheoryLevel},
  56. #{lastMusicTheoryCertificateUrl}, #{adviserName}, #{adviserPhone}, #{cardNo}, #{status},#{createTime},
  57. #{updateTime}, #{tenantId}, #{memo})
  58. </insert>
  59. <!-- 根据主键查询一条记录 -->
  60. <update id="update" parameterType="com.keao.edu.user.entity.ExamRegistration">
  61. UPDATE exam_registration
  62. <set>
  63. <if test="examinationBasicId != null">
  64. examination_basic_id_ = #{examinationBasicId},
  65. </if>
  66. <if test="studentId != null">
  67. student_id_ = #{studentId},
  68. </if>
  69. <if test="organId != null">
  70. organ_id_ = #{organId},
  71. </if>
  72. <if test="subjectId != null">
  73. subject_id_ = #{subjectId},
  74. </if>
  75. <if test="level != null">
  76. level_ = #{level},
  77. </if>
  78. <if test="levelFee != null">
  79. level_fee_ = #{levelFee},
  80. </if>
  81. <if test="songJson != null">
  82. song_json_ = #{songJson},
  83. </if>
  84. <if test="lastExamLevel != null">
  85. last_exam_level_ = #{lastExamLevel},
  86. </if>
  87. <if test="lastExamCertificateUrl != null">
  88. last_exam_certificate_url_ = #{lastExamCertificateUrl},
  89. </if>
  90. <if test="examMusicTheoryLevel!= null">
  91. exam_music_theory_level_ = #{examMusicTheoryLevel},
  92. </if>
  93. <if test="theoryLevelFee!= null">
  94. theory_level_fee_ = #{theoryLevelFee},
  95. </if>
  96. <if test="lastMusicTheoryLevel != null">
  97. last_music_theory_level_ = #{lastMusicTheoryLevel},
  98. </if>
  99. <if test="lastMusicTheoryCertificateUrl != null">
  100. last_music_theory_certificate_url_ = #{lastMusicTheoryCertificateUrl},
  101. </if>
  102. <if test="adviserName != null">
  103. adviser_name_ = #{adviserName},
  104. </if>
  105. <if test="adviserPhone != null">
  106. adviser_phone_ = #{adviserPhone},
  107. </if>
  108. <if test="cardNo!=null">
  109. card_no_ =#{cardNo},
  110. </if>
  111. <if test="status!=null">
  112. status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  113. </if>
  114. <if test="tenantId != null">
  115. tenant_id_ = #{tenantId},
  116. </if>
  117. <if test="createTime != null">
  118. create_time_ = #{createTime},
  119. </if>
  120. <if test="memo!=null">
  121. memo_ = #{memo},
  122. </if>
  123. update_time_ = NOW()
  124. </set>
  125. WHERE id_ = #{id}
  126. </update>
  127. <update id="batchUpdate" parameterType="com.keao.edu.user.entity.ExamRegistration">
  128. <foreach collection="regists" item="regist" separator=";">
  129. UPDATE exam_registration
  130. <set>
  131. <if test="regist.examinationBasicId != null">
  132. examination_basic_id_ = #{regist.examinationBasicId},
  133. </if>
  134. <if test="regist.studentId != null">
  135. student_id_ = #{regist.studentId},
  136. </if>
  137. <if test="regist.organId != null">
  138. organ_id_ = #{regist.organId},
  139. </if>
  140. <if test="regist.subjectId != null">
  141. subject_id_ = #{regist.subjectId},
  142. </if>
  143. <if test="regist.level != null">
  144. level_ = #{regist.level},
  145. </if>
  146. <if test="regist.levelFee != null">
  147. level_fee_ = #{regist.levelFee},
  148. </if>
  149. <if test="regist.songJson != null">
  150. song_json_ = #{regist.songJson},
  151. </if>
  152. <if test="regist.lastExamLevel != null">
  153. last_exam_level_ = #{regist.lastExamLevel},
  154. </if>
  155. <if test="regist.lastExamCertificateUrl != null">
  156. last_exam_certificate_url_ = #{regist.lastExamCertificateUrl},
  157. </if>
  158. <if test="regist.examMusicTheoryLevel!= null">
  159. exam_music_theory_level_ = #{regist.examMusicTheoryLevel},
  160. </if>
  161. <if test="regist.theoryLevelFee!= null">
  162. theory_level_fee_ = #{regist.theoryLevelFee},
  163. </if>
  164. <if test="regist.lastMusicTheoryLevel != null">
  165. last_music_theory_level_ = #{regist.lastMusicTheoryLevel},
  166. </if>
  167. <if test="regist.lastMusicTheoryCertificateUrl != null">
  168. last_music_theory_certificate_url_ = #{regist.lastMusicTheoryCertificateUrl},
  169. </if>
  170. <if test="regist.adviserName != null">
  171. adviser_name_ = #{regist.adviserName},
  172. </if>
  173. <if test="regist.adviserPhone != null">
  174. adviser_phone_ = #{regist.adviserPhone},
  175. </if>
  176. <if test="regist.cardNo!=null">
  177. card_no_ =#{regist.cardNo},
  178. </if>
  179. <if test="regist.status!=null">
  180. status_ = #{regist.status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  181. </if>
  182. <if test="regist.tenantId != null">
  183. tenant_id_ = #{regist.tenantId},
  184. </if>
  185. <if test="regist.memo!=null">
  186. memo_ = #{regist.memo},
  187. </if>
  188. update_time_ = NOW()
  189. </set>
  190. WHERE id_ = #{regist.id}
  191. </foreach>
  192. </update>
  193. <!-- 根据主键删除一条记录 -->
  194. <delete id="delete" >
  195. DELETE FROM exam_registration WHERE id_ = #{id}
  196. </delete>
  197. <sql id="queryCondition">
  198. <where>
  199. er.status_ NOT IN ('CANCEL')
  200. <if test="organIds!=null">
  201. AND er.organ_id_ IN
  202. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  203. #{organId}
  204. </foreach>
  205. </if>
  206. <if test="studentId!=null">
  207. AND er.student_id_=#{studentId}
  208. </if>
  209. <if test="examId!=null">
  210. AND er.examination_basic_id_ = #{examId}
  211. </if>
  212. <if test="organId != null">
  213. AND er.organ_id_ = #{organId}
  214. </if>
  215. <if test="organizationId != null">
  216. AND er.organ_id_ = #{organizationId}
  217. </if>
  218. <if test="subjectId!=null">
  219. AND er.subject_id_ = #{subjectId}
  220. </if>
  221. <if test="level!=null">
  222. AND er.level_ = #{level}
  223. </if>
  224. <if test="status!=null">
  225. AND er.status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  226. </if>
  227. <if test="search!=null and search!=''">
  228. AND (er.student_id_=#{search} OR su.phone_ LIKE CONCAT('%', #{search}, '%') OR su.real_name_ LIKE CONCAT('%', #{search}, '%') OR eb.name_ LIKE CONCAT('%', #{search}, '%'))
  229. </if>
  230. </where>
  231. </sql>
  232. <!-- 分页查询 -->
  233. <select id="queryPage" resultMap="ExamRegistration" parameterType="map">
  234. SELECT
  235. er.id_,
  236. er.examination_basic_id_,
  237. er.exam_music_theory_level_,
  238. er.card_no_,
  239. er.student_id_,
  240. er.memo_,
  241. su.real_name_ sys_user_real_name_,
  242. er.last_exam_certificate_url_,
  243. er.last_music_theory_certificate_url_,
  244. er.level_fee_,
  245. er.theory_level_fee_,
  246. er.organ_id_,
  247. er.subject_id_,
  248. er.level_,
  249. erp.trans_amount_,
  250. er.status_,
  251. er.create_time_
  252. FROM
  253. exam_registration er
  254. LEFT JOIN sys_user su ON er.student_id_ = su.id_
  255. LEFT JOIN exam_registration_payment erp ON er.id_ = erp.exam_registration_id_
  256. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  257. <include refid="queryCondition"/>
  258. ORDER BY er.id_
  259. <include refid="global.limit"/>
  260. </select>
  261. <!-- 查询当前表的总记录数 -->
  262. <select id="queryCount" resultType="int">
  263. SELECT COUNT(*) FROM exam_registration er
  264. <include refid="queryCondition"/>
  265. </select>
  266. <sql id="queryExamRegistCondition">
  267. <where>
  268. <if test="organIds!=null">
  269. AND er.organ_id_ IN
  270. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  271. #{organId}
  272. </foreach>
  273. </if>
  274. <if test="examId!=null">
  275. AND er.examination_basic_id_ = #{examId}
  276. </if>
  277. <if test="organId!=null">
  278. AND er.organ_id_ = #{organId}
  279. </if>
  280. <if test="subjectId!=null">
  281. AND er.subject_id_ = #{subjectId}
  282. </if>
  283. <if test="level!=null">
  284. AND er.level_ = #{level}
  285. </if>
  286. <if test="status!=null">
  287. AND er.status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  288. </if>
  289. <if test="inRoom!=null and inRoom=0">
  290. AND ersr.exam_room_id_ IS NULL
  291. </if>
  292. <if test="inRoom!=null and inRoom=1">
  293. AND ersr.exam_room_id_ IS NOT NULL
  294. </if>
  295. </where>
  296. </sql>
  297. <select id="queryExamRegist" resultMap="ExamRegistrationRoomDto" parameterType="map">
  298. SELECT
  299. er.id_,
  300. er.examination_basic_id_,
  301. er.exam_music_theory_level_,
  302. er.card_no_,
  303. er.student_id_,
  304. er.memo_,
  305. su.real_name_ sys_user_real_name_,
  306. su.phone_ sys_user_phone_,
  307. er.last_exam_certificate_url_,
  308. er.last_music_theory_certificate_url_,
  309. er.level_fee_,
  310. er.theory_level_fee_,
  311. er.song_json_,
  312. er.organ_id_,
  313. er.subject_id_,
  314. er.level_,
  315. er.status_,
  316. er.create_time_,
  317. ersr.exam_room_id_,
  318. ero.exam_start_time_,
  319. ero.exam_end_time_
  320. FROM
  321. exam_registration er
  322. LEFT JOIN sys_user su ON er.student_id_ = su.id_
  323. LEFT JOIN exam_room_student_relation ersr ON ersr.exam_registration_id_ = er.id_
  324. LEFT JOIN exam_room ero ON ero.id_ = ersr.exam_room_id_
  325. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  326. <include refid="queryCondition"/>
  327. ORDER BY er.id_ DESC
  328. <include refid="global.limit"/>
  329. </select>
  330. <select id="countExamRegist" resultType="int">
  331. SELECT COUNT(*) FROM exam_registration er
  332. LEFT JOIN sys_user su ON er.student_id_ = su.id_
  333. LEFT JOIN exam_room_student_relation ersr ON ersr.exam_registration_id_ = er.id_
  334. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  335. <include refid="queryCondition"/>
  336. </select>
  337. <select id="countWithoutExamRoomStudentNum" resultType="int">
  338. SELECT
  339. COUNT(ersr.id_)
  340. FROM
  341. exam_registration er
  342. LEFT JOIN exam_room_student_relation ersr ON ersr.student_id_ = er.student_id_
  343. WHERE 1=1
  344. <if test="organIds!=null">
  345. AND er.organ_id_ IN
  346. <foreach collection="organIds" item="organI" separator="," open="(" close=")">
  347. #{organI}
  348. </foreach>
  349. </if>
  350. AND er.examination_basic_id_ = #{examId}
  351. AND ersr.id_ IS NULL
  352. </select>
  353. <select id="countInExamRoomStudentNum" resultType="int">
  354. SELECT
  355. COUNT(ersr.id_)
  356. FROM
  357. exam_room_student_relation ersr
  358. LEFT JOIN exam_registration er ON ersr.exam_registration_id_ = er.id_
  359. WHERE 1=1
  360. <if test="organIds!=null">
  361. AND er.organ_id_ IN
  362. <foreach collection="organIds" item="organI" separator="," open="(" close=")">
  363. #{organI}
  364. </foreach>
  365. </if>
  366. AND ersr.examination_basic_id_ = #{examId}
  367. </select>
  368. <resultMap id="ExamRegistrationStatisticsDto" type="com.keao.edu.user.dto.ExamRegistrationStatisticsDto">
  369. <result property="totalRegistrationStudentNum" column="totalRegistrationStudentNum"/>
  370. <result property="childOrganRegistrationStudentNum" column="childOrganRegistrationStudentNum"/>
  371. <result property="waitAuditStudentNum" column="waitAuditStudentNum"/>
  372. <result property="refundedStudentNum" column="refundedStudentNum"/>
  373. </resultMap>
  374. <select id="getExamRegistrationStaticsInfo" resultMap="ExamRegistrationStatisticsDto">
  375. SELECT
  376. COUNT( er.student_id_ ) totalRegistrationStudentNum,
  377. SUM( CASE WHEN er.organ_id_ != #{selfOrganId} THEN 1 ELSE 0 END ) childOrganRegistrationStudentNum,
  378. SUM( CASE WHEN er.status_ = 'AUDIT_WAIT' THEN 1 ELSE 0 END ) waitAuditStudentNum,
  379. SUM( CASE WHEN er.status_ = 'REFUNDED' THEN 1 ELSE 0 END ) refundedStudentNum
  380. FROM
  381. exam_registration er
  382. WHERE
  383. er.status_ NOT IN ('CANCEL', 'PAY_WAIT')
  384. AND er.examination_basic_id_ = #{examId}
  385. <if test="organIds!=null">
  386. AND er.organ_id_ IN
  387. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  388. #{organId}
  389. </foreach>
  390. </if>
  391. </select>
  392. <select id="countTotalRegistrationStudentNumWithExam" resultType="int">
  393. SELECT
  394. COUNT(er.id_)
  395. FROM
  396. exam_registration er
  397. WHERE 1=1
  398. AND er.status_ IN ('AUDIT_PASS', 'AUDIT_WAIT')
  399. <if test="organIds!=null">
  400. AND er.organ_id_ IN
  401. <foreach collection="organIds" item="organI" separator="," open="(" close=")">
  402. #{organI}
  403. </foreach>
  404. </if>
  405. AND er.examination_basic_id_ = #{examId}
  406. AND er.status_ != ''
  407. </select>
  408. <select id="getWithExamAndStudents" resultMap="ExamRegistration">
  409. SELECT * FROM exam_registration WHERE examination_basic_id_=#{examId} AND student_id_ IN
  410. <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
  411. #{studentId}
  412. </foreach>
  413. </select>
  414. <select id="getRegists" resultMap="ExamRegistration">
  415. SELECT * FROM exam_registration WHERE id_ IN
  416. <foreach collection="registIds" item="registId" separator="," open="(" close=")">
  417. #{registId}
  418. </foreach>
  419. </select>
  420. <resultMap id="ExamRegistrationDtoMap" type="com.keao.edu.user.dto.ExamRegistrationDto">
  421. <result column="examination_basic_id_" property="examinationBasicId" />
  422. <result column="id_" property="id" />
  423. <result column="subject_id_" property="subjectId" />
  424. <result column="level_" property="level" />
  425. <result column="level_fee_" property="levelFee" />
  426. <result column="song_json_" property="songJson" />
  427. <result column="last_exam_level_" property="lastExamLevel" />
  428. <result column="last_exam_certificate_url_" property="lastExamCertificateUrl" />
  429. <result column="exam_music_theory_level_" property="examMusicTheoryLevel" />
  430. <result column="theory_level_fee_" property="theoryLevelFee" />
  431. <result column="last_music_theory_level_" property="lastMusicTheoryLevel" />
  432. <result column="last_music_theory_certificate_url_" property="lastMusicTheoryCertificateUrl" />
  433. <result column="card_no_" property="cardNo" />
  434. <result column="status_" property="status" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  435. <result column="memo_" property="memo" />
  436. <result property="studentName" column="studentName"/>
  437. <result property="subjectName" column="subjectName"/>
  438. <result property="examBaseName" column="examBaseName"/>
  439. <result property="examStartTime" column="expect_exam_start_time_"/>
  440. <result property="examEndTime" column="expect_exam_end_time_"/>
  441. <result property="enrollEndTime" column="enroll_end_time_"/>
  442. <result property="enrollStartTime" column="enroll_start_time_"/>
  443. <result property="performSongIdList" column="perform_song_id_list_"/>
  444. <result property="practiceSongIdList" column="practice_song_id_list_"/>
  445. </resultMap>
  446. <select id="countStudentList" resultType="java.lang.Integer">
  447. SELECT COUNT(er.id_) FROM exam_registration er
  448. <include refid="queryStudentListSql"/>
  449. </select>
  450. <sql id="queryStudentListSql">
  451. <where>
  452. <if test="studentId != null">
  453. AND er.student_id_ = #{studentId}
  454. </if>
  455. <if test="examRegistrationId != null">
  456. AND er.id_ = #{examRegistrationId}
  457. </if>
  458. <if test="paymentStatus != null and paymentStatus == 1">
  459. <if test="paymentStatus == 1">
  460. AND er.status_ IN ('AUDIT_PASS','AUDIT_WAIT','AUDIT_REJECT')
  461. </if>
  462. <if test="paymentStatus == 0">
  463. AND er.status_ IN ('CANCEL','PAY_WAIT')
  464. </if>
  465. </if>
  466. </where>
  467. </sql>
  468. <select id="queryStudentList" resultMap="ExamRegistrationDtoMap">
  469. SELECT er.*,eb.enroll_end_time_,eb.enroll_start_time_,eb.expect_exam_end_time_,
  470. eb.expect_exam_start_time_,eb.name_ examBaseName,ess.practice_song_id_list_,ess.perform_song_id_list_
  471. FROM exam_registration er
  472. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  473. LEFT JOIN exam_subject_song ess ON er.examination_basic_id_ = ess.examination_basic_id_
  474. <include refid="queryStudentListSql"/>
  475. ORDER BY er.update_time_ DESC
  476. <include refid="global.limit"/>
  477. </select>
  478. <resultMap id="ExamRecordDtoMap" type="com.keao.edu.user.dto.StudentExamListDto">
  479. <result property="level" column="level_"/>
  480. <result property="examRegistrationId" column="exam_registration_id_"/>
  481. <result property="examBaseName" column="exam_base_name_"/>
  482. <result property="actualExamEndTime" column="actual_exam_end_time_"/>
  483. <result property="actualExamStartTime" column="actual_exam_start_time_"/>
  484. <result property="avgScore" column="avg_score_"/>
  485. <result property="examAddress" column="exam_address_"/>
  486. <result property="examCertificationId" column="exam_certification_id_"/>
  487. <result property="examinationBasicId" column="examination_basic_id_"/>
  488. <result property="examMusicTheoryLevel" column="exam_music_theory_level_"/>
  489. <result property="isFinishedExam" column="is_finished_exam_"/>
  490. <result property="result" column="result_"/>
  491. <result property="theoryLevelFee" column="theory_level_fee_"/>
  492. <result property="videoUrl" column="video_url_"/>
  493. <result property="subjectId" column="subject_id_"/>
  494. <result property="cardNo" column="card_no_"/>
  495. </resultMap>
  496. <select id="queryExamList" resultMap="ExamRecordDtoMap">
  497. SELECT er.level_,ser.exam_registration_id_,eb.name_ exam_base_name_,eb.actual_exam_start_time_,
  498. eb.actual_exam_end_time_,ser.avg_score_,ec.exam_address_,ec.id_ exam_certification_id_,
  499. er.examination_basic_id_,er.exam_music_theory_level_,ser.is_finished_exam_,er.theory_level_fee_,
  500. ser.video_url_,ser.result_,er.subject_id_,ec.card_no_
  501. FROM exam_registration er
  502. LEFT JOIN student_exam_result ser ON ser.exam_registration_id_ = er.id_
  503. LEFT JOIN examination_basic eb ON eb.id_ = er.examination_basic_id_
  504. LEFT JOIN exam_certification ec ON ec.exam_registration_id_ = er.id_
  505. WHERE ser.id_ IS NOT NULL AND er.student_id_ = #{studentId}
  506. </select>
  507. <select id="countExamList" resultType="java.lang.Integer">
  508. SELECT COUNT(er.id_) FROM exam_registration er
  509. LEFT JOIN student_exam_result ser ON er.id_ = ser.exam_registration_id_
  510. WHERE ser.id_ IS NOT NULL AND er.student_id_ = #{studentId}
  511. </select>
  512. <!-- 获取报名信息 -->
  513. <select id="getExamRegistration" resultMap="ExamRegistrationDtoMap">
  514. SELECT er.*,s.name_ subjectName,su.real_name_ studentName,eb.expect_exam_start_time_,eb.expect_exam_end_time_ FROM exam_registration er
  515. LEFT JOIN sys_user su ON su.id_ = er.student_id_
  516. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  517. LEFT JOIN subject s on er.subject_id_ = s.id_
  518. WHERE er.id_ = #{examRegistrationId}
  519. </select>
  520. <select id="getExamRegistrationInfo" resultMap="ExamRegistration">
  521. SELECT er.*, su.id_ sys_user_id_, su.real_name_ sys_user_real_name_,su.phone_ sys_user_phone_ , s.id_ subject_id_,
  522. s.name_ subject_name_ ,eb.name_ examination_basic_name_
  523. FROM exam_registration er
  524. LEFT JOIN examination_basic eb ON eb.id_=er.examination_basic_id_
  525. LEFT JOIN sys_user su ON er.student_id_ = su.id_
  526. LEFT JOIN subject s on er.subject_id_ = s.id_
  527. WHERE er.id_ = #{id}
  528. </select>
  529. <select id="getRegistration" resultMap="ExamRegistration">
  530. SELECT * FROM exam_registration
  531. <where>
  532. <if test="examId != null">
  533. AND examination_basic_id_ = #{examId}
  534. </if>
  535. <if test="studentId != null">
  536. AND student_id_ =#{studentId}
  537. </if>
  538. <if test="subjectId != null">
  539. AND subject_id_=#{subjectId}
  540. </if>
  541. <if test="level != null">
  542. AND level_ = #{level}
  543. </if>
  544. <if test="statusEnumList != null">
  545. AND status_ IN
  546. <foreach collection="statusEnumList" item="status" open="(" close=")" separator=",">
  547. #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  548. </foreach>
  549. </if>
  550. </where>
  551. LIMIT 1
  552. </select>
  553. <select id="queryStudentTenantId" resultType="java.lang.Integer">
  554. SELECT DISTINCT tenant_id_ FROM exam_registration
  555. WHERE student_id_ = #{userId} AND tenant_id_ IS NOT NULL
  556. </select>
  557. <select id="countStudentBaseExams" resultType="java.lang.Integer">
  558. SELECT COUNT(er.id_) FROM exam_registration er
  559. <include refid="queryStudentListSql"/>
  560. </select>
  561. <resultMap id="StudentBaseExamsDtoMap" type="com.keao.edu.user.dto.StudentBaseExamsDto">
  562. <result property="baseExamName" column="examBaseName"/>
  563. <result property="tenantId" column="tenant_id_"/>
  564. </resultMap>
  565. <select id="queryStudentBaseExams" resultMap="StudentBaseExamsDtoMap">
  566. SELECT eb.name_ examBaseName,eb.tenant_id_ FROM examination_basic eb
  567. LEFT JOIN exam_registration er ON er.examination_basic_id_ = eb.id_
  568. <include refid="queryStudentListSql"/>
  569. ORDER BY er.update_time_ DESC
  570. <include refid="global.limit"/>
  571. </select>
  572. <resultMap id="StuRecordDetailDtoMap" type="com.keao.edu.user.dto.StuRecordDetailDto">
  573. <result property="songJson" column="song_json_"/>
  574. <result property="recordStartTime" column="record_start_time_"/>
  575. </resultMap>
  576. <select id="getStuRecordDetail" resultMap="StuRecordDetailDtoMap">
  577. SELECT er.song_json_,ser.record_start_time_
  578. FROM exam_registration er
  579. LEFT JOIN student_exam_result ser ON ser.exam_registration_id_ = er.id_
  580. WHERE er.id_ = #{examRegistrationId} LIMIT 1
  581. </select>
  582. </mapper>