| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?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.WatchFatigueDataMapper">
- <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchFatigueData">
- <result property="id" column="id" jdbcType="OTHER" typeHandler="com.fs.watch.handler.UUIDTypeHandler"/>
- <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
- <result property="fatigue" column="fatigue" jdbcType="INTEGER"/>
- <result property="createTime" column="create_time" jdbcType="VARCHAR"/>
- <result property="status" column="status" jdbcType="INTEGER"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,device_id,fatigue,
- create_time,status
- </sql>
- <!-- 插入数据 -->
- <update id="insert" parameterType="com.fs.watch.domain.WatchFatigueData">
- INSERT INTO watch_fatigue_data
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- id,
- </if>
- <if test="data.deviceId != null">
- device_id,
- </if>
- <if test="data.fatigue != null">
- fatigue,
- </if>
- <if test="data.createTime != null">
- create_time,
- </if>
- <if test="data.status != null">
- status,
- </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.fatigue != null">
- #{data.fatigue},
- </if>
- <if test="data.createTime != null">
- #{data.createTime},
- </if>
- <if test="data.status != null">
- #{data.status},
- </if>
- </trim>
- </update>
- <!-- 查询数据是否存在 -->
- <select id="queryByCreateTime" resultType="java.lang.Integer">
- SELECT COUNT(*)
- FROM watch_fatigue_data
- WHERE create_time = #{createTime}
- </select>
- <select id="getLastByDeviceId" resultMap="BaseResultMap">
- select * from watch_fatigue_data where device_id like #{deviceId} order by create_time desc limit 1
- </select>
- <select id="page" resultType="com.fs.watch.domain.vo.WatchFatigueDataVo">
- SELECT id, device_id, 100-fatigue as pressure,create_time,status
- from watch_fatigue_data
- where device_id = #{deviceId}
- <if test="beginTime != null">
- and create_time <![CDATA[>=]]> #{beginTime}
- </if>
- <if test="endTime != null">
- and create_time <![CDATA[<=]]> #{endTime}
- </if>
- <!-- 数据范围过滤 -->
- ORDER BY create_time ASC
- ${params.dataScope}
- </select>
- <select id="queryByDateAndDeviceId" resultType="com.fs.watch.domain.vo.WatchFatigueDataVo">
- SELECT id, device_id, 100-fatigue as pressure,create_time
- FROM watch_fatigue_data
- WHERE device_id = #{deviceId}
- AND toDate(create_time) = #{date}
- ORDER BY create_time ASC
- </select>
- <select id="countByDate" resultType="java.util.Map">
- SELECT
- status,
- COUNT(*) AS count
- FROM
- watch_fatigue_data
- WHERE
- create_time BETWEEN #{startTime} AND #{endTime}
- AND device_id = #{deviceId}
- GROUP BY
- status
- </select>
- <select id="list" resultType="com.fs.watch.domain.vo.WatchFatigueDataVo">
- SELECT
- id, device_id, 100-fatigue as pressure,create_time,status
- from
- watch_fatigue_data
- WHERE
- device_id = #{deviceId}
- AND create_time BETWEEN #{startTime} AND #{endTime}
- ORDER BY
- create_time ASC
- </select>
- </mapper>
|