| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="platform.modules.carrier.dao.BuildingDao">
- <select id="getParkBuildings" resultType="platform.modules.carrier.entity.Building">
- select * from ic_building
- where del_flag = 0
- <if test="condition.parkId != null and condition.parkId !=''">
- and park_id = #{condition.parkId}
- </if>
- <if test="condition.is_use != null and condition.is_use !=''">
- and is_use = #{condition.is_use}
- </if>
- <if test="condition.totalFloors != null and condition.totalFloors !=''">
- and floor_count = #{condition.totalFloors}
- </if>
- <if test="condition.buildName != null and condition.buildName !=''">
- and build_name like concat('%', concat(#{condition.buildName},'%'))
- </if>
- <if test="condition.no != null and condition.no !=''">
- and no = #{condition.no}
- </if>
- <if test="condition.carrierAttriute != null and condition.carrierAttriute !=''">
- and carrier_attriute = #{condition.carrierAttriute}
- </if>
- <if test="condition.carrierNature != null and condition.carrierNature !=''">
- and carrier_nature = #{condition.carrierNature}
- </if>
- <if test="condition.build_use != null and condition.build_use != ''">
- and build_use = #{condition.build_use}
- </if>
- order by create_time desc
- </select>
- <select id="getBuildingsByQuery" resultType="platform.modules.carrier.entity.Building">
- select
- DISTINCT b.*,
- p.name as park_name,
- s.name as street_name,
- p.contact,
- p.phone
- from ic_building b
- left join y_floor f on f.building_id = b.id
- left join ic_park p on p.id = b.park_id
- left join s_street s on s.id = p.street_id
- where b.del_flag = 0 and b.is_use = 1 and f.is_use = 1 and f.del_flag = 0 and p.is_start = 1 and p.del_flag = 0
- <if test="query.streetId != null and query.streetId != ''">
- and s.id in ( #{query.streetId} )
- </if>
- <if test="query.parkId != null and query.parkId != ''">
- and p.id in (#{query.parkId})
- </if>
- <choose>
- <when test="query.count != null and query.count == 1">
- <choose>
- <when test="query.demandDate != null and query.demandDate != ''">
- and (f.remain_area +
- (
- IFNULL(
- (
- SELECT
- IFNULL(SUM( cf.area ),0)
- FROM
- ic_contract_floor cf
- WHERE
- cf.floor_id = f.id AND cf.status = 2
- AND cf.contract_end > NOW() AND cf.contract_end <![CDATA[ < ]]> #{query.demandDate}
- )
- , 0 )
- ))
- >0
- <if test="query.minArea != null and query.minArea != ''">
- and (f.remain_area +
- (
- IFNULL(
- (
- SELECT
- IFNULL(SUM( cf.area ),0)
- FROM
- ic_contract_floor cf
- WHERE
- cf.floor_id = f.id AND cf.status = 2
- AND cf.contract_end > NOW() AND cf.contract_end <![CDATA[ < ]]> #{query.demandDate}
- ), 0)
- ))
- >= #{query.minArea}
- </if>
- <if test="query.maxArea != null and query.maxArea != ''">
- and (f.remain_area +
- (
- IFNULL(
- (
- SELECT
- IFNULL(SUM( cf.area ),0)
- FROM
- ic_contract_floor cf
- WHERE
- cf.floor_id = f.id AND cf.status = 2
- AND cf.contract_end > NOW() AND cf.contract_end <![CDATA[ < ]]> #{query.demandDate}
- ),0)
- ))
- <![CDATA[ <= ]]> #{query.maxArea}
- </if>
- </when>
- <otherwise>
- and f.remain_area > 0
- <if test="query.minArea != null and query.minArea != ''">
- and f.remain_area >= #{query.minArea}
- </if>
- <if test="query.maxArea != null and query.maxArea != ''">
- and f.remain_area <![CDATA[ <= ]]> #{query.maxArea}
- </if>
- </otherwise>
- </choose>
- </when>
- <otherwise>
- <choose>
- <when test="query.demandDate != null and query.demandDate != ''">
- and ((select IFNULL(SUM(remain_area),0) from y_floor where building_id = b.id AND del_flag = 0 AND is_use = 1) +
- (
- IFNULL(
- (
- SELECT
- IFNULL(SUM( cf.area ),0)
- FROM
- ic_contract_floor cf
- WHERE
- cf.building_id = b.id AND cf.status = 2
- AND cf.contract_end > NOW() AND cf.contract_end <![CDATA[ < ]]> #{query.demandDate}
- ),
- 0 )
- ))
- > 0
- <if test="query.minArea != null and query.minArea != ''">
- and ((select IFNULL(SUM(remain_area),0) from y_floor where building_id = b.id AND del_flag = 0 AND is_use = 1) +
- (
- IFNULL(
- (
- SELECT
- IFNULL(SUM( cf.area ),0)
- FROM
- ic_contract_floor cf
- WHERE
- cf.building_id = b.id AND cf.status = 2
- AND cf.contract_end > NOW() AND cf.contract_end <![CDATA[ < ]]> #{query.demandDate}
- ),
- 0)
- ))
- >= #{query.minArea}
- </if>
- <if test="query.maxArea != null and query.maxArea != ''">
- and ((select IFNULL(SUM(remain_area),0) from y_floor where building_id = b.id AND del_flag = 0 AND is_use = 1) +
- (
- IFNULL(
- (
- SELECT
- IFNULL(SUM( cf.area ),0)
- FROM
- ic_contract_floor cf
- WHERE
- cf.building_id = b.id AND cf.status = 2
- AND cf.contract_end > NOW() AND cf.contract_end <![CDATA[ < ]]> #{query.demandDate}
- ),
- 0 )
- ))
- <![CDATA[ <= ]]> #{query.maxArea}
- </if>
- <if test="query.minFloorArea != null and query.minFloorArea != ''">
- and (f.remain_area +
- (
- IFNULL(
- (
- SELECT
- IFNULL(SUM( cf.area ),0)
- FROM
- ic_contract_floor cf
- WHERE
- cf.floor_id = f.id AND cf.status = 2
- AND cf.contract_end > NOW() AND cf.contract_end <![CDATA[ < ]]> #{query.demandDate}
- ),
- 0)
- ))
- <![CDATA[ >= ]]> #{query.minFloorArea}
- </if>
- </when>
- <otherwise>
- and (select IFNULL(SUM(remain_area),0) from y_floor where building_id = b.id AND del_flag = 0 AND is_use = 1) > 0
- <if test="query.minArea != null and query.minArea != ''">
- and (select IFNULL(SUM(remain_area),0) from y_floor where building_id = b.id AND del_flag = 0 AND is_use = 1) >= #{query.minArea}
- </if>
- <if test="query.maxArea != null and query.maxArea != ''">
- and (select IFNULL(SUM(remain_area),0) from y_floor where building_id = b.id AND del_flag = 0 AND is_use = 1) <![CDATA[ <= ]]> #{query.maxArea}
- </if>
- </otherwise>
- </choose>
- </otherwise>
- </choose>
- <if test="query.carrierAttriute != null and query.carrierAttriute != ''">
- and b.carrier_attriute in (#{query.carrierAttriute})
- </if>
- <if test="query.carrierNature != null and query.carrierNature != ''">
- and b.carrier_nature = #{query.carrierNature}
- </if>
- <if test="query.carrierStructure != null and query.carrierStructure != ''">
- and b.carrier_structure in (#{query.carrierStructure})
- </if>
- <if test="query.landingPlatformCount != null and query.landingPlatformCount != ''">
- and b.landing_platform_count >= #{query.landingPlatformCount}
- </if>
- <if test="query.intercolumniation != null and query.intercolumniation != ''">
- and b.intercolumniation >= #{query.intercolumniation}
- </if>
- <if test="query.spqn != null and query.spqn != ''">
- and b.spqn in (#{query.spqn})
- </if>
- <if test="query.liftLoadBearing != null and query.liftLoadBearing != ''">
- and b.lift_load_bearing >= #{query.liftLoadBearing}
- </if>
- <if test="query.capacity != null and query.capacity != ''">
- and f.capacity >= #{query.capacity}
- </if>
- <if test="query.floorHeight != null and query.floorHeight != ''">
- and b.floor_height is not null and b.floor_height >= #{query.floorHeight}
- </if>
- <if test="query.build_use != null and query.build_use != ''">
- and b.build_use in (#{query.build_use})
- </if>
- </select>
- <select id="findBuildingList" resultType="platform.modules.carrier.dto.BuildingFloorVo"
- parameterType="platform.modules.carrier.dto.CustomSearchCondition">
- SELECT
- park.name park_name,
- building.id building_id,
- building.build_name building_name,
- floor.floor floor,
- floor.id floor_id,
- floor.floor_height,
- floor.capacity,
- floor.is_use isUse
- FROM
- y_floor floor
- JOIN ic_building building ON building.id = floor.building_id
- LEFT JOIN ic_park park ON park.id = building.park_id
- WHERE
- floor.del_flag = 0 and floor.is_use = 1
- AND building.del_flag = 0 and building.is_use = 1
- AND park.del_flag = 0 AND park.is_start = 1
- <if test="condition.park_id != null and condition.park_id != ''">
- AND park.id = #{condition.park_id}
- </if>
- <if test="condition.building_id != null and condition.building_id != ''">
- AND building.id = #{condition.building_id}
- </if>
- <if test="condition.building_name != null and condition.building_name != ''">
- AND building.build_name like concat('%', concat(#{condition.building_name}, '%'))
- </if>
- <if test="condition.isUse != null and condition.isUse != ''">
- AND floor.is_use = #{condition.isUse}
- </if>
- ORDER BY building.id DESC
- </select>
- <select id="findBuildingByCondition" resultType="platform.modules.carrier.entity.Building">
- select * from ic_building b
- left join ic_park p on p.id = b.park_id
- left join s_street s on s.id = p.street_id
- where b.del_flag = 0 and p.del_flag = 0 and s.del_flag = 0
- <if test="condition.no != null and condition.no != ''">
- and b.`no` like concat('%', concat(#{condition.no}, '%'))
- </if>
- <if test="condition.buildName != null and condition.buildName != ''">
- and b.build_name like concat('%', concat(#{condition.buildName}, '%'))
- </if>
- <if test="condition.streetNo != null and condition.streetNo != ''">
- and s.`no` = #{condition.streetNo}
- </if>
- <if test="condition.parkNo != null and condition.parkNo != ''">
- and p.`no` = #{condition.parkNo}
- </if>
- <if test="condition.streetId != null and condition.streetId != ''">
- and s.id = #{condition.streetId}
- </if>
- <if test="condition.parkId != null and condition.parkId != ''">
- and b.park_id = #{condition.parkId}
- </if>
- <if test="condition.minArea != null and condition.minArea != ''">
- and b.area >= #{condition.minArea}
- </if>
- <if test="condition.maxArea != null and condition.maxArea != ''">
- and b.area <![CDATA[ <= ]]> #{condition.maxArea}
- </if>
- <if test="condition.totalFloors != null and condition.totalFloors != ''">
- and b.floor_count = #{condition.totalFloors}
- </if>
- <if test="condition.build_use != null and condition.build_use != ''">
- and b.build_use = #{condition.build_use}
- </if>
- </select>
- <update id="updateNoBatch" parameterType="list">
- update ic_building
- <trim prefix="set" suffixOverrides=",">
- <trim prefix="no =case" suffix="end,">
- <foreach collection="list" item="i" index="index">
- <if test="i.no!=null">
- when id=#{i.id} then #{i.no}
- </if>
- </foreach>
- </trim>
- </trim>
- where
- <foreach collection="list" separator="or" item="i" index="index" >
- id=#{i.id}
- </foreach>
- </update>
- <select id="getBuildingStatistic" resultType="platform.modules.carrier.entity.Building">
- SELECT
- b.*
- FROM
- ic_building b
- WHERE
- b.del_flag = FALSE AND b.is_use = 1
- AND b.park_id = #{condition.parkId}
- <if test="condition.is_use != null and condition.is_use !=''">
- and b.is_use = #{condition.is_use}
- </if>
- <if test="condition.totalFloors != null and condition.totalFloors !=''">
- and b.floor_count = #{condition.totalFloors}
- </if>
- <if test="condition.buildName != null and condition.buildName !=''">
- and b.build_name like concat('%', concat(#{condition.buildName},'%'))
- </if>
- <if test="condition.no != null and condition.no !=''">
- and b.no like concat('%', concat(#{condition.no},'%'))
- </if>
- <if test="condition.carrierAttriute != null and condition.carrierAttriute !=''">
- and b.carrier_attriute = #{condition.carrierAttriute}
- </if>
- <if test="condition.carrierNature != null and condition.carrierNature !=''">
- and b.carrier_nature = #{condition.carrierNature}
- </if>
- <if test="condition.build_use != null and condition.build_use != ''">
- and b.build_use = #{condition.build_use}
- </if>
- order by b.create_time desc
- </select>
- <select id="getBuildAreaStatistic" resultType="platform.modules.carrier.dto.CarrierLibraryResult">
- SELECT
- IFNULL(SUM( f.remain_area ), 0) AS sumRestArea
- FROM
- ic_building b
- LEFT JOIN y_floor f ON f.building_id = b.id
- WHERE
- b.del_flag = FALSE AND b.is_use = 1 AND f.del_flag = FALSE AND f.is_use = 1
- and b.id = #{id}
- </select>
- <select id="getBuildRentAreaStatistic" resultType="java.lang.Double">
- SELECT
- IFNULL(SUM( cf.area ),0)
- FROM
- ic_building b
- LEFT JOIN y_floor f ON f.building_id = b.id
- LEFT JOIN ic_contract_floor cf ON cf.floor_id = f.id
- WHERE
- b.del_flag = FALSE AND b.is_use = 1 AND f.del_flag = FALSE AND f.is_use = 1 AND cf.status = 2
- AND cf.contract_end > NOW( )
- and b.id = #{id}
- </select>
- <select id="findBuildingNumByParkId" resultType="java.lang.Integer">
- select count(id) from ic_building
- where park_id = #{id}
- </select>
- <select id="getBuildingCount" resultType="java.lang.Integer">
- select count(id) from ic_building where del_flag = TRUE AND is_use =TRUE AND park_id = #{id}
- </select>
- <select id="findBuildingRemainArea" resultType="java.lang.Double">
- select IFNULL(SUM(remain_area),0)
- <if test="query.demandDate != null and query.demandDate != ''">
- + IFNULL((SELECT SUM(area) FROM ic_contract_floor WHERE contract_end <![CDATA[ < ]]> #{query.demandDate} AND building_id = #{query.building_id} AND status = 2), 0)
- </if>
- from y_floor where del_flag = false AND is_use = true AND building_id = #{query.building_id}
- </select>
- <select id="findBySteetId" resultType="platform.modules.carrier.entity.Building">
- SELECT
- b.id,
- b.build_name,
- IFNULL(
- b.area,
- (
- SELECT
- SUM(
- IFNULL(
- area,
- ( remain_area + ( SELECT SUM( area ) FROM ic_contract_floor cf WHERE cf.building_id = b.id AND cf.floor = floor AND `status` = 2) )
- )
- )
- FROM
- y_floor
- WHERE
- building_id = b.id
- )
- ) AS area
- FROM
- ic_building b
- LEFT JOIN ic_park p ON p.id = b.park_id
- WHERE
- p.street_id = #{id}
- AND b.is_use = 1
- AND b.del_flag = 0
- AND p.del_flag = 0
- AND p.is_start = 1
- </select>
- <select id="findStreetTotalArea" resultType="java.lang.Double">
- SELECT
- IFNULL(
- sum(
- IFNULL(
- b.area,
- (
- SELECT
- SUM(
- IFNULL(
- area,
- ( remain_area + ( SELECT SUM( area ) FROM ic_contract_floor cf WHERE cf.building_id = b.id AND cf.floor = floor AND `status` = 2) )
- )
- )
- FROM
- y_floor
- WHERE
- building_id = b.id
- )
- )
- )
- , 0)
- FROM
- ic_building b
- LEFT JOIN ic_park p ON p.id = b.park_id
- WHERE
- p.street_id = #{id}
- AND b.is_use = 1
- AND b.del_flag = 0
- AND p.del_flag = 0
- AND p.is_start = 1
- </select>
- <select id="findParkTotalArea" resultType="java.lang.Double">
- SELECT
- IFNULL(
- SUM(IFNULL(
- b.area,
- (
- SELECT
- SUM(
- IFNULL(
- area,
- ( remain_area + ( SELECT SUM( area ) FROM ic_contract_floor cf WHERE cf.building_id = b.id AND cf.floor = floor AND `status` = 2) )
- )
- )
- FROM
- y_floor
- WHERE
- building_id = b.id
- )
- ))
- , 0)
- FROM
- ic_building b
- WHERE
- b.park_id = #{id}
- AND b.is_use = 1
- AND b.del_flag = 0
- </select>
- <select id="findBuildingTotalArea" resultType="java.lang.Double">
- SELECT
- IFNULL(
- b.area,
- (
- SELECT
- SUM(
- IFNULL(
- area,
- (
- remain_area + ( SELECT SUM( area ) FROM ic_contract_floor cf WHERE cf.building_id = b.id AND cf.floor = floor AND `status` = 2 )
- )
- )
- )
- FROM
- y_floor
- WHERE
- building_id = b.id
- )
- )
- FROM
- ic_building b
- WHERE
- b.id = #{id}
- AND b.is_use = 1
- AND b.del_flag = 0
- </select>
- <select id="findCarrierEntryArea" resultType="java.lang.Double">
- SELECT
- IFNULL(
- sum(
- IFNULL(
- b.area,
- (
- SELECT
- SUM(
- IFNULL(
- area,
- ( remain_area + ( SELECT SUM( area ) FROM ic_contract_floor cf WHERE cf.building_id = b.id AND cf.floor = floor AND `status` = 2) )
- )
- )
- FROM
- y_floor
- WHERE
- building_id = b.id
- )
- )
- )
- , 0)
- FROM
- ic_building b
- LEFT JOIN ic_park p ON p.id = b.park_id
- WHERE
- b.is_use = 1
- AND b.del_flag = 0
- AND p.del_flag = 0
- AND p.is_start = 1
- <if test="startTime != null and endTime != ''">
- AND b.create_time >= #{startTime}
- </if>
- <if test="startTime != null and endTime != ''">
- AND b.create_time <![CDATA[ <= ]]> #{endTime}
- </if>
- </select>
- <select id="getStreetBuildingDistribution" resultType="platform.modules.carrier.entity.CarrierDistribution">
- SELECT
- s.id,
- s.`name` AS streetName,
- COUNT( b.id ) AS buildingCount,
- IFNULL(
- sum(
- IFNULL(
- b.area,
- (
- SELECT
- SUM(
- IFNULL(
- area,
- (
- remain_area + ( SELECT SUM( area ) FROM ic_contract_floor cf WHERE cf.building_id = b.id AND cf.floor = floor AND `status` = 2 )
- )
- )
- )
- FROM
- y_floor
- WHERE
- building_id = b.id
- )
- )
- ),
- 0
- ) AS buildingArea
- FROM
- ic_building b
- LEFT JOIN ic_park p ON p.id = b.park_id
- LEFT JOIN s_street s ON s.id = p.street_id
- WHERE
- b.del_flag = 0
- AND p.del_flag = 0
- AND s.del_flag = 0
- <if test="condition.buildingCount != null and condition.buildingCount != ''">
- AND b.floor_count = #{condition.buildingCount}
- </if>
- <if test="condition.landing_platform_count != null and condition.landing_platform_count != ''">
- AND b.landing_platform_count = #{condition.landing_platform_count}
- </if>
- <if test="condition.spqn != null and condition.spqn != ''">
- AND b.spqn = #{condition.spqn}
- </if>
- <if test="condition.carrierNature != null and condition.carrierNature != ''">
- AND b.carrier_nature = #{condition.carrierNature}
- </if>
- GROUP BY
- s.id
- </select>
- <select id="factoryBuildingCount" resultType="platform.modules.api.dto.SkyImageCount">
- SELECT
- b.no,
- IFNULL(SUM( f.remain_area ), 0) AS buildingArea,
- IFNULL(SUM( cf.area ),0) AS rentArea
- FROM
- ic_building b
- LEFT JOIN y_floor f ON f.building_id = b.id
- LEFT JOIN ic_contract_floor cf ON cf.floor_id = f.id
- WHERE
- b.del_flag = FALSE AND b.is_use = 1 AND f.del_flag = FALSE AND f.is_use = 1 AND cf.status = 2
- AND cf.contract_end > NOW( )
- </select>
- <select id="findEndContractByTime" resultType="platform.modules.api.dto.SkyImageCount">
- SELECT
- DISTINCT b.`no` as no
- FROM
- ic_building b
- LEFT JOIN ic_contract_floor cf ON cf.building_id = b.id
- WHERE b.del_flag = 0 AND b.is_use = 1 AND cf.del_flag = 0
- <if test="startTime != null and startTime != ''">
- AND cf.contract_end > #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND cf.contract_end <![CDATA[<]]> #{endTime}
- </if>
- </select>
- <select id="findByNo" resultType="platform.modules.carrier.entity.Building">
- select * from ic_building where no = #{no} and del_flag = 0
- </select>
- </mapper>
|