123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791 |
- <?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
- 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,
- 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,
- 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.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>
-
- <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>
-
- </mapper>
|