<?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.ssm.manage.mapper.JobContentListMapper">

    <resultMap id="BaseResultMap" type="com.ssm.manage.entity.JobContentList">
        <result property="id" column="id"/>
        <result property="staffId" column="staff_id"/>
        <result property="staffName" column="staff_name"/>
        <result property="sex" column="sex"/>
        <result property="mobilePhone" column="mobile_phone"/>
        <result property="identityCard" column="identity_card"/>
        <result property="checkTime" column="check_time"/>
        <result property="jobContent" column="job_content"/>
        <result property="regionId" column="region_id"/>
        <result property="storeId" column="store_id"/>
        <result property="type" column="type"/>
        <result property="checkContent" column="check_content"/>
        <result property="staffNum" column="staff_num"/>
        <result property="deptNumber" column="dept_number"/>
        <result property="deptName" column="dept_name"/>
        <result property="equipmentName" column="equipment_name"/>
        <result property="equipmentNum" column="equipment_num"/>
        <result property="verify" column="verify"/>
        <result property="isBeisen" column="is_beisen"/>
        <result property="checkEndTime" column="check_end_time"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        , staff_id, staff_name, sex, mobile_phone, identity_card, check_time, job_content, region_id, store_id, type ,check_content,verify,equipmentNum,equipmentName,
            deptName,deptNumber,staffNum,is_beisen,check_end_time
    </sql>

    <select id="queryAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from job_content_list
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="staffId != null">
                and staff_id = #{staffId}
            </if>
            <if test="staffName != null and staffName != ''">
                and staff_name = #{staffName}
            </if>
            <if test="sex != null">
                and sex = #{sex}
            </if>
            <if test="mobilePhone != null and mobilePhone != ''">
                and mobile_phone = #{mobilePhone}
            </if>
            <if test="identityCard != null and identityCard != ''">
                and identity_card = #{identityCard}
            </if>
            <if test="checkTime != null">
                and check_time = #{checkTime}
            </if>
            <if test="jobContent != null and jobContent != ''">
                and job_content = #{jobContent}
            </if>
            <if test="regionId != null">
                and region_id = #{regionId}
            </if>
            <if test="storeId != null">
                and store_id = #{storeId}
            </if>
            <if test="type != null">
                and type = #{type}
            </if>
        </where>
    </select>

    <select id="selectAbnormalRecords" resultMap="BaseResultMap">
        SELECT * FROM `job_content_list`
        WHERE `identity_card` = #{identityCard}
          AND `check_time` BETWEEN #{enterTime} AND #{leaveTime}
          AND `equipment_num` IN ('TBB5235000125', 'TBB5235000149', 'TBB5235000151', 'TBB5235000152', 'TBB5235000243', 'TBB5235000254')
          AND (
            `check_end_time` IS NULL OR HOUR(TIMEDIFF(`check_end_time`, `check_time`)) &lt;= 4
            )
    </select>

</mapper>
