BaseStudentPunishmentInfoMapper.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 != '' and dto.endTime != null and dto.endTime != ''">
  50. and t1.start_time between date_format(#{dto.startTime}, '%Y-%m-%d') and date_format(#{dto.endTime}, '%Y-%m-%d')
  51. </if>
  52. <if test="dto.credentialNumber != null and dto.credentialNumber != ''">
  53. and t5.credential_number = #{dto.credentialNumber}
  54. </if>
  55. <if test="dto.name != null and dto.name != ''">
  56. and t.name like concat('%', #{dto.name},'%')
  57. </if>
  58. ORDER BY t.id DESC;
  59. </select>
  60. <select id="getMobilePage" parameterType="com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobilePageDto"
  61. resultType="com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoMobilePageVo">
  62. SELECT t1.id,t3.name AS student_name,t3.gender,t3.credential_number,t4.punishment_type,t1.reason,t1.start_time
  63. FROM base_student_punishment_info t1
  64. INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
  65. INNER JOIN xjr_user t3 ON t1.user_id = t3.id
  66. LEFT JOIN base_punishment_type t4 ON t1.punishment_type_id = t4.id
  67. LEFT JOIN base_class t5 ON t2.class_id = t5.id
  68. WHERE t1.delete_mark = 0 AND t3.delete_mark = 0 AND t2.delete_mark = 0
  69. AND t5.id IN (SELECT id FROM base_class WHERE teacher_id = #{dto.teacherId})
  70. <if test="dto.punishmentTypeIds != null and dto.punishmentTypeIds.size() > 0">
  71. AND t4.id in
  72. <foreach item="punishmentTypeId" index="index" collection="dto.punishmentTypeIds" open="(" close=")"
  73. separator=",">
  74. #{punishmentTypeId}
  75. </foreach>
  76. </if>
  77. <if test="dto.startDate != null and dto.startDate != '' and dto.endDate != null and dto.endDate != ''">
  78. and t1.start_time between date_format(#{dto.startDate}, '%Y-%m-%d') and date_format(#{dto.endDate}, '%Y-%m-%d')
  79. </if>
  80. <if test="dto.isHandle != null">
  81. and t1.adjust_type is not null
  82. </if>
  83. <if test="dto.studentName != null and dto.studentName != ''">
  84. and (t3.name like concat('%',#{dto.studentName},'%') or t3.credential_number like concat('%',#{dto.studentName},'%'))
  85. </if>
  86. </select>
  87. <select id="getMobileInfo" parameterType="com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobileDetailDto"
  88. resultType="com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoMobileDetailVo">
  89. SELECT t.id,
  90. t1.name AS baseSemesterName,
  91. t2.punishment_type AS punishmentType,
  92. t.start_time,
  93. t.end_time,
  94. t.is_publicity,
  95. t.push_message_object,
  96. t.reason,
  97. t.class_name,
  98. t5.name as student_name,
  99. t5.name,
  100. t5.credential_number,
  101. t6.name AS gender,
  102. t5.credential_number as student_id,
  103. t3.name AS teacher_name,
  104. t.class_id,
  105. t8.name as major,
  106. (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
  107. LEFT JOIN base_punishment_type a2 ON a1.punishment_type_id = a2.id
  108. WHERE base_student_punishment_info_id = t.id
  109. ORDER BY adjust_date DESC,a1.id DESC LIMIT 1) AS adjust_type,
  110. (SELECT adjust_date FROM base_punishment_student_handle
  111. WHERE base_student_punishment_info_id = t.id
  112. ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_date,
  113. (SELECT adjust_reason FROM base_punishment_student_handle
  114. WHERE base_student_punishment_info_id = t.id
  115. ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_reason,
  116. (SELECT COUNT(*) FROM base_punishment_student_handle
  117. WHERE base_student_punishment_info_id = t.id) as handle_count
  118. FROM base_student_punishment_info t
  119. INNER JOIN base_punishment_type t2 ON (t2.id = t.punishment_type_id)
  120. INNER JOIN xjr_user t5 ON (t.user_id = t5.id)
  121. LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
  122. LEFT JOIN xjr_user t3 ON (t3.id = t.teacher_id)
  123. LEFT JOIN xjr_dictionary_detail t6 ON (t6.code = t5.gender)
  124. left join base_student_school_roll t7 on t.user_id = t7.user_id
  125. left join base_major_set t8 on t7.major_set_id = t8.id
  126. WHERE t.delete_mark = 0
  127. and t.id = #{dto.id}
  128. </select>
  129. <select id="getInfo"
  130. resultType="com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoDetailVo">
  131. SELECT t.id,
  132. t1.name AS baseSemesterName,
  133. t2.punishment_type AS punishmentType,
  134. t.start_time,
  135. t.end_time,
  136. t.is_publicity,
  137. t.push_message_object,
  138. t.reason,
  139. t.class_name,
  140. t5.name,
  141. t5.credential_number,
  142. t6.name AS gender,
  143. t3.name AS teacher_name,
  144. t.class_id,
  145. (SELECT adjust_type FROM base_punishment_student_handle
  146. WHERE base_student_punishment_info_id = t.id
  147. ORDER BY adjust_date DESC LIMIT 1) as adjust_type,
  148. (SELECT adjust_date FROM base_punishment_student_handle
  149. WHERE base_student_punishment_info_id = t.id
  150. ORDER BY adjust_date DESC LIMIT 1) as adjust_date,
  151. (SELECT adjust_reason FROM base_punishment_student_handle
  152. WHERE base_student_punishment_info_id = t.id
  153. ORDER BY adjust_date DESC LIMIT 1) as adjust_reason,
  154. (SELECT COUNT(*) FROM base_punishment_student_handle
  155. WHERE base_student_punishment_info_id = t.id) as handle_count,
  156. t.punishment_type_id,t.base_semester_id
  157. FROM base_student_punishment_info t
  158. INNER JOIN base_punishment_type t2 ON (t2.id = t.punishment_type_id)
  159. INNER JOIN xjr_user t5 ON (t.user_id = t5.id)
  160. LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
  161. LEFT JOIN xjr_user t3 ON (t3.id = t.teacher_id)
  162. LEFT JOIN xjr_dictionary_detail t6 ON (t6.code = t5.gender)
  163. WHERE t.delete_mark = 0 and t.id = #{id}
  164. </select>
  165. </mapper>