ExamRoomMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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.ExamRoomDao">
  8. <resultMap type="com.keao.edu.user.api.entity.ExamRoom" id="ExamRoom">
  9. <result column="id_" property="id" />
  10. <result column="name_" property="name"/>
  11. <result column="examination_basic_id_" property="examinationBasicId"/>
  12. <result column="exam_mode_" property="examMode" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  13. <result column="exam_location_id_" property="examLocationId" />
  14. <result column="subject_id_list_" property="subjectIdList" />
  15. <result column="subject_name_list_" property="subjectNameList"/>
  16. <result column="main_teacher_user_id_" property="mainTeacherUserId" />
  17. <result column="main_teacher_user_name_" property="mainTeacherName"/>
  18. <result column="assistant_teacher_user_id_list_" property="assistantTeacherUserIdList" />
  19. <result column="assistant_teacher_user_name_list_" property="assistantTeacherUserNameList"/>
  20. <result column="exam_start_time_" property="examStartTime" />
  21. <result column="exam_end_time_" property="examEndTime" />
  22. <result column="del_flag_" property="delFlag" />
  23. <result column="organ_id_" property="organId"/>
  24. <result column="open_flag_" property="openFlag"/>
  25. <result column="exam_plan_push_flag_" property="examPlanPushFlag"/>
  26. <result column="exam_room_student_num_" property="examRoomStudentNum"/>
  27. <result column="create_time_" property="createTime" />
  28. <result column="update_time_" property="updateTime" />
  29. <result column="tenant_id_" property="tenantId" />
  30. <result column="exam_flag_" property="examFlag" />
  31. <result column="shield_user_id_" property="shieldUserId" />
  32. </resultMap>
  33. <!-- 根据主键查询一条记录 -->
  34. <select id="get" resultMap="ExamRoom" >
  35. SELECT * FROM exam_room WHERE id_ = #{id}
  36. </select>
  37. <!-- 全查询 -->
  38. <select id="findAll" resultMap="ExamRoom">
  39. SELECT * FROM exam_room ORDER BY id_
  40. </select>
  41. <!-- 向数据库增加一条记录 -->
  42. <insert id="insert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  43. INSERT INTO exam_room (id_,name_,examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,subject_name_list_,
  44. main_teacher_user_id_,main_teacher_user_name_,assistant_teacher_user_id_list_,assistant_teacher_user_name_list_,
  45. exam_start_time_,exam_end_time_,del_flag_,organ_id_,exam_plan_push_flag_,
  46. exam_room_student_num_,create_time_,update_time_,tenant_id_,exam_flag_)
  47. VALUES(#{id},#{name},#{examinationBasicId},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examLocationId},
  48. #{subjectIdList},#{subjectNameList},#{mainTeacherUserId},#{mainTeacherName},#{assistantTeacherUserIdList},#{assistantTeacherUserNameList},
  49. #{examStartTime},#{examEndTime},#{delFlag},#{organId},#{examPlanPushFlag},
  50. #{examRoomStudentNum},NOW(),NOW(),#{tenantId},#{examFlag})
  51. </insert>
  52. <insert id="batchInsert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  53. INSERT INTO exam_room (name_,examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,subject_name_list_,
  54. main_teacher_user_id_,main_teacher_user_name_,assistant_teacher_user_id_list_,assistant_teacher_user_name_list_,
  55. exam_start_time_,exam_end_time_,del_flag_,organ_id_,exam_plan_push_flag_,
  56. exam_room_student_num_,create_time_,update_time_,tenant_id_)
  57. VALUES
  58. <foreach collection="examRooms" item="examRoom" separator=",">
  59. (#{examRoom.name},#{examRoom.examinationBasicId},#{examRoom.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examRoom.examLocationId},
  60. #{examRoom.subjectIdList},#{examRoom.subjectNameList},
  61. #{examRoom.mainTeacherUserId},#{examRoom.mainTeacherName},#{examRoom.assistantTeacherUserIdList},#{examRoom.assistantTeacherUserNameList},
  62. #{examRoom.examStartTime},#{examRoom.examEndTime},#{examRoom.delFlag},#{examRoom.organId},#{examRoom.examPlanPushFlag},
  63. #{examRoom.examRoomStudentNum},NOW(),NOW(),#{examRoom.tenantId})
  64. </foreach>
  65. </insert>
  66. <!-- 根据主键查询一条记录 -->
  67. <update id="update" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  68. UPDATE exam_room
  69. <set>
  70. <if test="name!=null">
  71. name_=#{name},
  72. </if>
  73. <if test="shieldUserId != null">
  74. shield_user_id_ = #{shieldUserId},
  75. </if>
  76. <if test="examFlag != null">
  77. exam_flag_ = #{examFlag},
  78. </if>
  79. <if test="delFlag != null">
  80. del_flag_ = #{delFlag},
  81. </if>
  82. <if test="openFlag != null">
  83. open_flag_ = #{openFlag},
  84. </if>
  85. <if test="examinationBasicId != null">
  86. examination_basic_id_ = #{examinationBasicId},
  87. </if>
  88. <if test="examStartTime != null">
  89. exam_start_time_ = #{examStartTime},
  90. </if>
  91. <if test="examEndTime != null">
  92. exam_end_time_ = #{examEndTime},
  93. </if>
  94. <if test="subjectIdList != null">
  95. subject_id_list_ = #{subjectIdList},
  96. </if>
  97. <if test="subjectNameList != null">
  98. subject_name_list_ = #{subjectNameList},
  99. </if>
  100. <if test="tenantId != null and tenantId != 0">
  101. tenant_id_ = #{tenantId},
  102. </if>
  103. <if test="examMode != null">
  104. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  105. </if>
  106. exam_location_id_ = #{examLocationId},
  107. <if test="mainTeacherUserId != null">
  108. main_teacher_user_id_ = #{mainTeacherUserId},
  109. </if>
  110. <if test="mainTeacherName != null">
  111. main_teacher_user_name_ = #{mainTeacherName},
  112. </if>
  113. <if test="assistantTeacherUserIdList != null">
  114. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  115. </if>
  116. <if test="assistantTeacherUserNameList != null">
  117. assistant_teacher_user_name_list_ = #{assistantTeacherUserNameList},
  118. </if>
  119. <if test="organId != null">
  120. organ_id_ = #{organId},
  121. </if>
  122. <if test="examPlanPushFlag != null">
  123. exam_plan_push_flag_ = #{examPlanPushFlag},
  124. </if>
  125. <if test="examRoomStudentNum!=null">
  126. exam_room_student_num_=#{examRoomStudentNum},
  127. </if>
  128. update_time_ = NOW()
  129. </set> WHERE id_ = #{id}
  130. </update>
  131. <!-- 根据主键查询一条记录 -->
  132. <update id="batchUpdate" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  133. <foreach collection="examRooms" item="er" separator=";">
  134. UPDATE exam_room
  135. <set>
  136. <if test="er.name!=null">
  137. name_=#{er.name},
  138. </if>
  139. <if test="er.delFlag != null">
  140. del_flag_ = #{er.delFlag},
  141. </if>
  142. <if test="er.openFlag != null">
  143. open_flag_ = #{er.openFlag},
  144. </if>
  145. <if test="er.examinationBasicId != null">
  146. examination_basic_id_ = #{er.examinationBasicId},
  147. </if>
  148. <if test="er.examStartTime != null">
  149. exam_start_time_ = #{er.examStartTime},
  150. </if>
  151. <if test="er.examEndTime != null">
  152. exam_end_time_ = #{er.examEndTime},
  153. </if>
  154. <if test="er.subjectIdList != null">
  155. subject_id_list_ = #{er.subjectIdList},
  156. </if>
  157. <if test="er.subjectNameList != null">
  158. subject_name_list_ = #{er.subjectNameList},
  159. </if>
  160. <if test="er.tenantId != null and er.tenantId != 0">
  161. tenant_id_ = #{er.tenantId},
  162. </if>
  163. <if test="er.examMode != null">
  164. exam_mode_ = #{er.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  165. </if>
  166. exam_location_id_ = #{er.examLocationId},
  167. <if test="er.mainTeacherUserId != null">
  168. main_teacher_user_id_ = #{er.mainTeacherUserId},
  169. </if>
  170. <if test="er.mainTeacherName != null">
  171. main_teacher_user_name_ = #{er.mainTeacherName},
  172. </if>
  173. <if test="er.assistantTeacherUserIdList != null">
  174. assistant_teacher_user_id_list_ = #{er.assistantTeacherUserIdList},
  175. </if>
  176. <if test="er.assistantTeacherUserNameList != null">
  177. assistant_teacher_user_name_list_ = #{er.assistantTeacherUserNameList},
  178. </if>
  179. <if test="er.organId != null">
  180. organ_id_ = #{er.organId},
  181. </if>
  182. <if test="er.examPlanPushFlag != null">
  183. exam_plan_push_flag_ = #{er.examPlanPushFlag},
  184. </if>
  185. <if test="er.examRoomStudentNum!=null">
  186. exam_room_student_num_=#{er.examRoomStudentNum},
  187. </if>
  188. update_time_ = NOW()
  189. </set> WHERE id_ = #{er.id}
  190. </foreach>
  191. </update>
  192. <update id="updateSL" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  193. UPDATE exam_room
  194. <set>
  195. <if test="delFlag != null">
  196. del_flag_ = #{delFlag},
  197. </if>
  198. <if test="examinationBasicId != null">
  199. examination_basic_id_ = #{examinationBasicId},
  200. </if>
  201. <if test="examStartTime != null">
  202. exam_start_time_ = #{examStartTime},
  203. </if>
  204. <if test="examEndTime != null">
  205. exam_end_time_ = #{examEndTime},
  206. </if>
  207. <if test="subjectIdList != null">
  208. subject_id_list_ = #{subjectIdList},
  209. </if>
  210. <if test="subjectNameList != null">
  211. subject_name_list_ = #{subjectNameList},
  212. </if>
  213. <if test="tenantId != null and tenantId != 0">
  214. tenant_id_ = #{tenantId},
  215. </if>
  216. <if test="examMode != null">
  217. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  218. </if>
  219. exam_location_id_ = #{examLocationId},
  220. <if test="mainTeacherUserId != null">
  221. main_teacher_user_id_ = #{mainTeacherUserId},
  222. </if>
  223. <if test="mainTeacherName != null">
  224. main_teacher_user_name_ = #{mainTeacherName},
  225. </if>
  226. <if test="assistantTeacherUserIdList != null">
  227. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  228. </if>
  229. <if test="assistantTeacherUserNameList != null">
  230. assistant_teacher_user_name_list_ = #{assistantTeacherUserNameList},
  231. </if>
  232. <if test="organId != null">
  233. organ_id_ = #{organId},
  234. </if>
  235. <if test="examPlanPushFlag != null">
  236. exam_plan_push_flag_ = #{examPlanPushFlag},
  237. </if>
  238. <if test="examRoomStudentNum!=null">
  239. exam_room_student_num_=#{examRoomStudentNum},
  240. </if>
  241. update_time_ = NOW()
  242. </set> WHERE id_ = #{id} AND update_time_=#{updateTime}
  243. </update>
  244. <!-- 根据主键删除一条记录 -->
  245. <delete id="delete" >
  246. DELETE FROM exam_room WHERE id_ = #{id}
  247. </delete>
  248. <delete id="batchDeleteExamRooms">
  249. DELETE FROM exam_room WHERE exam_plan_push_flag_=0 AND id_ IN
  250. <foreach collection="examRoomIds" item="examRoomId" separator="," open="(" close=")">
  251. #{examRoomId}
  252. </foreach>
  253. </delete>
  254. <!-- 分页查询 -->
  255. <select id="queryPage" resultMap="ExamRoom" parameterType="map">
  256. SELECT * FROM exam_room ORDER BY id_ <include refid="global.limit"/>
  257. </select>
  258. <!-- 查询当前表的总记录数 -->
  259. <select id="queryCount" resultType="int">
  260. SELECT COUNT(*) FROM exam_room
  261. </select>
  262. <sql id="queryExamRoomPageSql">
  263. <where>
  264. <if test="organIds!=null">
  265. AND er.organ_id_ IN
  266. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  267. #{organId}
  268. </foreach>
  269. </if>
  270. <if test="examRoomId!=null">
  271. AND er.id_ = #{examRoomId}
  272. </if>
  273. <if test="examId!=null">
  274. AND er.examination_basic_id_ = #{examId}
  275. </if>
  276. <if test="tenantId != null and tenantId != 0">
  277. AND er.tenant_id_ = #{tenantId}
  278. </if>
  279. <if test="startTime != null">
  280. AND eb.expect_exam_start_time_ >= #{startTime}
  281. </if>
  282. <if test="endTime != null">
  283. AND eb.expect_exam_end_time_ &lt;= #{endTime}
  284. </if>
  285. <if test="search != null and search != ''">
  286. AND eb.name_ LIKE CONCAT('%',#{search},'%')
  287. </if>
  288. <if test="examStatusEnum != null and examStatusEnum != ''">
  289. AND eb.status_ = #{examStatusEnum}
  290. </if>
  291. </where>
  292. </sql>
  293. <resultMap type="com.keao.edu.user.dto.ExamRoomDto" id="ExamRoomDto" extends="ExamRoom">
  294. <association property="examLocation" columnPrefix="el_" resultMap="com.keao.edu.user.dao.ExamLocationDao.ExamLocation"/>
  295. <association property="examinationBasic" columnPrefix="exam_" resultMap="com.keao.edu.user.dao.ExaminationBasicDao.ExaminationBasic"/>
  296. </resultMap>
  297. <resultMap id="ExamRoomListDtoMap" type="com.keao.edu.user.dto.ExamRoomListDto">
  298. <result property="examEndTime" column="exam_end_time_"/>
  299. <result property="examStartTime" column="exam_start_time_"/>
  300. <result property="openFlag" column="open_flag_"/>
  301. <result property="examRoomId" column="exam_room_id_"/>
  302. <result property="assistantTeacherUserIdList" column="assistant_teacher_user_id_list_"/>
  303. <result property="assistantTeacherUserNameList" column="assistant_teacher_user_name_list_"/>
  304. <result property="examBaseStatus" column="exam_base_status_"/>
  305. <result property="examName" column="exam_name_"/>
  306. <result property="getMainTeacherUserId" column="main_teacher_user_id_"/>
  307. <result property="mainTeacherUserName" column="main_teacher_user_name_"/>
  308. <result property="subjectNameList" column="subject_name_list_"/>
  309. </resultMap>
  310. <sql id="queryExamRoomPageListSql">
  311. <where>
  312. er.exam_plan_push_flag_ = 1 AND (er.main_teacher_user_id_ = #{teacherId} OR FIND_IN_SET(#{teacherId},er.assistant_teacher_user_id_list_))
  313. <if test="startTime != null and startTime != ''">
  314. AND DATE_FORMAT(er.exam_end_time_,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
  315. </if>
  316. <if test="examBaseStatus != null and examBaseStatus != ''">
  317. AND eb.status_ = #{examBaseStatus}
  318. </if>
  319. <if test="examMode != null and examMode != ''">
  320. AND er.exam_mode_ = #{examMode}
  321. </if>
  322. <if test="openFlag != null and openFlag == 1">
  323. AND er.open_flag_ = #{openFlag}
  324. </if>
  325. <if test="openFlag != null and openFlag == 0">
  326. AND er.open_flag_ = #{openFlag}
  327. </if>
  328. </where>
  329. </sql>
  330. <select id="countExamRoomPage" resultType="java.lang.Integer">
  331. SELECT COUNT(er.id_)
  332. FROM exam_room er
  333. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  334. <include refid="queryExamRoomPageListSql"/>
  335. </select>
  336. <select id="queryExamRoomPage" resultMap="ExamRoomListDtoMap">
  337. SELECT eb.name_ exam_name_,er.exam_end_time_,er.exam_start_time_,
  338. er.id_ exam_room_id_,er.subject_name_list_,er.main_teacher_user_name_,er.main_teacher_user_id_,
  339. er.assistant_teacher_user_id_list_,er.assistant_teacher_user_name_list_,eb.status_ exam_base_status_,er.open_flag_
  340. FROM exam_room er
  341. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  342. <include refid="queryExamRoomPageListSql"/>
  343. ORDER BY er.exam_start_time_ DESC
  344. <include refid="global.limit"/>
  345. </select>
  346. <sql id="queryExamRoomCondition">
  347. <where>
  348. <if test="organIds!=null">
  349. AND er.organ_id_ IN
  350. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  351. #{organId}
  352. </foreach>
  353. </if>
  354. <if test="examRoomId!=null">
  355. AND er.id_=#{examRoomId}
  356. </if>
  357. <if test="examId!=null">
  358. AND er.examination_basic_id_ = #{examId}
  359. </if>
  360. <if test="search!=null and search!=''">
  361. AND (er.id_=#{search})
  362. </if>
  363. </where>
  364. </sql>
  365. <select id="queryExamRoom" resultMap="ExamRoomDto">
  366. SELECT
  367. er.*,
  368. el.id_ el_id_,
  369. el.name_ el_name_
  370. FROM exam_room er
  371. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_
  372. <include refid="queryExamRoomCondition"/>
  373. ORDER BY er.id_ DESC
  374. <include refid="global.limit"/>
  375. </select>
  376. <select id="countExamRoom" resultType="java.lang.Integer">
  377. SELECT COUNT(er.id_) FROM exam_room er
  378. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_
  379. <include refid="queryExamRoomCondition"/>
  380. </select>
  381. <select id="getWithExam" resultMap="ExamRoom">
  382. SELECT * FROM exam_room WHERE examination_basic_id_=#{examId}
  383. <if test="organIds!=null">
  384. AND organ_id_ IN
  385. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  386. #{organId}
  387. </foreach>
  388. </if>
  389. </select>
  390. <select id="lockRoom" resultMap="ExamRoom">
  391. SELECT * FROM exam_room WHERE id_=#{examRoomId} FOR UPDATE
  392. </select>
  393. <select id="getWithDays" resultMap="ExamRoom">
  394. SELECT
  395. *
  396. FROM
  397. exam_room
  398. WHERE
  399. DATE_FORMAT( exam_start_time_, '%Y-%m-%d' ) IN
  400. <foreach collection="days" item="day" separator="," open="(" close=")" >
  401. #{day}
  402. </foreach>
  403. OR DATE_FORMAT( exam_end_time_, '%Y-%m-%d' ) IN
  404. <foreach collection="days" item="day" separator="," open="(" close=")" >
  405. #{day}
  406. </foreach>
  407. </select>
  408. <select id="getWithExamAndSubject" resultMap="ExamRoom">
  409. SELECT * FROM exam_room WHERE examination_basic_id_=#{examId} AND FIND_IN_SET(#{subjectId}, subject_id_list_);
  410. </select>
  411. <select id="getExamRoomExamTime" resultType="com.keao.edu.user.dto.ExamRoomExamTimeDto">
  412. SELECT
  413. MIN(exam_start_time_) examStartTime,
  414. MAX(exam_end_time_) examEndTime
  415. FROM exam_room WHERE examination_basic_id_=#{examId}
  416. </select>
  417. <select id="getHistoryOpenExamRoom" resultMap="ExamRoom">
  418. SELECT
  419. *
  420. FROM
  421. exam_room
  422. WHERE
  423. exam_start_time_ &lt; NOW( )
  424. AND open_flag_ =1
  425. </select>
  426. </mapper>