|
@@ -2,7 +2,7 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.welampiot.dao.ElectricBoxDao">
|
|
|
|
|
|
- <resultMap id="electricBoxAndSectionAndAirSwitchInfoResultMap" type="com.welampiot.dto.ElectricBoxDTO">
|
|
|
+ <resultMap id="electricBoxAndAirSwitchInfoResultMap" type="com.welampiot.dto.ElectricBoxDTO">
|
|
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
|
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
|
|
<result property="sectionId" column="sectionid" jdbcType="INTEGER"/>
|
|
@@ -22,7 +22,7 @@
|
|
|
</collection>
|
|
|
</resultMap>
|
|
|
|
|
|
- <select id="getElectricBoxListBySectionId" resultMap="electricBoxAndSectionAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
|
|
|
+ <select id="getElectricBoxListBySectionId" resultMap="electricBoxAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
|
|
|
select e.id,e.areaid areaId,e.sectionid sectionId,e.name,e.address,count(a.id) as airCount,a.online,
|
|
|
e.longitude,e.latitude,e.image,e.install_date installDate,e.expiration_date expirationDate,
|
|
|
(select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) as onlineCount
|
|
@@ -30,10 +30,18 @@
|
|
|
where <if test="keyword != null and keyword != ''">
|
|
|
e.name like '%${keyword}%' or e.address like '%${keyword}%'
|
|
|
</if>
|
|
|
+ <choose>
|
|
|
+ <when test="status == 1">
|
|
|
+ and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) > 0
|
|
|
+ </when>
|
|
|
+ <when test="status == 2">
|
|
|
+ and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) = 0
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
and <if test="sectionList != null and !sectionList.isEmpty()">
|
|
|
e.sectionid in
|
|
|
<foreach item="vo" collection="sectionList" open="(" separator="," close=")">
|
|
|
- #{vo.sectionId}
|
|
|
+ #{vo}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
order by convert(e.name using gbk) asc,e.id desc
|
|
@@ -42,4 +50,42 @@
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getTotalByStatus" resultMap="electricBoxAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
|
|
|
+ select count(*) as total
|
|
|
+ from (select e.id
|
|
|
+ from electric_box e
|
|
|
+ left join air_switch_info a on e.id = a.box_id
|
|
|
+ where e.sectionid in
|
|
|
+ <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
|
|
|
+ #{vo}
|
|
|
+ </foreach>
|
|
|
+ group by e.id) b
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getOnlineTotalByStatus" resultMap="electricBoxAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
|
|
|
+ select count(*) as total
|
|
|
+ from (select e.id
|
|
|
+ from electric_box e
|
|
|
+ left join air_switch_info a on e.id = a.box_id
|
|
|
+ where e.sectionid in
|
|
|
+ <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
|
|
|
+ #{vo}
|
|
|
+ </foreach>
|
|
|
+ and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) > 0
|
|
|
+ group by e.id) b
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getOfflineTotalByStatus" resultMap="electricBoxAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
|
|
|
+ select count(*) as total
|
|
|
+ from (select e.id
|
|
|
+ from electric_box e
|
|
|
+ left join air_switch_info a on e.id = a.box_id
|
|
|
+ where e.sectionid in
|
|
|
+ <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
|
|
|
+ #{vo}
|
|
|
+ </foreach>
|
|
|
+ and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) = 0
|
|
|
+ group by e.id) b
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|