ExamRegistrationMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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" />
  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="subjectId != null">
  67. subject_id_ = #{subjectId},
  68. </if>
  69. <if test="adviserPhone != null">
  70. adviser_phone_ = #{adviserPhone},
  71. </if>
  72. <if test="lastExamLevel != null">
  73. last_exam_level_ = #{lastExamLevel},
  74. </if>
  75. <if test="tenantId != null">
  76. tenant_id_ = #{tenantId},
  77. </if>
  78. <if test="level != null">
  79. level_ = #{level},
  80. </if>
  81. <if test="organId != null">
  82. organ_id_ = #{organId},
  83. </if>
  84. <if test="songJson != null">
  85. song_json_ = #{songJson},
  86. </if>
  87. <if test="adviserName != null">
  88. adviser_name_ = #{adviserName},
  89. </if>
  90. <if test="studentId != null">
  91. student_id_ = #{studentId},
  92. </if>
  93. <if test="lastExamCertificateUrl != null">
  94. last_exam_certificate_url_ = #{lastExamCertificateUrl},
  95. </if>
  96. <if test="cardNo!=null">
  97. card_no_ =#{cardNo},
  98. </if>
  99. <if test="status!=null">
  100. status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  101. </if>
  102. <if test="memo!=null">
  103. memo_ = #{memo},
  104. </if>
  105. update_time_ = NOW()
  106. </set> WHERE id_ = #{id}
  107. </update>
  108. <!-- 根据主键删除一条记录 -->
  109. <delete id="delete" >
  110. DELETE FROM exam_registration WHERE id_ = #{id}
  111. </delete>
  112. <sql id="queryCondition">
  113. <where>
  114. <if test="organIds!=null">
  115. AND er.organ_id_ IN
  116. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  117. #{organId}
  118. </foreach>
  119. </if>
  120. <if test="examId!=null">
  121. AND er.examination_basic_id_ = #{examId}
  122. </if>
  123. <if test="organId!=null">
  124. AND er.organ_id_ = #{organId}
  125. </if>
  126. <if test="subjectId!=null">
  127. AND er.subject_id_ = #{subjectId}
  128. </if>
  129. <if test="level!=null">
  130. AND er.level_ = #{level}
  131. </if>
  132. <if test="status!=null">
  133. AND er.status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  134. </if>
  135. </where>
  136. </sql>
  137. <!-- 分页查询 -->
  138. <select id="queryPage" resultMap="ExamRegistration" parameterType="map">
  139. SELECT
  140. er.id_,
  141. er.examination_basic_id_,
  142. er.exam_music_theory_level_,
  143. er.card_no_,
  144. er.student_id_,
  145. er.memo_,
  146. su.real_name_ sys_user_real_name_,
  147. er.last_exam_certificate_url_,
  148. er.last_music_theory_certificate_url_,
  149. er.level_fee_,
  150. er.theory_level_fee_,
  151. er.organ_id_,
  152. er.subject_id_,
  153. er.level_,
  154. erp.trans_amount_,
  155. er.status_,
  156. er.create_time_
  157. FROM
  158. exam_registration er
  159. LEFT JOIN sys_user su ON er.student_id_ = su.id_
  160. LEFT JOIN exam_registration_payment erp ON er.id_ = erp.exam_registration_id_
  161. <include refid="queryCondition"/>
  162. ORDER BY er.id_
  163. <include refid="global.limit"/>
  164. </select>
  165. <!-- 查询当前表的总记录数 -->
  166. <select id="queryCount" resultType="int">
  167. SELECT COUNT(*) FROM exam_registration er
  168. <include refid="queryCondition"/>
  169. </select>
  170. <sql id="queryExamRegistCondition">
  171. <where>
  172. <if test="organIds!=null">
  173. AND er.organ_id_ IN
  174. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  175. #{organId}
  176. </foreach>
  177. </if>
  178. <if test="examId!=null">
  179. AND er.examination_basic_id_ = #{examId}
  180. </if>
  181. <if test="organId!=null">
  182. AND er.organ_id_ = #{organId}
  183. </if>
  184. <if test="subjectId!=null">
  185. AND er.subject_id_ = #{subjectId}
  186. </if>
  187. <if test="level!=null">
  188. AND er.level_ = #{level}
  189. </if>
  190. <if test="status!=null">
  191. AND er.status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  192. </if>
  193. <if test="inRoom!=null and inRoom=0">
  194. AND ersr.exam_room_id_ IS NULL
  195. </if>
  196. <if test="inRoom!=null and inRoom=1">
  197. AND ersr.exam_room_id_ IS NOT NULL
  198. </if>
  199. </where>
  200. </sql>
  201. <select id="queryExamRegist" resultMap="ExamRegistrationRoomDto" parameterType="map">
  202. SELECT
  203. er.id_,
  204. er.examination_basic_id_,
  205. er.exam_music_theory_level_,
  206. er.card_no_,
  207. er.student_id_,
  208. er.memo_,
  209. su.real_name_ sys_user_real_name_,
  210. er.last_exam_certificate_url_,
  211. er.last_music_theory_certificate_url_,
  212. er.level_fee_,
  213. er.theory_level_fee_,
  214. er.organ_id_,
  215. er.subject_id_,
  216. er.level_,
  217. erp.trans_amount_,
  218. er.status_,
  219. er.create_time_,
  220. ersr.exam_room_id_,
  221. ero.exam_start_time_,
  222. ero.exam_end_time_
  223. FROM
  224. exam_registration er
  225. LEFT JOIN sys_user su ON er.student_id_ = su.id_
  226. LEFT JOIN exam_registration_payment erp ON er.id_ = erp.exam_registration_id_
  227. LEFT JOIN exam_room_student_relation ersr ON ersr.exam_registration_id_ = er.id_
  228. LEFT JOIN exam_room ero ON ero.id_ = ersr.exam_room_id_
  229. <include refid="queryCondition"/>
  230. ORDER BY er.id_
  231. <include refid="global.limit"/>
  232. </select>
  233. <select id="countExamRegist" resultType="int">
  234. SELECT COUNT(*) FROM exam_registration er
  235. LEFT JOIN exam_room_student_relation ersr ON ersr.exam_registration_id_ = er.id_
  236. <include refid="queryCondition"/>
  237. </select>
  238. <select id="countWithoutExamRoomStudentNum" resultType="int">
  239. SELECT
  240. COUNT(ersr.id_)
  241. FROM
  242. exam_registration er
  243. LEFT JOIN exam_room_student_relation ersr ON ersr.student_id_ = er.student_id_
  244. WHERE 1=1
  245. <if test="organIds!=null">
  246. AND ersr.organ_id_ IN
  247. <foreach collection="organIds" item="organI" separator="," open="(" close=")">
  248. #{organI}
  249. </foreach>
  250. </if>
  251. AND er.examination_basic_id_ = #{examId}
  252. AND ersr.id_ IS NULL
  253. </select>
  254. <select id="countInExamRoomStudentNum" resultType="int">
  255. SELECT
  256. COUNT(ersr.id_)
  257. FROM
  258. exam_room_student_relation ersr
  259. LEFT JOIN exam_registration er ON ersr.exam_registration_id_ = er.id_
  260. WHERE 1=1
  261. <if test="organIds!=null">
  262. AND er.organ_id_ IN
  263. <foreach collection="organIds" item="organI" separator="," open="(" close=")">
  264. #{organI}
  265. </foreach>
  266. </if>
  267. AND ersr.examination_basic_id_ = #{examId}
  268. </select>
  269. <resultMap id="ExamRegistrationStatisticsDto" type="com.keao.edu.user.dto.ExamRegistrationStatisticsDto">
  270. <result property="totalRegistrationStudentNum" column="totalRegistrationStudentNum"/>
  271. <result property="childOrganRegistrationStudentNum" column="childOrganRegistrationStudentNum"/>
  272. <result property="waitAuditStudentNum" column="waitAuditStudentNum"/>
  273. <result property="refundedStudentNum" column="refundedStudentNum"/>
  274. </resultMap>
  275. <select id="getExamRegistrationStaticsInfo" resultMap="ExamRegistrationStatisticsDto">
  276. SELECT
  277. SUM( CASE WHEN er.organ_id_ = #{selfOrganId} THEN 1 ELSE 0 END ) totalRegistrationStudentNum,
  278. SUM( CASE WHEN er.organ_id_ != #{selfOrganId} THEN 1 ELSE 0 END ) childOrganRegistrationStudentNum,
  279. SUM( CASE WHEN er.status_ = 'AUDIT_WAIT' THEN 1 ELSE 0 END ) waitAuditStudentNum,
  280. SUM( CASE WHEN er.status_ = 'REFUNDED' THEN 1 ELSE 0 END ) refundedStudentNum
  281. FROM
  282. exam_registration er
  283. WHERE
  284. er.examination_basic_id_ = #{examId}
  285. <if test="organIds!=null">
  286. AND er.organ_id_ IN
  287. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  288. #{organId}
  289. </foreach>
  290. </if>
  291. </select>
  292. <select id="countTotalRegistrationStudentNumWithExam" resultType="int">
  293. SELECT
  294. COUNT(er.id_)
  295. FROM
  296. exam_registration er
  297. WHERE 1=1
  298. <if test="organIds!=null">
  299. AND er.organ_id_ IN
  300. <foreach collection="organIds" item="organI" separator="," open="(" close=")">
  301. #{organI}
  302. </foreach>
  303. </if>
  304. AND er.examination_basic_id_ = #{examId}
  305. AND er.status_ != ''
  306. </select>
  307. <select id="getWithExamAndStudents" resultMap="ExamRegistration">
  308. SELECT * FROM exam_registration WHERE examination_basic_id_=#{examId} AND student_id_ IN
  309. <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
  310. #{studentId}
  311. </foreach>
  312. </select>
  313. <resultMap id="ExamRegistrationDtoMap" type="com.keao.edu.user.dto.ExamRegistrationDto" extends="ExamRegistration">
  314. <result property="studentName" column="studentName"/>
  315. <result property="subjectName" column="subjectName"/>
  316. <result property="examBaseName" column="examBaseName"/>
  317. <result property="examStartTime" column="expect_exam_start_time_"/>
  318. <result property="examEndTime" column="expect_exam_end_time_"/>
  319. <result property="enrollEndTime" column="enroll_end_time_"/>
  320. <result property="enrollStartTime" column="enroll_start_time_"/>
  321. </resultMap>
  322. <select id="countStudentList" resultType="java.lang.Integer">
  323. SELECT COUNT(er.id_) FROM exam_registration er
  324. <include refid="queryStudentListSql"/>
  325. </select>
  326. <sql id="queryStudentListSql">
  327. <where>
  328. <if test="studentId != null">
  329. er.student_id_ = #{studentId}
  330. </if>
  331. <if test="examRegistrationId != null">
  332. er.id_ = #{examRegistrationId}
  333. </if>
  334. <if test="tenantId != null">
  335. er.tenant_id_ = #{tenantId}
  336. </if>
  337. <if test="status != null and status != ''">
  338. er.status_ = #{status}
  339. </if>
  340. </where>
  341. </sql>
  342. <select id="queryStudentList" resultMap="ExamRegistrationDtoMap">
  343. SELECT er.*,eb.enroll_end_time_,eb.enroll_start_time_,eb.expect_exam_end_time_,eb.expect_exam_start_time_,eb.name_ examBaseName
  344. FROM exam_registration er
  345. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  346. <include refid="queryStudentListSql"/>
  347. ORDER BY er.update_time_ DESC
  348. <include refid="global.limit"/>
  349. </select>
  350. <resultMap id="ExamRecordDtoMap" type="com.keao.edu.user.dto.ExamRecordDto" extends="ExamRegistration">
  351. <result property="subjectName" column="subjectName"/>
  352. <result property="examBaseName" column="examBaseName"/>
  353. <result property="examCertificationId" column="examCertificationId"/>
  354. <association property="studentExamResult" resultMap="com.keao.edu.user.dao.StudentExamResultDao.StudentExamResult"/>
  355. </resultMap>
  356. <select id="queryExamList" resultMap="ExamRecordDtoMap">
  357. SELECT er.*,ser.* FROM exam_registration er
  358. LEFT JOIN student_exam_result ser ON er.id_ = ser.exam_registration_id_
  359. WHERE ser.id_ IS NOT NULL AND er.student_id_ = #{studentId}
  360. </select>
  361. <select id="countExamList" resultType="java.lang.Integer">
  362. SELECT COUNT(er.id_) FROM exam_registration er
  363. LEFT JOIN student_exam_result ser ON er.id_ = ser.exam_registration_id_
  364. WHERE ser.id_ IS NOT NULL AND er.student_id_ = #{studentId}
  365. </select>
  366. <!-- 获取报名信息 -->
  367. <select id="getExamRegistration" resultMap="ExamRegistrationDtoMap">
  368. SELECT er.*,s.name_ subjectName,su.real_name_ studentName,eb.expect_exam_start_time_,eb.expect_exam_end_time_ FROM exam_registration er
  369. LEFT JOIN sys_user su ON su.id_ = er.subject_id_
  370. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  371. LEFT JOIN subject s on er.subject_id_ = s.id_
  372. WHERE er.id_ = #{examRegistrationId}
  373. </select>
  374. <select id="getExamRegistrationInfo" resultMap="ExamRegistration">
  375. SELECT er.*, su.id_ sys_user_id_, su.real_name_ sys_user_real_name_,su.phone_ sys_user_phone_ , s.id_ subject_id_,
  376. s.name_ subject_name_ ,eb.name_ examination_basic_name_
  377. FROM exam_registration er
  378. LEFT JOIN examination_basic eb ON eb.id_=er.examination_basic_id_
  379. LEFT JOIN sys_user su ON er.student_id_ = su.id_
  380. LEFT JOIN subject s on er.subject_id_ = s.id_
  381. WHERE er.id_ = #{id}
  382. </select>
  383. </mapper>