HistoryDataMapper.xml 1.1 KB

1234567891011121314151617181920212223242526
  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.gbd.demp.data.exchange.mapper.HistoryDataMapper">
  4. <select id="getHistoryData" resultType="com.gbd.demp.data.exchange.entity.HistoryData">
  5. SELECT id, device_id, sensor_id, data_value, report_time, status
  6. FROM t_history_data
  7. where 1=1
  8. <choose>
  9. <when test="historyData.startTimeFrom != null and historyData.startTimeFrom !='' and historyData.startTimeTo!= null and historyData.startTimeTo !=''">
  10. And report_time &gt; #{historyData.startTimeFrom} And report_time &lt; #{historyData.startTimeTo}
  11. </when>
  12. <otherwise>
  13. and report_time>date_sub(now(),INTERVAL 30 MINUTE)
  14. </otherwise>
  15. </choose>
  16. <if test="switchValue==false">
  17. and status <![CDATA[ <> ]]> '06'
  18. </if>
  19. and device_id=#{historyData.deviceId}
  20. and sensor_id=#{historyData.sensorId}
  21. order by report_time
  22. </select>
  23. </mapper>