<?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.frozen.mapper.DdFsMapper">
    
    <resultMap type="com.zhyc.module.frozen.domain.DdFs" id="DdFsResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="freezeDt"    column="freeze_dt"    />
        <result property="breed"    column="breed"    />
        <result property="batch"    column="batch"    />
        <result property="spec"    column="spec"    />
        <result property="qty"    column="qty"    />
        <result property="sexCtl"    column="sex_ctl"    />
        <result property="stat"    column="stat"    />
        <result property="tech"    column="tech"    />
        <result property="tankId"    column="tank_id"    />
        <result property="bucketId"    column="bucket_id"    />
        <result property="rackId"    column="rack_id"    />
        <result property="outDt"    column="out_dt"    />
        <result property="discardTxt"    column="discard_txt"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectDdFsVo">
        select id, code, freeze_dt, breed, batch, spec, qty, sex_ctl, stat, tech, tank_id, bucket_id, rack_id, out_dt, discard_txt, remark, create_by, create_time from dd_fs
    </sql>

    <select id="selectDdFsList" parameterType="DdFs" resultMap="DdFsResult">
        <include refid="selectDdFsVo"/>
        <where>  
            <if test="code != null  and code != ''"> and code like concat('%', #{code}, '%')</if>
             <if test="stat != null and stat != ''">and stat = #{stat}</if>
            <if test="tech != null  and tech != ''"> and tech like concat('%', #{tech}, '%')</if>
            <if test="params.beginFreezeDt != null and params.endFreezeDt != null">
                and freeze_dt between #{params.beginFreezeDt} and #{params.endFreezeDt}
            </if>
            <if test="params.beginOutDt != null and params.endOutDt != null">
                and out_dt between #{params.beginOutDt} and #{params.endOutDt}
            </if>
        </where>
    </select>
    
    <select id="selectDdFsById" parameterType="Long" resultMap="DdFsResult">
        <include refid="selectDdFsVo"/>
        where id = #{id}
    </select>

    <insert id="insertDdFs" parameterType="DdFs" useGeneratedKeys="true" keyProperty="id">
        insert into dd_fs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="freezeDt != null">freeze_dt,</if>
            <if test="breed != null">breed,</if>
            <if test="batch != null">batch,</if>
            <if test="spec != null">spec,</if>
            <if test="qty != null">qty,</if>
            <if test="sexCtl != null">sex_ctl,</if>
            <if test="stat != null">stat,</if>
            <if test="tech != null">tech,</if>
            <if test="tankId != null">tank_id,</if>
            <if test="bucketId != null">bucket_id,</if>
            <if test="rackId != null">rack_id,</if>
            <if test="outDt != null">out_dt,</if>
            <if test="discardTxt != null">discard_txt,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="freezeDt != null">#{freezeDt},</if>
            <if test="breed != null">#{breed},</if>
            <if test="batch != null">#{batch},</if>
            <if test="spec != null">#{spec},</if>
            <if test="qty != null">#{qty},</if>
            <if test="sexCtl != null">#{sexCtl},</if>
            <if test="stat != null">#{stat},</if>
            <if test="tech != null">#{tech},</if>
            <if test="tankId != null">#{tankId},</if>
            <if test="bucketId != null">#{bucketId},</if>
            <if test="rackId != null">#{rackId},</if>
            <if test="outDt != null">#{outDt},</if>
            <if test="discardTxt != null">#{discardTxt},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateDdFs" parameterType="DdFs">
        update dd_fs
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="freezeDt != null">freeze_dt = #{freezeDt},</if>
            <if test="breed != null">breed = #{breed},</if>
            <if test="batch != null">batch = #{batch},</if>
            <if test="spec != null">spec = #{spec},</if>
            <if test="qty != null">qty = #{qty},</if>
            <if test="sexCtl != null">sex_ctl = #{sexCtl},</if>
            <if test="stat != null">stat = #{stat},</if>
            <if test="tech != null">tech = #{tech},</if>
            <if test="tankId != null">tank_id = #{tankId},</if>
            <if test="bucketId != null">bucket_id = #{bucketId},</if>
            <if test="rackId != null">rack_id = #{rackId},</if>
            <if test="outDt != null">out_dt = #{outDt},</if>
            <if test="discardTxt != null">discard_txt = #{discardTxt},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDdFsById" parameterType="Long">
        delete from dd_fs where id = #{id}
    </delete>

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