123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?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.LampInfoCacheByDayDao">
-
- <select id="getDayEleListByDTO" resultType="LampInfoCacheByDayDTO">
- select
- sum(l.consum) as conSumTotal,
- sum(l.powerSave) as powerSaveTotal,
- l.updatetime as updateTime
- from lamp_info_cache_by_day l
- left join lampinfo l1 on l.lampid = l1.id
- where l.updatetime between date_sub(now(),interval 30 day) and now()
- <if test="sectionList != null and !sectionList.isEmpty()">
- and l1.sectionid in
- <foreach collection="sectionList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="areaId != null and areaId != 0">
- and l1.areaid = #{areaId}
- </if>
- <if test="type == 2">
- and l1.lamp_pole_id != 0
- </if>
- group by l.updatetime
- </select>
- <select id="getTimezoneBySectionId" resultType="Integer">
- select s.timezone
- from lamp_info_cache_by_day l
- left join section s on l.sectionid = s.id
- limit 1
- </select>
-
- <select id="getMonthConSum" resultType="LampInfoCacheByDayDTO">
- SELECT SUM(l.consum) AS conSum,
- SUM(l.powerSave) AS powerSave,
- SUM(l.lightTime) AS lightTime,
- l.updatetime AS updateTime
- FROM lamp_info_cache_by_day l
- WHERE l.updatetime <![CDATA[ >= ]]> #{startDate}
- AND l.updatetime <![CDATA[ <= ]]> #{endDate}
- <choose>
- <when test="type == 0 and value != 0">
- AND l.lampid = #{value}
- </when>
- <when test="type == 1 and value != 0">
- AND l.sectionid = #{value}
- </when>
- <when test="type == 2 and value != 0">
- AND l.areaid = #{value}
- </when>
- </choose>
- GROUP BY l.updatetime
- ORDER BY l.updatetime DESC
- </select>
- <select id="getYearConSum" resultType="LampInfoCacheByDayDTO">
- SELECT SUM(l.consum) AS conSum,
- SUM(l.powerSave) AS powerSave,
- SUM(l.lightTime) AS lightTime,
- l.updatetime AS updateTime
- FROM lamp_info_cache_by_day l
- WHERE l.updatetime <![CDATA[ >= ]]> #{startDate}
- AND l.updatetime <![CDATA[ <= ]]> #{endDate}
- <choose>
- <when test="type == 0 and value != 0">
- AND l.lampid = #{value}
- </when>
- <when test="type == 1 and value != 0">
- AND l.sectionid = #{value}
- </when>
- <when test="type == 2 and value != 0">
- AND l.areaid = #{value}
- </when>
- </choose>
- GROUP BY MONTH(l.updatetime)
- ORDER BY l.updatetime DESC
- </select>
- </mapper>
|