RoomBedMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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.room.mapper.RoomBedMapper">
  6. <select id="getPage" parameterType="com.xjrsoft.module.room.dto.RoomBedPageDto" resultType="com.xjrsoft.module.room.vo.RoomBedPageVo">
  7. SELECT t1.id,t1.sort_code,t3.name AS build_name,t2.floor_number,t2.room_name,t1.bed_number,t4.name AS student_name,t5.student_id,
  8. t4.mobile,t9.name as gender_cn,t7.name AS grade_name,t8.name AS class_name FROM room_bed t1
  9. LEFT JOIN room t2 ON t1.room_id = t2.id
  10. LEFT JOIN base_office_build t3 ON t2.office_build_id = t3.id
  11. LEFT JOIN xjr_user t4 ON t1.student_user_id = t4.id
  12. LEFT JOIN base_student t5 ON t1.student_user_id = t5.user_id
  13. LEFT JOIN base_student_school_roll t6 ON t1.student_user_id = t6.user_id
  14. LEFT JOIN base_grade t7 ON t6.grade_id = t7.id
  15. LEFT JOIN base_class t8 ON t6.class_id = t8.id
  16. LEFT JOIN xjr_dictionary_detail t9 ON t2.gender = t9.code AND t9.item_id = 2023000000000000004
  17. where t1.delete_mark = 0 and t2.delete_mark = 0
  18. <if test="dto.officeBuildId != null">
  19. and t2.office_build_id = #{dto.officeBuildId}
  20. </if>
  21. <if test="dto.floorNumber != null">
  22. and t2.floor_number = #{dto.floorNumber}
  23. </if>
  24. <if test="dto.roomId != null">
  25. and t2.room_id = #{dto.roomId}
  26. </if>
  27. <if test="dto.gender != null and dto.gender != ''">
  28. and t2.gender = #{dto.gender}
  29. </if>
  30. <if test="dto.gradeId != null">
  31. and t7.id = #{dto.gradeId}
  32. </if>
  33. <if test="dto.classId != null">
  34. and t8.id = #{dto.classId}
  35. </if>
  36. <if test="dto.studentName != null">
  37. and t4.name like concat('%',#{dto.studentName},'%')
  38. </if>
  39. <if test="dto.studentId != null">
  40. and t5.student_id like concat('%',#{dto.studentId},'%')
  41. </if>
  42. <if test="dto.identity != null and dto.identity != ''">
  43. and t5.check_in_status like concat('%',#{dto.identity},'%')
  44. </if>
  45. ORDER BY t1.sort_code
  46. </select>
  47. <select id="getMaxSortCode" resultType="java.lang.Integer">
  48. SELECT IFNULL(MAX(sort_code),0) FROM room_bed WHERE delete_mark = 0
  49. </select>
  50. <select id="getDistributeClassInfo" parameterType="com.xjrsoft.module.room.dto.DistributeClassPageDto" resultType="com.xjrsoft.module.room.vo.DistributeClassPageVo">
  51. SELECT t1.id,t2.name AS grade_name,t3.name AS org_name,t1.name AS class_name,
  52. (SELECT COUNT(*) FROM base_student c1
  53. LEFT JOIN base_student_school_roll c2 ON c1.user_id = c2.user_id
  54. LEFT JOIN xjr_dictionary_detail c3 ON c2.stduy_status = c3.code AND c3.item_id = 2023000000000000030
  55. left join xjr_user c4 on c1.user_id = c4.id
  56. WHERE c1.delete_mark = 0 AND c2.delete_mark = 0
  57. AND c3.code = 'FB3002' AND c2.class_id = t1.id
  58. <if test="dto.gender != null">
  59. <if test="dto.gender == 'SB10001'">
  60. and c4.gender = 1
  61. </if>
  62. <if test="dto.gender == 'SB10002'">
  63. and c4.gender = 2
  64. </if>
  65. </if>
  66. ) AS need_count,(
  67. SELECT COUNT(*) FROM room_bed a1
  68. LEFT JOIN base_student_school_roll a2 ON a1.student_user_id = a2.user_id
  69. left join xjr_user c4 on a2.user_id = c4.id
  70. WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
  71. AND a2.class_id = t1.id
  72. <if test="dto.gender != null">
  73. <if test="dto.gender == 'SB10001'">
  74. and c4.gender = 1
  75. </if>
  76. <if test="dto.gender == 'SB10002'">
  77. and c4.gender = 2
  78. </if>
  79. </if>
  80. ) AS distribute_count FROM base_class t1
  81. LEFT JOIN base_grade t2 ON t1.grade_id = t2.id
  82. LEFT JOIN xjr_department t3 ON t1.org_id = t3.id
  83. WHERE t1.delete_mark = 0
  84. and (
  85. SELECT COUNT(*) FROM base_student c1
  86. LEFT JOIN base_student_school_roll c2 ON c1.user_id = c2.user_id
  87. LEFT JOIN xjr_dictionary_detail c3 ON c2.stduy_status = c3.code AND c3.item_id = 2023000000000000030
  88. WHERE c1.delete_mark = 0 AND c2.delete_mark = 0
  89. AND c3.code = 'FB3002' AND c2.class_id = t1.id
  90. ) >
  91. (
  92. SELECT COUNT(*) FROM room_bed a1
  93. LEFT JOIN base_student_school_roll a2 ON a1.student_user_id = a2.user_id
  94. WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
  95. AND a2.class_id = t1.id
  96. )
  97. <if test="dto.gradeId != null">
  98. and t1.grade_id = #{dto.gradeId}
  99. </if>
  100. <if test="dto.classId != null">
  101. and t1.id = #{dto.classId}
  102. </if>
  103. </select>
  104. <select id="getDistributeRoomBedInfo" parameterType="com.xjrsoft.module.room.dto.DistributeRoomBedPageDto" resultType="com.xjrsoft.module.room.vo.DistributeRoomBedPageVo">
  105. SELECT t1.id,t1.sort_code,t2.name AS build_name,t1.floor_number,t1.room_name,t4.name AS gender_cn, t3.name AS check_in_status_cn,
  106. t1.bed_count,(
  107. SELECT COUNT(*) FROM room_bed
  108. WHERE delete_mark = 0 AND room_id = t1.id
  109. AND student_user_id IS NOT NULL
  110. ) AS into_count,(
  111. SELECT GROUP_CONCAT(c3.name) FROM room_bed c1
  112. LEFT JOIN base_student_school_roll c2 ON c1.student_user_id = c2.user_id
  113. LEFT JOIN base_class c3 ON c2.class_id = c3.id
  114. WHERE c1.delete_mark = 0 AND c1.room_id = t1.id
  115. AND c1.student_user_id IS NOT NULL
  116. ) AS into_class FROM room t1
  117. LEFT JOIN base_office_build t2 ON t1.office_build_id = t2.id
  118. LEFT JOIN xjr_dictionary_detail t3 ON t1.check_in_status = t3.code AND t3.item_id = 1739843696019435521
  119. LEFT JOIN xjr_dictionary_detail t4 ON t1.gender = t4.code AND t4.item_id = 2023000000000000004
  120. WHERE t1.delete_mark = 0
  121. and
  122. (
  123. SELECT COUNT(*) FROM room_bed
  124. WHERE delete_mark = 0 AND room_id = t1.id
  125. AND student_user_id IS NOT NULL
  126. ) != t1.bed_count
  127. ORDER BY t1.sort_code
  128. </select>
  129. <select id="getBedInfo" resultType="com.xjrsoft.module.room.vo.RoomBedVo">
  130. SELECT t1.* FROM room_bed t1
  131. LEFT JOIN room t2 ON t1.room_id = t2.id
  132. WHERE t1.delete_mark = 0 AND t1.room_id IN
  133. <foreach item="roomId" index="index" collection="ids" open="(" close=")" separator=",">
  134. #{roomId}
  135. </foreach>
  136. ORDER BY t2.sort_code,t1.sort_code
  137. </select>
  138. <select id="getDistributeResult" parameterType="com.xjrsoft.module.room.dto.DistributeRoomBedDto" resultType="com.xjrsoft.module.room.vo.DistributeResultListVo">
  139. SELECT t5.class_id,t4.name,t6.name AS gender_cn,t3.name AS build_name,t2.room_name,t1.bed_number FROM room_bed t1
  140. LEFT JOIN room t2 ON t1.room_id = t2.id
  141. LEFT JOIN base_office_build t3 ON t2.office_build_id = t3.id
  142. LEFT JOIN xjr_user t4 ON t1.student_user_id = t4.id
  143. LEFT JOIN base_student_school_roll t5 ON t5.user_id = t4.id
  144. LEFT JOIN xjr_dictionary_detail t6 ON t2.gender = t6.code AND t6.item_id = 2023000000000000004
  145. WHERE t1.student_user_id IS NOT NULL AND t1.delete_mark = 0
  146. AND t1.room_id IN
  147. <foreach item="roomId" index="index" collection="dto.roomIds" open="(" close=")" separator=",">
  148. #{roomId}
  149. </foreach>
  150. AND t5.class_id IN
  151. <foreach item="classId" index="index" collection="dto.classIds" open="(" close=")" separator=",">
  152. #{classId}
  153. </foreach>
  154. ORDER BY t2.sort_code,t1.sort_code
  155. </select>
  156. <select id="getClassStudetBed" parameterType="com.xjrsoft.module.room.dto.AdjustClassPageDto" resultType="com.xjrsoft.module.room.vo.AdjustBedClassStudentPageVo">
  157. SELECT t1.user_id,t4.id AS class_id, t4.name AS class_name,t2.name AS student_name,REPLACE(REPLACE(t2.gender,1,'男'),2,'女') AS gender_cn,t7.name AS build_name,t6.room_name,t5.bed_number FROM base_student t1
  158. LEFT JOIN xjr_user t2 ON t1.user_id = t2.id
  159. LEFT JOIN base_student_school_roll t3 ON t1.user_id = t3.user_id
  160. LEFT JOIN base_class t4 ON t3.class_id = t4.id
  161. LEFT JOIN room_bed t5 ON t5.student_user_id = t1.user_id
  162. LEFT JOIN room t6 ON t5.room_id = t6.id
  163. LEFT JOIN base_office_build t7 ON t6.office_build_id = t7.id
  164. WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
  165. and t3.stduy_status = 'FB3002'
  166. <if test="dto.gradeId != null">
  167. and t4.grade_id = #{dto.gradeId}
  168. </if>
  169. <if test="dto.classId != null">
  170. and t4.id = #{dto.classId}
  171. </if>
  172. <if test="dto.gender != null and dto.gender != ''">
  173. and t6.gender = #{dto.gender}
  174. </if>
  175. <if test="dto.gender != null and dto.gender != ''">
  176. and t6.gender = #{dto.gender}
  177. </if>
  178. <if test="dto.isDistribute != null">
  179. <if test="dto.isDistribute == 1">
  180. and t5.student_user_id is not null
  181. </if>
  182. <if test="dto.isDistribute == 0">
  183. and t5.student_user_id is null
  184. </if>
  185. </if>
  186. <if test="dto.studentName != null and dto.studentName != ''">
  187. and t2.name like concat('%', #{dto.studentName}, '%')
  188. </if>
  189. </select>
  190. <select id="getBedStudentInfo" parameterType="com.xjrsoft.module.room.dto.AdjustBedPageDto" resultType="com.xjrsoft.module.room.vo.AdjustBedStudentPageVo">
  191. SELECT t1.id,t3.name AS build_name,t2.room_name,t5.name AS gender_cn,t1.bed_number,t4.name AS student_name,t4.id as student_user_id,t2.is_max,t2.id as room_id FROM room_bed t1
  192. LEFT JOIN room t2 ON t1.room_id = t2.id
  193. LEFT JOIN base_office_build t3 ON t2.office_build_id = t3.id
  194. LEFT JOIN xjr_user t4 ON t1.student_user_id = t4.id
  195. LEFT JOIN xjr_dictionary_detail t5 ON t2.gender = t5.code AND t5.item_id = 2023000000000000004
  196. LEFT JOIN base_student_school_roll t7 ON t4.id = t7.user_id
  197. WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
  198. <if test="dto.isEmptyRoom != null">
  199. <if test="dto.isEmptyRoom == 1">
  200. and t2.bed_count = (SELECT COUNT(*) FROM room_bed WHERE delete_mark = 0 AND student_user_id IS NULL AND is_check_in = 0 AND room_id = t2.id)
  201. </if>
  202. <if test="dto.isEmptyRoom == 0">
  203. and t2.bed_count != (SELECT COUNT(*) FROM room_bed WHERE delete_mark = 0 AND student_user_id IS NULL AND is_check_in = 0 AND room_id = t2.id)
  204. </if>
  205. </if>
  206. <if test="dto.roomName != null">
  207. and t2.room_name like concat('%', #{dto.roomName}, '%')
  208. </if>
  209. <if test="dto.isMax != null">
  210. and t2.is_max = #{dto.isMax}
  211. </if>
  212. <if test="dto.floorNumber != null">
  213. and t2.floor_number = #{dto.floorNumber}
  214. </if>
  215. <if test="dto.floorNumber != null">
  216. and t2.floor_number = #{dto.floorNumber}
  217. </if>
  218. <if test="dto.classId != null">
  219. and t7.class_id = #{dto.classId}
  220. </if>
  221. <if test="dto.buildId != null">
  222. and t3.id = #{dto.buildId}
  223. </if>
  224. ORDER BY t2.sort_code,t1.sort_code
  225. </select>
  226. <select id="getNoBedStudent" parameterType="com.xjrsoft.module.room.dto.AdjustBedPageDto" resultType="com.xjrsoft.module.room.vo.NoBedStudentPageVo">
  227. SELECT t1.user_id, t2.name AS student_name,REPLACE(REPLACE(t2.gender,1,'男'),2,'女') as gender_cn,t4.name AS class_name FROM base_student t1
  228. INNER JOIN xjr_user t2 ON t1.user_id = t2.id
  229. LEFT JOIN base_student_school_roll t3 ON t1.user_id = t3.user_id
  230. LEFT JOIN base_class t4 ON t3.class_id = t4.id
  231. WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
  232. AND t3.stduy_status = 'FB3001'
  233. AND t1.user_id NOT IN (
  234. SELECT student_user_id FROM room_bed WHERE delete_mark = 0 AND student_user_id IS NOT NULL
  235. )
  236. </select>
  237. </mapper>