RoomBedMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. <if test="dto.officeBuildId != null">
  18. and t2.office_build_id = #{dto.officeBuildId}
  19. </if>
  20. <if test="dto.floorNumber != null">
  21. and t2.floor_number = #{dto.floorNumber}
  22. </if>
  23. <if test="dto.roomId != null">
  24. and t2.room_id = #{dto.roomId}
  25. </if>
  26. <if test="dto.gender != null and dto.gender != ''">
  27. and t2.gender = #{dto.gender}
  28. </if>
  29. <if test="dto.gradeId != null">
  30. and t7.id = #{dto.gradeId}
  31. </if>
  32. <if test="dto.classId != null">
  33. and t8.id = #{dto.classId}
  34. </if>
  35. <if test="dto.studentName != null">
  36. and t4.name like concat('%',#{dto.studentName},'%')
  37. </if>
  38. <if test="dto.studentId != null">
  39. and t5.student_id like concat('%',#{dto.studentId},'%')
  40. </if>
  41. ORDER BY t1.sort_code
  42. </select>
  43. <select id="getMaxSortCode" resultType="java.lang.Integer">
  44. SELECT IFNULL(MAX(sort_code),0) FROM room_bed WHERE delete_mark = 0
  45. </select>
  46. <select id="getDistributeClassInfo" parameterType="com.xjrsoft.module.room.dto.DistributeClassPageDto" resultType="com.xjrsoft.module.room.vo.DistributeClassPageVo">
  47. SELECT t1.id,t2.name AS grade_name,t3.name AS org_name,t1.name AS class_name,
  48. (SELECT COUNT(*) FROM base_student c1
  49. LEFT JOIN base_student_school_roll c2 ON c1.user_id = c2.user_id
  50. LEFT JOIN xjr_dictionary_detail c3 ON c2.stduy_status = c3.code AND c3.item_id = 2023000000000000030
  51. WHERE c1.delete_mark = 0 AND c2.delete_mark = 0
  52. AND c3.code = 'FB3001' AND c2.class_id = t1.id) AS need_count,(
  53. SELECT COUNT(*) FROM room_bed a1
  54. LEFT JOIN base_student_school_roll a2 ON a1.student_user_id = a2.user_id
  55. WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
  56. AND a2.class_id = t1.id
  57. ) AS distribute_count FROM base_class t1
  58. LEFT JOIN base_grade t2 ON t1.grade_id = t2.id
  59. LEFT JOIN xjr_department t3 ON t1.org_id = t3.id
  60. WHERE t1.delete_mark = 0
  61. and (
  62. SELECT COUNT(*) FROM base_student c1
  63. LEFT JOIN base_student_school_roll c2 ON c1.user_id = c2.user_id
  64. LEFT JOIN xjr_dictionary_detail c3 ON c2.stduy_status = c3.code AND c3.item_id = 2023000000000000030
  65. WHERE c1.delete_mark = 0 AND c2.delete_mark = 0
  66. AND c3.code = 'FB3001' AND c2.class_id = t1.id
  67. ) !=
  68. (
  69. SELECT COUNT(*) FROM room_bed a1
  70. LEFT JOIN base_student_school_roll a2 ON a1.student_user_id = a2.user_id
  71. WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
  72. AND a2.class_id = t1.id
  73. )
  74. </select>
  75. <select id="getDistributeRoomBedInfo" parameterType="com.xjrsoft.module.room.dto.DistributeRoomBedPageDto" resultType="com.xjrsoft.module.room.vo.DistributeRoomBedPageVo">
  76. 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,
  77. t1.bed_count,(
  78. SELECT COUNT(*) FROM room_bed
  79. WHERE delete_mark = 0 AND room_id = t1.id
  80. AND student_user_id IS NOT NULL
  81. ) AS into_count,(
  82. SELECT GROUP_CONCAT(c3.name) FROM room_bed c1
  83. LEFT JOIN base_student_school_roll c2 ON c1.student_user_id = c2.user_id
  84. LEFT JOIN base_class c3 ON c2.class_id = c3.id
  85. WHERE c1.delete_mark = 0 AND c1.room_id = t1.id
  86. AND c1.student_user_id IS NOT NULL
  87. ) AS into_class FROM room t1
  88. LEFT JOIN base_office_build t2 ON t1.office_build_id = t2.id
  89. LEFT JOIN xjr_dictionary_detail t3 ON t1.check_in_status = t3.code AND t3.item_id = 1739843696019435521
  90. LEFT JOIN xjr_dictionary_detail t4 ON t1.gender = t4.code AND t4.item_id = 2023000000000000004
  91. WHERE t1.delete_mark = 0
  92. and
  93. (
  94. SELECT COUNT(*) FROM room_bed
  95. WHERE delete_mark = 0 AND room_id = t1.id
  96. AND student_user_id IS NOT NULL
  97. ) != t1.bed_count
  98. ORDER BY t1.sort_code
  99. </select>
  100. <select id="getBedInfo" resultType="com.xjrsoft.module.room.vo.RoomBedVo">
  101. SELECT t1.* FROM room_bed t1
  102. LEFT JOIN room t2 ON t1.room_id = t2.id
  103. WHERE t1.delete_mark = 0 AND t1.room_id IN
  104. <foreach item="roomId" index="index" collection="ids" open="(" close=")" separator=",">
  105. #{roomId}
  106. </foreach>
  107. ORDER BY t2.sort_code,t1.sort_code
  108. </select>
  109. </mapper>