|
@@ -2,11 +2,11 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.welampiot.dao.ElectricBoxDao">
|
|
|
|
|
|
- <select id="getElectricBoxListBySectionId" resultType="ElectricBoxDTO" parameterType="ElectricBoxDTO">
|
|
|
- select e.id,e.areaid as areaId,e.sectionid as sectionId,e.name,e.address,count(a.id) as airCount,
|
|
|
+ <select id="getElectricBoxListBySectionId" resultType="com.welampiot.dto.ElectricBoxDTO" parameterType="ElectricBoxDTO">
|
|
|
+ select e.id,e.areaid as areaId,e.sectionid as sectionId,e.name,e.address,(select count(*) from air_switch_info c where c.box_id = e.id) as airCount,
|
|
|
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
|
|
|
- from electric_box e left join air_switch_info a on a.box_id = e.id
|
|
|
+ (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) as onlineCount,e.devType
|
|
|
+ from electric_box e
|
|
|
where 1=1 <if test="keyword != null and keyword != ''">
|
|
|
and (e.name like '%${keyword}%' or e.address like '%${keyword}%')
|
|
|
</if>
|
|
@@ -18,8 +18,8 @@
|
|
|
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
|
|
|
+ <if test="sectionList != null and !sectionList.isEmpty()">
|
|
|
+ and e.sectionid in
|
|
|
<foreach item="dto" collection="sectionList" open="(" separator="," close=")">
|
|
|
#{dto}
|
|
|
</foreach>
|
|
@@ -35,11 +35,13 @@
|
|
|
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="dto" collection="sectionList" open="(" separator="," close=")">
|
|
|
- #{dto}
|
|
|
- </foreach>
|
|
|
- group by e.id) b
|
|
|
+ <if test="sectionList != null and !sectionList.isEmpty()">
|
|
|
+ where e.sectionid in
|
|
|
+ <foreach item="dto" collection="sectionList" open="(" separator="," close=")">
|
|
|
+ #{dto}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ group by e.id) b
|
|
|
</select>
|
|
|
|
|
|
<select id="getOnlineTotalByStatus" resultType="Integer" parameterType="ElectricBoxDTO">
|
|
@@ -47,11 +49,14 @@
|
|
|
from (select e.id
|
|
|
from electric_box e
|
|
|
left join air_switch_info a on e.id = a.box_id
|
|
|
- where e.sectionid in
|
|
|
+
|
|
|
+ where(select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) > 0
|
|
|
+ <if test="sectionList != null and !sectionList.isEmpty()">
|
|
|
+ and e.sectionid in
|
|
|
<foreach item="dto" collection="sectionList" open="(" separator="," close=")">
|
|
|
#{dto}
|
|
|
</foreach>
|
|
|
- and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) > 0
|
|
|
+ </if>
|
|
|
group by e.id) b
|
|
|
</select>
|
|
|
|
|
@@ -60,12 +65,41 @@
|
|
|
from (select e.id
|
|
|
from electric_box e
|
|
|
left join air_switch_info a on e.id = a.box_id
|
|
|
- where e.sectionid in
|
|
|
+ where (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) = 0
|
|
|
+ <if test="sectionList != null and !sectionList.isEmpty()">
|
|
|
+ and e.sectionid in
|
|
|
<foreach item="dto" collection="sectionList" open="(" separator="," close=")">
|
|
|
#{dto}
|
|
|
</foreach>
|
|
|
- and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) = 0
|
|
|
+ </if>
|
|
|
group by e.id) b
|
|
|
</select>
|
|
|
+ <insert id="add" parameterType="com.welampiot.dto.ElectricBoxDTO" useGeneratedKeys="true" keyProperty="id"
|
|
|
+ >
|
|
|
+ insert into electric_box(name,address,areaid,sectionid,longitude,latitude,createTime,devType
|
|
|
+ <if test="installDate != null">,install_date</if>
|
|
|
+ <if test="expirationDate != null">,expiration_date</if>
|
|
|
+ )
|
|
|
+ values
|
|
|
+ (#{name},#{address},#{areaId},#{sectionId},#{longitude},#{latitude},#{createTime},#{devType}
|
|
|
+ <if test="installDate != null">,#{installDate}</if>
|
|
|
+ <if test="expirationDate != null">,#{expirationDate}</if>
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+ <update id="update" parameterType="com.welampiot.dto.ElectricBoxDTO"
|
|
|
+ >
|
|
|
+ update electric_box
|
|
|
+ set
|
|
|
+ name=#{name},
|
|
|
+ address=#{address},
|
|
|
+ areaid=#{areaId},
|
|
|
+ sectionid=#{sectionId},
|
|
|
+ longitude=#{longitude},
|
|
|
+ latitude=#{latitude},
|
|
|
+ <if test="installDate != null">install_date=#{installDate},</if>
|
|
|
+ <if test="expirationDate != null">expiration_date=#{expirationDate},</if>
|
|
|
+ devType=#{devType}
|
|
|
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
</mapper>
|