<?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.TWarehousebillsitemsNewMapper">

    <resultMap type="TWarehousebillsitemsNew" id="TWarehousebillsitemsNewResult">
        <result property="fId" column="f_id"/>
        <result property="fBilltype" column="f_billtype"/>
        <result property="isCalculateStorageFees" column="is_calculate_storage_fees"/>
        <result property="fCorpid" column="f_corpid"/>
        <result property="fCName" column="f_c_name"/>
        <result property="fName" column="f_name"/>
        <result property="fMblno" column="f_mblno"/>
        <result property="fQty" column="f_qty"/>
        <result property="fGrossweight" column="f_grossweight"/>
        <result property="fWarehouseInformation" column="f_warehouse_information"/>
        <result property="fWarehouseid" column="f_warehouseid"/>
        <result property="fOriginalbilldate" column="f_originalbilldate"/>
        <result property="fBsdate" column="f_bsdate"/>
        <result property="fStorekeeper" column="f_storekeeper"/>
        <result property="fStorageFeeDeadline" column="f_storage_fee_deadline"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectTWarehousebillsitemsNewVo">
        select b.f_id as f_id,
               a.f_billtype,
               a.is_calculate_storage_fees,
               b.f_corpid,
               tc.f_name as f_c_name,
               t.f_name,
               a.f_mblno,
               a.f_qty,
               b.f_grossweight,
               a.f_warehouse_information,
               b.f_warehouseid,
               a.f_originalbilldate as f_originalbilldate,
               a.f_bsdate,
               b.f_storekeeper,
               a.f_storage_fee_deadline,
               a.create_by,
               a.create_time,
               a.update_by,
               a.update_time
        from t_warehousebillsitems a left join t_warehousebills b on a.f_pid = b.f_id
                                     left join t_goods t on a.f_goodsid = t.f_id
                                     left join t_corps tc on b.f_corpid=tc.f_id
    </sql>

    <select id="selectWarehouseBillItemsList" parameterType="TWarehousebillsitemsNew" resultMap="TWarehousebillsitemsNewResult">
        <include refid="selectTWarehousebillsitemsNewVo"/>
        <where>
            <if test="fBilltype != null ">and a.f_billtype = #{fBilltype}</if>
            <if test="isCalculateStorageFees != null ">and a.is_calculate_storage_fees = #{isCalculateStorageFees}</if>
            <if test="fCorpid != null">and b.f_corpid = #{fCorpid}</if>
            <if test="fCName != null">and f_c_name = #{fCName}</if>
            <if test="fName != null">and t.f_name, = #{fName}</if>
            <if test="fMblno != null ">and a.f_mblno like concat('%',#{fMblno},'%')</if>
            <if test="fQty != null ">and a.f_qty = #{fQty}</if>
            <if test="fGrossweight != null ">and b.f_grossweight = #{fGrossweight}</if>
            <if test="fWarehouseInformation != null ">and a.f_warehouse_information like concat('%',#{fWarehouseInformation},'%')</if>
            <if test="fWarehouseid != null ">and b.f_warehouseid=#{fWarehouseid}</if>
            and f_originalbilldate!='null'
            /*&lt; 小于符号转义字符，直接输入小于符号会报错*/
            <if test="fBsdate != null ">and b.f_bsdate &lt; #{fBsdate}</if>
            <if test="fStorekeeper != null ">and b.f_storekeeper = #{fStorekeeper}</if>
            <if test="fStorageFeeDeadline != null ">and a.f_storage_fee_deadline = #{fStorageFeeDeadline}</if>
            <if test="createBy != null ">and a.create_by = #{createBy}</if>
            <if test="createTime != null ">and a.create_time = #{createTime}</if>
            <if test="updateBy != null ">and a.update_by = #{updateBy}</if>
            <if test="updateTime != null ">and a.update_time = #{updateTime}</if>
        </where>
        order by a.create_time desc
    </select>

    <select id="selectWarehouseBillItemesById" parameterType="Long" resultMap="TWarehousebillsitemsNewResult">
        <include refid="selectTWarehousebillsitemsNewVo"/>
        where f_id = #{fId}
    </select>
</mapper>
