TaBuildingMapper.xml 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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.huiju.estateagents.mapper.TaBuildingMapper">
  4. <select id="buildingList" resultType="com.huiju.estateagents.entity.TaBuilding">
  5. SELECT * FROM ta_building
  6. <where>
  7. status > -1
  8. <if test="Name != null and Name != ''">
  9. and (ta_building.name like concat('%',#{Name,jdbcType=VARCHAR},'%') or ta_building.building_name like concat('%',#{Name,jdbcType=VARCHAR},'%'))
  10. </if>
  11. <if test="Code != null and Code != ''">
  12. and ta_building.code like concat('%',#{Code,jdbcType=VARCHAR},'%')
  13. </if>
  14. <if test="startDate != null">
  15. and TO_DAYS(ta_building.opening_date ) = TO_DAYS(#{startDate})
  16. </if>
  17. <if test="buildingStatus != null and buildingStatus != ''">
  18. and ta_building.status = #{buildingStatus}
  19. </if>
  20. <if test="marketStatus != null and marketStatus != ''">
  21. and ta_building.market_status =#{marketStatus}
  22. </if>
  23. <if test="cityId != null and cityId != ''">
  24. and ta_building.city_id =#{cityId}
  25. </if>
  26. <if test="isMain != null">
  27. and ta_building.is_main = #{isMain}
  28. </if>
  29. <if test="orgId != null">
  30. and ta_building.org_id = #{orgId}
  31. </if>
  32. <if test="personBuildingList != null and personBuildingList.size > 0">
  33. AND ta_building.building_id in
  34. <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
  35. #{personBuilding.buildingId}
  36. </foreach>
  37. </if>
  38. </where>
  39. ORDER BY status ASC, create_date DESC
  40. </select>
  41. <select id="buildingListSelect" resultType="com.huiju.estateagents.entity.TaBuilding">
  42. SELECT * FROM ta_building
  43. <where>
  44. 1 =1
  45. and status = 1
  46. <if test="Name != null and Name != ''">
  47. and (ta_building.name like concat('%',#{Name,jdbcType=VARCHAR},'%') or ta_building.building_name like concat('%',#{Name,jdbcType=VARCHAR},'%'))
  48. </if>
  49. <if test="Code != null and Code != ''">
  50. and ta_building.code like concat('%',#{Code,jdbcType=VARCHAR},'%')
  51. </if>
  52. <if test="startDate != null">
  53. and TO_DAYS(ta_building.opening_date ) = TO_DAYS(#{startDate})
  54. </if>
  55. <if test="marketStatus != null and marketStatus != ''">
  56. and ta_building.market_status =#{marketStatus}
  57. </if>
  58. <if test="cityId != null and cityId != ''">
  59. and ta_building.city_id =#{cityId}
  60. </if>
  61. <if test="isMain != null and isMain != ''">
  62. and ta_building.is_main = #{isMain}
  63. </if>
  64. <if test="orgId != null and orgId != ''">
  65. and ta_building.org_id = #{orgId}
  66. </if>
  67. <if test="personBuildingList != null and personBuildingList.size > 0">
  68. AND ta_building.building_id in
  69. <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
  70. #{personBuilding.buildingId}
  71. </foreach>
  72. </if>
  73. </where>
  74. ORDER BY create_date DESC,status asc
  75. </select>
  76. <select id="buildingAll" resultType="com.huiju.estateagents.entity.TaBuilding">
  77. SELECT * FROM ta_building
  78. where status > -1
  79. and org_id = #{orgId}
  80. </select>
  81. <select id="selectBuilding" resultType="com.huiju.estateagents.entity.TaBuilding">
  82. SELECT * FROM ta_building
  83. where building_id = #{buildingId}
  84. </select>
  85. <select id="selectBuildingStatistical" resultType="map">
  86. select
  87. IFNULL(sum(pv_num), 0) as pvNum,
  88. <if test="saveOrShare == 'save'">
  89. IFNULL(sum(save_num),0) as saveNum
  90. </if>
  91. <if test="saveOrShare == 'share'">
  92. IFNULL(sum(share_num),0) as shareNum
  93. </if>
  94. from ta_building
  95. where org_id = ${orgId}
  96. </select>
  97. <select id="selectBuildingPage" resultType="com.huiju.estateagents.entity.TaBuilding">
  98. SELECT
  99. tb.*
  100. FROM
  101. (
  102. select * from ta_building
  103. WHERE
  104. `status` = 1
  105. and org_id = #{orgId}
  106. <if test="cityId != null">
  107. AND city_id = #{cityId}
  108. </if>
  109. <if test="targets != null and targets.size > 0">
  110. AND building_id IN
  111. <foreach collection="targets" item="buildingId" open="(" close=")" separator=",">
  112. #{buildingId}
  113. </foreach>
  114. </if>
  115. <if test="name != null and name !=''">
  116. AND (`name` LIKE CONCAT('%',#{name},'%')
  117. OR `building_name` LIKE CONCAT('%',#{name},'%'))
  118. </if>
  119. ) as tb
  120. <if test="(priceList != null and priceList.size > 0) or (buildingTypeList != null and buildingTypeList.length > 0)">
  121. INNER JOIN
  122. (
  123. SELECT * FROM ta_building_project_type
  124. <trim prefix="where" prefixOverrides="and | or">
  125. <if test="priceList != null">
  126. <foreach collection="priceList" item="priceArr" open="(" close=")" separator=" OR ">
  127. (
  128. <if test='priceArr[0] != null and priceArr[0] != ""'>
  129. <![CDATA[ start_price >= ${priceArr[0]} ]]>
  130. </if>
  131. <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
  132. AND
  133. </if>
  134. <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
  135. <![CDATA[ start_price <= ${priceArr[1]} ]]>
  136. </if>
  137. ) or
  138. (
  139. <if test='priceArr[0] != null and priceArr[0] != ""'>
  140. <![CDATA[ end_price >= ${priceArr[0]} ]]>
  141. </if>
  142. <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
  143. AND
  144. </if>
  145. <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
  146. <![CDATA[ end_price <= ${priceArr[1]} ]]>
  147. </if>
  148. )
  149. </foreach>
  150. </if>
  151. <if test="priceType != null and priceType != ''">
  152. and price_type = #{priceType}
  153. </if>
  154. <if test="buildingTypeList != null and buildingTypeList.length > 0">
  155. AND building_type_id in
  156. <foreach collection="buildingTypeList" item="buildingType" open="(" close=")" separator=",">
  157. #{buildingType}
  158. </foreach>
  159. </if>
  160. </trim>
  161. GROUP BY building_id
  162. )
  163. AS tbpt ON tb.building_id = tbpt.building_id
  164. </if>
  165. <if test="(areaList != null and areaList.size > 0) or (houseTypeList != null and houseTypeList.length > 0)">
  166. INNER JOIN
  167. (
  168. SELECT * FROM ta_building_apartment
  169. <trim prefix="where" prefixOverrides="and | or">
  170. <if test="areaList != null">
  171. <foreach collection="areaList" item="areaArr" open="(" close=")" separator=" OR ">
  172. (
  173. <if test='areaArr[0] != null and areaArr[0] != ""'>
  174. <![CDATA[ building_area >= ${areaArr[0]} ]]>
  175. </if>
  176. <if test='areaArr.length > 1 and areaArr[0] != null and areaArr[0] != ""'>
  177. AND
  178. </if>
  179. <if test='areaArr.length > 1 and areaArr[1] != null and areaArr[1] != ""'>
  180. <![CDATA[ building_area <= ${areaArr[1]} ]]>
  181. </if>
  182. )
  183. </foreach>
  184. </if>
  185. <if test="houseTypeList != null and houseTypeList.length > 0">
  186. AND house_type in
  187. <foreach collection="houseTypeList" item="houseType" open="(" close=")" separator=",">
  188. #{houseType}
  189. </foreach>
  190. </if>
  191. </trim>
  192. GROUP BY building_id
  193. ) as tba ON tb.building_id = tba.building_id
  194. </if>
  195. WHERE tb.org_id = #{orgId}
  196. ORDER BY tb.order_no DESC
  197. </select>
  198. <select id="selectBuildingByBuildingTypeId" resultType="com.huiju.estateagents.entity.TaBuilding">
  199. SELECT
  200. tab.*
  201. FROM
  202. ta_building_project_type tbpt
  203. LEFT JOIN td_building_type tbt ON tbpt.building_type_id = tbt.building_type_id
  204. LEFT JOIN ta_building tab ON tbpt.building_id = tab.building_id
  205. WHERE
  206. tab.status <![CDATA[ > ]]> -1
  207. and
  208. tbpt.building_type_id = #{buildingTypeId}
  209. </select>
  210. <select id="getBuildingListById" resultType="com.huiju.estateagents.entity.TaBuilding">
  211. select * from ta_building t where t.building_id in (
  212. select t.building_id from ta_goods t where t.org_id = #{orgId} and t.city_id = #{cityId} and `status`=1 group by t.building_id
  213. )
  214. </select>
  215. <select id="countNumByHeavy" resultType="java.lang.Integer">
  216. select COUNT(1) from ta_building_dynamic t where t.heavy = #{heavy}
  217. <if test="dynamicId != null and dynamicId != ''">
  218. and t.dynamic_id != #{dynamicId}
  219. </if>
  220. </select>
  221. <select id="selectMainBuildings" resultType="com.huiju.estateagents.entity.TaBuilding">
  222. SELECT
  223. t.*,
  224. s.url AS list_poster,
  225. GROUP_CONCAT( m.tag_name ) AS tags
  226. FROM
  227. ta_building t
  228. LEFT JOIN ta_building_img s ON t.building_id = s.building_id
  229. AND s.img_type = 'list'
  230. LEFT JOIN ta_building_tag m ON t.building_id = m.building_id
  231. WHERE
  232. t.org_id = #{orgId}
  233. <if test="cityId != null and cityId != ''">
  234. AND t.city_id = #{cityId}
  235. </if>
  236. AND t.status = 1
  237. AND t.is_main = 1
  238. GROUP BY
  239. t.building_id
  240. ORDER BY t.order_no desc
  241. </select>
  242. </mapper>