|
@@ -213,4 +213,39 @@
|
|
</if>
|
|
</if>
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
+ <select id="getSectionLampCountsByBaseVO" resultType="SectionDTO">
|
|
|
|
+ SELECT
|
|
|
|
+ COALESCE(COUNT(l.id), 0) AS lampTotal,
|
|
|
|
+ COALESCE(SUM(IF(l.online = 1, 1, 0)), 0) AS lampOnlineCount,
|
|
|
|
+ COALESCE(SUM(IF(l.online = 0, 1, 0)), 0) AS lampOfflineCount,
|
|
|
|
+ COALESCE(SUM(IF(l.online = 1 AND l.lighteness > 0, 1, 0)), 0) AS lampLightCount,
|
|
|
|
+ COALESCE(SUM(IF(l.online = 1 AND l.faultstatus != 0 AND l.faultstatus != 128, 1, 0)), 0) AS lampAlarmCount
|
|
|
|
+ FROM
|
|
|
|
+ section s
|
|
|
|
+ LEFT JOIN lampinfo l ON s.id = l.sectionid
|
|
|
|
+ LEFT JOIN global_location a ON a.id = s.pid
|
|
|
|
+ LEFT JOIN global_location b ON b.id = a.pid
|
|
|
|
+ LEFT JOIN global_location c ON c.id = b.pid
|
|
|
|
+ WHERE
|
|
|
|
+ 1=1
|
|
|
|
+ <if test="sectionList != null and !sectionList.isEmpty()">
|
|
|
|
+ AND s.id IN
|
|
|
|
+ <foreach collection="sectionList" item="item" open="(" separator="," close=")">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="provinceId != null and provinceId != 0">
|
|
|
|
+ AND c.id = #{provinceId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="cityId != null and cityId != 0">
|
|
|
|
+ AND b.id = #{cityId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="areaId != null and areaId != 0">
|
|
|
|
+ AND a.id = #{areaId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="sectionId != null and sectionId != 0">
|
|
|
|
+ AND s.id = #{sectionId}
|
|
|
|
+ </if>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
</mapper>
|
|
</mapper>
|