123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- <?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.WaterImmersionDevInfoDao">
- <select id="getWaterImmersionListByDTO" resultType="WaterImmersionDevInfoDTO">
- select w.id,w.lamp_pole_id lampPoleId,s.name as section,g.chinese_name chArea,g.english_name enArea,
- g.ru_name ruArea,lp.name lampPoleName,w.number,w.name,w.model,w.status,w.probe1,w.probe2,w.delaytime as delayTime,
- w.level,w.powerstatus as powerStatus,w.address,w.box_address boxAddress,w.box_sub_address boxSubAddress,w.factory,
- w.deviceId,wifi.model as cloudBoxModel,w.createtime as createTime,w.updatetime as updateTime,w.install_date installDate,
- w.expiration_date expirationDate,s.timezone
- from water_immersion_dev_info w left join lamp_pole lp on lp.id = w.lamp_pole_id
- left join wifi on wifi.lamp_pole_id = lp.id
- left join section s on lp.sectionid = s.id
- left join global_location g on s.pid = g.id
- where w.lamp_pole_id != 0
- <if test="sectionList != null and !sectionList.isEmpty()">
- and lp.sectionid in
- <foreach collection="sectionList" open="(" separator="," close=")" item="dto">
- #{dto}
- </foreach>
- </if>
- <if test="keyword != null and keyword != ''">
- and (w.name like '%${keyword}%' or w.number like '%${keyword}%')
- </if>
- <choose>
- <when test="online == 0">
- and w.status = 0
- </when>
- <when test="online == 1">
- and w.status = 1
- </when>
- </choose>
- order by convert(lp.number using gbk) asc,
- convert(w.name using gbk) asc,w.id desc
- <if test="page >= 0 and count > 0">
- limit #{page},#{count}
- </if>
- </select>
- <select id="getDeviceTotalByDTO" resultType="Integer">
- select count(w.id) as total
- from water_immersion_dev_info w left join lamp_pole lp on w.lamp_pole_id = lp.id
- <if test="sectionList != null and !sectionList.isEmpty()">
- where lp.sectionid in
- <foreach collection="sectionList" open="(" separator="," close=")" item="dto">
- #{dto}
- </foreach>
- </if>
- </select>
-
- <select id="getLogListByDTO" resultType="WaterImmersionDevInfoLogDTO">
- select w1.id,w1.water_immersion_id waterImmersionId,w1.probe1,w1.probe2,w1.level,w1.powerstatus,w1.updatetime as updateTime,s.timezone
- from water_immersion_dev_info_log w1 left join water_immersion_dev_info w2 on w1.water_immersion_id = w2.id
- left join lamp_pole lp on lp.id = w2.lamp_pole_id
- left join section s on lp.sectionid = s.id
- where 1=1
- <if test="waterImmersionId != null and waterImmersionId != 0">
- and w1.water_immersion_id = #{waterImmersionId}
- </if>
- <if test="sectionList != null and !sectionList.isEmpty()">
- and lp.sectionid in
- <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
- #{dto}
- </foreach>
- </if>
- <if test="beginTime != null and beginTime != ''">
- and date_format(w1.updatetime,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endTime != null and endTime != ''">
- and date_format(w1.updatetime,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="page >= 0 and count > 0">
- limit #{page},#{count}
- </if>
- </select>
- <select id="getTimezoneById" resultType="Integer">
- select s.timezone
- from water_immersion_dev_info w1 left join lamp_pole lp on lp.id = w1.lamp_pole_id
- left join section s on lp.sectionid = s.id
- where w1.id = #{waterImmersionId}
- </select>
- <update id="updateWaterImmersionDataByDTO" parameterType="com.welampiot.dto.WaterImmersionDevInfoDTO">
- update water_immersion_dev_info
- set
- number = #{number},
- name = #{name},
- factory = #{factory},
- model = #{model},
- level = #{level},
- powerStatus = #{powerStatus},
- serial_port = #{serialPort},
- address = #{address},
- box_address = #{boxAddress}
- <if test="installDate != null and installDate != ''">
- ,install_date = #{installDate}
- </if>
- <if test="expirationDate != null and expirationDate != ''">
- ,expiration_date = #{expirationDate}
- </if>
- ,box_sub_address = #{boxSubAddress}
- where id = #{id}
- </update>
- <update id="updateDelayTimeByDto" parameterType="com.welampiot.dto.WaterImmersionDevInfoDTO">
- update water_immersion_dev_info
- set
- delaytime = #{delayTime}
- where id = #{id}
- </update>
- <select id="findByWaterImmersionDTO" resultType="Integer">
- select count(*)
- from `water_immersion_dev_info` w
- left join lamp_pole lp on lp.id = w.lamp_pole_id
- where 1=1
- <if test="sectionId != null">
- and lp.sectionid = #{sectionId}
- </if>
- <if test="name != null">
- and w.name = #{name}
- </if>
- <if test="number != null">
- and w.number = #{number}
- </if>
- <if test="id != null">
- and w.id != #{id}
- </if>
- </select>
- <select id="findSectionIdById" resultType="Integer">
- select lp.sectionid
- from `water_immersion_dev_info` w
- left join lamp_pole lp on w.lamp_pole_id = lp.id
- where w.id = #{id}
- </select>
- <delete id="deleteWaterImmersionDataByDTO">
- delete
- from water_immersion_dev_info
- where id = #{id};
- </delete>
- <delete id="deleteWaterImmersionLogDataByDTO">
- delete
- from water_immersion_dev_info_log
- where water_immersion_id = #{id};
- </delete>
- <select id="getWaterDTOById" resultType="WaterImmersionDevInfoDTO">
- select w.id,w.number,w.serial_port as serialPort,w.address,w.factory,c.num,c.model
- from water_immersion_dev_info w
- left join wifi c on c.lamp_pole_id = w.lamp_pole_id
- where w.id = #{id}
- </select>
- <select id="getWaterImmersionTotal" resultType="Integer">
- select
- count(*)
- from water_immersion_dev_info w
- left join lamp_pole lp on lp.id = w.lamp_pole_id
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and lp.sectionid in
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="areaId != null and areaId != 0">
- and lp.areaid = #{areaId}
- </if>
- <if test="sectionId != null and sectionId != 0">
- and lp.sectionid = #{sectionId}
- </if>
- </select>
- <select id="getWaterImmersionOnlineCount" resultType="Integer">
- select
- count(*)
- from water_immersion_dev_info w
- left join lamp_pole lp on lp.id = w.lamp_pole_id
- where w.status = 1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and lp.sectionid in
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="areaId != null and areaId != 0">
- and lp.areaid = #{areaId}
- </if>
- <if test="sectionId != null and sectionId != 0">
- and lp.sectionid = #{sectionId}
- </if>
- </select>
- <select id="getWaterImmersionAlarmCount" resultType="Integer">
- select
- count(*)
- from water_immersion_dev_info w
- left join lamp_pole lp on lp.id = w.lamp_pole_id
- where (w.probe1 = 1 or w.probe2 = 1)
- <if test="sectionList != null and !sectionList.isEmpty()">
- and lp.sectionid in
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="areaId != null and areaId != 0">
- and lp.areaid = #{areaId}
- </if>
- <if test="sectionId != null and sectionId != 0">
- and lp.sectionid = #{sectionId}
- </if>
- </select>
- <select id="getWaterImmersionNewCount" resultType="Integer">
- select
- count(*)
- from water_immersion_dev_info w
- left join lamp_pole lp on lp.id = w.lamp_pole_id
- where w.createtime >= date_sub(now(),interval 7 day)
- <if test="sectionList != null and !sectionList.isEmpty()">
- and lp.sectionid in
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="areaId != null and areaId != 0">
- and lp.areaid = #{areaId}
- </if>
- <if test="sectionId != null and sectionId != 0">
- and lp.sectionid = #{sectionId}
- </if>
- </select>
- <select id="getTotalBySectionList" resultType="Integer">
- select count(b.id) as total from water_immersion_dev_info b
- left join lamp_pole lp on b.lamp_pole_id = lp.id
- <if test="sectionList != null and !sectionList.isEmpty()">
- where lp.sectionid in
- <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
- #{dto}
- </foreach>
- </if>
- </select>
- </mapper>
|