| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <?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.WatchDeviceInfoMapper">
- <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchDeviceInfo">
- <id property="deviceId" column="device_id" jdbcType="BIGINT"/>
- <result property="companyId" column="company_id" jdbcType="BIGINT"/>
- <result property="companyUserId" column="company_user_id" jdbcType="BIGINT"/>
- <result property="doctorId" column="doctor_id" jdbcType="BIGINT"/>
- <result property="deviceNumber" column="device_number" jdbcType="VARCHAR"/>
- <result property="battery" column="battery" jdbcType="INTEGER"/>
- <result property="rssi" column="rssi" jdbcType="INTEGER"/>
- <result property="status" column="status" jdbcType="INTEGER"/>
- <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
- <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
- <result property="isDel" column="is_del" jdbcType="TINYINT"/>
- <result property="lifeStatus" column="life_status" jdbcType="INTEGER"/>
- <result property="isNormal" column="is_normal" jdbcType="INTEGER"/>
- </resultMap>
- <sql id="Base_Column_List">
- device_id,company_id,company_user_id,doctor_id,device_number,
- battery,rssi,status,
- create_by,create_time,update_by,
- update_time,is_del,life_status,is_normal
- </sql>
- <insert id="insert">
- insert into watch_device_info
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="deviceId != null">device_id,</if>
- <if test="createTime != null">create_time,</if>
- <if test="createBy != null">create_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="deviceNumber != null">device_number,</if>
- <if test="battery != null">battery,</if>
- <if test="rssi != null">rssi,</if>
- <if test="status != null">status,</if>
- <if test="lifeStatus != null">life_status,</if>
- <if test="isNormal != null">is_normal,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="deviceId != null">#{deviceId},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="deviceNumber != null">#{deviceNumber},</if>
- <if test="battery != null">#{battery},</if>
- <if test="rssi != null">#{rssi},</if>
- <if test="status != null">#{status},</if>
- <if test="lifeStatus != null">#{lifeStatus},</if>
- <if test="isNormal != null">#{isNormal},</if>
- </trim>
- </insert>
- <insert id="insertDeviceInfo" parameterType="WatchDeviceInfo" useGeneratedKeys="true" keyProperty="deviceId">
- insert into watch_device_info
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="createTime != null">create_time,</if>
- <if test="createBy != null">create_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="deviceNumber != null">device_number,</if>
- <if test="battery != null">battery,</if>
- <if test="rssi != null">rssi,</if>
- <if test="status != null">status,</if>
- <if test="lifeStatus != null">life_status,</if>
- <if test="isNormal != null">is_normal,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="createTime != null">#{createTime},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="deviceNumber != null">#{deviceNumber},</if>
- <if test="battery != null">#{battery},</if>
- <if test="rssi != null">#{rssi},</if>
- <if test="status != null">#{status},</if>
- <if test="lifeStatus != null">#{lifeStatus},</if>
- <if test="isNormal != null">#{isNormal},</if>
- </trim>
- </insert>
- <update id="updateByDeviceNumber">
- update watch_device_info
- <trim prefix="SET" suffixOverrides=",">
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="battery != null">battery = #{battery},</if>
- <if test="rssi != null">rssi = #{rssi},</if>
- <if test="status != null">status = #{status},</if>
- <if test="lifeStatus != null">life_status = #{lifeStatus},</if>
- <if test="isNormal != null">is_normal = #{isNormal},</if>
- </trim>
- where device_number like #{deviceNumber}
- </update>
- <update id="removeUserId">
- update watch_device_info
- <trim prefix="SET" suffixOverrides=",">
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- user_id = #{userId},
- <if test="battery != null">battery = #{battery},</if>
- <if test="rssi != null">rssi = #{rssi},</if>
- <if test="status != null">status = #{status},</if>
- <if test="lifeStatus != null">life_status = #{lifeStatus},</if>
- <if test="isNormal != null">is_normal = #{isNormal},</if>
- </trim>
- where device_number like #{deviceNumber}
- </update>
- <update id="remove">
- update watch_device_info set is_del = 1 where device_number like #{deviceNumber}
- </update>
- <update id="updateDeviceInfo" parameterType="WatchDeviceInfo">
- update watch_device_info
- <trim prefix="SET" suffixOverrides=",">
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="deviceNumber != null">device_number = #{deviceNumber},</if>
- <if test="battery != null">battery = #{battery},</if>
- <if test="rssi != null">rssi = #{rssi},</if>
- <if test="status != null">status = #{status},</if>
- <if test="lifeStatus != null">life_status = #{lifeStatus},</if>
- <if test="isNormal != null">is_normal = #{isNormal},</if>
- </trim>
- where device_id = #{deviceId}
- </update>
- <delete id="deleteDeviceInfoByDeviceIds" parameterType="String">
- <!-- delete from device_info where device_id in-->
- <!-- <foreach item="deviceId" collection="array" open="(" separator="," close=")">-->
- <!-- #{deviceId}-->
- <!-- </foreach>-->
- update watch_device_info set is_del = 1 where device_id in
- <foreach item="deviceId" collection="array" open="(" separator="," close=")">
- #{deviceId}
- </foreach>
- </delete>
- <select id="selectByDeviceNumber" resultType="com.fs.watch.domain.WatchDeviceInfo">
- SELECT * FROM watch_device_info WHERE device_number LIKE #{deviceNumber}
- </select>
- <select id="selectDeviceInfoList" parameterType="com.fs.watch.param.WatchDeviceInfoQueryParam" resultType="WatchDeviceInfoVo">
- SELECT a.*,
- IF(a.`status`=0,"OFFLINE",IF(a.`status` = 1,"ONLINE",IF(a.`status` = 3,"UNACTIVE",IF(a.`status` = 4,"DISABLE","NOT EXIST")))) as status_out,
- IF(a.`life_status`=0,"空置",IF(a.`life_status` = 1,"已送出","已激活")) as lifeStatusOut,fu.nick_name as watch_user_name,
- GROUP_CONCAT(DISTINCT c.company_name) AS company_name,
- GROUP_CONCAT(DISTINCT cu.nick_name) AS company_user_name,
- GROUP_CONCAT(DISTINCT fd.doctor_name) AS doctor_name,
- GROUP_CONCAT(DISTINCT fu2.nick_name) AS family_user_name
- FROM `watch_device_info` a
- LEFT JOIN watch_company wc ON wc.device_id = a.device_id
- LEFT JOIN watch_company_user wcu ON wcu.device_id = a.device_id
- LEFT JOIN watch_doctor wd ON wd.device_id = a.device_id
- LEFT JOIN watch_family wf ON wf.device_id = a.device_id
- LEFT JOIN fs_user fu ON fu.user_id = a.user_id
- LEFT JOIN company c ON c.company_id = wc.company_id
- LEFT JOIN fs_doctor fd ON fd.doctor_id = wd.doctor_id
- LEFT JOIN company_user cu ON cu.user_id = wcu.company_user_id
- LEFT JOIN fs_user fu2 ON fu2.user_id = wf.family_user_id
- where a.is_del = 0
- <if test="companyId != null "> and wc.company_id = #{companyId}</if>
- <if test="companyUserId != null "> and wcu.company_user_id = #{companyUserId}</if>
- <if test="doctorId != null ">and wd.doctor_id = #{doctorId}</if>
- <if test="userId != null "> and a.user_id = #{userId}</if>
- <if test="familyUserId != null "> and wf.family_user_id = #{familyUserId}</if>
- <if test="deviceNumber != null and deviceNumber != ''"> and a.device_number like concat("%",#{deviceNumber},"%")</if>
- <if test="battery != null "> and a.battery = #{battery}</if>
- <if test="rssi != null "> and a.rssi = #{rssi}</if>
- <if test="status != null "> and a.status = #{status}</if>
- <if test="lifeStatus != null">and a.life_status = #{lifeStatus}</if>
- <if test="isNormal != null">and a.is_normal = #{isNormal}</if>
- GROUP BY a.device_id
- </select>
- <select id="selectDeviceInfoList_COUNT" parameterType="com.fs.watch.param.WatchDeviceInfoQueryParam" resultType="long">
- SELECT COUNT(DISTINCT a.device_id) FROM `watch_device_info` a
- <if test="companyId != null ">
- LEFT JOIN watch_company wc ON wc.device_id = a.device_id
- </if>
- <if test="companyUserId != null ">
- LEFT JOIN watch_company_user wcu ON wcu.device_id = a.device_id
- </if>
- <if test="doctorId != null ">
- LEFT JOIN watch_doctor wd ON wd.device_id = a.device_id
- </if>
- <if test="userId != null ">
- LEFT JOIN fs_user fu ON fu.user_id = a.user_id
- </if>
- <if test="familyUserId != null ">
- LEFT JOIN watch_family wf ON wf.device_id = a.device_id
- </if>
- where a.is_del = 0
- <if test="companyId != null "> and wc.company_id = #{companyId}</if>
- <if test="companyUserId != null "> and wcu.company_user_id = #{companyUserId}</if>
- <if test="doctorId != null "> and wd.doctor_id = #{doctorId}</if>
- <if test="userId != null "> and a.user_id = #{userId}</if>
- <if test="familyUserId != null "> and wf.family_user_id = #{familyUserId}</if>
- <if test="deviceNumber != null and deviceNumber != ''"> and a.device_number like concat("%",#{deviceNumber},"%")</if>
- <if test="battery != null "> and a.battery = #{battery}</if>
- <if test="rssi != null "> and a.rssi = #{rssi}</if>
- <if test="status != null "> and a.status = #{status}</if>
- <if test="lifeStatus != null">and a.life_status = #{lifeStatus}</if>
- <if test="isNormal != null">and a.is_normal = #{isNormal}</if>
- </select>
- <select id="selectDeviceInfoByDeviceId" parameterType="Long" resultType="WatchDeviceInfoVo">
- <!-- <include refid="selectDeviceInfoVo"/>-->
- SELECT a.*,IF(a.`status`=0,"OFFLINE",IF(a.`status` = 1,"ONLINE",IF(a.`status` = 3,"UNACTIVE",IF(a.`status` = 4,"DISABLE","NOT EXIST")))) as status_out,
- IF(a.`life_status`=0,"空置",IF(a.`life_status` = 1,"已送出","已激活")) as lifeStatusOut,
- GROUP_CONCAT(DISTINCT c.company_name) AS company_name,
- GROUP_CONCAT(DISTINCT cu.nick_name) AS company_user_name,
- GROUP_CONCAT(DISTINCT fd.doctor_name) AS doctor_name,
- GROUP_CONCAT(DISTINCT fu2.nick_name) AS family_user_name,
- GROUP_CONCAT(DISTINCT c.company_id) AS company_id,
- GROUP_CONCAT(DISTINCT cu.user_id) AS company_user_id,
- GROUP_CONCAT(DISTINCT fd.doctor_id) AS doctor_id,
- GROUP_CONCAT(DISTINCT fu2.user_id) AS family_user_id
- FROM `watch_device_info` a
- LEFT JOIN watch_company wc ON wc.device_id = a.device_id
- LEFT JOIN watch_company_user wcu ON wcu.device_id = a.device_id
- LEFT JOIN watch_doctor wd ON wd.device_id = a.device_id
- LEFT JOIN watch_family wf ON wf.device_id = a.device_id
- LEFT JOIN fs_user fu ON fu.user_id = a.user_id
- LEFT JOIN company c ON c.company_id = wc.company_id
- LEFT JOIN fs_doctor fd ON fd.doctor_id = wd.doctor_id
- LEFT JOIN company_user cu ON cu.user_id = wcu.company_user_id
- LEFT JOIN fs_user fu2 ON fu2.user_id = wf.family_user_id
- where a.device_id = #{deviceId} and a.is_del = 0
- GROUP BY a.device_id
- </select>
- <select id="getByNumber" resultType="com.fs.watch.domain.vo.WatchDeviceInfoVo">
- SELECT a.*,IF(a.`status`=0,"OFFLINE",IF(a.`status` = 1,"ONLINE",IF(a.`status` = 3,"UNACTIVE",IF(a.`status` = 4,"DISABLE","NOT EXIST")))) as status_out,
- IF(a.`life_status`=0,"空置",IF(a.`life_status` = 1,"已送出","已激活")) as lifeStatusOut,
- GROUP_CONCAT(DISTINCT c.company_name) AS company_name,
- GROUP_CONCAT(DISTINCT cu.nick_name) AS company_user_name,
- GROUP_CONCAT(DISTINCT fd.doctor_name) AS doctor_name,
- GROUP_CONCAT(DISTINCT fu2.nick_name) AS family_user_name,
- GROUP_CONCAT(DISTINCT c.company_id) AS company_id,
- GROUP_CONCAT(DISTINCT cu.user_id) AS company_user_id,
- GROUP_CONCAT(DISTINCT fd.doctor_id) AS doctor_id,
- GROUP_CONCAT(DISTINCT fu2.user_id) AS family_user_id
- FROM `watch_device_info` a
- LEFT JOIN watch_company wc ON wc.device_id = a.device_id
- LEFT JOIN watch_company_user wcu ON wcu.device_id = a.device_id
- LEFT JOIN watch_doctor wd ON wd.device_id = a.device_id
- LEFT JOIN watch_family wf ON wf.device_id = a.device_id
- LEFT JOIN fs_user fu ON fu.user_id = a.user_id
- LEFT JOIN company c ON c.company_id = wc.company_id
- LEFT JOIN fs_doctor fd ON fd.doctor_id = wd.doctor_id
- LEFT JOIN company_user cu ON cu.user_id = wcu.company_user_id
- LEFT JOIN fs_user fu2 ON fu2.user_id = wf.family_user_id
- where a.device_number like #{number} and a.is_del = 0
- GROUP BY a.device_id
- </select>
- <select id="selectByUserExist" resultType="com.fs.watch.domain.WatchDeviceInfo">
- select a.*
- from `watch_device_info` a
- where a.is_del = 0 and user_id IS NOT NULL
- </select>
- <select id="selectListByUserOrFamilyUser" resultType="com.fs.watch.domain.WatchDeviceInfo">
- select i.*
- from `watch_device_info` i
- left join watch_family f on i.device_id = f.device_id
- where i.is_del = 0 and
- (f.family_user_id = #{userId} or i.user_id = #{userId} )
- </select>
- </mapper>
|