ParkDao.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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="platform.modules.carrier.dao.ParkDao">
  4. <select id="getParkListByCondition" resultType="platform.modules.carrier.entity.Park">
  5. select * from ic_park
  6. where del_flag = 0
  7. <if test="condition.no != null and condition.no != ''">
  8. and `no` like concat('%', concat(#{condition.no}, '%'))
  9. </if>
  10. <if test="condition.parkName != null and condition.parkName != ''">
  11. and name like concat('%', concat(#{condition.parkName}, '%'))
  12. </if>
  13. <if test="condition.area != null and condition.area != ''">
  14. and area >= #{condition.area}
  15. </if>
  16. <if test="condition.restArea != null and condition.restArea != ''">
  17. and rest_area >= #{condition.restArea}
  18. </if>
  19. <if test="condition.restRentArea != null and condition.restRentArea != ''">
  20. and rest_rent_area >= #{condition.restRentArea}
  21. </if>
  22. <if test="condition.transformer != null and condition.transformer != ''">
  23. and transformer = #{condition.transformer}
  24. </if>
  25. <if test="condition.isProperty != null and condition.isProperty != ''">
  26. and is_property = #{condition.isProperty}
  27. </if>
  28. <if test="condition.kvaCompensate != null and condition.kvaCompensate != ''">
  29. and kva_compensate = #{condition.kvaCompensate}
  30. </if>
  31. </select>
  32. <select id="findParkList" resultType="platform.modules.carrier.entity.Park">
  33. select
  34. p.*,
  35. s.name as streetName,
  36. (select COALESCE(sum(f.area),0) from y_floor f left join ic_building b on b.id = f.building_id where f.del_flag = false and b.park_id = p.id) AS sumBuildArea,
  37. (select COALESCE(sum(f.remain_area),0) from y_floor f left join ic_building b on b.id = f.building_id where f.del_flag = false and b.park_id = p.id) AS sumRestArea,
  38. IFNULL((SELECT COUNT(id) FROM ic_building WHERE park_id = p.id AND del_flag = 0 AND is_use = 1),0) AS buildingNum
  39. from ic_park p
  40. left join s_street s on s.id = p.street_id
  41. where
  42. p.del_flag = false and p.is_start = 1
  43. <if test="condition.streetId != null and condition.streetId != ''">
  44. and s.id = #{condition.streetId}
  45. </if>
  46. <if test="condition.parkId != null and condition.parkId != ''">
  47. and (p.id = #{condition.parkId} or p.id IN (SELECT park_id FROM ic_sub_park WHERE parent_id = #{condition.parkId}))
  48. </if>
  49. <if test="condition.parkName != null and condition.parkName != ''">
  50. and p.name like concat('%', concat(#{condition.parkName}, '%'))
  51. </if>
  52. order by CONVERT( p.name USING gbk ) COLLATE gbk_chinese_ci ASC
  53. </select>
  54. <update id="updateNoBatch" parameterType="list">
  55. update ic_park
  56. <trim prefix="set" suffixOverrides=",">
  57. <trim prefix="no =case" suffix="end,">
  58. <foreach collection="list" item="i" index="index">
  59. <if test="i.no!=null">
  60. when id=#{i.id} then #{i.no}
  61. </if>
  62. </foreach>
  63. </trim>
  64. </trim>
  65. where
  66. <foreach collection="list" separator="or" item="i" index="index">
  67. id=#{i.id}
  68. </foreach>
  69. </update>
  70. <resultMap id="parkBuildingList" type="platform.modules.carrier.dto.ParkDto">
  71. <id column="park_id" jdbcType="INTEGER" property="id"/>
  72. <result column="name" jdbcType="VARCHAR" property="name"/>
  73. <collection property="treeList" ofType="platform.modules.carrier.dto.BuildingDto">
  74. <id column="building_id" jdbcType="INTEGER" property="id"/>
  75. <result column="build_name" jdbcType="VARCHAR" property="build_name"/>
  76. <collection property="floorDtos" ofType="platform.modules.carrier.dto.FloorDto">
  77. <id column="floor_id" jdbcType="INTEGER" property="id"/>
  78. <result column="area" jdbcType="NUMERIC" property="area"/>
  79. <result column="remain_area" jdbcType="NUMERIC" property="remain_area"/>
  80. <result column="floor" jdbcType="VARCHAR" property="floor"/>
  81. </collection>
  82. </collection>
  83. </resultMap>
  84. <select id="findParkBuildingList" resultMap="parkBuildingList"
  85. parameterType="platform.modules.carrier.dto.CustomSearchCondition">
  86. SELECT
  87. park.id park_id,
  88. park. NAME,
  89. building.id building_id,
  90. building.build_name,
  91. floor.id floor_id,
  92. floor.area,
  93. floor.floor,
  94. floor.remain_area
  95. FROM
  96. ic_park park
  97. LEFT JOIN ic_building building ON building.park_id = park.id
  98. LEFT JOIN y_floor floor ON floor.building_id = building.id
  99. LEFT JOIN s_street street ON street.id = park.street_id
  100. WHERE park.del_flag = false and park.is_start = true
  101. <if test="param.street_id != null and param.street_id != '' ">
  102. AND street.id = #{param.street_id}
  103. </if>
  104. <if test="param.park_id != null and param.park_id != '' ">
  105. AND park.id = #{param.park_id}
  106. <if test="param.is_parent != null and param.is_parent != ''">
  107. OR park.id IN (SELECT park_id FROM ic_sub_park WHERE parent_id = #{param.park_id})
  108. </if>
  109. </if>
  110. </select>
  111. <select id="getParkStatistic" resultType="platform.modules.carrier.dto.CarrierLibraryResult">
  112. SELECT
  113. p.id,
  114. p.NO,
  115. p.`name`,
  116. IFNULL((SELECT SUM(b.area) FROM ic_building b WHERE b.park_id = p.id AND del_flag = 0 AND is_use = 1),0) AS sumBuildArea,
  117. IFNULL((SELECT SUM(f.remain_area) FROM ic_building b LEFT JOIN y_floor f ON f.building_id = b.id WHERE b.park_id = p.id AND b.del_flag = 0 AND b.is_use = 1 AND f.del_flag = 0 AND f.is_use = 1),0) AS sumRestArea,
  118. IFNULL((SELECT COUNT(id) FROM ic_building WHERE park_id = p.id AND del_flag = 0 AND is_use = 1),0) AS buildingNum
  119. FROM
  120. ic_park p
  121. WHERE
  122. p.del_flag = FALSE AND p.is_start = TRUE
  123. AND p.street_id = #{id}
  124. GROUP BY
  125. p.id
  126. </select>
  127. <select id="getParkAreaStatistic" resultType="platform.modules.carrier.dto.CarrierLibraryResult">
  128. SELECT
  129. SUM( b.area ) AS sumBuildArea,
  130. SUM( f.remain_area ) AS sumRestArea
  131. FROM
  132. ic_building b
  133. LEFT JOIN y_floor f ON f.building_id = b.id
  134. WHERE
  135. b.del_flag = FALSE AND f.del_flag = FALSE AND f.is_use = TRUE
  136. AND b.park_id = #{id}
  137. </select>
  138. <select id="getParkRentAreaStatistic" resultType="java.lang.Double">
  139. SELECT
  140. IFNULL(SUM( cf.area ),0)
  141. FROM
  142. ic_building b
  143. LEFT JOIN y_floor f ON f.building_id = b.id
  144. LEFT JOIN ic_contract_floor cf ON cf.floor_id = f.id
  145. WHERE
  146. b.del_flag = FALSE
  147. AND b.park_id = #{id} AND cf.status = 2
  148. AND cf.contract_end > NOW( )
  149. </select>
  150. <select id="findByStreetId" resultType="platform.modules.carrier.entity.Park">
  151. select id, `name` from ic_park
  152. WHERE del_flag = FALSE
  153. AND street_id = #{id}
  154. </select>
  155. <select id="findParkNames" resultType="platform.modules.carrier.entity.Park">
  156. select
  157. p.id,
  158. p.name
  159. from ic_park p
  160. left join s_street s on s.id = p.street_id
  161. where
  162. p.del_flag = false and p.is_start = true and p.is_start = 1
  163. <if test="condition.streetId != null and condition.streetId != ''">
  164. and s.id = #{condition.streetId}
  165. </if>
  166. <if test="condition.parkId != null and condition.parkId != ''">
  167. and (p.id = #{condition.parkId} or p.id IN (SELECT park_id FROM ic_sub_park WHERE parent_id = #{condition.parkId}))
  168. </if>
  169. order by CONVERT( p.name USING gbk ) COLLATE gbk_chinese_ci ASC
  170. </select>
  171. <select id="findParentParkById" resultType="platform.modules.carrier.entity.Park">
  172. SELECT * FROM ic_sub_park WHERE parent_id = #{park_id}
  173. </select>
  174. <select id="findbyNo" resultType="platform.modules.carrier.entity.Park">
  175. SELECT * FROM ic_park WHERE no = #{no} and del_flag = false
  176. </select>
  177. <select id="findBuildingNum" resultType="java.lang.Integer">
  178. select count(id) from ic_building where park_id = #{id} and del_flag = false and is_use = true
  179. </select>
  180. <select id="findParkRemainArea" resultType="java.lang.Double">
  181. SELECT IFNULL(SUM(f.remain_area),0) FROM ic_building b LEFT JOIN y_floor f ON f.building_id = b.id WHERE b.park_id = #{id} AND b.del_flag = 0 AND b.is_use = 1 AND f.del_flag = 0 AND f.is_use = 1
  182. </select>
  183. </mapper>