<?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.xjrsoft.module.teacher.mapper.FaceImportMapper">
    <select id="GetTeacherUserIdById" parameterType="long" resultType="java.lang.String">
        select t.user_id
        from teacher_face_process t
        where t.delete_mark = 0
        <if test="id != null">
            and t.id = #{id}
        </if>
    </select>

    <select id="GetTeacherHikvisionImgById" parameterType="long" resultType="java.lang.String">
        select t1.file_url
        from teacher_face_process t
        left join xjr_file t1 on t1.folder_id = t.face_photo
        where t.delete_mark = 0
        <if test="id != null">
            and t.id = #{id}
        </if>
    </select>

    <select id="GetStudentUserIdById" parameterType="long" resultType="java.lang.String">
        select t.user_id
        from stundent_face_process t
        where t.delete_mark = 0
        <if test="id != null">
            and t.id = #{id}
        </if>
        and t.status = 1
    </select>

    <select id="GetStudentHikvisionImgById" parameterType="long" resultType="java.lang.String">
        select t1.file_url
        from stundent_face_process t
        left join xjr_file t1 on t1.folder_id = t.face_photo
        where t.delete_mark = 0
        <if test="id != null">
            and t.id = #{id}
        </if>
    </select>

    <select id="GetHikvisonPersonId" parameterType="string" resultType="java.lang.String">
        select t.hikvision_id
        from hikvision_data t
        left join car_message_apply t1 on t1.user_id = t.source_id
        where t1.status = 1
        <if test="id != null">
            and t1.id = #{id}
        </if>
    </select>

    <select id="IsStudentTypeByPersonId" parameterType="long" resultType="java.lang.String">
        select t.role_id
        from xjr_user_role_relation t
        where t.user_id = #{id}
    </select>

    <select id="GetTeacherIdByPersonId" parameterType="long" resultType="java.lang.Long">
        select t1.teacher_id
        from base_student_school_roll t
        left join base_class t1 on t.class_id = t1.id
        where t.delete_mark = 0
        <if test="id != null">
            and t.user_id = #{id}
        </if>
    </select>

    <select id="GetClassIdByPersonId" parameterType="long" resultType="java.lang.Long">
        select t1.id
        from base_student_school_roll t
        left join base_class t1 on t.class_id = t1.id
        where t.delete_mark = 0
        <if test="id != null">
            and t.user_id = #{id}
        </if>
    </select>

    <select id="GetStudentUrlList"  resultType="java.lang.String">
        select t.eventId
        from student_out_in_record t
        where t.delete_mark = 0
    </select>

    <select id="GetTeacherUrlList"  resultType="java.lang.String">
        select t.eventId
        from teacher_out_in_record t
        where t.delete_mark = 0
    </select>

    <select id="GetReservationSchoolIdList" resultType="java.lang.String">
        SELECT event_id
        FROM visitor_out_in_record
        where delete_mark = 0
    </select>

    <select id="GetReservationSchoolId"  parameterType="string" resultType="java.lang.Long">
        SELECT reservation_schoo_id
        FROM reservation_school_people
        where delete_mark = 0
        <if test="id != null">
            and JSON_VALUE(registration_result, '$.data.orderId') = #{id};
        </if>
    </select>

    <select id="GetCarMessageApplyIdByCarNumber"  parameterType="string" resultType="java.lang.String">
        SELECT id
        FROM car_message_apply
        WHERE delete_mark = 0 and now() between start_time and end_time
        <if test="id != null">
            AND car_number = #{id}
        </if>
    </select>

    <select id="GetVehicleIdList" resultType="java.lang.String">
        SELECT cross_record_syscode
        FROM car_out_in_record
        WHERE delete_mark = 0
    </select>

    <select id="GetPhoneNumberByPlanNum" resultType="java.lang.String">
        SELECT 手机号
        FROM car_info
        <if test="id != null">
            where 车牌号码 = #{id}
        </if>
    </select>

    <select id="GetNameByPlanNum" resultType="java.lang.String">
        SELECT 车主姓名
        FROM car_info
        <if test="id != null">
            where 车牌号码 = #{id}
        </if>
    </select>

    <select id="GetVisitIdList" resultType="java.lang.String">
        SELECT event_id
        FROM visitor_out_in_record
        where delete_mark = 0
    </select>

    <select id="getTeacherUserIds" resultType="java.lang.Long">
        SELECT t1.id FROM xjr_user t1
        INNER JOIN base_teacher t2 ON t1.id = t2.user_id
        WHERE t1.delete_mark = 0
    </select>
</mapper>