<?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.yx.face.dao.AdminDataShowDao">
    <sql id="adminSearch">
        <if test="adminVO.type == 1">

        </if>
        <if test="adminVO.type == 2">
            and a.province_id = #{adminVO.provinceId}
            and a.type in (3 ,4 ,5)
        </if>
        <if test="adminVO.type == 3">
            and a.province_id = #{adminVO.provinceId}
            and a.type in (4 , 5)
            and a.tag_id = #{adminVO.tagId}
        </if>
        <if test="adminVO.type == 4">
            and a.city_id = #{adminVO.cityId}
            and a.type = 5
            and a.tag_id = #{adminVO.tagId}
        </if>
        <if test="adminVO.type == 5">
            and a.id =#{adminVO.adminId}
        </if>
    </sql>

    <select id="getDeviceNumber" resultType="com.yx.face.model.entity.FaceDevice">
        select
            fd.id,
            fd.online
        from face_device fd
        left join admin a on a.id = fd.admin_id
        <where>
            <include refid="adminSearch"></include>
        </where>
    </select>
    <select id="getAdminList" resultType="java.lang.Integer">
        select
            a.id
        from admin a
        <where>
            <include refid="adminSearch"></include>
            and a.type = 5
        </where>
    </select>
    <select id="getFaceLogByAdminIdAndBiggerNum" resultType="com.yx.face.model.entity.FaceLog">
        select
        log.id AS id,
        log.recordid AS recordid,
        log.action AS action,
        log.device_sn AS deviceSn,
        log.user_id AS userId,
        replace(log.`name`,' ','') AS name,
        log.photo AS photo,
        log.cardid AS cardid,
        log.cardidex AS cardidex,
        log.verify_type AS verifyType,
        log.rightno AS rightno,
        replace(log.`tw_status`,' ','') AS twStatus,
        log.jkm_status AS jkmStatus,
        log.hs_status AS hsStatus,
        log.ym_status AS ymStatus,
        log.xc_info AS xcInfo,
        log.extend3 AS extend3,
        log.face_time AS faceTime,
        log.create_time AS createTime
        FROM face_log AS log
        <where>
            <if test="adminId != null">
                and log.admin_id = #{adminId}
            </if>
            <if test="biggerNum != null">
                and log.id > #{biggerNum}
            </if>
        </where>

    </select>
    <select id="getCountByTimeAndSn" resultType="java.lang.Long">
        select
            id
        from face_log
        where create_time BETWEEN #{stratTime} and #{endTime} and device_sn = #{sn} and id != #{id}
    </select>
</mapper>

