BaseStudentPunishmentInfoMapper.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.xjrsoft.module.student.mapper.BaseStudentPunishmentInfoMapper">
  6. <select id="getPage" parameterType="com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoPageDto"
  7. resultType="com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoPageVo">
  8. SELECT t.id,
  9. t1.name AS baseSemesterName,
  10. t2.punishment_type AS punishmentType,
  11. t.start_time,
  12. t.end_time,
  13. t.is_publicity,
  14. t.push_message_object,
  15. t.reason,
  16. t.class_name,
  17. t5.name,
  18. t5.credential_number,
  19. t6.name AS gender,
  20. t3.name AS teacher_name,
  21. t.class_id,ifnull((SELECT punishment_type_id FROM base_punishment_student_handle
  22. WHERE base_student_punishment_info_id = t.id
  23. ORDER BY adjust_date DESC,id desc LIMIT 1), t.punishment_type_id) as punishment_type_id,
  24. (SELECT IF(a1.adjust_type = 3, REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),CONCAT(REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),'(',a2.punishment_type,')')) FROM base_punishment_student_handle a1
  25. LEFT JOIN base_punishment_type a2 ON a1.punishment_type_id = a2.id
  26. WHERE base_student_punishment_info_id = t.id
  27. ORDER BY adjust_date DESC,a1.id DESC LIMIT 1) AS adjust_type,
  28. (SELECT adjust_date FROM base_punishment_student_handle
  29. WHERE base_student_punishment_info_id = t.id
  30. ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_date,
  31. (SELECT adjust_reason FROM base_punishment_student_handle
  32. WHERE base_student_punishment_info_id = t.id
  33. ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_reason,
  34. (SELECT COUNT(*) FROM base_punishment_student_handle
  35. WHERE base_student_punishment_info_id = t.id) as handle_count
  36. FROM base_student_punishment_info t
  37. INNER JOIN base_punishment_type t2 ON (t2.id = t.punishment_type_id)
  38. INNER JOIN xjr_user t5 ON (t.user_id = t5.id)
  39. LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
  40. LEFT JOIN xjr_user t3 ON (t3.id = t.teacher_id)
  41. LEFT JOIN xjr_dictionary_detail t6 ON (t6.code = t5.gender)
  42. WHERE t.delete_mark = 0
  43. <if test="dto.semesterId != null and dto.semesterId > 0">
  44. and t.base_semester_id = #{dto.semesterId}
  45. </if>
  46. <if test="dto.punishmentTypeId != null and dto.punishmentTypeId > 0">
  47. and t.punishment_type_id = #{dto.punishmentTypeId}
  48. </if>
  49. <if test="dto.startTime != null and dto.startTime != ''">
  50. and t.start_time = #{dto.startTime}
  51. </if>
  52. <if test="dto.endTime != null and dto.endTime != ''">
  53. and t.end_time = #{dto.endTime}
  54. </if>
  55. <if test="dto.credentialNumber != null and dto.endTime != ''">
  56. and t5.credential_number = #{dto.credentialNumber}
  57. </if>
  58. <if test="dto.name != null and dto.name != ''">
  59. and t.name like concat('%', #{dto.name},'%')
  60. </if>
  61. ORDER BY t.id DESC;
  62. </select>
  63. <select id="getMobilePage" parameterType="com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobilePageDto"
  64. resultType="com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoMobilePageVo">
  65. SELECT t1.id,t3.name AS student_name,t3.gender,t3.credential_number,t4.punishment_type,t1.reason,t1.start_time
  66. FROM base_student_punishment_info t1
  67. INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
  68. INNER JOIN xjr_user t3 ON t1.user_id = t3.id
  69. LEFT JOIN base_punishment_type t4 ON t1.punishment_type_id = t4.id
  70. LEFT JOIN base_class t5 ON t2.class_id = t5.id
  71. WHERE t1.delete_mark = 0 AND t3.delete_mark = 0 AND t2.delete_mark = 0
  72. AND t5.id IN (SELECT id FROM base_class WHERE teacher_id = #{dto.teacherId})
  73. <if test="dto.punishmentTypeIds != null and dto.punishmentTypeIds.size() > 0">
  74. AND t4.id in
  75. <foreach item="punishmentTypeId" index="index" collection="dto.punishmentTypeIds" open="(" close=")"
  76. separator=",">
  77. #{punishmentTypeId}
  78. </foreach>
  79. </if>
  80. <if test="dto.startDate != null and dto.startDate != ''">
  81. and t1.start_time &gt;= #{dto.startDate}
  82. </if>
  83. <if test="dto.endDate != null and dto.endDate != ''">
  84. and t1.start_time &lt;= #{dto.endDate}
  85. </if>
  86. <if test="dto.isHandle != null">
  87. and t1.adjust_type is not null
  88. </if>
  89. <if test="dto.studentName != null and dto.studentName != ''">
  90. and t1.name like concat('$',#{dto.studentName},'%')
  91. </if>
  92. <if test="dto.credentialNumber != null and dto.endTime != ''">
  93. and t3.credential_number = #{dto.credentialNumber}
  94. </if>
  95. </select>
  96. <select id="getMobileInfo" parameterType="com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobileDetailDto"
  97. resultType="com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoMobileDetailVo">
  98. SELECT t.id,
  99. t1.name AS baseSemesterName,
  100. t2.punishment_type AS punishmentType,
  101. t.start_time,
  102. t.end_time,
  103. t.is_publicity,
  104. t.push_message_object,
  105. t.reason,
  106. t.class_name,
  107. t5.name as student_name,
  108. t5.name,
  109. t5.credential_number,
  110. t6.name AS gender,
  111. t5.credential_number as student_id,
  112. t3.name AS teacher_name,
  113. t.class_id,
  114. t8.name as major,
  115. (SELECT IF(a1.adjust_type = 3, REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),CONCAT(REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),'(',a2.punishment_type,')')) FROM base_punishment_student_handle a1
  116. LEFT JOIN base_punishment_type a2 ON a1.punishment_type_id = a2.id
  117. WHERE base_student_punishment_info_id = t.id
  118. ORDER BY adjust_date DESC,a1.id DESC LIMIT 1) AS adjust_type,
  119. (SELECT adjust_date FROM base_punishment_student_handle
  120. WHERE base_student_punishment_info_id = t.id
  121. ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_date,
  122. (SELECT adjust_reason FROM base_punishment_student_handle
  123. WHERE base_student_punishment_info_id = t.id
  124. ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_reason,
  125. (SELECT COUNT(*) FROM base_punishment_student_handle
  126. WHERE base_student_punishment_info_id = t.id) as handle_count
  127. FROM base_student_punishment_info t
  128. INNER JOIN base_punishment_type t2 ON (t2.id = t.punishment_type_id)
  129. INNER JOIN xjr_user t5 ON (t.user_id = t5.id)
  130. LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
  131. LEFT JOIN xjr_user t3 ON (t3.id = t.teacher_id)
  132. LEFT JOIN xjr_dictionary_detail t6 ON (t6.code = t5.gender)
  133. left join base_student_school_roll t7 on t.user_id = t7.user_id
  134. left join base_major_set t8 on t7.major_set_id = t8.id
  135. WHERE t.delete_mark = 0
  136. and t.id = #{dto.id}
  137. </select>
  138. <select id="getInfo"
  139. resultType="com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoDetailVo">
  140. SELECT t.id,
  141. t1.name AS baseSemesterName,
  142. t2.punishment_type AS punishmentType,
  143. t.start_time,
  144. t.end_time,
  145. t.is_publicity,
  146. t.push_message_object,
  147. t.reason,
  148. t.class_name,
  149. t5.name,
  150. t5.credential_number,
  151. t6.name AS gender,
  152. t3.name AS teacher_name,
  153. t.class_id,
  154. (SELECT adjust_type FROM base_punishment_student_handle
  155. WHERE base_student_punishment_info_id = t.id
  156. ORDER BY adjust_date DESC LIMIT 1) as adjust_type,
  157. (SELECT adjust_date FROM base_punishment_student_handle
  158. WHERE base_student_punishment_info_id = t.id
  159. ORDER BY adjust_date DESC LIMIT 1) as adjust_date,
  160. (SELECT adjust_reason FROM base_punishment_student_handle
  161. WHERE base_student_punishment_info_id = t.id
  162. ORDER BY adjust_date DESC LIMIT 1) as adjust_reason,
  163. (SELECT COUNT(*) FROM base_punishment_student_handle
  164. WHERE base_student_punishment_info_id = t.id) as handle_count
  165. FROM base_student_punishment_info t
  166. INNER JOIN base_punishment_type t2 ON (t2.id = t.punishment_type_id)
  167. INNER JOIN xjr_user t5 ON (t.user_id = t5.id)
  168. LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
  169. LEFT JOIN xjr_user t3 ON (t3.id = t.teacher_id)
  170. LEFT JOIN xjr_dictionary_detail t6 ON (t6.code = t5.gender)
  171. WHERE t.delete_mark = 0 and t.id = #{id}
  172. </select>
  173. </mapper>