<?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.ruoyi.warehouseBusiness.mapper.TWarehousebillsModifyMapper">
    
    <resultMap type="TWarehousebillsModify" id="TWarehousebillsModifyResult">
        <result property="fId"    column="f_id"    />
        <result property="fPid"    column="f_pid"    />
        <result property="fBillno"    column="f_billno"    />
        <result property="fDc"    column="f_dc"    />
        <result property="fCorpid"    column="f_corpid"    />
        <result property="fBilltype"    column="f_billtype"    />
        <result property="fMblno"    column="f_mblno"    />
        <result property="fGoodsid"    column="f_goodsid"    />
        <result property="fMarks"    column="f_marks"    />
        <result property="fWarehouseid"    column="f_warehouseid"    />
        <result property="fBstime"    column="f_bstime"    />
        <result property="delFlag"    column="del_flag"    />
        <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="fStatus"    column="f_status"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTWarehousebillsModifyVo">
        select f_id, f_pid, f_billno, f_dc, f_corpid, f_billtype, f_mblno, f_goodsid, f_marks, f_warehouseid, f_bstime, del_flag, f_status, create_by, create_time, update_by, update_time, remark from t_warehousebills_modify
    </sql>

    <select id="selectTWarehousebillsModifyList" parameterType="TWarehousebillsModify" resultMap="TWarehousebillsModifyResult">
        <include refid="selectTWarehousebillsModifyVo"/>
        <where>  
            <if test="fBillno != null  and fBillno != ''"> and f_billno = #{fBillno}</if>
            <if test="fDc != null  and fDc != ''"> and f_dc = #{fDc}</if>
            <if test="fCorpid != null "> and f_corpid = #{fCorpid}</if>
            <if test="fBilltype != null  and fBilltype != ''"> and f_billtype = #{fBilltype}</if>
            <if test="fMblno != null  and fMblno != ''"> and f_mblno = #{fMblno}</if>
            <if test="fGoodsid != null "> and f_goodsid = #{fGoodsid}</if>
            <if test="fMarks != null  and fMarks != ''"> and f_marks = #{fMarks}</if>
            <if test="fWarehouseid != null "> and f_warehouseid = #{fWarehouseid}</if>
            <if test="fStatus != null "> and f_status = #{fStatus}</if>
            <if test="bstimeList != null and bstimeList[0] != null and bstimeList[0] != ''"> and f_bstime BETWEEN #{bstimeList[0]} and #{bstimeList[1]}</if>
            <if test="createTimeList != null and createTimeList[0] != null and createTimeList[0] != ''"> and create_time BETWEEN #{createTimeList[0]} and #{createTimeList[1]}</if>
        </where>
        order by f_id desc
    </select>
    
    <select id="selectTWarehousebillsModifyById" parameterType="Long" resultMap="TWarehousebillsModifyResult">
        <include refid="selectTWarehousebillsModifyVo"/>
        where f_id = #{fId}
    </select>

    <select id="selectBillNoByIds" resultType="java.lang.String">
        select f_billno from t_warehousebills_modify where f_id in
        <foreach item="fId" collection="ids" open="(" separator="," close=")">
            #{fId}
        </foreach>
    </select>

    <insert id="insertTWarehousebillsModify" parameterType="TWarehousebillsModify" useGeneratedKeys="true" keyProperty="fId">
        insert into t_warehousebills_modify
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fBillno != null">f_billno,</if>
            <if test="fDc != null">f_dc,</if>
            <if test="fPid != null">f_pid,</if>
            <if test="fCorpid != null">f_corpid,</if>
            <if test="fBilltype != null">f_billtype,</if>
            <if test="fMblno != null">f_mblno,</if>
            <if test="fGoodsid != null">f_goodsid,</if>
            <if test="fMarks != null">f_marks,</if>
            <if test="fWarehouseid != null">f_warehouseid,</if>
            <if test="fBstime != null">f_bstime,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="fStatus != null">f_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fBillno != null">#{fBillno},</if>
            <if test="fDc != null">#{fDc},</if>
            <if test="fPid != null">#{fPid},</if>
            <if test="fCorpid != null">#{fCorpid},</if>
            <if test="fBilltype != null">#{fBilltype},</if>
            <if test="fMblno != null">#{fMblno},</if>
            <if test="fGoodsid != null">#{fGoodsid},</if>
            <if test="fMarks != null">#{fMarks},</if>
            <if test="fWarehouseid != null">#{fWarehouseid},</if>
            <if test="fBstime != null">#{fBstime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="fStatus != null">#{fStatus},</if>
         </trim>
    </insert>

    <update id="updateTWarehousebillsModify" parameterType="TWarehousebillsModify">
        update t_warehousebills_modify
        <trim prefix="SET" suffixOverrides=",">
            <if test="fBillno != null">f_billno = #{fBillno},</if>
            <if test="fDc != null">f_dc = #{fDc},</if>
            <if test="fPid != null">f_pid = #{fPid},</if>
            <if test="fCorpid != null">f_corpid = #{fCorpid},</if>
            <if test="fBilltype != null">f_billtype = #{fBilltype},</if>
            <if test="fMblno != null">f_mblno = #{fMblno},</if>
            <if test="fGoodsid != null">f_goodsid = #{fGoodsid},</if>
            <if test="fMarks != null">f_marks = #{fMarks},</if>
            <if test="fWarehouseid != null">f_warehouseid = #{fWarehouseid},</if>
            <if test="fBstime != null">f_bstime = #{fBstime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="fStatus != null">f_status = #{fStatus},</if>
        </trim>
        where f_id = #{fId}
    </update>

    <delete id="deleteTWarehousebillsModifyById" parameterType="Long">
        delete from t_warehousebills_modify where f_id = #{fId}
    </delete>

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