WatchPpgDataMapper.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.WatchPpgDataMapper">
  6. <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchPpgData">
  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="fval" column="json_data.fval" jdbcType="ARRAY" typeHandler="com.fs.watch.handler.IntegerArrayTypeHandler"/>
  10. <result property="sval" column="json_data.sval" jdbcType="ARRAY" typeHandler="com.fs.watch.handler.IntegerArrayTypeHandler"/>
  11. <result property="createTime" column="create_time" jdbcType="VARCHAR"/>
  12. </resultMap>
  13. <sql id="Base_Column_List">
  14. id,device_id,json_data.fval,
  15. json_data.sval,create_time
  16. </sql>
  17. <!-- 插入血糖数据 -->
  18. <update id="insert" parameterType="com.fs.watch.domain.WatchPpgData">
  19. INSERT INTO watch_ppg_data
  20. <trim prefix="(" suffix=")" suffixOverrides=",">
  21. <if test="data.id != null">
  22. id,
  23. </if>
  24. <if test="data.deviceId != null">
  25. device_id,
  26. </if>
  27. <if test="data.fval != null">
  28. json_data.fval,
  29. </if>
  30. <if test="data.sval != null">
  31. json_data.sval,
  32. </if>
  33. <if test="data.createTime != null">
  34. create_time,
  35. </if>
  36. </trim>
  37. <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
  38. <if test="data.id != null">
  39. #{data.id},
  40. </if>
  41. <if test="data.deviceId != null">
  42. #{data.deviceId},
  43. </if>
  44. <if test="data.fval != null">
  45. #{data.fval},
  46. </if>
  47. <if test="data.sval != null">
  48. #{data.sval},
  49. </if>
  50. <if test="data.createTime != null">
  51. #{data.createTime},
  52. </if>
  53. </trim>
  54. </update>
  55. <!-- 查询数据是否存在 -->
  56. <select id="queryByCreateTime" resultType="java.lang.Integer">
  57. SELECT COUNT(*)
  58. FROM watch_ppg_data
  59. WHERE create_time = #{createTime}
  60. </select>
  61. <select id="getLastByDeviceId" resultMap="BaseResultMap">
  62. select * from watch_ppg_data where device_id like #{deviceId} order by create_time desc limit 1
  63. </select>
  64. </mapper>