WatchMultiLeadsEcgDataMapper.xml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.WatchMultiLeadsEcgDataMapper">
  6. <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchMultiLeadsEcgData">
  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="channel" column="channel" jdbcType="INTEGER"/>
  10. <result property="singleChannelLength" column="single_channel_length" jdbcType="INTEGER"/>
  11. <result property="channels" column="json_data.channel" jdbcType="ARRAY" typeHandler="com.fs.watch.handler.IntegerArrayTypeHandler"/>
  12. <result property="val" column="json_data.val" jdbcType="ARRAY" typeHandler="com.fs.watch.handler.IntegerArrayTypeHandler"/>
  13. <result property="createTime" column="create_time" jdbcType="VARCHAR"/>
  14. </resultMap>
  15. <sql id="Base_Column_List">
  16. id,device_id,channel,
  17. single_channel_length,json_data.channel,json_data.val,
  18. create_time
  19. </sql>
  20. <!-- 插入多导联心电图数据 -->
  21. <update id="insert" parameterType="com.fs.watch.domain.WatchMultiLeadsEcgData">
  22. INSERT INTO watch_multi_leads_ecg_data
  23. <trim prefix="(" suffix=")" suffixOverrides=",">
  24. <if test="data.id != null">
  25. id,
  26. </if>
  27. <if test="data.deviceId != null">
  28. device_id,
  29. </if>
  30. <if test="data.channel != null">
  31. channel,
  32. </if>
  33. <if test="data.singleChannelLength != null">
  34. single_channel_length,
  35. </if>
  36. <if test="data.channels != null">
  37. json_data.channel,
  38. </if>
  39. <if test="data.val != null">
  40. json_data.val,
  41. </if>
  42. <if test="data.createTime != null">
  43. create_time,
  44. </if>
  45. </trim>
  46. <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
  47. <if test="data.id != null">
  48. #{data.id},
  49. </if>
  50. <if test="data.deviceId != null">
  51. #{data.deviceId},
  52. </if>
  53. <if test="data.channel != null">
  54. #{data.channel},
  55. </if>
  56. <if test="data.singleChannelLength != null">
  57. #{data.singleChannelLength},
  58. </if>
  59. <if test="data.channels != null">
  60. #{data.channels},
  61. </if>
  62. <if test="data.val != null">
  63. #{data.val},
  64. </if>
  65. <if test="data.createTime != null">
  66. #{data.createTime},
  67. </if>
  68. </trim>
  69. </update>
  70. <!-- 查询数据是否存在 -->
  71. <select id="queryByCreateTime" resultType="java.lang.Integer">
  72. SELECT COUNT(*)
  73. FROM watch_multi_leads_ecg_data
  74. WHERE create_time = #{createTime}
  75. </select>
  76. <select id="getLastByDeviceId" resultMap="BaseResultMap">
  77. select * from watch_multi_leads_ecg_data where device_id like #{deviceId} order by create_time desc limit 1
  78. </select>
  79. </mapper>