|
@@ -1306,6 +1306,58 @@
|
|
|
select count(1) from sc_building where status = 1 and name = #{name} and site_id = #{siteId} and community = #{community}
|
|
|
<if test="id != null"> and id != #{id}</if>
|
|
|
</select>
|
|
|
+ <select id="obtainBuildingInformationOnTheIntegratedMap"
|
|
|
+ resultType="com.bz.smart_city.dto.BuildingInfoListDto">
|
|
|
+ select
|
|
|
+ sb.id as building_id,
|
|
|
+ sb.name as building_name,
|
|
|
+ sb.address ,
|
|
|
+ sb.province,
|
|
|
+ sb.city,
|
|
|
+ sb.region,
|
|
|
+ sb.community,
|
|
|
+ sa1.name as province_name,
|
|
|
+ sa2.name as city_name,
|
|
|
+ sa3.name as region_name,
|
|
|
+ sc.name as community_name,
|
|
|
+ sb.latitude,
|
|
|
+ sb.longitude,
|
|
|
+ temp.device_count,
|
|
|
+ temp.normal_count,
|
|
|
+ temp.alarm_count,
|
|
|
+ temp.fault_count,
|
|
|
+ temp.offline_count,
|
|
|
+ temp.device_unused_count
|
|
|
+ from sc_building sb
|
|
|
+ JOIN(
|
|
|
+ SELECT
|
|
|
+ sd.building_id,
|
|
|
+ count(1) as device_count,
|
|
|
+ SUM(IF(sd.device_status = 1, 1, 0)) as normal_count,
|
|
|
+ SUM(IF(sd.device_status = 2, 1, 0)) as alarm_count,
|
|
|
+ SUM(IF(sd.device_status = 3, 1, 0)) as fault_count,
|
|
|
+ SUM(IF(sd.device_status = 4, 1, 0)) as offline_count,
|
|
|
+ SUM(IF(sd.device_status = 5, 1, 0)) as device_unused_count
|
|
|
+ from sc_device sd
|
|
|
+ <if test="programItems != null and programItems.size() != 0">
|
|
|
+ left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
|
|
|
+ WHERE sd.status = 1 and sd.sys_id != -99
|
|
|
+ <if test="programItems != null and programItems.size() != 0"> and
|
|
|
+ <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
|
|
|
+ sdd.${item.dimensionCode} = #{item.dimensionValue}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY sd.building_id
|
|
|
+ ) temp on (sb.id = temp.building_id)
|
|
|
+ left join sc_area sa1 on sa1.id = sb.province
|
|
|
+ left join sc_area sa2 on sa2.id = sb.city
|
|
|
+ left join sc_area sa3 on sa3.id = sb.region
|
|
|
+ left join sc_community sc on sc.id = sb.community
|
|
|
+ where sb.status = 1
|
|
|
+ <if test=" longitudeMin != 0 and longitudeMax != 0"> and sb.longitude > #{longitudeMin} AND sb.longitude <![CDATA[ < ]]> #{longitudeMax} </if>
|
|
|
+ <if test=" latitudeMin != 0 and latitudeMax != 0"> and sb.latitude > #{latitudeMin} AND sb.latitude <![CDATA[ < ]]> #{latitudeMax} </if>
|
|
|
+
|
|
|
+ </select>
|
|
|
|
|
|
|
|
|
</mapper>
|