HouseNumberMapper.xml 14 KB

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