<?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.boman.web.core.mapper.BirthRecordsMapper">

    <resultMap type="com.boman.web.core.domain.BirthRecords" id="BirthRecordsResult">
        <result property="id"    column="id"    />
        <result property="csrq"    column="csrq"    />
        <result property="csyxzmbh"    column="csyxzmbh"    />
        <result property="fqmz"    column="fqmz"    />
        <result property="csyxzmbb"    column="csyxzmbb"    />
        <result property="xsexbdm"    column="xsexbdm"    />
        <result property="sfgwrs"    column="sfgwrs"    />
        <result property="sfycsqx"    column="sfycsqx"    />
        <result property="csjkzk"    column="csjkzk"    />
        <result property="cstz"    column="cstz"    />
        <result property="sfzjhm"    column="sfzjhm"    />
        <result property="sfzjlx"    column="sfzjlx"    />
        <result property="fqgj"    column="fqgj"    />
        <result property="csdxz"    column="csdxz"    />
        <result property="ycfjkzk"    column="ycfjkzk"    />
        <result property="mqmz"    column="mqmz"    />
        <result property="xsexb"    column="xsexb"    />
        <result property="fmfs"    column="fmfs"    />
        <result property="mqsfzjlx"    column="mqsfzjlx"    />
        <result property="mqxm" column="mqxm"/>
        <result property="mz" column="mz"/>
        <result property="cssc" column="cssc"/>
        <result property="xsexm" column="xsexm"/>
        <result property="fqxm" column="fqxm"/>
        <result property="fqsfzjlx" column="fqsfzjlx"/>
        <result property="cstc" column="cstc"/>
        <result property="csdxzqh" column="csdxzqh"/>
        <result property="mqgj" column="mqgj"/>
        <result property="csyxzmqfrq" column="csyxzmqfrq"/>
        <result property="csyxzmqfjg" column="csyxzmqfjg"/>
        <result property="fqsfzjhm" column="fqsfzjhm"/>
        <result property="csyljg" column="csyljg"/>
        <result property="mqsfzjhm" column="mqsfzjhm"/>
        <result property="csyz" column="csyz"/>
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remark"    column="remark"    />
    </resultMap>
    <insert id="insertListBirthRecords" useGeneratedKeys="true" keyProperty="id">
        insert into birth_records(create_by,
        update_by,
        is_del,
        remark,
        csrq,
        csyxzmbh,
        fqmz,
        csyxzmbb,
        xsexbdm,
        sfgwrs,
        sfycsqx,
        csjkzk,
        cstz,
        sfzjhm,
        sfzjlx,
        fqgj,
        csdxz,
        ycfjkzk,
        mqmz,
        xsexb,
        fmfs,
        mqsfzjlx,
        mqxm,
        mz,
        cssc,
        xsexm,
        fqxm,
        fqsfzjlx,
        cstc,
        csdxzqh,
        mqgj,
        csyxzmqfrq,
        csyxzmqfjg,fqsfzjhm,csyljg,mqsfzjhm,csyz,status,create_time,update_time)
        values
        <foreach item="birthRecords" index="index" collection="birthRecordsList" separator=",">
            (#{birthRecords.createBy},
            #{birthRecords.updateBy},
            #{birthRecords.isDel},
            #{birthRecords.remark},
            #{birthRecords.csrq},
            #{birthRecords.csyxzmbh},
            #{birthRecords.fqmz},
            #{birthRecords.csyxzmbb},
            #{birthRecords.xsexbdm},
            #{birthRecords.sfgwrs},
            #{birthRecords.sfycsqx},
            #{birthRecords.csjkzk},
            #{birthRecords.cstz},
            #{birthRecords.sfzjhm},
            #{birthRecords.sfzjlx},
            #{birthRecords.fqgj},
            #{birthRecords.csdxz},
            #{birthRecords.ycfjkzk},
            #{birthRecords.mqmz},
            #{birthRecords.xsexb},
            #{birthRecords.fmfs},
            #{birthRecords.mqsfzjlx},
            #{birthRecords.mqxm},
            #{birthRecords.mz},
            #{birthRecords.cssc},
            #{birthRecords.xsexm},
            #{birthRecords.fqxm},
            #{birthRecords.fqsfzjlx},
            #{birthRecords.cstc},
            #{birthRecords.csdxzqh},
            #{birthRecords.mqgj},
            #{birthRecords.csyxzmqfrq},
            #{birthRecords.csyxzmqfjg},
            #{birthRecords.fqsfzjhm},
            #{birthRecords.csyljg},
            #{birthRecords.mqsfzjhm},
            #{birthRecords.csyz},
            #{birthRecords.status},
            sysdate(),sysdate())
        </foreach>
    </insert>
    <update id="updataBirthRecordsInfo">
        update birth_records set status='2' where sfzjhm = #{idCard}
    </update>
    <select id="queryList" resultMap="BirthRecordsResult">
        select id, create_by,update_by,is_del,remark,csrq,
        csyxzmbh,fqmz,csyxzmbb,xsexbdm,sfgwrs,sfycsqx,csjkzk,cstz,sfzjhm,sfzjlx,
        fqgj,csdxz,ycfjkzk,mqmz,xsexb,fmfs,mqsfzjlx,mqxm,mz,cssc,xsexm,fqxm,fqsfzjlx,cstc,csdxzqh,mqgj,
        csyxzmqfrq,csyxzmqfjg,fqsfzjhm,csyljg,mqsfzjhm,csyz,status,create_time,update_time
        from birth_records
        <where>
            is_del = 'N'
            <if test="mqxm != null  and mqxm != ''">
                and mqxm like concat(#{mqxm}, '%')
            </if>
            <if test="csrq != null  and csrq != ''">and csrq = #{csrq}</if>
            <if test="csyxzmbh != null and csyxzmbh != '' ">and csyxzmbh = #{csyxzmbh}</if>
            <if test="fqmz != null  and fqmz != ''">and fqmz = #{fqmz}</if>
            <if test="csyxzmbb != null  and csyxzmbb != ''">and csyxzmbb = #{csyxzmbb}</if>
            <if test="xsexbdm != null  and xsexbdm != ''">and xsexbdm = #{xsexbdm}</if>
            <if test="sfgwrs != null  and sfgwrs != ''">and sfgwrs = #{sfgwrs}</if>
            <if test="sfycsqx != null  and sfycsqx != ''">and sfycsqx = #{sfycsqx}</if>
            <if test="csjkzk != null  and csjkzk != ''">and csjkzk = #{csjkzk}</if>
            <if test="sfzjhm != null  and sfzjhm != ''">and sfzjhm = #{sfzjhm}</if>
            <if test="fqgj != null  and fqgj != ''">and fqgj = #{fqgj}</if>

            <if test="csdxz != null  and csdxz != ''">and csdxz = #{csdxz}</if>
            <if test="mqmz != null  and mqmz != ''">and mqmz = #{mqmz}</if>
            <if test="xsexb != null  and xsexb != ''">and xsexb = #{xsexb}</if>


            <if test="mz != null  and mz != ''">and mz = #{mz}</if>
            <if test="xsexm != null  and xsexm != ''">
                and xsexm like concat(#{xsexm}, '%')
            </if>
            <if test="fqxm != null  and fqxm != ''">
                and fqxm like concat(#{fqxm}, '%')
            </if>
            <if test="csdxzqh != null  and csdxzqh != ''">and csdxzqh = #{csdxzqh}</if>
            <if test="mqgj != null  and mqgj != ''">and mqgj = #{mqgj}</if>
            <if test="csyxzmqfrq != null  and csyxzmqfrq != ''">and csyxzmqfrq = #{csyxzmqfrq}</if>
            <if test="csyxzmqfjg != null  and csyxzmqfjg != ''">and csyxzmqfjg = #{csyxzmqfjg}</if>
            <if test="fqsfzjhm != null  and fqsfzjhm != ''">and fqsfzjhm = #{fqsfzjhm}</if>
            <if test="mqsfzjhm != null  and mqsfzjhm != ''">and mqsfzjhm = #{mqsfzjhm}</if>
            <if test="status != null  and status != ''">and status = #{status}</if>
        </where>
        order by status, create_time DESC


    </select>
    <select id="getBirthRecordsInfo" resultMap="BirthRecordsResult">
        select id, create_by,update_by,is_del,remark,csrq,
               csyxzmbh,fqmz,csyxzmbb,xsexbdm,sfgwrs,sfycsqx,csjkzk,cstz,sfzjhm,sfzjlx,
               fqgj,csdxz,ycfjkzk,mqmz,xsexb,fmfs,mqsfzjlx,mqxm,mz,cssc,xsexm,fqxm,fqsfzjlx,cstc,csdxzqh,mqgj,
               csyxzmqfrq,csyxzmqfjg,fqsfzjhm,csyljg,mqsfzjhm,csyz,status,create_time,update_time
        from birth_records
        where id = #{id}
    </select>

</mapper>