| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.fs.watch.mapper.WatchEcgDataMapper">
- <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchEcgData">
- <result property="id" column="id" jdbcType="OTHER" typeHandler="com.fs.watch.handler.UUIDTypeHandler"/>
- <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
- <result property="val" column="json_data.val" jdbcType="OTHER" typeHandler="com.fs.watch.handler.IntegerArrayTypeHandler"/>
- <result property="count" column="count" jdbcType="INTEGER"/>
- <result property="createTime" column="create_time" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,device_id,json_data.val,
- count,create_time
- </sql>
- <!-- 插入心电图数据 -->
- <update id="insert" parameterType="com.fs.watch.domain.WatchEcgData">
- INSERT INTO watch_ecg_data
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- id,
- </if>
- <if test="data.deviceId != null">
- device_id,
- </if>
- <if test="data.val != null">
- json_data.val,
- </if>
- <if test="data.count != null">
- count,
- </if>
- <if test="data.createTime != null">
- create_time,
- </if>
- </trim>
- <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- #{data.id},
- </if>
- <if test="data.deviceId != null">
- #{data.deviceId},
- </if>
- <if test="data.val != null">
- #{data.val},
- </if>
- <if test="data.count != null">
- #{data.count},
- </if>
- <if test="data.createTime != null">
- #{data.createTime},
- </if>
- </trim>
- </update>
- <!-- 查询数据是否存在 -->
- <select id="queryByCreateTime" resultType="java.lang.Integer">
- SELECT COUNT(*)
- FROM watch_ecg_data
- WHERE create_time = #{createTime}
- </select>
- <!-- 根据日期和设备ID查询心电图数据 -->
- <select id="getByDateAndDeviceId" resultMap="BaseResultMap">
- SELECT id, device_id, `json_data.val`, count, create_time
- FROM watch_ecg_data
- WHERE device_id = #{deviceId}
- AND toDate(create_time) = #{date}
- ORDER BY create_time ASC
- </select>
- <select id="getLastByDeviceId" resultMap="BaseResultMap">
- select * from watch_ecg_data where device_id like #{deviceId} order by create_time desc limit 1
- </select>
- </mapper>
|