| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- <?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.LampPoleDao">
- <select id="getCountByVO" resultType="Integer" parameterType="com.welampiot.vo.LampPoleCountVO">
- select count(*) from lamp_pole a
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and a.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="name != null">
- AND a.name = #{name}
- </if>
- <if test="number != null">
- AND a.number = #{number}
- </if>
- <if test="sectionId != null">
- AND a.sectionid = #{sectionId}
- </if>
- <if test="id != null">
- AND a.id != #{id}
- </if>
- </select>
- <select id="getNavByVO" resultType="com.welampiot.dto.LampPoleDTO" parameterType="com.welampiot.vo.LampPoleVO">
- select LP.id,LP.name,LP.longitude,LP.latitude,W.online from lamp_pole LP
- left join wifi as W on W.lamp_pole_id = LP.id
- left join envmonitor as E on E.lamp_pole_id = LP.id
- <if test="devType == 2">
- left join video_monitor as V on V.lamp_pole_id = LP.id
- </if>
- <if test="devType == 1">
- left join lampinfo as L on L.lamp_pole_id = LP.id
- </if>
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and LP.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="devType != null">
- <choose>
- <when test="devType == 1">
- <if test="devId == null">
- AND (LP.devtype like "%0%")
- </if>
- <if test="devId != null">
- AND (LP.devtype like "%0%" OR L.id = #{devId})
- </if>
- </when>
- <when test="devType == 2">
- <if test="devId == null">
- AND (LP.devtype like "%1%")
- </if>
- <if test="devId != null">
- AND (LP.devtype like "%1%" OR L.id = #{devId})
- </if>
- </when>
- <otherwise>
- <if test="devId == null">
- AND (LP.devtype like "%7%")
- </if>
- <if test="devId != null">
- AND (LP.devtype like "%7%" OR L.id = #{devId})
- </if>
- </otherwise>
- </choose>
- </if>
- </select>
- <select id="getListByVO" resultType="com.welampiot.dto.LampPoleDTO" parameterType="com.welampiot.vo.LampPoleVO">
- select LP.id,LP.name,LP.devtype as devType,LP.createtime,LP.sn,LP.longitude,LP.latitude from lamp_pole LP
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and LP.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="keyword != null">
- AND (LP.name like '%#{keyword}%' OR LP.sn like '%#{keyword}%')
- </if>
- </select>
- <select id="lampPoleList" resultType="com.welampiot.dto.LampPoleDTO" parameterType="com.welampiot.vo.LampPoleVO">
- select LP.id,LP.name,LP.devtype as devType,LP.sn,LP.longitude,LP.latitude,LP.createtime as createTime,L.faultstatus,LI.grid_active_power as power,LI.dim_value as lighteness,L.policy_type as policyType,P.name as policyName,LP.devtype as devType,LI.updatetime as updateTime,V.is_inspec as isInspec,S.timezone,S.name as section,C.name as company,L.policyid as policyId,LP.install_date as installDate,LP.expiration_date as expirationDate,
- <choose>
- <when test="version == 1">
- G.english_name as area,G2.english_name as city
- </when>
- <when test="version == 2">
- G.ru_name as area,G2.ru_name as city
- </when>
- <otherwise>
- G.chinese_name as area,G2.chinese_name as city
- </otherwise>
- </choose> from lamp_pole LP
- left join section as S on S.id = LP.sectionid
- left join lampinfo as L on L.lamp_pole_id = LP.id
- left join lamp_info_log_new as LI on LI.lampid = L.id
- left join global_location as G on G.id = S.pid
- left join global_location as G2 on G.pid = G2.id
- left join policy as P on L.policyid = P.id
- left join video_monitor as V on V.lamp_pole_id = LP.id
- left join user as U on U.id = LP.create_id
- left join company as C on U.company_id = C.id
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and LP.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="keyword != null">
- AND (LP.name like '%#{keyword}%' OR LP.sn like '%#{keyword}%')
- </if>
- <if test="isInspec != null">
- and V.is_inspec = #{isInspec}
- </if>
- order by convert(LP.number using gbk) ASC,convert(LP.name using gbk) ASC,LP.id DESC
- <if test="offset != null and limit != null">
- limit #{offset},#{limit}
- </if>
- </select>
- <select id="lampPoleCount" resultType="int" parameterType="com.welampiot.vo.LampPoleVO">
- select count(LP.id) as total from lamp_pole LP
- left join video_monitor as V on V.lamp_pole_id = LP.id
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and LP.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="keyword != null">
- AND (LP.name like '%#{keyword}%' OR LP.sn like '%#{keyword}%')
- </if>
- <if test="isInspec != null">
- and V.is_inspec = #{isInspec}
- </if>
- </select>
- <insert id="add" parameterType="com.welampiot.dto.LampPoleDTO" useGeneratedKeys="true" keyProperty="id"
- >
- insert into lamp_pole(name,number,height,areaid,sectionid,longitude,latitude,createtime,create_id,install_date,expiration_date
- <!-- <if test="mode != null">-->
- <!-- ,mode-->
- <!-- </if>-->
- )
- values
- (#{name},#{number},#{height},#{areaId},#{sectionId},#{longitude},#{latitude},#{createTime},#{createId},#{installDate},#{expirationDate}
- <!-- <if test="mode != null">-->
- <!-- ,#{mode}-->
- <!-- </if>-->
- )
- </insert>
- <insert id="update" parameterType="com.welampiot.dto.LampPoleDTO"
- >
- update lamp_pole
- set
- <if test="sn != null">sn = #{sn},</if>
- <if test="name != null">name = #{name},</if>
- <if test="number != null">number = #{number},</if>
- <if test="height != null">height = #{height},</if>
- <if test="areaId != null">areaid = #{areaId},</if>
- <if test="devType != null">devtype = #{devType},</if>
- <if test="sectionId != null">sectionid = #{sectionId},</if>
- <if test="longitude != null">longitude = #{longitude},</if>
- <if test="latitude != null">latitude = #{latitude},</if>
- <if test="installDate != null">install_date = #{installDate},</if>
- <if test="expirationDate != null">expiration_date = #{expirationDate},</if>
- id=#{id}
- where id = #{id}
- </insert>
- <select id="getDetailById" resultType="com.welampiot.dto.LampPoleDTO" parameterType="int">
- select id,name,number,height,areaid as areaId,sectionid as sectionId,longitude,latitude,install_date as installDate,expiration_date as expirationDate,devtype as devType from lamp_pole
- where id=#{id}
- </select>
- <delete id="deleteById" parameterType="int">
- delete from lamp_pole
- where id=#{id}
- </delete>
-
- <select id="getLampPoleListByDTO" resultType="com.welampiot.dto.LampPoleDTO">
- select
- <choose>
- <when test="version == 0">
- gl.chinese_name as area,
- </when>
- <when test="version == 1">
- gl.english_name as area,
- </when>
- <otherwise>
- gl.ru_name as area,
- </otherwise>
- </choose>
- lp.id,lp.sn,lp.longitude,lp.latitude,lp.devtype as devType,s.name as section,lp.name,
- l.updatetime as updateTime,l1.grid_active_power as power,l1.gridvolt as gridVolt,
- l1.gridcurr as gridCurr,n.snr,n.rssi,l.id as lampId,vm.id as videoId,l.faultstatus,
- l1.work_time_total as lightTime,l.lighteness,n.status,s.timezone
- from lamp_pole lp
- left join section s on lp.sectionid = s.id
- left join global_location gl on s.pid = gl.id
- left join lampinfo l on lp.id = l.lamp_pole_id
- left join lamp_info_log_new l1 on l1.lampid = l.id
- left join network n on l.networkid = n.id
- left join video_monitor vm on lp.id = vm.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>
- <choose>
- <when test="alarmType == 16">
- and l.faultstatus = 16
- </when>
- <when test="alarmType == 8">
- and l.faultstatus = 8
- </when>
- <when test="alarmType == 4">
- and l.faultstatus = 4
- </when>
- <when test="alarmType == 2">
- and l.faultstatus = 2
- </when>
- <when test="alarmType == 1">
- and l.faultstatus = 1
- </when>
- <otherwise>
- and l.faultstatus = 0
- </otherwise>
- </choose>
- <choose>
- <when test="online1 == '1'">
- and n.status = 1
- </when>
- <when test="online1 == '0'">
- and n.status = 0
- </when>
- </choose>
- </select>
- <!-- 灯杆安装总数 -->
- <select id="getLampPoleInstallTotalByDTO" resultType="Integer">
- select count(l.id)
- from lamp_pole l
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and l.sectionid in
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="areaId != null and areaId != 0">
- and l.areaid = #{areaId}
- </if>
- </select>
- <!-- 摄像头数量 -->
- <select id="getVideoCount" resultType="Integer">
- SELECT
- count(vm.id)
- AS total
- FROM lamp_pole lp
- LEFT JOIN video_monitor vm
- ON vm.lamp_pole_id = lp.id
- WHERE vm.lamp_pole_id != 0
- <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>
- </select>
- <!-- 屏幕数量 -->
- <select id="getScreenCount" resultType="Integer">
- SELECT
- count(s.id)
- AS total
- FROM lamp_pole lp
- LEFT JOIN screen s
- ON s.lamp_pole_id = lp.id
- WHERE s.lamp_pole_id != 0
- <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>
- </select>
- <!-- WIFI数量 -->
- <select id="getWifiCount" resultType="Integer">
- SELECT
- count(w.id)
- AS total
- FROM lamp_pole lp
- LEFT JOIN wifi w
- ON w.lamp_pole_id = lp.id
- WHERE w.lamp_pole_id != 0
- <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>
- </select>
- <!-- 气象站数量 -->
- <select id="getWeatherCount" resultType="Integer">
- SELECT
- count(e.id)
- AS total
- FROM lamp_pole lp
- LEFT JOIN envmonitor e
- ON e.lamp_pole_id = lp.id
- WHERE e.lamp_pole_id != 0
- <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>
- </select>
- <!-- 充电桩数量 -->
- <select id="getChargeCount" resultType="Integer">
- SELECT
- count(c.id)
- AS total
- FROM lamp_pole lp
- LEFT JOIN charge c
- ON c.lamp_pole_id = lp.id
- WHERE c.lamp_pole_id != 0
- <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>
- </select>
- <!-- 一键报警数量 -->
- <select id="getEmergencyCount" resultType="Integer">
- SELECT
- count(c.id)
- AS total
- FROM lamp_pole lp
- LEFT JOIN emergency c
- ON c.lamp_pole_id = lp.id
- WHERE c.lamp_pole_id != 0
- <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>
- </select>
- <!-- RFID数量 -->
- <select id="getRfidCount" resultType="Integer">
- SELECT
- count(r.id)
- AS total
- FROM lamp_pole lp
- LEFT JOIN rfid r
- ON r.lamp_pole_id = lp.id
- WHERE r.lamp_pole_id != 0
- <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>
- </select>
- <!-- 广播数量 -->
- <select id="getBroadcastCount" resultType="Integer">
- SELECT
- count(b.id)
- AS total
- FROM lamp_pole lp
- LEFT JOIN broadcast b
- ON b.lamp_pole_id = lp.id
- WHERE b.lamp_pole_id != 0
- <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>
- </select>
- <select id="getSectionIdByLampPoleId" resultType="Integer">
- select lp.sectionid
- from lamp_pole lp
- where lp.id = #{id}
- </select>
- <update id="changeLampPoleLocationById" parameterType="LampPoleDTO">
- update
- lamp_pole l
- set
- l.longitude = #{longitude},
- l.latitude = #{latitude}
- where l.id = #{id}
- </update>
-
- </mapper>
|