HouseNumberMapper.xml 17 KB

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