WatchThirdBkDataMapper.xml 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.watch.mapper.WatchThirdBkDataMapper">
  6. <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchThirdBkData">
  7. <result property="id" column="id" jdbcType="OTHER" typeHandler="com.fs.watch.handler.UUIDTypeHandler"/>
  8. <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
  9. <result property="val" column="val" jdbcType="FLOAT"/>
  10. <result property="status" column="status" jdbcType="INTEGER"/>
  11. <result property="createTime" column="create_time" jdbcType="VARCHAR" />
  12. <!-- <id property="id" column="id" jdbcType="CHAR"/>-->
  13. <!-- <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>-->
  14. <!-- <result property="val" column="val" jdbcType="FLOAT"/>-->
  15. <!-- <result property="status" column="status" jdbcType="TINYINT"/>-->
  16. <!-- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>-->
  17. </resultMap>
  18. <sql id="Base_Column_List">
  19. id,device_id,val,
  20. status,create_time
  21. </sql>
  22. <update id="insert" parameterType="com.fs.watch.domain.WatchThirdBkData">
  23. INSERT INTO watch_third_bk_data
  24. <trim prefix="(" suffix=")" suffixOverrides=",">
  25. <if test="data.id != null">
  26. id,
  27. </if>
  28. <if test="data.deviceId != null">
  29. device_id,
  30. </if>
  31. <if test="data.val != null">
  32. val,
  33. </if>
  34. <if test="data.status != null">
  35. status,
  36. </if>
  37. <if test="data.createTime != null">
  38. create_time,
  39. </if>
  40. </trim>
  41. <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
  42. <if test="data.id != null">
  43. #{data.id},
  44. </if>
  45. <if test="data.deviceId != null">
  46. #{data.deviceId},
  47. </if>
  48. <if test="data.val != null">
  49. #{data.val},
  50. </if>
  51. <if test="data.status != null">
  52. #{data.status},
  53. </if>
  54. <if test="data.createTime != null">
  55. #{data.createTime},
  56. </if>
  57. </trim>
  58. </update>
  59. <!-- 查询创建时间是否存在 -->
  60. <select id="queryByCreateTime" parameterType="String" resultType="Integer">
  61. SELECT COUNT(*)
  62. FROM watch_third_bk_data
  63. WHERE create_time = #{createTime}
  64. </select>
  65. <!-- 查询某天某个设备的血压数据 -->
  66. <select id="queryByDateAndDeviceId" parameterType="map" resultMap="BaseResultMap">
  67. SELECT id, device_id, val, create_time
  68. FROM watch_third_bk_data
  69. WHERE device_id = #{deviceId}
  70. AND toDate(create_time) = #{date}
  71. ORDER BY create_time ASC
  72. </select>
  73. <select id="getLatest" resultMap="BaseResultMap">
  74. SELECT
  75. <include refid="Base_Column_List"/>
  76. FROM
  77. watch_third_bk_data
  78. WHERE
  79. device_id = #{deviceId}
  80. ORDER BY
  81. create_time DESC LIMIT 1
  82. </select>
  83. </mapper>