| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.template.mapper.HouseNumberMapper">
- <select id="houseStatePage" resultType="com.template.model.vo.HouseStateVo">
- SELECT
- hn.id AS houseNumberId,
- hn.house_id as houseId,
- hn.room_number as houseNumber,
- hn.house_status as houseStatus,
- h.room_name as houseName,
- hns.`status` AS status,
- ho.reserve_name as reserveName,
- ho.reserve_live_time as reserveLiveTime,
- ho.reserve_leave_time as reserveLeaveTime,
- h.room_live_time as roomLiveTime,
- h.receiving_time as receivingTime,
- hns.id as houseNumberStateId,
- ho.order_number as orderNumber,
- h.room_type as roomType,
- b.building,
- b.element,
- ho.key_type as lockStatus,
- ho.key_pass_word as passWord,
- ho.order_status as orderStatus,
- ho.id as houseOrderId,
- ho.live_time AS liveTime,
- ho.leave_time AS leaveTime
- FROM
- `house_number` hn
- LEFT JOIN house h ON h.id = hn.house_id
- AND h.deleted = 0
- LEFT JOIN house_number_state hns ON hn.id = hns.house_number_id
- AND hns.deleted = 0
- AND #{end}>= hns.start_time
- AND hns.end_time>= #{start}
- LEFT JOIN house_order ho ON hns.order_number = ho.order_number
- AND ho.deleted = 0
- LEFT JOIN building b ON b.id = hn.building_id
- AND b.deleted = 0
- <where>
- hn.deleted = 0
- <if test="houseType != null and houseType != ''">
- AND h.room_type = #{houseType}
- </if>
- <if test="keyWord != null and keyWord != ''">
- AND ( hn.room_number LIKE '%' #{keyWord} '%' OR ho.reserve_name LIKE '%' #{keyWord} '%' )
- </if>
- <if test="houseId != null and houseId != ''">
- AND hn.house_id = #{houseId}
- </if>
- <if test="buildingId != null and buildingId != ''">
- AND hn.building_id = #{buildingId}
- </if>
- <if test="houseStatus != null and houseStatus != ''">
- AND hns.status = #{houseStatus}
- </if>
- <if test="houseNumberStatus != null and houseNumberStatus != ''">
- AND hn.house_status = #{houseNumberStatus}
- </if>
- </where>
- ORDER BY
- hn.room_number
- </select>
- <select id="houseStateCalendarPage" resultType="com.template.model.vo.CalendarPageVo">
- SELECT
- hn.id AS houseNumberId,
- hn.house_id as houseId,
- hn.room_number as houseNumber,
- hn.house_status as houseStatus,
- hn.id as houseNumberStateId,
- -- hn.`status` as houseType,
- h.room_name as houseName,
- -- hns.`status` AS status
- -- ho.reserve_name as reserveName,
- -- ho.reserve_live_time as reserveLiveTime,
- -- ho.reserve_leave_time as reserveLeaveTime,
- h.room_price as price,
- h.room_live_time as roomLiveTime,
- h.receiving_time as receivingTime,
- b.building,
- b.element
- FROM
- `house_number` hn
- LEFT JOIN house h ON h.id = hn.house_id
- AND h.deleted = 0
- LEFT JOIN building b ON b.id = hn.building_id
- AND b.deleted = 0
- -- LEFT JOIN house_number_state hns ON hn.id = hns.house_number_id
- -- AND hns.deleted = 0
- -- LEFT JOIN house_order ho ON hns.order_number = ho.order_number
- -- AND ho.deleted = 0
- <where>
- hn.deleted = 0
- <if test="houseType != null and houseType != ''">
- AND h.room_type = #{houseType}
- </if>
- <if test="keyWord != null and keyWord != ''">
- AND hn.room_number LIKE '%' #{keyWord} '%'
- </if>
- <if test="houseId != null and houseId != ''">
- AND hn.house_id = #{houseId}
- </if>
- <if test="buildingId != null and buildingId != ''">
- AND hn.building_id = #{buildingId}
- </if>
- </where>
- ORDER BY
- hn.room_number
- </select>
- <select id="houseLockListDto" resultType="com.template.model.vo.houseLockListVo">
- SELECT
- hn.house_id AS houseId,
- hn.id AS houseNumberId,
- hn.room_number AS roomNumber,
- hl.equipment_type AS equipmentType,
- hl.network_type as networkType,
- hl.wifi_mac as wifiMac,
- hl.binding_time as bindingTime,
- hl.electric_quantity as electricQuantity,
- hl.network_state as networkState,
- hl.equipment_state as equipmentState
- FROM
- `house_number` hn
- LEFT JOIN house_lock hl ON hl.house_number_id = hn.id and hl.deleted=0
- LEFT JOIN building b ON b.id = hn.building_id AND b.deleted = 0
- <where>
- FIND_IN_SET( hn.house_id, #{houseIds})
- and hn.deleted = 0
- <if test="roomNumber != null and roomNumber != ''">
- AND hn.room_number LIKE '%' #{roomNumber} '%'
- </if>
- <if test="buildingId != null and buildingId != ''">
- AND hn.building_id = #{buildingId}
- </if>
- </where>
- ORDER BY
- hn.room_number
- </select>
- <select id="getNumberState" resultType="java.lang.Integer">
- SELECT hn.id
- FROM `house_number` hn
- LEFT JOIN house_number_state hns on hns.house_number_id = hn.id AND hns.deleted = 0
- WHERE hns.end_time > #{date}
- AND hn.deleted = 0
- GROUP BY hn.id
- </select>
- <select id="freeDropDownShow" resultType="com.template.model.vo.FreeVo">
- SELECT hn.id,
- hn.house_id as houseId,
- hn.room_number as roomNumber,
- hn.house_status as houseStatus,
- h.room_type as roomType
- FROM `house_number` hn
- LEFT JOIN house h ON h.id = hn.house_id
- AND h.deleted = 0
- WHERE hn.deleted = 0
- AND FIND_IN_SET(hn.id, #{houseNumberIds})
- AND hn.house_status = 1
- </select>
- <select id="dirtyDropDownShow" resultType="com.template.model.vo.FreeVo">
- SELECT hn.id,
- hn.house_id as houseId,
- hn.room_number as roomNumber,
- hn.house_status as houseStatus,
- h.room_type as roomType
- FROM `house_number` hn
- LEFT JOIN house h ON h.id = hn.house_id
- AND h.deleted = 0
- WHERE hn.deleted = 0
- AND hn.house_status = 2
- </select>
- <select id="lockDropDownShow" resultType="com.template.model.vo.FreeVo">
- SELECT hn.id,
- hn.house_id as houseId,
- hn.room_number as roomNumber,
- hn.house_status as houseStatus,
- h.room_type as roomType
- FROM `house_number` hn
- LEFT JOIN house_number_state hns ON hns.house_number_id = hn.id
- AND hns.deleted = 0
- LEFT JOIN house h ON h.id = hn.house_id
- AND h.deleted = 0
- WHERE #{date} >= hns.start_time
- AND hns.end_time > #{date}
- AND hns.status = 5
- AND hn.deleted = 0
- </select>
- <select id="shutDropDownShow" resultType="com.template.model.vo.FreeVo">
- SELECT hn.id,
- hn.house_id as houseId,
- hn.room_number as roomNumber,
- hn.house_status as houseStatus,
- h.room_type as roomType
- FROM `house_number` hn
- LEFT JOIN house h ON h.id = hn.house_id
- AND h.deleted = 0
- WHERE hn.deleted = 0
- AND FIND_IN_SET(hn.id, #{houseNumberIds})
- AND hn.house_status = 1
- AND hn.electric_type = 1
- </select>
- <select id="openDropDownShow" resultType="com.template.model.vo.FreeVo">
- SELECT hn.id,
- hn.house_id as houseId,
- hn.room_number as roomNumber,
- hn.house_status as houseStatus,
- h.room_type as roomType
- FROM `house_number` hn
- LEFT JOIN house h ON h.id = hn.house_id
- AND h.deleted = 0
- WHERE hn.deleted = 0
- AND FIND_IN_SET(hn.id, #{houseNumberIds})
- AND hn.house_status = 1
- AND hn.electric_type = 2
- </select>
- <select id="roomChangePage" resultType="com.template.model.vo.HouseNumberVo">
- SELECT hn.id,
- hn.house_id as houseId,
- hn.room_number as roomNumber,
- hn.house_status as houseStatus,
- hn.electric_type as electricType,
- hn.electric_equipment_id as electricEquipmentId,
- hn.electric_equipment_meter_name as electricEquipmentMeterName,
- hn.water_equipment_id as waterEquipmentId,
- hn.water_equipment_meter_name as waterEquipmentMeterName,
- h.room_name as roomName,
- h.room_type as roomType,
- h.room_price as roomPrice
- FROM `house_number` hn
- LEFT JOIN house h on h.id = hn.house_id and hn.deleted = 0
- WHERE hn.house_id = #{houseId}
- AND hn.deleted = 0
- and hn.house_status = 1
- </select>
- <select id="pageList" resultType="com.template.model.vo.HouseNumberPageVo">
- SELECT
- hn.id,
- hn.house_id as houseId,
- hn.room_number as roomNumber,
- hn.house_status as houseStatus,
- hn.electric_type as electricType,
- hn.electric_equipment_id as electricEquipmentId,
- hn.electric_equipment_meter_name as electricEquipmentMeterName,
- hn.water_equipment_id as waterEquipmentId,
- hn.water_equipment_meter_name as waterEquipmentMeterName,
- hn.create_time as createTime,
- h.room_name as houseName,
- h.room_type as roomType
- FROM
- `house_number` hn
- LEFT JOIN house h on h.id=hn.house_id AND h.deleted=0
- LEFT JOIN building b ON b.id = hn.building_id
- AND b.deleted = 0
- WHERE
- hn.deleted=0
- <if test="keyWord != null and keyWord != ''">
- AND (hn.room_number LIKE '%' #{keyWord} '%' OR hn.electric_equipment_meter_name LIKE '%' #{keyWord} '%' OR
- hn.water_equipment_meter_name LIKE '%' #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
- AND #{endTime} >= hn.create_time
- AND hn.create_time >= #{startTime}
- </if>
- <if test="houseId != null and houseId != ''">
- AND h.id = #{houseId}
- </if>
- <if test="buildingId != null and buildingId != ''">
- AND hn.building_id=#{buildingId}
- </if>
- ORDER BY h.id
- </select>
- <select id="listExport" resultType="com.template.model.vo.HouseNumberPageVo">
- SELECT
- hn.id,
- hn.house_id as houseId,
- hn.room_number as roomNumber,
- hn.house_status as houseStatus,
- hn.electric_type as electricType,
- hn.electric_equipment_id as electricEquipmentId,
- hn.electric_equipment_meter_name as electricEquipmentMeterName,
- hn.water_equipment_id as waterEquipmentId,
- hn.water_equipment_meter_name as waterEquipmentMeterName,
- hn.create_time as createTime,
- h.room_name as houseName,
- h.room_type as roomType,
- b.building as building,
- b.element
- FROM
- `house_number` hn
- LEFT JOIN house h on h.id=hn.house_id AND h.deleted=0
- LEFT JOIN building b ON b.id = hn.building_id
- AND b.deleted = 0
- WHERE
- hn.deleted=0
- <if test="keyWord != null and keyWord != ''">
- AND (hn.room_number LIKE '%' #{keyWord} '%' OR hn.electric_equipment_meter_name LIKE '%' #{keyWord} '%' OR
- hn.water_equipment_meter_name LIKE '%' #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
- AND #{endTime} >= hn.create_time
- AND hn.create_time >= #{startTime}
- </if>
- <if test="houseId != null and houseId != ''">
- AND h.id = #{houseId}
- </if>
- <if test="buildingId != null and buildingId != ''">
- AND hn.building_id=#{buildingId}
- </if>
- ORDER BY h.id
- </select>
- <select id="getpage" resultType="com.template.model.vo.HouseNumberListVo">
- SELECT
- b.building as building,
- b.element,
- hl.equipment_type as doorLock,
- h.room_name as roomName,
- h.room_type as roomType,
- hn.id,
- hn.room_number AS roomNumber,
- hn.house_status AS houseStatus,
- hn.electric_type AS electricType,
- hn.electric_equipment_id AS electricEquipmentId,
- hn.electric_equipment_meter_name AS electricEquipmentMeterName,
- hn.water_equipment_id AS waterEquipmentId,
- hn.water_equipment_meter_name AS waterEquipmentMeterName,
- b.id as buildingId,
- h.id as houseId
- FROM
- `house_number` hn
- LEFT JOIN building b ON b.id = hn.building_id AND b.deleted=0
- LEFT JOIN house_lock hl ON hl.house_number_id = hn.id AND hl.deleted=0
- LEFT JOIN house h ON h.id = hn.house_id AND h.deleted=0
- WHERE
- hn.deleted=0
- <if test="keyWord != null and keyWord != ''">
- AND hn.room_number LIKE '%' #{keyWord} '%'
- </if>
- <if test="buildingId != null and buildingId != ''">
- AND b.id= #{buildingId}
- </if>
- <if test="houseId != null and houseId != ''">
- AND h.id= #{houseId}
- </if>
- ORDER BY b.building,b.element
- </select>
- </mapper>
|