<?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.shipping.mapper.TWarehousebillsCntrMapper">

    <resultMap type="TWarehousebillsCntr" id="TWarehousebillsCntrResult">
        <result property="fId" column="f_id"/>
        <result property="fPid" column="f_pid"/>
        <result property="fGoodsid" column="f_goodsid"/>
        <result property="fPackageid" column="f_packageid"/>
        <result property="fCntrid" column="f_cntrid"/>
        <result property="fCntrcount" column="f_cntrcount"/>
        <result property="fCntrweight" column="f_cntrweight"/>
        <result property="fCntrstatus" column="f_cntrstatus"/>
        <result property="fSoc" column="f_soc"/>
        <result property="fTemperature" column="f_temperature"/>
        <result property="fDraught" column="f_Draught"/>
        <result property="fHumidity" column="f_Humidity"/>
        <result property="fPrecooling" column="f_precooling"/>
        <result property="fPlantakecntr" column="f_plantakecntr"/>
        <result property="fIfdanger" column="f_IFDANGER"/>
        <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="remark" column="remark"/>
    </resultMap>

    <sql id="selectTWarehousebillsCntrVo">
        select f_id,
               f_pid,
               f_goodsid,
               f_packageid,
               f_cntrid,
               f_cntrcount,
               f_cntrweight,
               f_cntrstatus,
               f_soc,
               f_temperature,
               f_Draught,
               f_Humidity,
               f_precooling,
               f_plantakecntr,
               f_IFDANGER,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from t_warehousebills_cntr
    </sql>

    <select id="selectTWarehousebillsCntrList" parameterType="TWarehousebillsCntr"
            resultMap="TWarehousebillsCntrResult">
        SELECT
        tw.f_id,
        tw.f_pid,
        tw.f_goodsid,
        tg.f_name goodsName,
        pro.dict_label typeidName,
        tw.f_packageid,
        sd.dict_label packageName,
        tw.f_cntrid,
        tc.f_no cntrName,
        tw.f_cntrcount,
        tw.f_cntrweight,
        tw.f_cntrstatus,
        tw.f_soc,
        tw.f_temperature,
        tw.f_Draught,
        tw.f_Humidity,
        tw.f_precooling,
        si.dict_label precoolingName,
        tw.f_plantakecntr,
        tw.f_IFDANGER,
        sc.dict_label ifdangerName,
        tw.create_by,
        tw.create_time,
        tw.update_by,
        tw.update_time,
        tw.remark
        FROM
        t_warehousebills_cntr tw
        LEFT JOIN t_goods tg ON tg.f_id = tw.f_goodsid
        LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_packageid
        AND sd.dict_type = 'f_packageid'
        LEFT JOIN t_cntr tc ON tc.f_id = tw.f_cntrid
        LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_precooling
        AND si.dict_type = 'f_precooling'
        LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_IFDANGER
        AND sc.dict_type = 'f_IFDANGER'
        LEFT JOIN sys_dict_data pro ON pro.dict_value = tg.f_typeid and pro.dict_type = 'data_goods_category'
        <where>
            <if test="fPid != null ">and tw.f_pid = #{fPid}</if>
            <if test="fGoodsid != null ">and tw.f_goodsid = #{fGoodsid}</if>
            <if test="fPackageid != null  and fPackageid != ''">and tw.f_packageid = #{fPackageid}</if>
            <if test="fCntrid != null ">and tw.f_cntrid = #{fCntrid}</if>
            <if test="fCntrcount != null ">and tw.f_cntrcount = #{fCntrcount}</if>
            <if test="fCntrweight != null ">and tw.f_cntrweight = #{fCntrweight}</if>
            <if test="fCntrstatus != null  and fCntrstatus != ''">and tw.f_cntrstatus = #{fCntrstatus}</if>
            <if test="fSoc != null  and fSoc != ''">and tw.f_soc = #{fSoc}</if>
            <if test="fTemperature != null  and fTemperature != ''">and tw.f_temperature = #{fTemperature}</if>
            <if test="fDraught != null  and fDraught != ''">and tw.f_Draught = #{fDraught}</if>
            <if test="fHumidity != null  and fHumidity != ''">and tw.f_Humidity = #{fHumidity}</if>
            <if test="fPrecooling != null  and fPrecooling != ''">and tw.f_precooling = #{fPrecooling}</if>
            <if test="fPlantakecntr != null ">and tw.f_plantakecntr = #{fPlantakecntr}</if>
            <if test="fIfdanger != null  and fIfdanger != ''">and tw.f_IFDANGER = #{fIfdanger}</if>
        </where>
    </select>

    <select id="selectTWarehousebillsCntrById" parameterType="Long" resultMap="TWarehousebillsCntrResult">
        <include refid="selectTWarehousebillsCntrVo"/>
        where f_id = #{fId}
    </select>

    <select id="selectTWarehousebillsCntrByPId" parameterType="Long" resultMap="TWarehousebillsCntrResult">
        <include refid="selectTWarehousebillsCntrVo"/>
        where f_pid = #{fId}
    </select>

    <insert id="insertTWarehousebillsCntr" parameterType="TWarehousebillsCntr" useGeneratedKeys="true"
            keyProperty="fId">
        insert into t_warehousebills_cntr
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fPid != null">f_pid,</if>
            <if test="fGoodsid != null">f_goodsid,</if>
            <if test="fPackageid != null and fPackageid != ''">f_packageid,</if>
            <if test="fCntrid != null">f_cntrid,</if>
            <if test="fCntrcount != null">f_cntrcount,</if>
            <if test="fCntrweight != null">f_cntrweight,</if>
            <if test="fCntrstatus != null">f_cntrstatus,</if>
            <if test="fSoc != null">f_soc,</if>
            <if test="fTemperature != null">f_temperature,</if>
            <if test="fDraught != null">f_Draught,</if>
            <if test="fHumidity != null">f_Humidity,</if>
            <if test="fPrecooling != null">f_precooling,</if>
            <if test="fPlantakecntr != null">f_plantakecntr,</if>
            <if test="fIfdanger != null">f_IFDANGER,</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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fPid != null">#{fPid},</if>
            <if test="fGoodsid != null">#{fGoodsid},</if>
            <if test="fPackageid != null and fPackageid != ''">#{fPackageid},</if>
            <if test="fCntrid != null">#{fCntrid},</if>
            <if test="fCntrcount != null">#{fCntrcount},</if>
            <if test="fCntrweight != null">#{fCntrweight},</if>
            <if test="fCntrstatus != null">#{fCntrstatus},</if>
            <if test="fSoc != null">#{fSoc},</if>
            <if test="fTemperature != null">#{fTemperature},</if>
            <if test="fDraught != null">#{fDraught},</if>
            <if test="fHumidity != null">#{fHumidity},</if>
            <if test="fPrecooling != null">#{fPrecooling},</if>
            <if test="fPlantakecntr != null">#{fPlantakecntr},</if>
            <if test="fIfdanger != null">#{fIfdanger},</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>
        </trim>
    </insert>

    <update id="updateTWarehousebillsCntr" parameterType="TWarehousebillsCntr">
        update t_warehousebills_cntr
        <trim prefix="SET" suffixOverrides=",">
            <if test="fPid != null">f_pid = #{fPid},</if>
            <if test="fGoodsid != null">f_goodsid = #{fGoodsid},</if>
            <if test="fPackageid != null and fPackageid != ''">f_packageid = #{fPackageid},</if>
            <if test="fCntrid != null">f_cntrid = #{fCntrid},</if>
            <if test="fCntrcount != null">f_cntrcount = #{fCntrcount},</if>
            <if test="fCntrweight != null">f_cntrweight = #{fCntrweight},</if>
            <if test="fCntrstatus != null">f_cntrstatus = #{fCntrstatus},</if>
            <if test="fSoc != null">f_soc = #{fSoc},</if>
            <if test="fTemperature != null">f_temperature = #{fTemperature},</if>
            <if test="fDraught != null">f_Draught = #{fDraught},</if>
            <if test="fHumidity != null">f_Humidity = #{fHumidity},</if>
            <if test="fPrecooling != null">f_precooling = #{fPrecooling},</if>
            <if test="fPlantakecntr != null">f_plantakecntr = #{fPlantakecntr},</if>
            <if test="fIfdanger != null">f_IFDANGER = #{fIfdanger},</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>
        </trim>
        where f_id = #{fId}
    </update>

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

    <delete id="deleteTWarehousebillsCntrByIds" parameterType="String">
        delete from t_warehousebills_cntr where f_id in
        <foreach item="fId" collection="array" open="(" separator="," close=")">
            #{fId}
        </foreach>
    </delete>
    <delete id="deleteTWarehousebillsCntrfPid" parameterType="Long">
        delete
        from t_warehousebills_cntr
        where f_pid = #{fPid}
    </delete>

    <delete id="deleteTWarehousebillsCntrfPids" parameterType="String">
        delete from t_warehousebills_cntr where f_pid in
        <foreach item="fPid" collection="array" open="(" separator="," close=")">
            #{fPid}
        </foreach>
    </delete>

</mapper>