HouseNumberMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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.template.mapper.HouseNumberMapper">
  4. <select id="houseStatePage" resultType="com.template.model.vo.HouseStateVo">
  5. SELECT
  6. hn.id AS houseNumberId,
  7. hn.house_id as houseId,
  8. hn.room_number as houseNumber,
  9. hn.house_status as houseStatus,
  10. h.room_name as houseName,
  11. hns.`status` AS status,
  12. ho.reserve_name as reserveName,
  13. hns.start_time as reserveLiveTime,
  14. hns.end_time as reserveLeaveTime,
  15. h.room_live_time as roomLiveTime,
  16. h.receiving_time as receivingTime,
  17. hns.id as houseNumberStateId,
  18. ho.order_number as orderNumber,
  19. h.room_type as roomType,
  20. b.building,
  21. b.element,
  22. ho.key_type as lockStatus,
  23. ho.key_pass_word as passWord,
  24. ho.order_status as orderStatus
  25. FROM
  26. `house_number` hn
  27. LEFT JOIN house h ON h.id = hn.house_id
  28. AND h.deleted = 0
  29. LEFT JOIN house_number_state hns ON hn.id = hns.house_number_id
  30. AND hns.deleted = 0
  31. AND #{end}>= hns.start_time
  32. AND hns.end_time>= #{start}
  33. LEFT JOIN house_order ho ON hns.order_number = ho.order_number
  34. AND ho.deleted = 0
  35. LEFT JOIN building b ON b.id = hn.building_id
  36. AND b.deleted = 0
  37. <where>
  38. hn.deleted = 0
  39. <if test="houseType != null and houseType != ''">
  40. AND h.room_type = #{houseType}
  41. </if>
  42. <if test="keyWord != null and keyWord != ''">
  43. AND ( hn.room_number LIKE '%' #{keyWord} '%' OR ho.reserve_name LIKE '%' #{keyWord} '%' )
  44. </if>
  45. <if test="houseId != null and houseId != ''">
  46. AND hn.house_id = #{houseId}
  47. </if>
  48. <if test="buildingId != null and buildingId != ''">
  49. AND hn.building_id = #{buildingId}
  50. </if>
  51. <if test="houseStatus != null and houseStatus != ''">
  52. AND hns.status = #{houseStatus}
  53. </if>
  54. <if test="houseNumberStatus != null and houseNumberStatus != ''">
  55. AND hn.house_status = #{houseNumberStatus}
  56. </if>
  57. </where>
  58. ORDER BY
  59. hn.room_number
  60. </select>
  61. <select id="houseStateCalendarPage" resultType="com.template.model.vo.CalendarPageVo">
  62. SELECT
  63. hn.id AS houseNumberId,
  64. hn.house_id as houseId,
  65. hn.room_number as houseNumber,
  66. hn.house_status as houseStatus,
  67. hn.id as houseNumberStateId,
  68. -- hn.`status` as houseType,
  69. h.room_name as houseName,
  70. -- hns.`status` AS status
  71. -- ho.reserve_name as reserveName,
  72. -- ho.reserve_live_time as reserveLiveTime,
  73. -- ho.reserve_leave_time as reserveLeaveTime,
  74. h.room_price as price,
  75. h.room_live_time as roomLiveTime,
  76. h.receiving_time as receivingTime,
  77. b.building,
  78. b.element
  79. FROM
  80. `house_number` hn
  81. LEFT JOIN house h ON h.id = hn.house_id
  82. AND h.deleted = 0
  83. LEFT JOIN building b ON b.id = hn.building_id
  84. AND b.deleted = 0
  85. -- LEFT JOIN house_number_state hns ON hn.id = hns.house_number_id
  86. -- AND hns.deleted = 0
  87. -- LEFT JOIN house_order ho ON hns.order_number = ho.order_number
  88. -- AND ho.deleted = 0
  89. <where>
  90. hn.deleted = 0
  91. <if test="houseType != null and houseType != ''">
  92. AND h.room_type = #{houseType}
  93. </if>
  94. <if test="keyWord != null and keyWord != ''">
  95. AND hn.room_number LIKE '%' #{keyWord} '%'
  96. </if>
  97. <if test="houseId != null and houseId != ''">
  98. AND hn.house_id = #{houseId}
  99. </if>
  100. <if test="buildingId != null and buildingId != ''">
  101. AND hn.building_id = #{buildingId}
  102. </if>
  103. </where>
  104. ORDER BY
  105. hn.room_number
  106. </select>
  107. <select id="houseLockListDto" resultType="com.template.model.vo.houseLockListVo">
  108. SELECT
  109. hn.house_id AS houseId,
  110. hn.id AS houseNumberId,
  111. hn.room_number AS roomNumber,
  112. hl.equipment_type AS equipmentType,
  113. hl.network_type as networkType,
  114. hl.wifi_mac as wifiMac,
  115. hl.binding_time as bindingTime,
  116. hl.electric_quantity as electricQuantity,
  117. hl.network_state as networkState,
  118. hl.equipment_state as equipmentState
  119. FROM
  120. `house_number` hn
  121. LEFT JOIN house_lock hl ON hl.house_number_id = hn.id and hl.deleted=0
  122. LEFT JOIN building b ON b.id = hn.building_id AND b.deleted = 0
  123. <where>
  124. FIND_IN_SET( hn.house_id, #{houseIds})
  125. and hn.deleted = 0
  126. <if test="roomNumber != null and roomNumber != ''">
  127. AND hn.room_number LIKE '%' #{roomNumber} '%'
  128. </if>
  129. <if test="buildingId != null and buildingId != ''">
  130. AND hn.building_id = #{buildingId}
  131. </if>
  132. </where>
  133. ORDER BY
  134. hn.room_number
  135. </select>
  136. <select id="getNumberState" resultType="java.lang.Integer">
  137. SELECT hn.id
  138. FROM `house_number` hn
  139. LEFT JOIN house_number_state hns on hns.house_number_id = hn.id AND hns.deleted = 0
  140. WHERE hns.end_time > #{date}
  141. AND hn.deleted = 0
  142. GROUP BY hn.id
  143. </select>
  144. <select id="freeDropDownShow" resultType="com.template.model.vo.FreeVo">
  145. SELECT hn.id,
  146. hn.house_id as houseId,
  147. hn.room_number as roomNumber,
  148. hn.house_status as houseStatus,
  149. h.room_type as roomType
  150. FROM `house_number` hn
  151. LEFT JOIN house h ON h.id = hn.house_id
  152. AND h.deleted = 0
  153. WHERE hn.deleted = 0
  154. AND FIND_IN_SET(hn.id, #{houseNumberIds})
  155. AND hn.house_status = 1
  156. </select>
  157. <select id="dirtyDropDownShow" resultType="com.template.model.vo.FreeVo">
  158. SELECT hn.id,
  159. hn.house_id as houseId,
  160. hn.room_number as roomNumber,
  161. hn.house_status as houseStatus,
  162. h.room_type as roomType
  163. FROM `house_number` hn
  164. LEFT JOIN house h ON h.id = hn.house_id
  165. AND h.deleted = 0
  166. WHERE hn.deleted = 0
  167. AND hn.house_status = 2
  168. </select>
  169. <select id="lockDropDownShow" resultType="com.template.model.vo.FreeVo">
  170. SELECT hn.id,
  171. hn.house_id as houseId,
  172. hn.room_number as roomNumber,
  173. hn.house_status as houseStatus,
  174. h.room_type as roomType
  175. FROM `house_number` hn
  176. LEFT JOIN house_number_state hns ON hns.house_number_id = hn.id
  177. AND hns.deleted = 0
  178. LEFT JOIN house h ON h.id = hn.house_id
  179. AND h.deleted = 0
  180. WHERE #{date} >= hns.start_time
  181. AND hns.end_time > #{date}
  182. AND hns.status = 5
  183. AND hn.deleted = 0
  184. </select>
  185. <select id="shutDropDownShow" resultType="com.template.model.vo.FreeVo">
  186. SELECT hn.id,
  187. hn.house_id as houseId,
  188. hn.room_number as roomNumber,
  189. hn.house_status as houseStatus,
  190. h.room_type as roomType
  191. FROM `house_number` hn
  192. LEFT JOIN house h ON h.id = hn.house_id
  193. AND h.deleted = 0
  194. WHERE hn.deleted = 0
  195. AND FIND_IN_SET(hn.id, #{houseNumberIds})
  196. AND hn.house_status = 1
  197. AND hn.electric_type = 1
  198. </select>
  199. <select id="openDropDownShow" resultType="com.template.model.vo.FreeVo">
  200. SELECT hn.id,
  201. hn.house_id as houseId,
  202. hn.room_number as roomNumber,
  203. hn.house_status as houseStatus,
  204. h.room_type as roomType
  205. FROM `house_number` hn
  206. LEFT JOIN house h ON h.id = hn.house_id
  207. AND h.deleted = 0
  208. WHERE hn.deleted = 0
  209. AND FIND_IN_SET(hn.id, #{houseNumberIds})
  210. AND hn.house_status = 1
  211. AND hn.electric_type = 2
  212. </select>
  213. <select id="roomChangePage" resultType="com.template.model.vo.HouseNumberVo">
  214. SELECT hn.id,
  215. hn.house_id as houseId,
  216. hn.room_number as roomNumber,
  217. hn.house_status as houseStatus,
  218. hn.electric_type as electricType,
  219. hn.electric_equipment_id as electricEquipmentId,
  220. hn.electric_equipment_meter_name as electricEquipmentMeterName,
  221. hn.water_equipment_id as waterEquipmentId,
  222. hn.water_equipment_meter_name as waterEquipmentMeterName,
  223. h.room_name as roomName,
  224. h.room_type as roomType,
  225. h.room_price as roomPrice
  226. FROM `house_number` hn
  227. LEFT JOIN house h on h.id = hn.house_id and hn.deleted = 0
  228. WHERE hn.house_id = #{houseId}
  229. AND hn.deleted = 0
  230. and hn.house_status = 1
  231. </select>
  232. <select id="pageList" resultType="com.template.model.vo.HouseNumberPageVo">
  233. SELECT
  234. hn.id,
  235. hn.house_id as houseId,
  236. hn.room_number as roomNumber,
  237. hn.house_status as houseStatus,
  238. hn.electric_type as electricType,
  239. hn.electric_equipment_id as electricEquipmentId,
  240. hn.electric_equipment_meter_name as electricEquipmentMeterName,
  241. hn.water_equipment_id as waterEquipmentId,
  242. hn.water_equipment_meter_name as waterEquipmentMeterName,
  243. hn.create_time as createTime,
  244. h.room_name as houseName,
  245. h.room_type as roomType
  246. FROM
  247. `house_number` hn
  248. LEFT JOIN house h on h.id=hn.house_id AND h.deleted=0
  249. LEFT JOIN building b ON b.id = hn.building_id
  250. AND b.deleted = 0
  251. WHERE
  252. hn.deleted=0
  253. <if test="keyWord != null and keyWord != ''">
  254. AND (hn.room_number LIKE '%' #{keyWord} '%' OR hn.electric_equipment_meter_name LIKE '%' #{keyWord} '%' OR
  255. hn.water_equipment_meter_name LIKE '%' #{keyWord} '%')
  256. </if>
  257. <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
  258. AND #{endTime} >= hn.create_time
  259. AND hn.create_time >= #{startTime}
  260. </if>
  261. <if test="houseId != null and houseId != ''">
  262. AND h.id = #{houseId}
  263. </if>
  264. <if test="buildingId != null and buildingId != ''">
  265. AND hn.building_id=#{buildingId}
  266. </if>
  267. ORDER BY h.id
  268. </select>
  269. <select id="listExport" resultType="com.template.model.vo.HouseNumberPageVo">
  270. SELECT
  271. hn.id,
  272. hn.house_id as houseId,
  273. hn.room_number as roomNumber,
  274. hn.house_status as houseStatus,
  275. hn.electric_type as electricType,
  276. hn.electric_equipment_id as electricEquipmentId,
  277. hn.electric_equipment_meter_name as electricEquipmentMeterName,
  278. hn.water_equipment_id as waterEquipmentId,
  279. hn.water_equipment_meter_name as waterEquipmentMeterName,
  280. hn.create_time as createTime,
  281. h.room_name as houseName,
  282. h.room_type as roomType
  283. FROM
  284. `house_number` hn
  285. LEFT JOIN house h on h.id=hn.house_id AND h.deleted=0
  286. LEFT JOIN building b ON b.id = hn.building_id
  287. AND b.deleted = 0
  288. WHERE
  289. hn.deleted=0
  290. <if test="keyWord != null and keyWord != ''">
  291. AND (hn.room_number LIKE '%' #{keyWord} '%' OR hn.electric_equipment_meter_name LIKE '%' #{keyWord} '%' OR
  292. hn.water_equipment_meter_name LIKE '%' #{keyWord} '%')
  293. </if>
  294. <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
  295. AND #{endTime} >= hn.create_time
  296. AND hn.create_time >= #{startTime}
  297. </if>
  298. <if test="houseId != null and houseId != ''">
  299. AND h.id = #{houseId}
  300. </if>
  301. <if test="buildingId != null and buildingId != ''">
  302. AND hn.building_id=#{buildingId}
  303. </if>
  304. ORDER BY h.id
  305. </select>
  306. <select id="getpage" resultType="com.template.model.vo.HouseNumberListVo">
  307. SELECT
  308. b.building as building,
  309. b.element,
  310. hl.equipment_type as doorLock,
  311. h.room_name as roomName,
  312. h.room_type as roomType,
  313. hn.id,
  314. hn.room_number AS roomNumber,
  315. hn.house_status AS houseStatus,
  316. hn.electric_type AS electricType,
  317. hn.electric_equipment_id AS electricEquipmentId,
  318. hn.electric_equipment_meter_name AS electricEquipmentMeterName,
  319. hn.water_equipment_id AS waterEquipmentId,
  320. hn.water_equipment_meter_name AS waterEquipmentMeterName,
  321. b.id as buildingId,
  322. h.id as houseId
  323. FROM
  324. `house_number` hn
  325. LEFT JOIN building b ON b.id = hn.building_id
  326. LEFT JOIN house_lock hl ON hl.house_number_id = hn.id
  327. LEFT JOIN house h ON h.id = hn.house_id
  328. WHERE
  329. hn.deleted=0
  330. <if test="keyWord != null and keyWord != ''">
  331. AND hn.room_number LIKE '%' #{keyWord} '%'
  332. </if>
  333. <if test="buildingId != null and buildingId != ''">
  334. AND b.id= #{buildingId}
  335. </if>
  336. <if test="houseId != null and houseId != ''">
  337. AND h.id= #{houseId}
  338. </if>
  339. ORDER BY b.building,b.element
  340. </select>
  341. </mapper>