RoomRealtimeStatuDao.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.chuanghai.ihotel.dao.RoomRealtimeStatuDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.chuanghai.ihotel.entity.RoomRealtimeStatuEntity" id="roomRealtimeStatuMap">
  6. <result property="id" column="id"/>
  7. <result property="roomId" column="room_id"/>
  8. <result property="roomTypeId" column="room_type_id"/>
  9. <result property="startTime" column="start_time"/>
  10. <result property="endTime" column="end_time"/>
  11. <result property="statu" column="statu"/>
  12. <result property="remark" column="remark"/>
  13. <result property="bizId" column="biz_id"/>
  14. </resultMap>
  15. <select id="getBusyNum" resultType="int">
  16. select count(1)
  17. from room_realtime_statu
  18. where
  19. room_type_id = #{roomTypeId}
  20. and statu != '1'
  21. and not(end_time <![CDATA[<]]> #{startTime} or start_time <![CDATA[>]]> #{endTime})
  22. </select>
  23. <!-- 查询指定时间段内处于繁忙状态的房间id -->
  24. <select id="getBusyRoomId" resultType="java.lang.Long">
  25. select room_id
  26. from room_realtime_statu
  27. where
  28. room_type_id = #{roomTypeId}
  29. and statu != '1'
  30. and not(end_time <![CDATA[<]]> #{startTime} or start_time <![CDATA[>]]> #{endTime})
  31. </select>
  32. <!-- <select id="getByRoomIdsAndTime" resultMap="roomRealtimeStatuMap">-->
  33. <!-- select *-->
  34. <!-- from room_realtime_statu-->
  35. <!-- where-->
  36. <!-- (statu = '4')-->
  37. <!-- or-->
  38. <!-- (-->
  39. <!-- (statu != '1' and statu != '4')-->
  40. <!-- and room_id in-->
  41. <!-- <foreach collection="roomIds" item="item" open="(" close=")" index="i" separator=","> #{item}-->
  42. <!-- </foreach>-->
  43. <!-- and not(end_time <![CDATA[<]]> #{startTime} or start_time <![CDATA[>]]> #{endTime})-->
  44. <!-- )-->
  45. <!-- ORDER BY id DESC-->
  46. <!-- LIMIT 1-->
  47. <!-- </select>-->
  48. <select id="getByRoomIdsAndTime" resultMap="roomRealtimeStatuMap">
  49. select *
  50. from room_realtime_statu
  51. where
  52. statu != '1' and room_id in
  53. <foreach collection="roomIds" item="item" open="(" close=")" index="i" separator=","> #{item}
  54. </foreach>
  55. and (NOT(end_time <![CDATA[<]]> #{startTime} OR start_time <![CDATA[>]]> #{endTime}) OR (start_time <![CDATA[>=]]> #{startTime} AND start_time <![CDATA[<]]> #{endTime}))
  56. </select>
  57. <!-- 查询当前时间段内房间状态 -->
  58. <select id="getByRoomIdAndTime" resultMap="roomRealtimeStatuMap">
  59. select *
  60. from room_realtime_statu
  61. where
  62. room_id = #{roomId}
  63. and not(end_time <![CDATA[<]]> #{startTime} or start_time <![CDATA[>]]> #{endTime})
  64. ORDER BY id DESC
  65. limit 1
  66. </select>
  67. </mapper>