<?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.zehong.system.mapper.TLpgGasBottleFilesMapper">
    
    <resultMap type="TLpgGasBottleFiles" id="TLpgGasBottleFilesResult">
        <result property="fGasBottleFilesId"    column="f_gas_bottle_files_id"    />
        <result property="fRegCode"    column="f_reg_code"    />
        <result property="fEquNo"    column="f_equ_no"    />
        <result property="fEquType"    column="f_equ_type"    />
        <result property="fMedium"    column="f_medium"    />
        <result property="fMakeDate"    column="f_make_date"    />
        <result property="fMakeInfo"    column="f_make_info"    />
        <result property="fSelfId"    column="f_self_id"    />
        <result property="fPressure"    column="f_pressure"    />
        <result property="fVolume"    column="f_volume"    />
        <result property="fAppId"    column="f_app_id"    />
        <result property="fQRcode"    column="f_q_rcode"    />
        <result property="fBuildUser"    column="f_build_user"    />
        <result property="fOptName"    column="f_opt_name"    />
        <result property="fAddTime"    column="f_add_time"    />
        <result property="fUpTime"    column="f_up_time"    />
        <result property="fState"    column="f_state"    />
        <result property="fUpOptName"    column="f_up_opt_name"    />
        <result property="fPChkDate"    column="f_p_chk_date"    />
        <result property="fNChkDate"    column="f_n_chk_date"    />
        <result property="fProductDate"    column="f_product_date"    />
        <result property="fDiscardDate"    column="f_discard_date"    />
        <result property="fSafeJudgeDate"    column="f_safe_judge_date"    />
        <result property="fGPressure"    column="f_g_pressure"    />
        <result property="fWPressure"    column="f_w_pressure"    />
        <result property="fSelfWeight"    column="f_self_weight"    />
        <result property="fThickness"    column="f_thickness"    />
        <result property="fPermitNo"    column="f_permit_no"    />
        <result property="fValveName"    column="f_valve_name"    />
        <result property="fPayImage"    column="f_pay_image"    />
        <result property="fBatchImage"    column="f_batch_image"    />
        <result property="fDeviceImage"    column="f_device_image"    />
        <result property="fCheckImage"    column="f_check_image"    />
        <result property="fEquNoImage"    column="f_equ_no_image"    />
        <result property="fSelfIdImage"    column="f_self_id_image"    />
        <result property="fBotImage"    column="f_bot_image"    />
        <result property="fBotSpecName"    column="f_bot_spec_name"    />
        <result property="fBottleType"    column="f_bottle_type"    />
        <result property="fInspectedTimes"    column="f_inspected_times"    />
        <result property="fIsSpecialized"    column="f_is_specialized"    />
        <result property="fValveManuFacturer"    column="f_valve_manu_facturer"    />
        <result property="fInspectionLabel"    column="f_inspection_label"    />
        <result property="fThirdPartyLabel"    column="f_third_party_label"    />
        <result property="fHoleCode"    column="f_hole_code"    />
        <result property="fBottleStorageType"    column="f_bottle_storage_type"    />
        <result property="fRowVersion"    column="f_row_version"    />
    </resultMap>

    <sql id="selectTLpgGasBottleFilesVo">
        select f_gas_bottle_files_id, f_reg_code, f_equ_no, f_equ_type, f_medium, f_make_date, f_make_info, f_self_id,f_pressure, f_volume, f_app_id, f_q_rcode,f_build_user,f_p_chk_date, f_n_chk_date, f_product_date, f_discard_date, f_safe_judge_date, f_g_pressure, f_w_pressure, f_self_weight, f_thickness, f_permit_no, f_valve_name, f_pay_image, f_batch_image, f_device_image, f_check_image, f_equ_no_image, f_self_id_image, f_bot_image, f_bot_spec_name, f_bottle_type, f_inspected_times,
               ( CASE f_is_specialized WHEN '1' THEN '专用' WHEN '2' THEN '托管' ELSE '-' END ) AS f_is_specialized,
               f_valve_manu_facturer, f_inspection_label, f_third_party_label, f_hole_code, f_bottle_storage_type,
               ( CASE f_state WHEN '1' THEN '新增' WHEN '2' THEN '修改' WHEN '-1' THEN '删除' ELSE '-' END ) AS f_state,
               f_opt_name, f_add_time, f_up_time, f_up_opt_name, f_row_version from t_lpg_gas_bottle_files
    </sql>

    <select id="selectTLpgGasBottleFilesList" parameterType="TLpgGasBottleFiles" resultMap="TLpgGasBottleFilesResult">
        <include refid="selectTLpgGasBottleFilesVo"/>
        <where>  
            <if test="fPChkDate != null "> and f_p_chk_date = #{fPChkDate}</if>
            <if test="fNChkDate != null "> and f_n_chk_date = #{fNChkDate}</if>
            <if test="fProductDate != null "> and f_product_date = #{fProductDate}</if>
            <if test="fDiscardDate != null "> and f_discard_date = #{fDiscardDate}</if>
            <if test="fSafeJudgeDate != null "> and f_safe_judge_date = #{fSafeJudgeDate}</if>
            <if test="fGPressure != null "> and f_g_pressure = #{fGPressure}</if>
            <if test="fWPressure != null "> and f_w_pressure = #{fWPressure}</if>
            <if test="fSelfWeight != null "> and f_self_weight = #{fSelfWeight}</if>
            <if test="fPermitNo != null  and fPermitNo != ''"> and f_permit_no = #{fPermitNo}</if>
            <if test="fValveName != null "> and f_valve_name like concat('%', #{fValveName}, '%')</if>
            <if test="fQRcode != null and fQRcode != ''"> and f_q_rcode like concat('%', #{fQRcode}, '%')</if>
            <if test="fState != null "> and f_state = #{fState}</if>
        </where>
    </select>
    
    <select id="selectTLpgGasBottleFilesById" parameterType="Long" resultMap="TLpgGasBottleFilesResult">
        <include refid="selectTLpgGasBottleFilesVo"/>
        where f_gas_bottle_files_id = #{fGasBottleFilesId}
    </select>
        
    <insert id="insertTLpgGasBottleFiles" parameterType="TLpgGasBottleFiles" useGeneratedKeys="true" keyProperty="fGasBottleFilesId">
        insert into t_lpg_gas_bottle_files
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fRegCode != null">f_reg_code,</if>
            <if test="fEquNo != null">f_equ_no,</if>
            <if test="fEquType != null">f_equ_type,</if>
            <if test="fMedium != null">f_medium,</if>
            <if test="fMakeDate != null">f_make_date,</if>
            <if test="fMakeInfo != null">f_make_info,</if>
            <if test="fSelfId != null">f_self_id,</if>

            <if test="fPressure != null">f_pressure,</if>
            <if test="fVolume != null">f_volume,</if>
            <if test="fAppId != null">f_app_id,</if>
            <if test="fQRcode != null">f_q_rcode,</if>
            <if test="fBuildUser != null">f_build_user,</if>
            <if test="fPChkDate != null">f_p_chk_date,</if>
            <if test="fNChkDate != null">f_n_chk_date,</if>
            <if test="fProductDate != null">f_product_date,</if>
            <if test="fDiscardDate != null">f_discard_date,</if>
            <if test="fSafeJudgeDate != null">f_safe_judge_date,</if>
            <if test="fGPressure != null">f_g_pressure,</if>
            <if test="fWPressure != null">f_w_pressure,</if>
            <if test="fSelfWeight != null">f_self_weight,</if>
            <if test="fThickness != null">f_thickness,</if>
            <if test="fPermitNo != null">f_permit_no,</if>
            <if test="fValveName != null">f_valve_name,</if>
            <if test="fPayImage != null">f_pay_image,</if>
            <if test="fBatchImage != null">f_batch_image,</if>
            <if test="fDeviceImage != null">f_device_image,</if>
            <if test="fCheckImage != null">f_check_image,</if>
            <if test="fEquNoImage != null">f_equ_no_image,</if>
            <if test="fSelfIdImage != null">f_self_id_image,</if>
            <if test="fBotImage != null">f_bot_image,</if>
            <if test="fBotSpecName != null">f_bot_spec_name,</if>
            <if test="fBottleType != null">f_bottle_type,</if>
            <if test="fInspectedTimes != null">f_inspected_times,</if>
            <if test="fIsSpecialized != null">f_is_specialized,</if>
            <if test="fValveManuFacturer != null">f_valve_manu_facturer,</if>
            <if test="fInspectionLabel != null">f_inspection_label,</if>
            <if test="fThirdPartyLabel != null">f_third_party_label,</if>
            <if test="fHoleCode != null">f_hole_code,</if>
            <if test="fBottleStorageType != null">f_bottle_storage_type,</if>
            <if test="fState != null">f_state,</if>
            <if test="fOptName != null">f_opt_name,</if>
            <if test="fAddTime != null">f_add_time,</if>
            <if test="fUpTime != null">f_up_time,</if>
            <if test="fUpOptName != null">f_up_opt_name,</if>
            <if test="fRowVersion != null">f_row_version,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fRegCode != null">#{fRegCode},</if>
            <if test="fEquNo != null">#{fEquNo},</if>
            <if test="fEquType != null">#{fEquType},</if>
            <if test="fMedium != null">#{fMedium},</if>
            <if test="fMakeDate != null">#{fMakeDate},</if>
            <if test="fMakeInfo != null">#{fMakeInfo},</if>
            <if test="fSelfId != null">#{fSelfId},</if>

            <if test="fPressure != null">#{fPressure},</if>
            <if test="fVolume != null">#{fVolume},</if>
            <if test="fAppId != null">#{fAppId},</if>
            <if test="fQRcode != null">#{fQRcode},</if>
            <if test="fBuildUser != null">#{fBuildUser},</if>
            <if test="fPChkDate != null">#{fPChkDate},</if>
            <if test="fNChkDate != null">#{fNChkDate},</if>
            <if test="fProductDate != null">#{fProductDate},</if>
            <if test="fDiscardDate != null">#{fDiscardDate},</if>
            <if test="fSafeJudgeDate != null">#{fSafeJudgeDate},</if>
            <if test="fGPressure != null">#{fGPressure},</if>
            <if test="fWPressure != null">#{fWPressure},</if>
            <if test="fSelfWeight != null">#{fSelfWeight},</if>
            <if test="fThickness != null">#{fThickness},</if>
            <if test="fPermitNo != null">#{fPermitNo},</if>
            <if test="fValveName != null">#{fValveName},</if>
            <if test="fPayImage != null">#{fPayImage},</if>
            <if test="fBatchImage != null">#{fBatchImage},</if>
            <if test="fDeviceImage != null">#{fDeviceImage},</if>
            <if test="fCheckImage != null">#{fCheckImage},</if>
            <if test="fEquNoImage != null">#{fEquNoImage},</if>
            <if test="fSelfIdImage != null">#{fSelfIdImage},</if>
            <if test="fBotImage != null">#{fBotImage},</if>
            <if test="fBotSpecName != null">#{fBotSpecName},</if>
            <if test="fBottleType != null">#{fBottleType},</if>
            <if test="fInspectedTimes != null">#{fInspectedTimes},</if>
            <if test="fIsSpecialized != null">#{fIsSpecialized},</if>
            <if test="fValveManuFacturer != null">#{fValveManuFacturer},</if>
            <if test="fInspectionLabel != null">#{fInspectionLabel},</if>
            <if test="fThirdPartyLabel != null">#{fThirdPartyLabel},</if>
            <if test="fHoleCode != null">#{fHoleCode},</if>
            <if test="fBottleStorageType != null">#{fBottleStorageType},</if>
            <if test="fState != null">#{fState},</if>
            <if test="fOptName != null">#{fOptName},</if>
            <if test="fAddTime != null">#{fAddTime},</if>
            <if test="fUpTime != null">#{fUpTime},</if>

            <if test="fUpOptName != null">#{fUpOptName},</if>
            <if test="fRowVersion != null">#{fRowVersion},</if>
         </trim>
    </insert>

    <update id="updateTLpgGasBottleFiles" parameterType="TLpgGasBottleFiles">
        update t_lpg_gas_bottle_files
        <trim prefix="SET" suffixOverrides=",">
            <if test="fRegCode != null">f_reg_code = #{fRegCode},</if>
            <if test="fEquNo != null">f_equ_no = #{fEquNo},</if>
            <if test="fEquType != null">f_equ_type = #{fEquType},</if>
            <if test="fMedium != null">f_medium = #{fMedium},</if>
            <if test="fMakeDate != null">f_make_date = #{fMakeDate},</if>
            <if test="fMakeInfo != null">f_make_info = #{fMakeInfo},</if>
            <if test="fSelfId != null">f_self_id = #{fSelfId},</if>

            <if test="fPressure != null">f_pressure = #{fPressure},</if>
            <if test="fVolume != null">f_volume = #{fVolume},</if>
            <if test="fAppId != null">f_app_id = #{fAppId},</if>
            <if test="fQRcode != null">f_q_rcode = #{fQRcode},</if>
            <if test="fBuildUser != null">f_build_user = #{fBuildUser},</if>
            <if test="fPChkDate != null">f_p_chk_date = #{fPChkDate},</if>
            <if test="fNChkDate != null">f_n_chk_date = #{fNChkDate},</if>
            <if test="fProductDate != null">f_product_date = #{fProductDate},</if>
            <if test="fDiscardDate != null">f_discard_date = #{fDiscardDate},</if>
            <if test="fSafeJudgeDate != null">f_safe_judge_date = #{fSafeJudgeDate},</if>
            <if test="fGPressure != null">f_g_pressure = #{fGPressure},</if>
            <if test="fWPressure != null">f_w_pressure = #{fWPressure},</if>
            <if test="fSelfWeight != null">f_self_weight = #{fSelfWeight},</if>
            <if test="fThickness != null">f_thickness = #{fThickness},</if>
            <if test="fPermitNo != null">f_permit_no = #{fPermitNo},</if>
            <if test="fValveName != null">f_valve_name = #{fValveName},</if>
            <if test="fPayImage != null">f_pay_image = #{fPayImage},</if>
            <if test="fBatchImage != null">f_batch_image = #{fBatchImage},</if>
            <if test="fDeviceImage != null">f_device_image = #{fDeviceImage},</if>
            <if test="fCheckImage != null">f_check_image = #{fCheckImage},</if>
            <if test="fEquNoImage != null">f_equ_no_image = #{fEquNoImage},</if>
            <if test="fSelfIdImage != null">f_self_id_image = #{fSelfIdImage},</if>
            <if test="fBotImage != null">f_bot_image = #{fBotImage},</if>
            <if test="fBotSpecName != null">f_bot_spec_name = #{fBotSpecName},</if>
            <if test="fBottleType != null">f_bottle_type = #{fBottleType},</if>
            <if test="fInspectedTimes != null">f_inspected_times = #{fInspectedTimes},</if>
            <if test="fIsSpecialized != null">f_is_specialized = #{fIsSpecialized},</if>
            <if test="fValveManuFacturer != null">f_valve_manu_facturer = #{fValveManuFacturer},</if>
            <if test="fInspectionLabel != null">f_inspection_label = #{fInspectionLabel},</if>
            <if test="fThirdPartyLabel != null">f_third_party_label = #{fThirdPartyLabel},</if>
            <if test="fHoleCode != null">f_hole_code = #{fHoleCode},</if>
            <if test="fBottleStorageType != null">f_bottle_storage_type = #{fBottleStorageType},</if>
            <if test="fState != null">f_state = #{fState},</if>
            <if test="fOptName != null">f_opt_name = #{fOptName},</if>
            <if test="fAddTime != null">f_add_time = #{fAddTime},</if>
            <if test="fUpTime != null">f_up_time = #{fUpTime},</if>
            <if test="fUpOptName != null">f_up_opt_name = #{fUpOptName},</if>
            <if test="fRowVersion != null">f_row_version = #{fRowVersion},</if>
        </trim>
        where f_gas_bottle_files_id = #{fGasBottleFilesId}
    </update>

    <delete id="deleteTLpgGasBottleFilesById" parameterType="Long">
        delete from t_lpg_gas_bottle_files where f_gas_bottle_files_id = #{fGasBottleFilesId}
    </delete>

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