| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 | <?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.welampiot.dao.ElectricBoxDao">    <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,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>              <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>             <if test="sectionList != null and !sectionList.isEmpty()">                 and e.sectionid in                    <foreach item="dto" collection="sectionList" open="(" separator="," close=")">                        #{dto}                    </foreach>                </if>            order by convert(e.name using gbk) asc,e.id desc            <if test="page >= 0 and count > 0">                 limit #{page},#{count}            </if>    </select>    <select id="getTotalByStatus" resultType="Integer" parameterType="ElectricBoxDTO">        select count(*) as total        from (select e.id              from electric_box e                  left join air_switch_info a on e.id = a.box_id        <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">        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(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>        </if>            group by e.id) b    </select>    <select id="getOfflineTotalByStatus" resultType="Integer" parameterType="ElectricBoxDTO">        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 (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>        </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>    <select id="checkData" resultType="Integer" parameterType="ElectricBoxDTO">        select count(e.id)        from electric_box e        where 1=1        <if test="sectionList != null and !sectionList.isEmpty()">            and e.sectionid in            <foreach item="dto" collection="sectionList" open="(" separator="," close=")">                #{dto}            </foreach>        </if>        <if test="sectionId != null">            and e.sectionid = #{sectionId}        </if>        <if test="name != null">            and e.name = #{name}        </if>        <if test="id != null">            and e.id != #{id}        </if>    </select>    <delete id="delete" parameterType="com.welampiot.dto.AirSwitchInfoDTO">        delete from electric_box where id=#{id}    </delete>    <select id="getDetailsById" resultType="com.welampiot.dto.ElectricBoxDTO" parameterType="int">        select id,areaid as areaId,sectionid as sectionId,name,address,longitude,latitude,image,install_date installDate,expiration_date expirationDate,devType        from electric_box        where id = #{id}    </select>    <update id="changeElectricBoxLocationById" parameterType="ElectricBoxDTO">        update            `electric_box` e        set            e.longitude = #{longitude},            e.latitude = #{latitude}        where e.id = #{id}    </update></mapper>
 |