123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?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.WatchThirdBpDataMapper">
- <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchThirdBpData">
- <result property="id" column="id" jdbcType="OTHER" typeHandler="com.fs.watch.handler.UUIDTypeHandler"/>
- <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
- <result property="sbp" column="sbp" jdbcType="INTEGER"/>
- <result property="dbp" column="dbp" jdbcType="INTEGER"/>
- <result property="hr" column="hr" jdbcType="INTEGER"/>
- <result property="pulse" column="pulse" jdbcType="INTEGER"/>
- <result property="status" column="status" jdbcType="INTEGER"/>
- <result property="mode" column="mode" jdbcType="INTEGER"/>
- <result property="createTime" column="create_time" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,device_id,sbp,
- dbp,hr,pulse,status,
- mode,create_time
- </sql>
- <!-- 查询创建时间是否存在 -->
- <select id="queryByCreateTime" parameterType="String" resultType="Integer">
- SELECT COUNT(*)
- FROM watch_third_bp_data
- WHERE create_time = #{createTime}
- </select>
- <!-- 插入血压数据 -->
- <update id="insert" parameterType="com.fs.watch.domain.WatchThirdBpData">
- INSERT INTO watch_third_bp_data
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- id,
- </if>
- <if test="data.deviceId != null">
- device_id,
- </if>
- <if test="data.sbp != null">
- sbp,
- </if>
- <if test="data.dbp != null">
- dbp,
- </if>
- <if test="data.hr != null">
- hr,
- </if>
- <if test="data.pulse != null">
- pulse,
- </if>
- <if test="data.status != null">
- status,
- </if>
- <if test="data.mode != null">
- mode,
- </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.sbp != null">
- #{data.sbp},
- </if>
- <if test="data.dbp != null">
- #{data.dbp},
- </if>
- <if test="data.hr != null">
- #{data.hr},
- </if>
- <if test="data.pulse != null">
- #{data.pulse},
- </if>
- <if test="data.status != null">
- #{data.status},
- </if>
- <if test="data.mode != null">
- #{data.mode},
- </if>
- <if test="data.createTime != null">
- #{data.createTime},
- </if>
- </trim>
- </update>
- <!-- 查询某天某个设备的血压数据 -->
- <select id="queryByDateAndDeviceId" parameterType="map" resultMap="BaseResultMap">
- SELECT id, device_id, sbp, dbp, hr, pulse,status, mode, create_time
- FROM watch_third_bp_data
- WHERE device_id = #{deviceId}
- AND toDate(create_time) = #{date}
- ORDER BY create_time ASC
- </select>
- <select id="queryBpByDate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM
- watch_third_bp_data
- WHERE
- device_id = #{deviceId}
- AND create_time BETWEEN #{startTime} AND #{endTime}
- <if test="status != null and status !=''" >
- AND status = #{status}
- </if>
- ORDER BY
- create_time ASC
- </select>
- <select id="getLastByDeviceId" resultMap="BaseResultMap">
- select * from watch_third_bp_data where device_id like #{deviceId} order by create_time desc limit 1
- </select>
- <select id="getLast" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM
- watch_third_bp_data
- WHERE
- device_id = #{deviceId}
- ORDER BY
- create_time DESC LIMIT 1
- </select>
- <select id="countBpByDate" resultType="java.util.Map">
- SELECT
- status,
- COUNT(*) AS count
- FROM
- watch_third_bp_data
- WHERE
- create_time BETWEEN #{startTime} AND #{endTime}
- AND device_id = #{deviceId}
- GROUP BY
- status
- </select>
- <select id="countBpPageByDate" resultType="java.lang.Integer">
- SELECT count(0)
- FROM watch_third_bp_data
- WHERE
- device_id = #{deviceId}
- <if test="status!=null and status !=''">
- and status = #{status}
- </if>
- AND (create_time BETWEEN #{startTime} AND #{endTime})
- </select>
- <select id="queryBgPageByDate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM watch_third_bp_data
- WHERE
- device_id = #{deviceId}
- <if test="status!=null and status !=''">
- and status = #{status}
- </if>
- AND create_time BETWEEN #{startTime} AND #{endTime}
- ORDER BY create_time ASC LIMIT #{num},#{size}
- </select>
- <select id="queryByMonth" resultMap="BaseResultMap">
- SELECT *
- FROM watch.watch_third_bp_data
- WHERE device_id like #{deviceId} and toYYYYMM(create_time) = #{monthStr}
- </select>
- </mapper>
|