| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375 | <?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 as 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 as newFaultStatus,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.zegbee_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 as 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,lamp_ctrl_id        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.zegbee_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 as 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="address != null">            and L.address = #{address}        </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 networkId !=0">            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="address != null">            and L.address = #{address}        </if>        <if test="id != null">            and L.id != #{id}        </if>        <if test="macAddress != null">            and L.macAddress = #{macAddress}        </if>        <if test="devAddr != null">            and L.dev_addr = #{devAddr}        </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>        <if test="devAddr != null">,dev_addr</if>        <if test="freqId != null">,freqId</if>        <if test="loopNumber != null">,zegbee_section_id</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>        <if test="devAddr != null">,#{devAddr}</if>        <if test="freqId != null">,#{freqId}</if>        <if test="loopNumber != null">,#{zegbeeSectionId}</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 as 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 as newFaultStatus        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 as 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 and n.protocoltype != 11) or (n.protocoltype = 11 and l.online = 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 l.faultstatus != 0        <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.sectionid = 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=#{lighteness}        <if test="policyId != null">,policyid=#{policyId}</if>        <if test="policyType != null">,policy_type=#{policyType}</if>        <if test="lighteness > 0">,status=1</if>        <if test="lighteness == 0">,status=0</if>        <if test="updateTime != null">,updatetime=#{updateTime}</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>        <if test="status == 1">            and a.status = #{status}        </if>    </select>    <select id="getMapDataByVO" resultType="com.welampiot.dto.LampInfoDTO" parameterType="com.welampiot.vo.MapDataVO">        select L.id,L.number,L.longitude,L.latitude,N.status as netStatus,        <choose>            <when test="version == 1">                A.english_name as area,            </when>            <when test="version == 2">                A.ru_name as area,            </when>            <otherwise>                A.chinese_name as area,            </otherwise>        </choose>        S.name as section,L.status,L.lighteness,LI.gridvolt as voltage,LI.gridcurr as current,LI.day_gener_energy as dayConsumption,LI.work_time_total as lightTime,LI.updatetime as updateTime,L.loopid,LI.grid_active_power as power,N.rssi,N.snr,L.faultstatus as faultStatus,L.new_faultstatus as newFaultStatus,AI.stralarmtype,LO.name as loopName,AI.id as alarmId,L.name,L.install_date as installDate,L.expiration_date as expirationDate        from lampinfo L        left join network N on L.networkid = N.id        left join section S on L.sectionid = S.id        left join global_location A on A.id = S.pid        left join `loop` LO on LO.id = L.loopid        left join policy P on P.id = L.policyid        left join lamp_info_log_new LI on L.id = LI.lampid        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) AI on L.id = AI.lampid        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>        <if test="keyword != null and !keyword.isEmpty()">            and L.number like '%${keyword}%'        </if>        <choose>            <when test="!lngLow.isEmpty() and !lngHigh.isEmpty() and Double.parseDouble(lngLow) > Double.parseDouble(lngHigh)">                and ((L.longitude >= #{lngLow} and L.longitude <= 180) or (L.longitude <= #{lngLow} and L.longitude >= -180))            </when>            <otherwise>                <if test="!lngLow.isEmpty()">                    and L.longitude >= #{lngLow}                </if>                <if test="!lngHigh.isEmpty()">                    and L.longitude <= #{lngHigh}                </if>            </otherwise>        </choose>        <if test="!latLow.isEmpty()">            and L.latitude >= #{latLow}        </if>        <if test="!latHigh.isEmpty()">            and L.latitude <= #{latHigh}        </if>        group by L.id    </select>    <select id="getNewMapDataByVO" resultType="com.welampiot.dto.LampInfoDTO" parameterType="com.welampiot.vo.MapDataVO">        select L.id,L.number,L.longitude,L.latitude,N.status as netStatus,L.status,L.lighteness as light,N.rssi,N.snr,L.faultstatus,L.name        from lampinfo L        left join network N on L.networkid = N.id        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>        <if test="keyword != null and !keyword.isEmpty()">            and L.number like '%${keyword}%'        </if>        <choose>            <when test="!lngLow.isEmpty() and !lngHigh.isEmpty() and Double.parseDouble(lngLow) > Double.parseDouble(lngHigh)">                and ((L.longitude <![CDATA[ >= ]]> #{lngLow} and L.longitude <![CDATA[ <= ]]> 180) or (L.longitude <![CDATA[ <= ]]> #{lngLow} and L.longitude <![CDATA[ >= ]]> -180))            </when>            <otherwise>                <if test="!lngLow.isEmpty()">                    and L.longitude <![CDATA[ >= ]]> #{lngLow}                </if>                <if test="!lngHigh.isEmpty()">                    and L.longitude <![CDATA[ <= ]]> #{lngHigh}                </if>            </otherwise>        </choose>        <if test="!latLow.isEmpty()">            and L.latitude <![CDATA[ >= ]]> #{latLow}        </if>        <if test="!latHigh.isEmpty()">            and L.latitude <![CDATA[ <= ]]> #{latHigh}        </if>        group by L.id    </select>    <!-- 灯控路段故障数前十 -->    <select id="getLampSectionAlarmCountTop" resultType="LampInfoDTO">        SELECT        COUNT(b.id) as total,        s.name        FROM        lampinfo b        LEFT JOIN section s on b.sectionid = s.id,        (            SELECT            t1.lampid AS lampId            FROM            all_alarm_info_log t1,            (                SELECT                l.id,                a.id AS alarmId,                MAX( a.id ) AS maxId,                MAX( a.updatetime ) AS maxTime,                a.lampid,                a.`status`,                a.devType                FROM                lampinfo l                LEFT JOIN                all_alarm_info_log 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>                <if test="areaId != null and areaId != 0">                    AND l.areaid = #{areaId}                </if>                <if test="sectionId != null and sectionId != 0">                    AND l.sectionid = #{sectionId}                </if>                GROUP BY                a.lampid            ) t2            WHERE            t1.id = t2.maxId            AND t1.`status` != 2        ) t3        WHERE        b.id = t3.lampId        GROUP BY b.sectionid        ORDER BY total DESC        LIMIT 10    </select>    <!-- 智诺云·智慧灯杆-设备组件:灯控设备组件 -->    <select id="getLampOfLampPoleById" resultType="lampInfoDTO">        select l.id as lampId,l2.gridvolt as gridVolt,l2.gridcurr as gridCurr,l.id,lp.createtime as createTime,               l2.grid_active_power as gridActivePower,l2.gridPF,l2.work_time_total as workTimeTotal,               l2.total_gener_energy_cache as usedEnergyTotal,l2.total_ele_save_cache as powerSave,               p.name as policyName,l.lighteness,l.colour_val as colourVal,l.status,l.control_type as controlType        from lampinfo l        left join lamp_pole lp on l.lamp_pole_id = lp.id        left join lamp_info_log_new l2 on l2.lampid = l.id        left join policy p on p.id = l.policyid        where l.lamp_pole_id = #{lampPoleId}        <if test="lampId != null and lampId != 0">            and l.id = #{lampId}        </if>    </select>    <!-- 根据设备地址查找灯控设备信息 -->    <select id="findLampDeviceBySn" resultType="LampInfoDTO">        select l.id,n.protocoltype as protocolType,l.control_type as controlType,               s.name as section,n.status as `online`,l1.gridvolt as voltage,l1.gridcurr as `current`,               l1.grid_active_power as power,l1.gridPF,l.lighteness,l1.devicetime as cmdTime,l1.updatetime as updateTime,               l1.total_gener_energy_cache as totalEnergy,l1.work_time_total as lightTime               <choose>                   <when test="version == 0">                       ,g1.chinese_name as area,g2.chinese_name as city,g3.chinese_name as province                   </when>                   <when test="version == 1">                       ,g1.english_name as area,g2.english_name as city,g3.english_name as province                   </when>                   <otherwise>                       ,g1.ru_name as area,g2.ru_name as city,g3.ru_name as province                   </otherwise>               </choose>        from lampinfo l        left join lamp_info_log_new l1 on l1.lampid = l.id        left join network n on n.id = l.networkid        left join section s on l.sectionid = s.id        left join global_location g1 on s.pid = g1.id        left join global_location g2 on g1.pid = g2.id        left join global_location g3 on g2.pid = g3.id        where l.address = #{address}    </select>    <select id="getDataByVO" resultType="LampInfoDTO">        select id,address,sectionid as sectionId,number,networkid as networkId from lampinfo        <trim prefix="where" suffixOverrides="and|or">            <if test="id != null">                id = #{id} or            </if>            <if test="address != null and address != ''">                address = #{address} or            </if>            <if test="networkId != null and networkId != 0">                networkid = #{networkId} or            </if>            <if test="macAddress != null and macAddress != ''">                macAddress = #{macAddress} or            </if>        </trim>        limit 0,1    </select>    <select id="getListByDto" resultType="LampInfoDTO">        select id,address,mode,control_type as controlType,dev_addr as devAddr from lampinfo        <trim prefix="where" suffixOverrides="and|or">            <if test="id != null">                id = #{id} or            </if>            <if test="address != null and macAddress != ''">                address = #{address} and macAddress = #{macAddress} or            </if>        </trim>        limit 0,2    </select>    <insert id="addByDto" 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="macAddress != null">,macAddress</if>        <if test="mode != null">,mode</if>        <if test="lampPoleId != null and lampPoleId != 0">,lamp_pole_id</if>        <if test="installDate != null">,install_date</if>        <if test="expirationDate != null">,expiration_date</if>        <if test="devAddr != null and devAddr != 0">,dev_addr</if>        <if test="freqId != null">,freqId</if>        <if test="loopNumber != null">,zegbee_section_id</if>        <if test="bindStatus != null">,bindStatus</if>        )        values        (#{networkId},#{name},#{number},#{address},#{areaId},#{sectionId},#{longitude},#{latitude},#{createTime},#{ratedPower},#{controlType}        <if test="macAddress != null">,#{macAddress}</if>        <if test="mode != null">,#{mode}</if>        <if test="lampPoleId != null and lampPoleId != 0">,#{lampPoleId}</if>        <if test="installDate != null">,#{installDate}</if>        <if test="expirationDate != null">,#{expirationDate}</if>        <if test="devAddr != null and devAddr != 0">,#{devAddr}</if>        <if test="freqId != null">,#{freqId}</if>        <if test="loopNumber != null">,#{zegbeeSectionId}</if>        <if test="bindStatus != null">,#{bindStatus}</if>        )    </insert>    <update id="updateById" parameterType="com.welampiot.dto.LampInfoDTO"    >        update lampinfo        set        networkid=#{networkId},        name=#{name},        number=#{number},        address=#{address},        areaid=#{areaId},        control_type=#{controlType},        sectionid=#{sectionId},        longitude=#{longitude},        latitude=#{latitude}        <if test="mode != null">,mode=#{mode}</if>        <if test="lampPoleId != null and lampPoleId != 0">,lamp_pole_id=#{lampPoleId}</if>        <if test="installDate != null">,install_date=#{installDate}</if>        <if test="expirationDate != null">,expiration_date=#{expirationDate}</if>        <if test="ratedpower != null and ratedpower != 0">,ratedpower=#{ratedPower}</if>        where id = #{id}    </update>    <select id="getOneData" parameterType="HashMap" resultType="LampInfoDTO">        select id,name,address,mode        from lampinfo        where areaid = #{areaId} and sectionid = #{sectionId}        <if test="name != null">            and  name = #{name}        </if>        <if test="number != null">            and number = #{number}        </if>        <if test="mode != null">            and mode = #{mode}        </if>    </select>        <select id="getLampJoinLogList" parameterType="Integer" resultType="LampInfoDTO">        select a.lighteness,a.usedEnergyTotal,a.power_save as powerSave,b.work_time_total as workTimeTotal,a.policy_type as policyType,a.policyid as policyId,a.number,a.id from lampinfo a left join lamp_info_log_new b on a.id = b.lampid where a.lamp_pole_id = #{id} order by a.id desc    </select>        <select id="getLampLocaltion" resultType="LampInfoDTO" parameterType="LampInfoDTO">        select id,longitude,latitude,number from lampinfo        <trim prefix="where" suffixOverrides="and|or">            <if test="lampPoleId == 0">                lamp_pole_id = #{lampPoleId} and            </if>            <if test="sectionList != null and !sectionList.isEmpty()">                 sectionid IN                <foreach collection="sectionList" item="item" open="(" separator="," close=")">                    #{item}                </foreach>            </if>        </trim>    </select>    <select id="getLampById" resultType="LampInfoDTO">        select lighteness,colour_val as colourVal,power_save as powerSave,id,sectionid as sectionId        from lampinfo        where lamp_pole_id = #{id};    </select></mapper>
 |