DataRealTimeMapper.xml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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.usky.backend.mapper.DataRealTimeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.usky.backend.domain.DataRealTime">
  6. <id column="id" property="id" />
  7. <result column="device_id" property="deviceId" />
  8. <result column="product_code" property="productCode" />
  9. <result column="device_type" property="deviceType" />
  10. <result column="attribute_name" property="attributeName" />
  11. <result column="attribute_data" property="attributeData" />
  12. <result column="data_time" property="dataTime" />
  13. <result column="insert_time" property="insertTime" />
  14. </resultMap>
  15. <!-- <insert id="insertHistoryTable" >-->
  16. <!-- insert into ${tableName} ( device_id, device_type, attribute_name, attribute_data, data_time, insert_time)-->
  17. <!-- values (#{dataInfo.deviceId}, #{dataInfo.deviceType}, #{dataInfo.name}, #{dataInfo.value}, #{dataInfo.timestamp}, #{curTime})-->
  18. <!-- </insert>-->
  19. <select id="QueryHistoryData" resultType="com.usky.backend.domain.MetricItemVo">
  20. SELECT
  21. attribute_data as value,data_time as timestamp
  22. FROM
  23. ${tableName}
  24. <where>
  25. <if test="deviceId != null">
  26. and device_id = #{deviceId}
  27. </if>
  28. <if test="metric != null">
  29. and attribute_name = #{metric}
  30. </if>
  31. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  32. and data_time BETWEEN #{startTime} AND #{endTime}
  33. </if>
  34. </where>
  35. </select>
  36. </mapper>