|
|
|
|
<?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="com.techsor.datacenter.business.dao.ex.BasicBuildingMapperExt">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="checkExist" resultType="java.util.Map">
|
|
|
|
|
SELECT
|
|
|
|
|
CASE
|
|
|
|
|
WHEN name = #{buildingName} THEN 'buildingName'
|
|
|
|
|
WHEN udf_building_id = #{udfBuildingId} THEN 'udfBuildingId'
|
|
|
|
|
END AS conflict_field
|
|
|
|
|
FROM
|
|
|
|
|
basic_building
|
|
|
|
|
WHERE
|
|
|
|
|
flag != 1
|
|
|
|
|
AND (
|
|
|
|
|
name = #{buildingName}
|
|
|
|
|
OR
|
|
|
|
|
udf_building_id = #{udfBuildingId}
|
|
|
|
|
)
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
AND company_id = #{companyId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="buildingId != null">
|
|
|
|
|
AND building_id != #{buildingId}
|
|
|
|
|
</if>
|
|
|
|
|
LIMIT 1
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getListPage" resultType="com.techsor.datacenter.business.vo.building.BuildingPageVO">
|
|
|
|
|
SELECT
|
|
|
|
|
bbuilding.building_id buildingId,
|
|
|
|
|
bbuilding.company_id companyId,
|
|
|
|
|
bcomp.company_name companyName,
|
|
|
|
|
bbuilding.name buildingName,
|
|
|
|
|
bbuilding.address,
|
|
|
|
|
bbuilding.udf_building_id udfBuildingId,
|
|
|
|
|
bbuilding.building_bucket,
|
|
|
|
|
bbuilding.floor_info_list,
|
|
|
|
|
bbuilding.thumbnail_num,
|
|
|
|
|
bbuilding.show_switch_2d3d,
|
|
|
|
|
bbuilding.brief_introduction,
|
|
|
|
|
bbuilding.picture_introduction,
|
|
|
|
|
bbuilding.special_notes,
|
|
|
|
|
bbuilding.latitude,
|
|
|
|
|
bbuilding.longitude,
|
|
|
|
|
bbuilding.salesforce_primary_id,
|
|
|
|
|
bbuilding.site_manager,
|
|
|
|
|
bbuilding.king_contract_no,
|
|
|
|
|
bsales.salesforce_id,
|
|
|
|
|
GROUP_CONCAT(DISTINCT pa.id ORDER BY pa.id) AS siteIds,
|
|
|
|
|
GROUP_CONCAT(DISTINCT pa.code ORDER BY pa.id) AS siteCodes,
|
|
|
|
|
GROUP_CONCAT(DISTINCT pa.name ORDER BY pa.id) AS siteNames,
|
|
|
|
|
|
|
|
|
|
GROUP_CONCAT(DISTINCT area.id ORDER BY area.id) AS areaIds,
|
|
|
|
|
GROUP_CONCAT(DISTINCT area.code ORDER BY area.id) AS areaCodes,
|
|
|
|
|
GROUP_CONCAT(DISTINCT area.name ORDER BY area.id) AS areaName,
|
|
|
|
|
|
|
|
|
|
GROUP_CONCAT(DISTINCT store.id ORDER BY store.id) AS storeIds,
|
|
|
|
|
GROUP_CONCAT(DISTINCT store.code ORDER BY store.id) AS storeCodes,
|
|
|
|
|
GROUP_CONCAT(DISTINCT store.name ORDER BY store.id) AS storeNames,
|
|
|
|
|
|
|
|
|
|
GROUP_CONCAT(DISTINCT branch.id ORDER BY branch.id) AS branchIds,
|
|
|
|
|
GROUP_CONCAT(DISTINCT branch.code ORDER BY branch.id) AS branchCodes,
|
|
|
|
|
GROUP_CONCAT(DISTINCT branch.name ORDER BY branch.id) AS branchNames
|
|
|
|
|
FROM
|
|
|
|
|
basic_building bbuilding
|
|
|
|
|
INNER JOIN data_center_aeon_admin.basic_company bcomp
|
|
|
|
|
ON bcomp.id = bbuilding.company_id
|
|
|
|
|
|
|
|
|
|
LEFT JOIN dashboard_level_relation_site_building rela
|
|
|
|
|
ON bbuilding.building_id = rela.building_id
|
|
|
|
|
|
|
|
|
|
LEFT JOIN dashboard_level_site pa
|
|
|
|
|
ON rela.site_id = pa.id
|
|
|
|
|
AND pa.flag = 0
|
|
|
|
|
|
|
|
|
|
LEFT JOIN dashboard_level_relation_area_site ras
|
|
|
|
|
ON pa.id = ras.site_id
|
|
|
|
|
|
|
|
|
|
LEFT JOIN dashboard_level_area area
|
|
|
|
|
ON ras.area_id = area.id
|
|
|
|
|
AND area.flag = 0
|
|
|
|
|
|
|
|
|
|
LEFT JOIN dashboard_level_relation_store_area rsa
|
|
|
|
|
ON area.id = rsa.area_id
|
|
|
|
|
|
|
|
|
|
LEFT JOIN dashboard_level_store store
|
|
|
|
|
ON rsa.store_id = store.id
|
|
|
|
|
AND store.flag = 0
|
|
|
|
|
|
|
|
|
|
LEFT JOIN dashboard_level_relation_branch_store rbs
|
|
|
|
|
ON store.id = rbs.store_id
|
|
|
|
|
|
|
|
|
|
LEFT JOIN dashboard_level_branch branch
|
|
|
|
|
ON rbs.branch_id = branch.id
|
|
|
|
|
AND branch.flag = 0
|
|
|
|
|
|
|
|
|
|
LEFT JOIN basic_salesforce bsales
|
|
|
|
|
ON bsales.id = bbuilding.salesforce_primary_id
|
|
|
|
|
|
|
|
|
|
WHERE
|
|
|
|
|
bbuilding.flag != 1 AND bcomp.flag != 1
|
|
|
|
|
AND bbuilding.company_id IN <foreach collection="companyIdList" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
<if test="bindBuildingIdList != null">
|
|
|
|
|
AND bbuilding.building_id IN <foreach collection="bindBuildingIdList" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="buildingIdList != null">
|
|
|
|
|
AND bbuilding.building_id IN <foreach collection="buildingIdList" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="buildingName != null and buildingName != ''">
|
|
|
|
|
AND bbuilding.name LIKE CONCAT('%',#{buildingName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="platformType != null and platformType == 1">
|
|
|
|
|
AND bbuilding.show_switch_2d3d = 0
|
|
|
|
|
</if>
|
|
|
|
|
<if test="siteId != null">
|
|
|
|
|
AND pa.`id` = #{siteId}
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY bbuilding.building_id
|
|
|
|
|
ORDER BY bbuilding.building_id DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getAll" resultType="com.techsor.datacenter.business.vo.building.BuildingPageVO">
|
|
|
|
|
SELECT
|
|
|
|
|
bbuilding.building_id buildingId,
|
|
|
|
|
bbuilding.company_id companyId,
|
|
|
|
|
bcomp.company_name companyName,
|
|
|
|
|
bbuilding.name buildingName,
|
|
|
|
|
bbuilding.address,
|
|
|
|
|
bbuilding.udf_building_id udfBuildingId
|
|
|
|
|
FROM
|
|
|
|
|
basic_building bbuilding
|
|
|
|
|
INNER JOIN data_center_aeon_admin.basic_company bcomp ON bcomp.id = bbuilding.company_id
|
|
|
|
|
WHERE
|
|
|
|
|
bbuilding.flag != 1
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
AND bbuilding.company_id = #{companyId}
|
|
|
|
|
</if>
|
|
|
|
|
AND bcomp.flag != 1
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getAllInList" resultType="com.techsor.datacenter.business.vo.building.BuildingPageVO">
|
|
|
|
|
SELECT
|
|
|
|
|
bbuilding.building_id buildingId,
|
|
|
|
|
bbuilding.company_id companyId,
|
|
|
|
|
bcomp.company_name companyName,
|
|
|
|
|
bbuilding.name buildingName,
|
|
|
|
|
bbuilding.address,
|
|
|
|
|
bbuilding.udf_building_id udfBuildingId
|
|
|
|
|
FROM
|
|
|
|
|
basic_building bbuilding
|
|
|
|
|
INNER JOIN data_center_aeon_admin.basic_company bcomp ON bcomp.id = bbuilding.company_id
|
|
|
|
|
WHERE
|
|
|
|
|
bbuilding.flag != 1
|
|
|
|
|
<if test="bindBuildingIdList != null">
|
|
|
|
|
AND bbuilding.building_id IN <foreach collection="bindBuildingIdList" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="companyIdList != null and companyIdList.size() > 0">
|
|
|
|
|
AND bbuilding.company_id IN <foreach collection="companyIdList" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
AND bcomp.flag != 1
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectAll" resultType="com.techsor.datacenter.business.model.BasicBuilding">
|
|
|
|
|
SELECT *
|
|
|
|
|
FROM basic_building
|
|
|
|
|
WHERE flag = 0
|
|
|
|
|
AND company_id = #{companyId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="batchInsert">
|
|
|
|
|
|
|
|
|
|
INSERT INTO basic_building
|
|
|
|
|
(
|
|
|
|
|
company_id,
|
|
|
|
|
name,
|
|
|
|
|
udf_building_id,
|
|
|
|
|
site_manager,
|
|
|
|
|
king_contract_no,
|
|
|
|
|
flag,
|
|
|
|
|
create_time,
|
|
|
|
|
creator_id,
|
|
|
|
|
modify_time,
|
|
|
|
|
modifier_id
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
VALUES
|
|
|
|
|
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
#{item.companyId},
|
|
|
|
|
#{item.name},
|
|
|
|
|
#{item.udfBuildingId},
|
|
|
|
|
#{item.siteManager},
|
|
|
|
|
#{item.kingContractNo},
|
|
|
|
|
0,
|
|
|
|
|
#{item.createTime},
|
|
|
|
|
#{item.creatorId},
|
|
|
|
|
#{item.modifyTime},
|
|
|
|
|
#{item.modifierId}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateSalesforce">
|
|
|
|
|
|
|
|
|
|
UPDATE basic_building
|
|
|
|
|
|
|
|
|
|
SET
|
|
|
|
|
salesforce_primary_id = #{salesforceId},
|
|
|
|
|
site_manager = #{siteManager},
|
|
|
|
|
king_contract_no = #{kingContractNo},
|
|
|
|
|
modify_time = #{modifyTime},
|
|
|
|
|
modifier_id = #{modifierId}
|
|
|
|
|
|
|
|
|
|
WHERE building_id = #{buildingId}
|
|
|
|
|
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
</mapper>
|