1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051 |
- <?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.LampDao">
- <select id="getCountByVO" resultType="Integer" parameterType="com.welampiot.vo.LampCountVO">
- select count(*) from lampinfo L
- left join section as S on S.id = L.sectionid
- left join global_location as G on G.id = S.pid
- left join lamp_info_log_new as LI on LI.lampid = L.id
- left join network as N on N.id = L.networkid
- left join net_card_info as CD on N.id = CD.net_id
- left join policy as P on P.id = L.policyid
- left join (select t1.* from all_alarm_info_log t1, (select lampid, max(updatetime) as maxtime from all_alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI on L.id = AI.lampid
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and L.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="onlineStatus != null">
- and N.status = #{onlineStatus}
- </if>
- <if test="lampStatus != null">
- <if test="lampStatus == 0">
- and L.lighteness = 0
- </if>
- <if test="lampStatus == 1">
- and L.lighteness > 0
- </if>
- </if>
- <if test="alarmStatus != null">
- <if test="alarmStatus == 0">
- and (L.faultstatus = 0 or L.faultstatus = 128)
- </if>
- <if test="alarmStatus == 1">
- and L.faultstatus != 0 and L.faultstatus != 128
- </if>
- </if>
- <if test="keyword != null">
- AND (L.number like '%#{keyword}%' OR L.address like '%#{keyword}%' OR L.macAddress like '%#{keyword}%')
- </if>
- </select>
- <select id="getConsumptionByVO" resultType="Float" parameterType="com.welampiot.vo.LampCountVO">
- select sum((select sum(consum) from lamp_info_cache_by_day t
- where t.lampid = a.id
- <if test="startDate != null and startDate != ''">
- and t.updatetime >= #{startDate}
- </if>
- )) as consum
- from lampinfo a
- left join lamp_info_log_new b on a.id = b.lampid
- 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>
- </select>
- <select id="getDayConsumptionByVO" resultType="Float" parameterType="com.welampiot.vo.LampCountVO">
- select sum(b.day_gener_energy) as consum
- from lampinfo a left join lamp_info_log_new b on a.id = b.lampid
- 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="startDate != null and startDate != ''">
- and b.updatetime >= #{startDate}
- </if>
- </select>
- <select id="getConsumptionListByVO" resultType="com.welampiot.vo.LampLogVO" parameterType="com.welampiot.vo.LampCountVO">
- select * from (
- select sum(a.consum) as consumption,sum(a.powerSave) as powerSave,a.updatetime as updateTime
- from lamp_info_cache_by_day a left join lampinfo b on b.id = a.lampid
- where b.id is not null
- <if test="sectionList != null and !sectionList.isEmpty()">
- and a.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="startDate != null and startDate != ''">
- and a.updatetime >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.updatetime <= #{endDate}
- </if>
- group by a.updatetime
- ) as t order by t.updatetime asc
- </select>
- <select id="getListByVO" resultType="com.welampiot.dto.LampInfoDTO" parameterType="com.welampiot.vo.LampListResponseVO">
- select
- L.number,
- L.id,
- L.address as sn,
- <choose>
- <when test="version == 1">
- G.english_name as area,
- </when>
- <when test="version == 2">
- G.ru_name as area,
- </when>
- <otherwise>
- G.chinese_name as area,
- </otherwise>
- </choose>
- S.name as section,
- S.timezone,
- L.lighteness,
- L.name,
- LI.gridvolt as voltage,
- LI.gridcurr as current,
- LI.grid_active_power as power,
- LI.work_time_total as lightTime,
- LI.used_energy_total as totalEnergy,
- LI.devicetime as cmdTime,
- LI.led_lux_value,LI.leakage_cur,
- N.status as networkStatus,
- L.status as lampStatus,
- L.online as lampOnline,
- N.rssi,
- N.snr,
- N.protocoltype,
- LI.updatetime as updateTime,
- L.faultstatus,
- L.mode,
- N.hw_version as hwVersion,
- N.sw_version as swVersion,
- L.control_type as controlType,
- L.macAddress,
- L.dev_addr as devAddr,
- L.bindStatus,
- L.policy_type as policyType,
- L.policyid as policyId,
- L.longitude,
- L.latitude,L.new_faultstatus,L.install_date,L.expiration_date,
- P.name as policyName,AI.status as alarmStatus,AI.id as alarmid,AI.stralarmtype,
- CD.dueDate,CD.workingCondition,CD.remainGprs,CD.useGprs,CD.totalGprs,CD.comboName,CD.comboType,CD.id as card_id
- from lampinfo L
- left join section as S on S.id = L.sectionid
- left join global_location as G on G.id = S.pid
- left join lamp_info_log_new as LI on LI.lampid = L.id
- left join network as N on N.id = L.networkid
- left join net_card_info as CD on N.id = CD.net_id
- left join policy as P on P.id = L.policyid
- left join (select t1.* from all_alarm_info_log t1, (select lampid, max(updatetime) as maxtime from all_alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI on L.id = AI.lampid
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and L.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="online != null">
- AND ((N.status = #{online} and N.protocoltype != 5 and N.protocoltype != 11) or (L.online = #{online} and N.protocoltype = 5) or (L.online = #{online} and N.protocoltype = 11 and L.control_type != 26 and L.control_type != 27) or (N.status = #{online} and N.protocoltype = 11 and (L.control_type = 26 or L.control_type = 27)))
- </if>
- <if test="lightStatus != null">
- <if test="lightStatus == 0">
- AND ((N.status = 0 and N.protocoltype != 5) or (L.online = 0 and N.protocoltype = 5) or L.lighteness = 0)
- </if>
- <if test="lightStatus == 1">
- AND ((N.status = 1 and N.protocoltype != 5) or (L.online = 1 and N.protocoltype = 5)) and L.lighteness != 0
- </if>
- </if>
- <if test="keyword != null">
- AND (L.number like '%#{keyword}%' OR L.address like '%#{keyword}%' OR L.macAddress like '%#{keyword}%')
- </if>
- <if test="alarmType != null">
- AND L.faultstatus = #{alarmType}
- </if>
- <if test="lampPoleId != null">
- AND L.lamp_pole_id = #{lampPoleId}
- </if>
- order by L.number asc,L.mode asc,L.createtime desc,L.id desc
- <if test="offset != null and limit != null">
- limit #{offset},#{limit}
- </if>
- </select>
- <select id="getDetailsById" resultType="com.welampiot.dto.LampInfoDTO" parameterType="Integer">
- select
- L.number,
- L.id,
- L.address as sn,
- <choose>
- <when test="version == 1">
- GL.english_name as area,
- </when>
- <when test="version == 2">
- GL.ru_name as area,
- </when>
- <otherwise>
- GL.chinese_name as area,
- </otherwise>
- </choose>
- L.networkid as networkId,N.protocoltype as protocolType,L.areaid as areaId,
- L.sectionid as sectionId,L.groupid as groupId,L.longitude,L.latitude,S.name as section,L.dev_addr as devAddr,
- L.macAddress,L.section_id as loopNumber,G.name as `group`,N.network_name as network,N.rssi,
- L.lamp_pole_id as lampPoleId,LP.name as lampPoleName,L.control_type as controlType,
- L.lighteness,N.status as netStatus,LI.colour_value as colourValue,LI.used_energy_total as usedEnergyTotal,LI.updatetime,LI.work_time_total as workTimeTotal,
- LI.gridPF,LI.used_energy_tonight as usedEnergyTonight,L.faultstatus,N.snr,N.rssi,AI.id as alarmId,
- AI.stralarmtype as alarmInfo,S.timezone,L.status as lampStatas,L.freqId,
- L.ratedpower as power,L.address as imei,N.simid,L.name,N.sw_version as solfVersion,
- N.hw_version as hardVersion,L.install_date,L.expiration_date,L.mode
- from lampinfo L
- left join section as S on S.id = L.sectionid
- left join global_location as GL on GL.id = S.pid
- left join lamp_info_log_new as LI on LI.lampid = L.id
- left join network as N on N.id = L.networkid
- left join net_card_info as CD on N.id = CD.net_id
- left join policy as P on P.id = L.policyid
- left join lamp_pole as LP on LP.id = L.lamp_pole_id
- left join `group` as G on G.id = L.groupid
- left join (select t1.* from all_alarm_info_log t1, (select lampid, max(updatetime) as maxtime from all_alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI on L.id = AI.lampid
- where L.id=#{id}
- </select>
- <select id="getDetailsByAddress" resultType="com.welampiot.dto.LampInfoDTO" parameterType="String">
- select
- L.number,
- L.id,
- L.address as sn,
- <choose>
- <when test="version == 1">
- GL.english_name as area,
- </when>
- <when test="version == 2">
- GL.ru_name as area,
- </when>
- <otherwise>
- GL.chinese_name as area,
- </otherwise>
- </choose>
- L.networkid as networkId,N.protocoltype as protocolType,L.areaid as areaId,
- L.sectionid as sectionId,L.groupid as groupId,L.longitude,L.latitude,S.name as section,L.dev_addr as devAddr,
- L.macAddress,L.section_id as loopNumber,G.name as `group`,N.network_name as network,N.rssi,
- L.lamp_pole_id as lampPoleId,LP.name as lampPoleName,L.control_type as controlType,
- L.lighteness,N.status as netStatus,LI.colour_value as colourValue,LI.used_energy_total as usedEnergyTotal,LI.updatetime,LI.work_time_total as workTimeTotal,
- LI.gridPF,LI.used_energy_tonight as usedEnergyTonight,L.faultstatus,N.snr,N.rssi,AI.id as alarmId,
- AI.stralarmtype as alarmInfo,S.timezone,L.status as lampStatas,L.freqId,
- L.ratedpower as power,L.address as imei,N.simid,L.name,N.sw_version as solfVersion,
- N.hw_version as hardVersion,L.install_date,L.expiration_date
- from lampinfo L
- left join section as S on S.id = L.sectionid
- left join global_location as GL on GL.id = S.pid
- left join lamp_info_log_new as LI on LI.lampid = L.id
- left join network as N on N.id = L.networkid
- left join net_card_info as CD on N.id = CD.net_id
- left join policy as P on P.id = L.policyid
- left join lamp_pole as LP on LP.id = L.lamp_pole_id
- left join `group` as G on G.id = L.groupid
- left join (select t1.* from all_alarm_info_log t1, (select lampid, max(updatetime) as maxtime from all_alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI on L.id = AI.lampid
- where L.address=#{address}
- </select>
- <select id="findByVO" resultType="Integer" parameterType="com.welampiot.dto.LampInfoDTO">
- select count(*) from lampinfo L
- where 1=1
- <if test="sectionId != null">
- and L.sectionid = #{sectionId}
- </if>
- <if test="name != null">
- and L.name = #{name}
- </if>
- <if test="number != null">
- and L.number = #{number}
- </if>
- <if test="sn != null">
- and L.address = #{sn}
- </if>
- <if test="id != null">
- and L.id != #{id}
- </if>
- </select>
- <select id="checkData" resultType="Integer" parameterType="com.welampiot.dto.LampInfoDTO">
- select IFNULL(L.id,0) from lampinfo L
- where 1=1
- <if test="sectionId != null">
- and L.sectionid = #{sectionId}
- </if>
- <if test="networkId != null">
- and L.networkid != #{networkId}
- </if>
- <if test="name != null">
- and L.name = #{name}
- </if>
- <if test="number != null">
- and L.number = #{number}
- </if>
- <if test="sn != null">
- and L.address = #{sn}
- </if>
- <if test="id != null">
- and L.id != #{id}
- </if>
- limit 1
- </select>
- <insert id="add" parameterType="com.welampiot.dto.LampInfoDTO" useGeneratedKeys="true" keyProperty="id"
- >
- insert into lampinfo(networkid,name,number,address,areaid,sectionid,longitude,latitude,createtime,ratedpower,control_type
- <if test="mode != null">,mode</if>
- <if test="lampPoleId != null">,lamp_pole_id</if>
- <if test="installDate != null">,install_date</if>
- <if test="expirationDate != null">,expiration_date</if>
- )
- values
- (#{networkId},#{name},#{number},#{sn},#{areaId},#{sectionId},#{longitude},#{latitude},#{createTime},#{ratedPower},#{controlType}
- <if test="mode != null">,#{mode}</if>
- <if test="lampPoleId != null">,#{lampPoleId}</if>
- <if test="installDate != null">,#{installDate}</if>
- <if test="expirationDate != null">,#{expirationDate}</if>
- )
- </insert>
- <update id="update" parameterType="com.welampiot.dto.LampInfoDTO"
- >
- update lampinfo
- set
- networkid=#{networkId},
- name=#{name},
- number=#{number},
- address=#{sn},
- areaid=#{areaId},
- control_type=#{controlType},
- sectionid=#{sectionId},
- longitude=#{longitude},
- latitude=#{latitude},
- <if test="mode != null">mode=#{mode},</if>
- <if test="lampPoleId != null">lamp_pole_id=#{lampPoleId},</if>
- <if test="installDate != null">install_date=#{installDate},</if>
- <if test="expirationDate != null">expiration_date=#{expirationDate},</if>
- ratedpower=#{ratedPower}
- where id = #{id}
- </update>
- <select id="groupSelectLamp" resultType="com.welampiot.dto.LampInfoDTO" parameterType="com.welampiot.vo.LampListResponseVO">
- select
- L.number,
- L.id,
- L.address as sn,
- <choose>
- <when test="version == 1">
- G.english_name as area,
- </when>
- <when test="version == 2">
- G.ru_name as area,
- </when>
- <otherwise>
- G.chinese_name as area,
- </otherwise>
- </choose>
- S.name as section,
- S.timezone,
- L.lighteness,
- L.name,
- LI.gridvolt as voltage,
- LI.gridcurr as current,
- LI.grid_active_power as power,
- LI.work_time_total as lightTime,
- LI.used_energy_total as totalEnergy,
- LI.devicetime as cmdTime,
- LI.led_lux_value,LI.leakage_cur,
- N.status as networkStatus,
- L.status as lampStatus,
- L.online as lampOnline,
- N.rssi,
- N.snr,
- N.protocoltype,
- LI.updatetime as updateTime,
- L.faultstatus,
- L.mode,
- N.hw_version as hwVersion,
- N.sw_version as swVersion,
- L.control_type as controlType,
- L.macAddress,
- L.dev_addr as devAddr,
- L.bindStatus,
- L.policy_type as policyType,
- L.policyid as policyId,
- L.longitude,
- L.latitude,L.new_faultstatus
- from lampinfo L
- left join section as S on S.id = L.sectionid
- left join global_location as G on G.id = S.pid
- left join lamp_info_log_new as LI on LI.lampid = L.id
- left join network as N on N.id = L.networkid
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and L.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="lampIds != null">
- and L.id in (#{lampIds})
- </if>
- </select>
- <delete id="deleteById">
- delete from lampinfo where id=#{id};
- </delete>
- <select id="getNavByVO" resultType="com.welampiot.dto.LampInfoDTO" parameterType="com.welampiot.vo.LampListResponseVO">
- select
- L.number,
- L.id,
- L.mode,
- N.protocoltype,
- L.areaid as areaId,
- L.control_type as controlType
- from lampinfo L
- left join network as N on N.id = L.networkid
- where 1=1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and L.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- <if test="lampType != null and lampType == 1">
- and L.lamp_pole_id != 0
- </if>
- order by L.number asc,L.mode asc,L.createtime desc,L.id desc
- </select>
- <select id="getLampPoleDetailListByLampPoleId" resultType="com.welampiot.dto.LampInfoDTO" parameterType="int">
- select
- L.number,
- L.id,
- L.address as sn,
- L.address,
- L.areaid as areaId,
- L.sectionid as sectionId,
- L.name,
- N.protocoltype,
- L.control_type as controlType,
- L.macAddress,
- L.dev_addr as devAddr,
- L.longitude,
- L.latitude,L.install_date as installDate,L.expiration_date as expirationDate,L.ratedpower as ratedPower
- from lampinfo L
- left join section as S on S.id = L.sectionid
- left join network as N on N.id = L.networkid
- where lamp_pole_id=#{lampPoleId}
- </select>
- <select id="getLampInfoListByDTO" resultType="com.welampiot.dto.LampInfoDTO">
- select l.id,l.number,l.status,l.lighteness,n.status as netStatus,l1.grid_active_power as power,l.updatetime as updateTime,
- l1.gridvolt as voltage,l1.gridcurr as current,l1.gridPF,l1.used_energy_tonight as usedEnergyTonight,l1.work_time_total as lightTime,
- l.faultstatus,l.longitude,l.latitude,l.groupid as groupId,l.loopid as loopId,n.rssi,n.snr,l1.used_energy_total as usedEnergyTotal,
- l.control_type as controlType,l.colour_val as colourVal,a.id as alarmId,s.timezone
- from lampinfo l
- left join network n on l.networkid = n.id
- left join lamp_info_log_new l1 on l.id = l1.lampid
- left join all_alarm_info_log a on l.id = a.lampid
- left join section s on s.id = l.sectionid
- where 1=1
- <if test="keyword != null and keyword != ''">
- and (l.name like '%${keyword}%' or l.number like '%${keyword}%')
- </if>
- <if test="sectionList != null and !sectionList.isEmpty()">
- and l.sectionid in
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="type == 5">
- and l.faultstatus != 0 and n.status = 1 and l.faultstatus != 128
- </when>
- <when test="type == 4">
- and n.status = 1
- </when>
- <when test="type == 3">
- and n.status = 0
- </when>
- <when test="type == 2">
- and n.status = 1 and l.status = 0
- </when>
- <when test="type == 1">
- and n.status = 1 and l.status = 1
- </when>
- </choose>
- <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>
- </select>
- <select id="getLampLocationByGroupId" resultType="com.welampiot.dto.LampInfoDTO">
- select l.latitude,l.longitude
- from lampinfo l
- left join `group` g on g.id = l.groupid
- where g.id = #{id}
- </select>
- <select id="getLampLocationByLoopId" resultType="com.welampiot.dto.LampInfoDTO">
- select l.latitude,l.longitude
- from lampinfo l
- left join `loop` l1 on l1.id = l.loopid
- where l1.id = #{id}
- </select>
- <!-- 灯控安装总数 -->
- <select id="getLampInstallTotalByDTO" resultType="Integer">
- select count(l.id)
- from lampinfo l
- where 1=1
- <if test="type != null and type == 2">
- and l.lamp_pole_id != 0
- </if>
- <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>
- <if test="sectionId != null and sectionId != 0">
- and l.sectionid = #{sectionId}
- </if>
- </select>
- <!-- 灯控亮灯数 -->
- <select id="getLampLightTotalByDTO" resultType="Integer">
- select count(l.id)
- from lampinfo l
- left join network n on l.networkid = n.id
- where n.status = 1 and l.status = 1
- <if test="type != null and type == 2">
- and l.lamp_pole_id != 0
- </if>
- <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>
- <if test="sectionId != null and sectionId != 0">
- and l.sectionid = #{sectionId}
- </if>
- </select>
- <!-- 灯控在线数 -->
- <select id="getLampOnlineTotalByDTO" resultType="Integer">
- select count(l.id)
- from lampinfo l
- left join network n on l.networkid = n.id
- where n.status = 1
- <if test="type != null and type == 2">
- and l.lamp_pole_id != 0
- </if>
- <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>
- <if test="sectionId != null and sectionId != 0">
- and l.sectionid = #{sectionId}
- </if>
- </select>
- <!-- 灯控故障数 -->
- <select id="getLampFaultTotalByDTO" resultType="Integer">
- select count(l.id)
- from lampinfo l
- left join network n on l.networkid = n.id
- where n.status = 1 and l.faultstatus != 0 and l.faultstatus != 128
- <if test="type != null and type == 2">
- and l.lamp_pole_id != 0
- </if>
- <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>
- <if test="sectionId != null and sectionId != 0">
- and l.sectionid = #{sectionId}
- </if>
- </select>
- <update id="changeLampLocationById" parameterType="LampInfoDTO">
- update
- lampinfo l
- set
- l.longitude = #{longitude},
- l.latitude = #{latitude}
- where l.id = #{id}
- </update>
- <select id="getSectionOfLampCountBySectionId" resultType="Integer">
- select count(l.id) as total
- from lampinfo l
- where l.sectionid = #{id}
- </select>
- <select id="getNameOrNumber" resultType="String">
- <choose>
- <when test="type == 0">
- select l.number
- from lampinfo l
- where l.id = #{value}
- </when>
- <when test="type == 1">
- select s.name
- from section s
- where s.id = #{value}
- </when>
- <when test="type == 2">
- select
- <choose>
- <when test="version == 0">
- g.chinese_name
- </when>
- <when test="version == 1">
- g.english_name
- </when>
- <otherwise>
- g.ru_name
- </otherwise>
- </choose>
- from global_location g
- where g.id = #{value}
- </when>
- </choose>
- </select>
- <select id="getLampInfoDTOById" resultType="com.welampiot.dto.LampInfoDTO">
- select l.id,l.number
- from lampinfo l
- where l.id = #{id}
- </select>
- <select id="getLampList" resultType="com.welampiot.dto.LampInfoDTO">
- select
- l.id,l.lamp_pole_id as lampPoleId,lp.name as lampPoleName,w.num as sn,s.name as section,l.number,l.name
- <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>
- ,n.status,l.lighteness,l1.gridcurr as current,l1.gridvolt as voltage,n.protocoltype as protocolType,
- l1.grid_active_power as power,l.address,l.updatetime as updateTime,l.install_date as installDate,l.online as lampOnline,
- l.expiration_date as expirationDate,p.name as policyName,l1.devicetime as serverTime,l1.work_time_total as lightTime
- from lampinfo l
- left join lamp_pole lp on l.lamp_pole_id = lp.id
- left join wifi w on lp.id = w.lamp_pole_id
- left join section s on l.section_id = s.id
- left join global_location gl on gl.id = l.areaid
- left join network n on l.networkid = n.id
- left join lamp_info_log_new l1 on l1.lampid = l.id
- left join policy p on l.policyid = p.id
- 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>
- <if test="sectionId != null and sectionId != 0">
- and l.sectionid = #{sectionId}
- </if>
- <if test="keyword != null and keyword != ''">
- and (l.number like '%${keyword}%' or l.address like '%${keyword}%')
- </if>
- <choose>
- <when test="online == 1">
- and n.status = 0
- </when>
- <when test="online == 2">
- and n.status = 1
- </when>
- </choose>
- <if test="page >= 0 and count > 0">
- limit #{page},#{count}
- </if>
- </select>
- <select id="getLampTotal" resultType="Integer">
- select count(*)
- from lampinfo 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>
- <if test="sectionId != null and sectionId != 0">
- and l.sectionid = #{sectionId}
- </if>
- </select>
- <select id="getCityLampCount" resultType="Integer">
- select count(*)
- from lampinfo l
- left join section s on l.sectionid = s.id
- left join global_location gl on s.pid = gl.id
- left join global_location gl1 on gl.pid = gl1.id
- where gl1.id = #{id}
- </select>
- <select id="getLampDataByLampIds" resultType="LampInfoDTO">
- select
- l.name,
- l.address,
- l.number,
- l.lighteness,
- l.status,
- l.control_type as controlType,
- n.status as `online`,
- l.power,
- l.mode,
- n.protocoltype as protocolType
- from lampinfo l
- left join network n on l.networkid = n.id
- where l.id in
- <foreach collection="lampIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </select>
- <update id="updateLight" parameterType="com.welampiot.dto.LampInfoDTO"
- >
- update lampinfo
- set
- lighteness=#{light}
- <if test="policyId != null">,policyid=#{policyId}</if>
- <if test="policyType != null">,policy_type=#{policyType}</if>
- <if test="light > 0">,status=1</if>
- <if test="light == 0">,status=0</if>
- where id = #{id}
- </update>
- <select id="getListByIdList" resultType="com.welampiot.dto.LampInfoDTO" parameterType="java.util.List">
- select
- L.id,
- L.address as sn,
- N.protocoltype,
- L.mode,
- L.control_type as controlType,
- from lampinfo L
- left join section as S on S.id = L.sectionid
- left join network as N on N.id = L.networkid
- where 1=1
- <if test="idList != null and !idList.isEmpty()">
- and L.id in
- <foreach item="vo" collection="idList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- </select>
- <select id="getLampPoleCountByVO" resultType="Integer" parameterType="com.welampiot.vo.LampCountVO">
- select count(*) from lampinfo L
- left join section as S on S.id = L.sectionid
- left join network as N on N.id = L.networkid
- where L.lamp_pole_id != 0
- <if test="sectionList != null and !sectionList.isEmpty()">
- and L.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- </select>
- <select id="areaInfoLampList" parameterType="com.welampiot.vo.LampListResponseVO" resultType="com.welampiot.dto.LampInfoDTO">
- select a.areaid as areaId,a.id,d.id as companyId from lampinfo a
- left join lamp_pole b on a.lamp_pole_id = b.id
- left join user c on b.create_id = c.id
- left join company d on d.id = c.company_id
- where a.lamp_pole_id != 0
- <if test="sectionList != null and !sectionList.isEmpty()">
- and a.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- </select>
- <select id="getLampListByLampPoleId" resultType="LampInfoDTO">
- select
- l.id,
- l.number
- from lampinfo l
- left join lamp_pole lp on l.lamp_pole_id = lp.id
- where l.lamp_pole_id = #{lampPoleId}
- </select>
- <select id="getLampPoleIdByLampId" resultType="Integer">
- select l.lamp_pole_id
- from lampinfo l
- where l.id = #{id}
- </select>
- <select id="getLampCountByLampPoleId" resultType="Integer">
- select count(*)
- from lampinfo l
- where l.lamp_pole_id = #{lampPoleId}
- </select>
- <update id="updateLampInfoForLoopId" parameterType="LampInfoDTO">
- update lampinfo l
- set
- l.loopid = #{loopId}
- where l.id = #{id}
- </update>
-
- <select id="getLampInfoListForGroup" resultType="LampInfoDTO">
- select
- l.id,
- l.number,
- n.status as networkStatus,
- l.status as lampStatus,
- l.lighteness,
- l1.gridcurr as `current`,
- l1.gridvolt as voltage,
- l1.grid_active_power as power,
- n.rssi,
- n.snr,
- n.protocoltype as protocolType,
- l.updatetime as updateTime,
- s.name as section,
- l1.work_time_total as lightTime
- <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>
- from lampinfo l
- left join lamp_info_log_new l1 on l1.lampid = l.id
- left join network n on l.networkid = n.id
- left join section s on s.id = l.sectionid
- left join global_location gl on gl.id = s.pid
- 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="sectionId != null and sectionId != 0">
- and l.sectionid = #{secitonId}
- </if>
- </select>
- <select id="getAlarmAreaCountTop" resultType="LampInfoDTO">
- SELECT COUNT(*) AS alarmCount
- <choose>
- <when test="version == 0">
- ,a.chinese_name AS area
- </when>
- <when test="version == 1">
- ,a.english_name AS area
- </when>
- <otherwise>
- ,a.ru_name AS area
- </otherwise>
- </choose>
- FROM `lampinfo` l
- LEFT JOIN global_location a ON a.id = l.areaid
- WHERE l.faultstatus != 0 AND l.faultstatus != 128
- <if test="sectionList != null and !sectionList.isEmpty()">
- and l.sectionid IN
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY l.areaid
- ORDER BY alarmCount DESC
- LIMIT 5
- </select>
- <select id="getLampEleUseSectionTop" resultType="LampInfoDTO">
- SELECT
- COUNT(l.id) as lampCount,
- s.name as section,
- SUM(a.total_gener_energy_cache) as consumption
- FROM lampinfo l
- LEFT JOIN section s ON s.id = l.sectionid
- LEFT JOIN lamp_info_log_new a ON a.lampid = l.id
- <if test="sectionList != null and !sectionList.isEmpty()">
- WHERE l.sectionid IN
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY l.sectionid
- ORDER BY consumption DESC
- LIMIT 5
- </select>
- <select id="getLampInfoAlarmList" resultType="LampInfoDTO">
- SELECT
- a.stralarmtype AS alarmStr,
- a.updatetime AS updateTime,
- l.number,
- s.name AS section
- <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>
- FROM lampinfo l
- LEFT JOIN section s ON s.id = l.sectionid
- LEFT JOIN global_location gl ON gl.id = s.pid
- LEFT JOIN
- (SELECT t1.*
- FROM all_alarm_info_log t1,
- (SELECT lampid,
- max(updatetime) AS maxtime
- FROM all_alarm_info_log
- GROUP BY lampid) t2
- WHERE t1.lampid = t2.lampid
- AND t1.updatetime = t2.maxtime) AS a ON a.lampid = l.id
- WHERE a.devType = 0
- <if test="sectionList != null and !sectionList.isEmpty()">
- AND l.sectionid IN
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- ORDER BY a.updatetime DESC
- <if test="page >= 0 and count > 0">
- LIMIT #{page},#{count}
- </if>
- </select>
- <select id="getLampAlarmTotal" resultType="LampInfoDTO">
- SELECT
- COUNT(l.id) AS lampCount,
- DATE(a.updatetime) AS updateTime
- FROM lampinfo l
- LEFT JOIN
- (SELECT t1.*
- FROM all_alarm_info_log t1,
- (SELECT lampid, MAX(updatetime) AS maxtime FROM all_alarm_info_log ORDER BY lampid) t2
- WHERE t1.lampid = t2.lampid AND t1.updatetime = t2.maxtime) AS a ON a.lampid = l.id
- WHERE a.devType = 0 AND a.updatetime <![CDATA[ <= ]]> #{endDate} AND a.updatetime >= #{startDate}
- <if test="sectionList != null and !sectionList.isEmpty()">
- AND l.sectionid IN
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY DATE(a.updatetime)
- ORDER BY DATE(a.updatetime) DESC
- </select>
- <select id="getComBySectionList" resultType="com.welampiot.dto.LampInfoLogNewDTO" parameterType="com.welampiot.vo.LampVO">
- select sum(b.day_gener_energy) as dayGeneraEnergy,
- sum(b.month_gener_energy_cache) as monthGeneraEnergyCache,
- sum(b.year_gener_energy_cache) as yearGeneraEnergyCache,
- sum(b.total_gener_energy_cache) as totalGeneraEnergyCache,
- sum(b.month_ele_save_cache) as monthEleSaveCache,
- sum(b.year_ele_save_cache) as yearEleSaveCache,
- sum(b.total_ele_save_cache) as totalEleSaveCache,
- sum(b.day_ele_save) as dayEleSave
- from lampinfo a
- left join lamp_info_log_new b on b.lampid = a.id
- where a.id is not null and b.day_gener_energy < 50 and b.day_ele_save < 50
- <if test="sectionList != null and !sectionList.isEmpty()">
- and a.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- </select>
- <select id="getAlarmCountByVO" resultType="int" parameterType="com.welampiot.vo.LampVO">
- select count(*)
- from lampinfo a
- where ((a.faultstatus != 0 and a.faultstatus != 128) or a.new_faultstatus != 0)
- <if test="sectionList != null and !sectionList.isEmpty()">
- and a.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- </select>
- <select id="getOnlineCountByVO" resultType="int" parameterType="com.welampiot.vo.LampVO">
- select count(*)
- from lampinfo a
- left join network b on a.networkid = b.id
- where b.status = 1
- <if test="sectionList != null and !sectionList.isEmpty()">
- and a.sectionid in
- <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
- #{vo}
- </foreach>
- </if>
- </select>
- </mapper>
|