<?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.bonus.tcp.smartIdentify.mapper.SmartIdentifyMapper">
    <!--添加告警信息-->
    <insert id="addWarnInfo" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO tb_warn
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="proId != null">pro_id,</if>
            <if test="teamId != null">team_id,</if>
            <if test="devId != null">dev_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="warnContent != null and warnContent!=''">warn_content,</if>
            <if test="warnTime != null and warnTime!=''">warn_time,</if>
            <if test="warnType != null">warn_type,</if>
            <if test="devType != null">dev_type,</if>
            <if test="peopleType != null">people_type,</if>
            create_time,
            del_flag,
            id
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="proId != null">#{proId},</if>
            <if test="teamId != null">#{teamId},</if>
            <if test="devId != null">#{devId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="warnContent != null and warnContent!=''">#{warnContent},</if>
            <if test="warnTime != null and warnTime!=''">#{warnTime},</if>
            <if test="warnType != null">#{warnType},</if>
            <if test="devType != null">#{devType},</if>
            <if test="peopleType != null">#{peopleType},</if>
            #{createTime},
            #{delFlag},
            null
        </trim>
    </insert>

    <!--判断球机是否被班组领用-->
    <select id="getDevices" resultType="com.bonus.common.entity.tcp.DeviceUseVo">
        SELECT tdub.dev_id AS devId,
               tdu.pro_id AS proId,
               tdu.gt_id AS gtId,
               tdu.team_id AS teamId
        FROM tb_dev_use_bid tdub
        LEFT JOIN tb_dev_use tdu ON tdub.id = tdu.id
        WHERE dev_code = #{puid} AND dev_type = 'ball' AND gh_time IS NULL
    </select>
    <!--根据身份证号获取班组成员/临时人员-->
    <select id="getUserByIdCard" resultType="com.bonus.common.entity.tcp.PeopleVioVo">
        SELECT id,name,0 AS peopleType FROM tb_people tp WHERE id_card = #{idCard} AND del_flag = 0
        UNION ALL
        SELECT id,name,0 AS peopleType FROM tb_ls_user tlu WHERE id_card = #{idCard}
    </select>
</mapper>