RoomMapper.xml 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.RoomMapper">
  6. <select id="getPage" parameterType="com.xjrsoft.module.room.dto.RoomPageDto" resultType="com.xjrsoft.module.room.vo.RoomPageVo">
  7. SELECT t1.id,t1.sort_code,t2.name AS bulid_name,t1.floor_number,t1.room_name,t3.name AS check_in_status_cn,t4.name AS gender_cn,t1.bed_count,
  8. (SELECT GROUP_CONCAT(c2.name) FROM room_student_appoint c1
  9. LEFT JOIN xjr_user c2 ON c1.student_user_id = c2.id
  10. WHERE c1.delete_mark = 0 AND c1.room_id = t1.id) AS student_appoint_names,
  11. (SELECT GROUP_CONCAT(c2.name) FROM room_teacher_appoint c1
  12. LEFT JOIN xjr_user c2 ON c1.user_id = c2.id
  13. WHERE c1.delete_mark = 0 AND c1.room_id = t1.id) AS teacher_appoint_names,t1.is_max,t1.remark FROM room t1
  14. LEFT JOIN base_office_build t2 ON t1.office_build_id = t2.id
  15. LEFT JOIN xjr_dictionary_detail t3 ON t1.check_in_status = t3.code AND t3.item_id = 1739843696019435521
  16. LEFT JOIN xjr_dictionary_detail t4 ON t1.gender = t4.code AND t4.item_id = 2023000000000000004
  17. WHERE t1.delete_mark = 0
  18. <if test="dto.officeBuildId != null">
  19. and t1.office_build_id = #{dto.officeBuildId}
  20. </if>
  21. <if test="dto.floorNumber != null">
  22. and t1.floor_number = #{dto.floorNumber}
  23. </if>
  24. <if test="dto.checkInStatus != null and dto.checkInStatus != ''">
  25. and t1.check_in_status = #{dto.checkInStatus}
  26. </if>
  27. <if test="dto.gender != null and dto.gender != ''">
  28. and t1.gender = #{dto.gender}
  29. </if>
  30. ORDER BY t1.sort_code
  31. </select>
  32. <select id="getList" parameterType="com.xjrsoft.module.room.dto.RoomPageDto" resultType="com.xjrsoft.module.room.vo.RoomExcelVo">
  33. SELECT t1.id,t1.sort_code,t2.name AS bulid_name,t1.floor_number,t1.room_name,t3.name AS check_in_status_cn,t4.name AS gender_cn,t1.bed_count,
  34. (SELECT GROUP_CONCAT(c2.name) FROM room_student_appoint c1
  35. LEFT JOIN xjr_user c2 ON c1.student_user_id = c2.id
  36. WHERE c1.delete_mark = 0 AND c1.room_id = t1.id) AS student_appoint_names,
  37. (SELECT GROUP_CONCAT(c2.name) FROM room_teacher_appoint c1
  38. LEFT JOIN xjr_user c2 ON c1.user_id = c2.id
  39. WHERE c1.delete_mark = 0 AND c1.room_id = t1.id) AS teacher_appoint_names,t1.is_max,t1.remark FROM room t1
  40. LEFT JOIN base_office_build t2 ON t1.office_build_id = t2.id
  41. LEFT JOIN xjr_dictionary_detail t3 ON t1.check_in_status = t3.code AND t3.item_id = 1739843696019435521
  42. LEFT JOIN xjr_dictionary_detail t4 ON t1.gender = t4.code AND t4.item_id = 2023000000000000004
  43. WHERE t1.delete_mark = 0
  44. <if test="dto.officeBuildId != null">
  45. and t1.office_build_id = #{dto.officeBuildId}
  46. </if>
  47. <if test="dto.floorNumber != null">
  48. and t1.floor_number = #{dto.floorNumber}
  49. </if>
  50. <if test="dto.checkInStatus != null and dto.checkInStatus != ''">
  51. and t1.check_in_status = #{dto.checkInStatus}
  52. </if>
  53. <if test="dto.gender != null and dto.gender != ''">
  54. and t1.gender = #{dto.gender}
  55. </if>
  56. ORDER BY t1.sort_code
  57. </select>
  58. <select id="getMaxSortCode" resultType="java.lang.Integer">
  59. SELECT IFNULL(MAX(sort_code),1) FROM room WHERE delete_mark = 0
  60. </select>
  61. <select id="getRoomClassCount" resultType="com.xjrsoft.module.room.vo.RoomClassCountVo">
  62. SELECT id,(
  63. SELECT COUNT(*) FROM (
  64. SELECT COUNT(*) FROM base_class t1
  65. LEFT JOIN base_student_school_roll t2 ON t2.class_id = t1.id
  66. LEFT JOIN room_bed t3 ON t2.user_id = t3.student_user_id
  67. WHERE t3.room_id = room.id GROUP BY t1.id
  68. ) class_data
  69. ) AS class_count FROM room
  70. where 1 = 1
  71. <if test="ids != null and ids.size() > 0">
  72. and id in
  73. <foreach item="roomId" index="index" collection="ids" open="(" close=")" separator=",">
  74. #{roomId}
  75. </foreach>
  76. </if>
  77. </select>
  78. </mapper>