|
|
@@ -2,25 +2,43 @@
|
|
|
<!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 a left join network b on a.networkid = b.id
|
|
|
+ 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 a.sectionid in
|
|
|
+ and L.sectionid in
|
|
|
<foreach item="vo" collection="sectionList" open="(" separator="," close=")">
|
|
|
#{vo}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
<if test="onlineStatus != null">
|
|
|
- and b.status = #{onlineStatus}
|
|
|
+ and N.status = #{onlineStatus}
|
|
|
</if>
|
|
|
<if test="lampStatus != null">
|
|
|
<if test="lampStatus == 0">
|
|
|
- and a.lighteness = 0
|
|
|
+ and L.lighteness = 0
|
|
|
</if>
|
|
|
<if test="lampStatus == 1">
|
|
|
- and a.lighteness > 0
|
|
|
+ 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">
|
|
|
@@ -49,25 +67,274 @@
|
|
|
#{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}
|
|
|
+ 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="endDate != null and endDate != ''">
|
|
|
- and a.updatetime <= #{endDate}
|
|
|
+ <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>
|
|
|
- group by a.updatetime
|
|
|
- ) as t order by t.updatetime asc
|
|
|
+ </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 AI.faultstatus = #{alarmType}
|
|
|
+ </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>
|
|
|
+ )
|
|
|
+ values
|
|
|
+ (#{networkId},#{name},#{number},#{sn},#{areaId},#{sectionId},#{longitude},#{latitude},#{createTime},#{ratedPower},#{controlType}
|
|
|
+ <if test="mode != null">
|
|
|
+ ,#{mode}
|
|
|
+ </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>
|
|
|
+ ratedpower=#{ratedPower}
|
|
|
+
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteById">
|
|
|
+ delete from lampinfo where id=#{id};
|
|
|
+ </delete>
|
|
|
</mapper>
|