<?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.zehong.system.mapper.TEmployedPeopleInfoErrorMapper">
    
    <resultMap type="TEmployedPeopleInfoError" id="TEmployedPeopleInfoErrorResult">
        <result property="employedPeopleErrorId"    column="employed_people_error_id"    />
        <result property="employedPeopleName"    column="employed_people_name"    />
        <result property="idCard"    column="id_card"    />
        <result property="certificateNum"    column="certificate_num"    />
        <result property="beyondEnterpriseName"    column="beyond_enterprise_name"    />
        <result property="registerExaminationType"    column="register_examination_type"    />
        <result property="peopleOccupation"    column="people_occupation"    />
        <result property="issueDate"    column="issue_date"    />
        <result property="certificateChange"    column="certificate_change"    />
        <result property="createBy"    column="create_by"    />
        <result property="errorMsg"    column="error_msg"    />
    </resultMap>

    <sql id="selectTEmployedPeopleInfoErrorVo">
        select employed_people_error_id, employed_people_name, id_card, certificate_num, beyond_enterprise_name, register_examination_type, people_occupation, issue_date, certificate_change, create_by,error_msg from t_employed_people_info_error
    </sql>

    <select id="selectTEmployedPeopleInfoErrorList" parameterType="TEmployedPeopleInfoError" resultMap="TEmployedPeopleInfoErrorResult">
        <include refid="selectTEmployedPeopleInfoErrorVo"/>
        <where>  
            <if test="employedPeopleName != null  and employedPeopleName != ''"> and employed_people_name like concat('%', #{employedPeopleName}, '%')</if>
            <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
            <if test="certificateNum != null  and certificateNum != ''"> and certificate_num = #{certificateNum}</if>
            <if test="beyondEnterpriseName != null  and beyondEnterpriseName != ''"> and beyond_enterprise_name like concat('%', #{beyondEnterpriseName}, '%')</if>
            <if test="registerExaminationType != null  and registerExaminationType != ''"> and register_examination_type = #{registerExaminationType}</if>
            <if test="peopleOccupation != null  and peopleOccupation != ''"> and people_occupation = #{peopleOccupation}</if>
            <if test="issueDate != null  and issueDate != ''"> and issue_date = #{issueDate}</if>
            <if test="certificateChange != null  and certificateChange != ''"> and certificate_change = #{certificateChange}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
            <if test="errorMsg != null  and errorMsg != ''"> and error_msg = #{errorMsg}</if>
        </where>
    </select>
    
    <select id="selectTEmployedPeopleInfoErrorById" parameterType="Long" resultMap="TEmployedPeopleInfoErrorResult">
        <include refid="selectTEmployedPeopleInfoErrorVo"/>
        where employed_people_error_id = #{employedPeopleErrorId}
    </select>
        
    <insert id="insertTEmployedPeopleInfoError" parameterType="TEmployedPeopleInfoError" useGeneratedKeys="true" keyProperty="employedPeopleErrorId">
        insert into t_employed_people_info_error
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="employedPeopleName != null">employed_people_name,</if>
            <if test="idCard != null">id_card,</if>
            <if test="certificateNum != null">certificate_num,</if>
            <if test="beyondEnterpriseName != null">beyond_enterprise_name,</if>
            <if test="registerExaminationType != null">register_examination_type,</if>
            <if test="peopleOccupation != null">people_occupation,</if>
            <if test="issueDate != null">issue_date,</if>
            <if test="certificateChange != null">certificate_change,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="errorMsg != null and errorMsg != ''">error_msg,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="employedPeopleName != null">#{employedPeopleName},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="certificateNum != null">#{certificateNum},</if>
            <if test="beyondEnterpriseName != null">#{beyondEnterpriseName},</if>
            <if test="registerExaminationType != null">#{registerExaminationType},</if>
            <if test="peopleOccupation != null">#{peopleOccupation},</if>
            <if test="issueDate != null">#{issueDate},</if>
            <if test="certificateChange != null">#{certificateChange},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="errorMsg != null and errorMsg != ''">#{errorMsg},</if>
         </trim>
    </insert>

    <insert id="batchInsertTEmployedPeopleInfoError" parameterType="list">
        insert into t_employed_people_info_error (employed_people_name,
        id_card, certificate_num, beyond_enterprise_name,
        register_examination_type, people_occupation, issue_date,
        certificate_change, create_by,error_msg)
        values
        <foreach collection="tEmployedPeopleInfoErrors" separator="," item="item">
            (#{item.employedPeopleName,jdbcType=VARCHAR}, #{item.idCard,jdbcType=VARCHAR},
            #{item.certificateNum,jdbcType=CHAR},#{item.beyondEnterpriseName,jdbcType=VARCHAR},
            #{item.registerExaminationType,jdbcType=VARCHAR}, #{item.peopleOccupation,jdbcType=VARCHAR},
            #{item.issueDate,jdbcType=TIMESTAMP}, #{item.certificateChange,jdbcType=VARCHAR},
            #{item.createBy,jdbcType=VARCHAR},#{item.errorMsg,jdbcType=VARCHAR})
        </foreach>
    </insert>

    <update id="updateTEmployedPeopleInfoError" parameterType="TEmployedPeopleInfoError">
        update t_employed_people_info_error
        <trim prefix="SET" suffixOverrides=",">
            <if test="employedPeopleName != null">employed_people_name = #{employedPeopleName},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="certificateNum != null">certificate_num = #{certificateNum},</if>
            <if test="beyondEnterpriseName != null">beyond_enterprise_name = #{beyondEnterpriseName},</if>
            <if test="registerExaminationType != null">register_examination_type = #{registerExaminationType},</if>
            <if test="peopleOccupation != null">people_occupation = #{peopleOccupation},</if>
            <if test="issueDate != null">issue_date = #{issueDate},</if>
            <if test="certificateChange != null">certificate_change = #{certificateChange},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="errorMsg != null and errorMsg != ''">error_msg = #{errorMsg},</if>
        </trim>
        where employed_people_error_id = #{employedPeopleErrorId}
    </update>

    <delete id="deleteTEmployedPeopleInfoErrorById" parameterType="Long">
        delete from t_employed_people_info_error where employed_people_error_id = #{employedPeopleErrorId}
    </delete>

    <delete id="deleteTEmployedPeopleInfoErrorByIds" parameterType="String">
        delete from t_employed_people_info_error where employed_people_error_id in 
        <foreach item="employedPeopleErrorId" collection="array" open="(" separator="," close=")">
            #{employedPeopleErrorId}
        </foreach>
    </delete>
    <select id="countByCreateByInt" parameterType="String" resultType="int">
        select count(*) from t_employed_people_info_error where create_by = #{createBy}
    </select>
    <delete id="clearImportError" parameterType="String">
        delete from t_employed_people_info_error where create_by = #{createBy}
    </delete>
</mapper>