<?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.zhyc.module.produce.embryo.mapper.ScEmbryoFlushMapper">
    
    <resultMap type="ScEmbryoFlush" id="ScEmbryoFlushResult">
        <result property="id"    column="id"    />
        <result property="flushTime"    column="flush_time"    />
        <result property="donorFemaleNo"    column="donor_female_no"    />
        <result property="donorMaleNo"    column="donor_male_no"    />
        <result property="gradeAPlus"    column="grade_a_plus"    />
        <result property="gradeA"    column="grade_a"    />
        <result property="gradeB"    column="grade_b"    />
        <result property="gradeC"    column="grade_c"    />
        <result property="gradeD"    column="grade_d"    />
        <result property="cell24"    column="cell_2_4"    />
        <result property="cell8"    column="cell_8"    />
        <result property="cell16"    column="cell_16"    />
        <result property="unfertilized"    column="unfertilized"    />
        <result property="degenerated"    column="degenerated"    />
        <result property="transferred"    column="transferred"    />
        <result property="recipientCnt"    column="recipient_cnt"    />
        <result property="embryoType"    column="embryo_type"    />
        <result property="embryoSource"    column="embryo_source"    />
        <result property="destination"    column="destination"    />
        <result property="storageMethod"    column="storage_method"    />
        <result property="flushOperator"    column="flush_operator"    />
        <result property="collectOperator"    column="collect_operator"    />
        <result property="remark"    column="remark"    />
        <result property="createdBy"    column="created_by"    />
        <result property="createdAt"    column="created_at"    />
    </resultMap>

    <sql id="selectScEmbryoFlushVo">
        select id, flush_time, donor_female_no, donor_male_no, grade_a_plus, grade_a, grade_b, grade_c, grade_d, cell_2_4, cell_8, cell_16, unfertilized, degenerated, transferred, recipient_cnt, embryo_type, embryo_source, destination, storage_method, flush_operator, collect_operator, remark, created_by, created_at from sc_embryo_flush
    </sql>

    <select id="selectScEmbryoFlushList" parameterType="ScEmbryoFlush" resultMap="ScEmbryoFlushResult">
        <include refid="selectScEmbryoFlushVo"/>
        <where>  
            <if test="flushTime != null "> and flush_time = #{flushTime}</if>
            <if test="donorFemaleNo != null  and donorFemaleNo != ''"> and donor_female_no = #{donorFemaleNo}</if>
            <if test="donorMaleNo != null  and donorMaleNo != ''"> and donor_male_no = #{donorMaleNo}</if>
            <if test="gradeAPlus != null "> and grade_a_plus = #{gradeAPlus}</if>
            <if test="gradeA != null "> and grade_a = #{gradeA}</if>
            <if test="gradeB != null "> and grade_b = #{gradeB}</if>
            <if test="gradeC != null "> and grade_c = #{gradeC}</if>
            <if test="gradeD != null "> and grade_d = #{gradeD}</if>
            <if test="cell24 != null "> and cell_2_4 = #{cell24}</if>
            <if test="cell8 != null "> and cell_8 = #{cell8}</if>
            <if test="cell16 != null "> and cell_16 = #{cell16}</if>
            <if test="unfertilized != null "> and unfertilized = #{unfertilized}</if>
            <if test="degenerated != null "> and degenerated = #{degenerated}</if>
            <if test="transferred != null "> and transferred = #{transferred}</if>
            <if test="recipientCnt != null "> and recipient_cnt = #{recipientCnt}</if>
            <if test="embryoType != null  and embryoType != ''"> and embryo_type = #{embryoType}</if>
            <if test="embryoSource != null  and embryoSource != ''"> and embryo_source = #{embryoSource}</if>
            <if test="destination != null  and destination != ''"> and destination = #{destination}</if>
            <if test="storageMethod != null  and storageMethod != ''"> and storage_method = #{storageMethod}</if>
            <if test="flushOperator != null  and flushOperator != ''"> and flush_operator = #{flushOperator}</if>
            <if test="collectOperator != null  and collectOperator != ''"> and collect_operator = #{collectOperator}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
        </where>
    </select>
    
    <select id="selectScEmbryoFlushById" parameterType="Long" resultMap="ScEmbryoFlushResult">
        <include refid="selectScEmbryoFlushVo"/>
        where id = #{id}
    </select>

    <insert id="insertScEmbryoFlush" parameterType="ScEmbryoFlush" useGeneratedKeys="true" keyProperty="id">
        insert into sc_embryo_flush
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="flushTime != null">flush_time,</if>
            <if test="donorFemaleNo != null and donorFemaleNo != ''">donor_female_no,</if>
            <if test="donorMaleNo != null and donorMaleNo != ''">donor_male_no,</if>
            <if test="gradeAPlus != null">grade_a_plus,</if>
            <if test="gradeA != null">grade_a,</if>
            <if test="gradeB != null">grade_b,</if>
            <if test="gradeC != null">grade_c,</if>
            <if test="gradeD != null">grade_d,</if>
            <if test="cell24 != null">cell_2_4,</if>
            <if test="cell8 != null">cell_8,</if>
            <if test="cell16 != null">cell_16,</if>
            <if test="unfertilized != null">unfertilized,</if>
            <if test="degenerated != null">degenerated,</if>
            <if test="transferred != null">transferred,</if>
            <if test="recipientCnt != null">recipient_cnt,</if>
            <if test="embryoType != null and embryoType != ''">embryo_type,</if>
            <if test="embryoSource != null and embryoSource != ''">embryo_source,</if>
            <if test="destination != null">destination,</if>
            <if test="storageMethod != null">storage_method,</if>
            <if test="flushOperator != null and flushOperator != ''">flush_operator,</if>
            <if test="collectOperator != null and collectOperator != ''">collect_operator,</if>
            <if test="remark != null">remark,</if>
            <if test="createdBy != null and createdBy != ''">created_by,</if>
            <if test="createdAt != null">created_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="flushTime != null">#{flushTime},</if>
            <if test="donorFemaleNo != null and donorFemaleNo != ''">#{donorFemaleNo},</if>
            <if test="donorMaleNo != null and donorMaleNo != ''">#{donorMaleNo},</if>
            <if test="gradeAPlus != null">#{gradeAPlus},</if>
            <if test="gradeA != null">#{gradeA},</if>
            <if test="gradeB != null">#{gradeB},</if>
            <if test="gradeC != null">#{gradeC},</if>
            <if test="gradeD != null">#{gradeD},</if>
            <if test="cell24 != null">#{cell24},</if>
            <if test="cell8 != null">#{cell8},</if>
            <if test="cell16 != null">#{cell16},</if>
            <if test="unfertilized != null">#{unfertilized},</if>
            <if test="degenerated != null">#{degenerated},</if>
            <if test="transferred != null">#{transferred},</if>
            <if test="recipientCnt != null">#{recipientCnt},</if>
            <if test="embryoType != null and embryoType != ''">#{embryoType},</if>
            <if test="embryoSource != null and embryoSource != ''">#{embryoSource},</if>
            <if test="destination != null">#{destination},</if>
            <if test="storageMethod != null">#{storageMethod},</if>
            <if test="flushOperator != null and flushOperator != ''">#{flushOperator},</if>
            <if test="collectOperator != null and collectOperator != ''">#{collectOperator},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createdBy != null and createdBy != ''">#{createdBy},</if>
            <if test="createdAt != null">#{createdAt},</if>
         </trim>
    </insert>

    <update id="updateScEmbryoFlush" parameterType="ScEmbryoFlush">
        update sc_embryo_flush
        <trim prefix="SET" suffixOverrides=",">
            <if test="flushTime != null">flush_time = #{flushTime},</if>
            <if test="donorFemaleNo != null and donorFemaleNo != ''">donor_female_no = #{donorFemaleNo},</if>
            <if test="donorMaleNo != null and donorMaleNo != ''">donor_male_no = #{donorMaleNo},</if>
            <if test="gradeAPlus != null">grade_a_plus = #{gradeAPlus},</if>
            <if test="gradeA != null">grade_a = #{gradeA},</if>
            <if test="gradeB != null">grade_b = #{gradeB},</if>
            <if test="gradeC != null">grade_c = #{gradeC},</if>
            <if test="gradeD != null">grade_d = #{gradeD},</if>
            <if test="cell24 != null">cell_2_4 = #{cell24},</if>
            <if test="cell8 != null">cell_8 = #{cell8},</if>
            <if test="cell16 != null">cell_16 = #{cell16},</if>
            <if test="unfertilized != null">unfertilized = #{unfertilized},</if>
            <if test="degenerated != null">degenerated = #{degenerated},</if>
            <if test="transferred != null">transferred = #{transferred},</if>
            <if test="recipientCnt != null">recipient_cnt = #{recipientCnt},</if>
            <if test="embryoType != null and embryoType != ''">embryo_type = #{embryoType},</if>
            <if test="embryoSource != null and embryoSource != ''">embryo_source = #{embryoSource},</if>
            <if test="destination != null">destination = #{destination},</if>
            <if test="storageMethod != null">storage_method = #{storageMethod},</if>
            <if test="flushOperator != null and flushOperator != ''">flush_operator = #{flushOperator},</if>
            <if test="collectOperator != null and collectOperator != ''">collect_operator = #{collectOperator},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createdBy != null and createdBy != ''">created_by = #{createdBy},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteScEmbryoFlushById" parameterType="Long">
        delete from sc_embryo_flush where id = #{id}
    </delete>

    <delete id="deleteScEmbryoFlushByIds" parameterType="String">
        delete from sc_embryo_flush where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>