TaBuildingMapper.xml 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 > 0
  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. </where>
  33. ORDER BY status ASC, create_date DESC
  34. </select>
  35. <select id="buildingListSelect" resultType="com.huiju.estateagents.entity.TaBuilding">
  36. SELECT * FROM ta_building
  37. <where>
  38. 1 =1
  39. <if test="Name != null and Name != ''">
  40. and (ta_building.name like concat('%',#{Name,jdbcType=VARCHAR},'%') or ta_building.building_name like concat('%',#{Name,jdbcType=VARCHAR},'%'))
  41. </if>
  42. <if test="Code != null and Code != ''">
  43. and ta_building.code like concat('%',#{Code,jdbcType=VARCHAR},'%')
  44. </if>
  45. <if test="startDate != null">
  46. and TO_DAYS(ta_building.opening_date ) = TO_DAYS(#{startDate})
  47. </if>
  48. <if test="marketStatus != null and marketStatus != ''">
  49. and ta_building.market_status =#{marketStatus}
  50. </if>
  51. <if test="cityId != null and cityId != ''">
  52. and ta_building.city_id =#{cityId}
  53. </if>
  54. <if test="isMain != null and isMain != ''">
  55. and ta_building.is_main = #{isMain}
  56. </if>
  57. <if test="orgId != null and orgId != ''">
  58. and ta_building.org_id = #{orgId}
  59. </if>
  60. </where>
  61. ORDER BY create_date DESC,status asc
  62. </select>
  63. <select id="buildingAll" resultType="com.huiju.estateagents.entity.TaBuilding">
  64. SELECT * FROM ta_building
  65. where status > -1
  66. and org_id = #{orgId}
  67. </select>
  68. <select id="selectBuilding" resultType="com.huiju.estateagents.entity.TaBuilding">
  69. SELECT * FROM ta_building
  70. where building_id = #{buildingId}
  71. </select>
  72. <select id="selectBuildingStatistical" resultType="map">
  73. select
  74. IFNULL(sum(pv_num), 0) as pvNum,
  75. <if test="saveOrShare == 'save'">
  76. IFNULL(sum(save_num),0) as saveNum
  77. </if>
  78. <if test="saveOrShare == 'share'">
  79. IFNULL(sum(share_num),0) as shareNum
  80. </if>
  81. from ta_building
  82. where org_id = ${orgId}
  83. </select>
  84. <select id="selectBuildingPage" resultType="com.huiju.estateagents.entity.TaBuilding">
  85. SELECT
  86. tb.*
  87. FROM
  88. (
  89. select * from ta_building
  90. WHERE
  91. `status` = 1
  92. and org_id = #{orgId}
  93. <if test="cityId != null">
  94. AND city_id = #{cityId}
  95. </if>
  96. <if test="targets != null and targets.size > 0">
  97. AND building_id IN
  98. <foreach collection="targets" item="buildingId" open="(" close=")" separator=",">
  99. #{buildingId}
  100. </foreach>
  101. </if>
  102. <if test="name != null and name !=''">
  103. AND (`name` LIKE CONCAT('%',#{name},'%')
  104. OR `building_name` LIKE CONCAT('%',#{name},'%'))
  105. </if>
  106. ) as tb
  107. <if test="(priceList != null and priceList.size > 0) or (buildingTypeList != null and buildingTypeList.length > 0)">
  108. INNER JOIN
  109. (
  110. SELECT * FROM ta_building_project_type
  111. <trim prefix="where" prefixOverrides="and | or">
  112. <if test="priceList != null">
  113. <foreach collection="priceList" item="priceArr" open="(" close=")" separator=" OR ">
  114. (
  115. <if test='priceArr[0] != null and priceArr[0] != ""'>
  116. <![CDATA[ price >= ${priceArr[0]} ]]>
  117. </if>
  118. <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
  119. AND
  120. </if>
  121. <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
  122. <![CDATA[ price <= ${priceArr[1]} ]]>
  123. </if>
  124. )
  125. </foreach>
  126. </if>
  127. <if test="buildingTypeList != null and buildingTypeList.length > 0">
  128. AND building_type_id in
  129. <foreach collection="buildingTypeList" item="buildingType" open="(" close=")" separator=",">
  130. #{buildingType}
  131. </foreach>
  132. </if>
  133. </trim>
  134. GROUP BY building_id
  135. )
  136. AS tbpt ON tb.building_id = tbpt.building_id
  137. </if>
  138. <if test="(areaList != null and areaList.size > 0) or (houseTypeList != null and houseTypeList.length > 0)">
  139. INNER JOIN
  140. (
  141. SELECT * FROM ta_building_apartment
  142. <trim prefix="where" prefixOverrides="and | or">
  143. <if test="areaList != null">
  144. <foreach collection="areaList" item="areaArr" open="(" close=")" separator=" OR ">
  145. (
  146. <if test='areaArr[0] != null and areaArr[0] != ""'>
  147. <![CDATA[ building_area >= ${areaArr[0]} ]]>
  148. </if>
  149. <if test='areaArr.length > 1 and areaArr[0] != null and areaArr[0] != ""'>
  150. AND
  151. </if>
  152. <if test='areaArr.length > 1 and areaArr[1] != null and areaArr[1] != ""'>
  153. <![CDATA[ building_area <= ${areaArr[1]} ]]>
  154. </if>
  155. )
  156. </foreach>
  157. </if>
  158. <if test="houseTypeList != null and houseTypeList.length > 0">
  159. AND house_type in
  160. <foreach collection="houseTypeList" item="houseType" open="(" close=")" separator=",">
  161. #{houseType}
  162. </foreach>
  163. </if>
  164. </trim>
  165. GROUP BY building_id
  166. ) as tba ON tb.building_id = tba.building_id
  167. </if>
  168. WHERE tb.org_id = #{orgId}
  169. ORDER BY tb.order_no DESC
  170. </select>
  171. <select id="selectBuildingByBuildingTypeId" resultType="com.huiju.estateagents.entity.TaBuilding">
  172. SELECT
  173. tab.*
  174. FROM
  175. ta_building_project_type tbpt
  176. LEFT JOIN td_building_type tbt ON tbpt.building_type_id = tbt.building_type_id
  177. LEFT JOIN ta_building tab ON tbpt.building_id = tab.building_id
  178. WHERE
  179. tab.status <![CDATA[ > ]]> -1
  180. and
  181. tbpt.building_type_id = #{buildingTypeId}
  182. </select>
  183. <select id="getBuildingListById" resultType="com.huiju.estateagents.entity.TaBuilding">
  184. select * from ta_building t where t.building_id in (
  185. 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
  186. )
  187. </select>
  188. <select id="countNumByHeavy" resultType="java.lang.Integer">
  189. select COUNT(1) from ta_building_dynamic t where t.heavy = #{heavy}
  190. <if test="dynamicId != null and dynamicId != ''">
  191. and t.dynamic_id != #{dynamicId}
  192. </if>
  193. </select>
  194. </mapper>