| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?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.WatchContinuousSpo2DataMapper">
- <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchContinuousSpo2Data">
- <result property="id" column="id" jdbcType="OTHER" typeHandler="com.fs.watch.handler.UUIDTypeHandler"/>
- <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
- <result property="spo2" column="json_data.spo2" jdbcType="ARRAY" typeHandler="com.fs.watch.handler.IntegerListTypeHandler"/>
- <result property="hr" column="json_data.hr" jdbcType="ARRAY" typeHandler="com.fs.watch.handler.IntegerListTypeHandler"/>
- <result property="perfusion" column="json_data.perfusion" jdbcType="ARRAY" typeHandler="com.fs.watch.handler.IntegerListTypeHandler"/>
- <result property="touch" column="json_data.touch" jdbcType="ARRAY" typeHandler="com.fs.watch.handler.IntegerListTypeHandler"/>
- <result property="createTime" column="create_time" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,device_id,json_data.spo2,
- json_data.hr,json_data.perfusion,json_data.touch,
- create_time
- </sql>
- <!-- 插入数据 -->
- <update id="insert" parameterType="com.fs.watch.domain.WatchContinuousSpo2Data">
- INSERT INTO watch_continuous_spo2_data
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- id,
- </if>
- <if test="data.deviceId != null">
- device_id,
- </if>
- <if test="data.spo2 != null">
- json_data.spo2,
- </if>
- <if test="data.hr != null">
- json_data.hr,
- </if>
- <if test="data.perfusion != null">
- json_data.perfusion,
- </if>
- <if test="data.touch != null">
- json_data.touch,
- </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.spo2 != null">
- #{data.spo2},
- </if>
- <if test="data.hr != null">
- #{data.hr},
- </if>
- <if test="data.perfusion != null">
- #{data.perfusion},
- </if>
- <if test="data.touch != null">
- #{data.touch},
- </if>
- <if test="data.createTime != null">
- #{data.createTime},
- </if>
- </trim>
- </update>
- <!-- 根据创建时间查询记录数 -->
- <select id="queryByCreateTime" resultType="java.lang.Integer">
- SELECT COUNT(*)
- FROM watch_continuous_spo2_data
- WHERE create_time = #{createTime}
- </select>
- <!-- <!– 根据日期和设备 ID 查询数据 –>-->
- <!-- <select id="queryOneByDateAndDeviceIdAndState" parameterType="map" resultMap="BaseResultMap">-->
- <!-- SELECT id, device_id, `json_data.spo2`, `json_data.hr`, `json_data.perfusion`, `json_data.touch`, create_time-->
- <!-- FROM watch_continuous_spo2_data-->
- <!-- WHERE device_id = #{deviceId}-->
- <!-- AND Date(create_time) = #{date}-->
- <!-- ORDER BY create_time-->
- <!-- </select>-->
- <select id="getLastByDeviceId" resultMap="BaseResultMap">
- select * from watch_continuous_spo2_data where device_id like #{deviceId} order by create_time desc limit 1
- </select>
- <select id="queryByDateAndDeviceIdAndState" resultMap="BaseResultMap">
- SELECT id, device_id, `json_data.spo2`, `json_data.hr`, `json_data.perfusion`, `json_data.touch`, create_time
- FROM watch_continuous_spo2_data
- WHERE device_id = #{deviceId}
- AND toDate(create_time) = #{date}
- ORDER BY create_time ASC
- </select>
- <select id="getLatest" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM
- watch_continuous_spo2_data
- WHERE
- device_id = #{deviceId}
- ORDER BY
- create_time DESC LIMIT 1
- </select>
- <select id="querySpPageByDate" resultMap="BaseResultMap">
- SELECT <include refid="Base_Column_List"/>
- FROM watch_continuous_spo2_data
- WHERE
- device_id = #{deviceId}
- AND create_time BETWEEN #{startTime} AND #{endTime}
- ORDER BY create_time ASC LIMIT #{num},#{size}
- </select>
- <select id="countSpPageByDate" resultType="java.lang.Integer">
- SELECT count(0)
- FROM watch_continuous_spo2_data
- WHERE
- device_id = #{deviceId}
- AND (create_time BETWEEN #{startTime} AND #{endTime})
- </select>
- <select id="querySpByDate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"></include>
- FROM
- watch_continuous_spo2_data
- WHERE
- device_id = #{deviceId}
- AND create_time BETWEEN #{startTime} AND #{endTime}
- ORDER BY
- create_time ASC
- </select>
- <!-- 根据日期和设备 ID 查询数据 -->
- <select id="queryOneByDateAndDeviceIdAndState" parameterType="map" resultMap="BaseResultMap">
- SELECT id, device_id, `json_data.spo2`, `json_data.hr`, `json_data.perfusion`, `json_data.touch`, create_time
- FROM watch_continuous_spo2_data
- WHERE device_id = #{deviceId}
- AND toDate(create_time) = #{date}
- ORDER BY create_time
- </select>
- <select id="queryByMonth" resultMap="BaseResultMap">
- SELECT *
- FROM watch.watch_continuous_spo2_data
- WHERE device_id like #{deviceId} and toYYYYMM(create_time) = #{monthStr}
- </select>
- </mapper>
|