LampInfoCacheByDayMapper.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.welampiot.dao.LampInfoCacheByDayDao">
  4. <select id="getDayEleListByDTO" resultType="LampInfoCacheByDayDTO">
  5. select
  6. sum(l.consum) as conSumTotal,
  7. sum(l.powerSave) as powerSaveTotal,
  8. l.updatetime as updateTime
  9. from lamp_info_cache_by_day l
  10. left join lampinfo l1 on l.lampid = l1.id
  11. where l.updatetime between date_sub(now(),interval 30 day) and now()
  12. <if test="sectionList != null and !sectionList.isEmpty()">
  13. and l1.sectionid in
  14. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  15. #{item}
  16. </foreach>
  17. </if>
  18. <if test="areaId != null and areaId != 0">
  19. and l1.areaid = #{areaId}
  20. </if>
  21. <if test="type == 2">
  22. and l1.lamp_pole_id != 0
  23. </if>
  24. group by l.updatetime
  25. </select>
  26. <select id="getTimezoneBySectionId" resultType="Integer">
  27. select s.timezone
  28. from lamp_info_cache_by_day l
  29. left join section s on l.sectionid = s.id
  30. limit 1
  31. </select>
  32. <select id="getMonthConSum" resultType="LampInfoCacheByDayDTO">
  33. SELECT SUM(l.consum) AS conSum,
  34. SUM(l.powerSave) AS powerSave,
  35. SUM(l.lightTime) AS lightTime,
  36. l.updatetime AS updateTime
  37. FROM lamp_info_cache_by_day l
  38. WHERE l.updatetime <![CDATA[ >= ]]> #{startDate}
  39. AND l.updatetime <![CDATA[ <= ]]> #{endDate}
  40. <choose>
  41. <when test="type == 0 and value != 0">
  42. AND l.lampid = #{value}
  43. </when>
  44. <when test="type == 1 and value != 0">
  45. AND l.sectionid = #{value}
  46. </when>
  47. <when test="type == 2 and value != 0">
  48. AND l.areaid = #{value}
  49. </when>
  50. </choose>
  51. GROUP BY l.updatetime
  52. ORDER BY l.updatetime DESC
  53. </select>
  54. <select id="getYearConSum" resultType="LampInfoCacheByDayDTO">
  55. SELECT SUM(l.consum) AS conSum,
  56. SUM(l.powerSave) AS powerSave,
  57. SUM(l.lightTime) AS lightTime,
  58. l.updatetime AS updateTime
  59. FROM lamp_info_cache_by_day l
  60. WHERE l.updatetime <![CDATA[ >= ]]> #{startDate}
  61. AND l.updatetime <![CDATA[ <= ]]> #{endDate}
  62. <choose>
  63. <when test="type == 0 and value != 0">
  64. AND l.lampid = #{value}
  65. </when>
  66. <when test="type == 1 and value != 0">
  67. AND l.sectionid = #{value}
  68. </when>
  69. <when test="type == 2 and value != 0">
  70. AND l.areaid = #{value}
  71. </when>
  72. </choose>
  73. GROUP BY MONTH(l.updatetime)
  74. ORDER BY l.updatetime DESC
  75. </select>
  76. </mapper>