<?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.yunfeiyun.agmp.fms.mapper.TssGoodsperiodrcdMapper">
    
    <resultMap type="TssGoodsperiodrcd" id="TssGoodsperiodrcdResult">
        <result property="goodsperiodrcdId"    column="goodsperiodrcdId"    />
        <result property="finishgoodPickno"    column="finishgoodPickno"    />
        <result property="goodsperiodrcdStartdate"    column="goodsperiodrcdStartdate"    />
        <result property="goodsperiodrcdEnddate"    column="goodsperiodrcdEnddate"    />
        <result property="goodsperiodrcdType"    column="goodsperiodrcdType"    />
        <result property="goodsperiodrcdParentid"    column="goodsperiodrcdParentid"    />
        <result property="goodsperiodrcdFmstaskcreateddate"    column="goodsperiodrcdFmstaskcreateddate"    />
        <result property="goodsperiodrcdFmstaskremark"    column="goodsperiodrcdFmstaskremark"    />
        <result property="goodsperiodrcdFmstaskmanagername"    column="goodsperiodrcdFmstaskmanagername"    />
        <result property="goodsperiodrcdName"    column="goodsperiodrcdName"    />
    </resultMap>

    <sql id="selectTssGoodsperiodrcdVo">
        select goodsperiodrcdId, finishgoodPickno, goodsperiodrcdStartdate, goodsperiodrcdEnddate, goodsperiodrcdType, goodsperiodrcdParentid, goodsperiodrcdFmstaskcreateddate, goodsperiodrcdFmstaskremark, goodsperiodrcdFmstaskmanagername, goodsperiodrcdName from TssGoodsperiodrcd
    </sql>

    <select id="selectTssGoodsperiodrcdList" parameterType="TssGoodsperiodrcd" resultMap="TssGoodsperiodrcdResult">
        <include refid="selectTssGoodsperiodrcdVo"/>
        <where>
            <if test="finishgoodPickno != null  and finishgoodPickno != ''"> and finishgoodPickno = #{finishgoodPickno}</if>
            <if test="goodsperiodrcdStartdate != null  and goodsperiodrcdStartdate != ''"> and goodsperiodrcdStartdate = #{goodsperiodrcdStartdate}</if>
            <if test="goodsperiodrcdEnddate != null  and goodsperiodrcdEnddate != ''"> and goodsperiodrcdEnddate = #{goodsperiodrcdEnddate}</if>
            <if test="goodsperiodrcdType != null  and goodsperiodrcdType != ''"> and goodsperiodrcdType = #{goodsperiodrcdType}</if>
            <if test="goodsperiodrcdParentid != null  and goodsperiodrcdParentid != ''"> and goodsperiodrcdParentid = #{goodsperiodrcdParentid}</if>
            <if test="goodsperiodrcdFmstaskcreateddate != null  and goodsperiodrcdFmstaskcreateddate != ''"> and goodsperiodrcdFmstaskcreateddate = #{goodsperiodrcdFmstaskcreateddate}</if>
            <if test="goodsperiodrcdFmstaskremark != null  and goodsperiodrcdFmstaskremark != ''"> and goodsperiodrcdFmstaskremark = #{goodsperiodrcdFmstaskremark}</if>
            <if test="goodsperiodrcdFmstaskmanagername != null  and goodsperiodrcdFmstaskmanagername != ''"> and goodsperiodrcdFmstaskmanagername like concat('%', #{goodsperiodrcdFmstaskmanagername}, '%')</if>
            <if test="goodsperiodrcdName != null  and goodsperiodrcdName != ''"> and goodsperiodrcdName like concat('%', #{goodsperiodrcdName}, '%')</if>
        </where>
    </select>
    <select id="selectTssGoodsperiodrcdWithResList" parameterType="TssGoodsperiodrcd" resultType="TssGoodsperiodrcd">
        select
        goodsperiodrcdId,
        finishgoodPickno,
        goodsperiodrcdStartdate,
        goodsperiodrcdEnddate,
        goodsperiodrcdType,
        goodsperiodrcdParentid,
        goodsperiodrcdFmstaskcreateddate,
        goodsperiodrcdFmstaskremark,
        goodsperiodrcdFmstaskmanagername,
        goodsperiodrcdName,
        <if test="isOssCloudPolicy = false">
            SysRes.resUrl as periodPreview
        </if>
        <if test="isOssCloudPolicy = true">
            SysRes.resOssUrl as periodPreview
        </if>
        from
        TssGoodsperiodrcd
        LEFT JOIN SysRes on TssGoodsperiodrcd.goodsperiodrcdId = SysRes.resBusId
        <where>
            <if test="tssGoodsperiodrcd.finishgoodPickno != null  and tssGoodsperiodrcd.finishgoodPickno != ''"> and finishgoodPickno = #{tssGoodsperiodrcd.finishgoodPickno}</if>
            <if test="tssGoodsperiodrcd.goodsperiodrcdStartdate != null  and tssGoodsperiodrcd.goodsperiodrcdStartdate != ''"> and goodsperiodrcdStartdate = #{tssGoodsperiodrcd.goodsperiodrcdStartdate}</if>
            <if test="tssGoodsperiodrcd.goodsperiodrcdEnddate != null  and tssGoodsperiodrcd.goodsperiodrcdEnddate != ''"> and goodsperiodrcdEnddate = #{tssGoodsperiodrcd.goodsperiodrcdEnddate}</if>
            <if test="tssGoodsperiodrcd.goodsperiodrcdType != null  and tssGoodsperiodrcd.goodsperiodrcdType != ''"> and goodsperiodrcdType = #{tssGoodsperiodrcd.goodsperiodrcdType}</if>
            <if test="tssGoodsperiodrcd.goodsperiodrcdParentid != null  and tssGoodsperiodrcd.goodsperiodrcdParentid != ''"> and goodsperiodrcdParentid = #{tssGoodsperiodrcd.goodsperiodrcdParentid}</if>
            <if test="tssGoodsperiodrcd.goodsperiodrcdFmstaskcreateddate != null  and tssGoodsperiodrcd.goodsperiodrcdFmstaskcreateddate != ''"> and goodsperiodrcdFmstaskcreateddate = #{tssGoodsperiodrcd.goodsperiodrcdFmstaskcreateddate}</if>
            <if test="tssGoodsperiodrcd.goodsperiodrcdFmstaskremark != null  and tssGoodsperiodrcd.goodsperiodrcdFmstaskremark != ''"> and goodsperiodrcdFmstaskremark = #{tssGoodsperiodrcd.goodsperiodrcdFmstaskremark}</if>
            <if test="tssGoodsperiodrcd.goodsperiodrcdFmstaskmanagername != null  and tssGoodsperiodrcd.goodsperiodrcdFmstaskmanagername != ''"> and goodsperiodrcdFmstaskmanagername like concat('%', #{tssGoodsperiodrcd.goodsperiodrcdFmstaskmanagername}, '%')</if>
            <if test="tssGoodsperiodrcd.goodsperiodrcdName != null  and tssGoodsperiodrcd.goodsperiodrcdName != ''"> and goodsperiodrcdName like concat('%', #{tssGoodsperiodrcd.goodsperiodrcdName}, '%')</if>
        </where>
    </select>
    
    <select id="selectTssGoodsperiodrcdByGoodsperiodrcdId" parameterType="String" resultMap="TssGoodsperiodrcdResult">
        <include refid="selectTssGoodsperiodrcdVo"/>
        where goodsperiodrcdId = #{goodsperiodrcdId}
    </select>
        
    <insert id="insertTssGoodsperiodrcd" parameterType="TssGoodsperiodrcd">
        insert into TssGoodsperiodrcd
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="goodsperiodrcdId != null">goodsperiodrcdId,</if>
            <if test="finishgoodPickno != null">finishgoodPickno,</if>
            <if test="goodsperiodrcdStartdate != null">goodsperiodrcdStartdate,</if>
            <if test="goodsperiodrcdEnddate != null">goodsperiodrcdEnddate,</if>
            <if test="goodsperiodrcdType != null">goodsperiodrcdType,</if>
            <if test="goodsperiodrcdParentid != null">goodsperiodrcdParentid,</if>
            <if test="goodsperiodrcdFmstaskcreateddate != null">goodsperiodrcdFmstaskcreateddate,</if>
            <if test="goodsperiodrcdFmstaskremark != null">goodsperiodrcdFmstaskremark,</if>
            <if test="goodsperiodrcdFmstaskmanagername != null">goodsperiodrcdFmstaskmanagername,</if>
            <if test="goodsperiodrcdName != null">goodsperiodrcdName,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="goodsperiodrcdId != null">#{goodsperiodrcdId},</if>
            <if test="finishgoodPickno != null">#{finishgoodPickno},</if>
            <if test="goodsperiodrcdStartdate != null">#{goodsperiodrcdStartdate},</if>
            <if test="goodsperiodrcdEnddate != null">#{goodsperiodrcdEnddate},</if>
            <if test="goodsperiodrcdType != null">#{goodsperiodrcdType},</if>
            <if test="goodsperiodrcdParentid != null">#{goodsperiodrcdParentid},</if>
            <if test="goodsperiodrcdFmstaskcreateddate != null">#{goodsperiodrcdFmstaskcreateddate},</if>
            <if test="goodsperiodrcdFmstaskremark != null">#{goodsperiodrcdFmstaskremark},</if>
            <if test="goodsperiodrcdFmstaskmanagername != null">#{goodsperiodrcdFmstaskmanagername},</if>
            <if test="goodsperiodrcdName != null">#{goodsperiodrcdName},</if>
         </trim>
    </insert>

    <insert id="insertTssGoodsperiodrcdBatch" parameterType="TssGoodsperiodrcd">
        insert into TssGoodsperiodrcd
        <trim prefix="(" suffix=")" suffixOverrides=",">
            goodsperiodrcdId,
            finishgoodPickno,
            goodsperiodrcdStartdate,
            goodsperiodrcdEnddate,
            goodsperiodrcdType,
            goodsperiodrcdParentid,
            goodsperiodrcdFmstaskcreateddate,
            goodsperiodrcdFmstaskremark,
            goodsperiodrcdFmstaskmanagername,
            goodsperiodrcdName,
        </trim>
        values
        <foreach item="data" collection="list" separator=",">
            (
            #{data.goodsperiodrcdId},
            #{data.finishgoodPickno},
            #{data.goodsperiodrcdStartdate},
            #{data.goodsperiodrcdEnddate},
            #{data.goodsperiodrcdType},
            #{data.goodsperiodrcdParentid},
            #{data.goodsperiodrcdFmstaskcreateddate},
            #{data.goodsperiodrcdFmstaskremark},
            #{data.goodsperiodrcdFmstaskmanagername},
            #{data.goodsperiodrcdName}
            )
        </foreach>
    </insert>

    <update id="updateTssGoodsperiodrcd" parameterType="TssGoodsperiodrcd">
        update TssGoodsperiodrcd
        <trim prefix="SET" suffixOverrides=",">
            <if test="finishgoodPickno != null">finishgoodPickno = #{finishgoodPickno},</if>
            <if test="goodsperiodrcdStartdate != null">goodsperiodrcdStartdate = #{goodsperiodrcdStartdate},</if>
            <if test="goodsperiodrcdEnddate != null">goodsperiodrcdEnddate = #{goodsperiodrcdEnddate},</if>
            <if test="goodsperiodrcdType != null">goodsperiodrcdType = #{goodsperiodrcdType},</if>
            <if test="goodsperiodrcdParentid != null">goodsperiodrcdParentid = #{goodsperiodrcdParentid},</if>
            <if test="goodsperiodrcdFmstaskcreateddate != null">goodsperiodrcdFmstaskcreateddate = #{goodsperiodrcdFmstaskcreateddate},</if>
            <if test="goodsperiodrcdFmstaskremark != null">goodsperiodrcdFmstaskremark = #{goodsperiodrcdFmstaskremark},</if>
            <if test="goodsperiodrcdFmstaskmanagername != null">goodsperiodrcdFmstaskmanagername = #{goodsperiodrcdFmstaskmanagername},</if>
            <if test="goodsperiodrcdName != null">goodsperiodrcdName = #{goodsperiodrcdName},</if>
        </trim>
        where goodsperiodrcdId = #{goodsperiodrcdId}
    </update>

    <delete id="deleteTssGoodsperiodrcdByGoodsperiodrcdId" parameterType="String">
        delete from TssGoodsperiodrcd where goodsperiodrcdId = #{goodsperiodrcdId}
    </delete>

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