| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?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.WatchRriDataMapper">
- <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchRriData">
- <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="ARRAY" typeHandler="com.fs.watch.handler.ShortListTypeHandler"/>
- <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>
- <!-- 查询数据是否存在 -->
- <select id="queryByCreateTime" resultType="java.lang.Integer">
- SELECT COUNT(*)
- FROM watch_rri_data
- WHERE create_time = #{createTime}
- </select>
- <!-- 插入RRI数据 -->
- <update id="insert" parameterType="com.fs.watch.domain.WatchRriData">
- INSERT INTO watch_rri_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>
- <!-- 查询指定日期和设备ID的RRI数据 -->
- <select id="getByDateAndDeviceId" resultMap="BaseResultMap">
- SELECT id, device_id, json_data.val, count, create_time
- FROM watch_rri_data
- WHERE device_id = #{deviceId}
- AND toDate(create_time) = #{date}
- ORDER BY create_time ASC
- </select>
- <select id="getLastByDateAndDeviceId" resultMap="BaseResultMap">
- SELECT *
- FROM watch_rri_data
- WHERE device_id LIKE #{deviceId}
- AND create_time > toStartOfDay(parseDateTimeBestEffort(#{time}))
- AND create_time < toStartOfDay(parseDateTimeBestEffort(#{time})) + INTERVAL 1 DAY
- </select>
- <select id="getLastTime" resultType="java.lang.String">
- SELECT MAX(create_time) AS latest_create_time
- FROM watch_rri_data
- WHERE device_id LIKE #{deviceId}
- </select>
- </mapper>
|