<?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.TLpgSafeCheckRecordMapper">
    
    <resultMap type="TLpgSafeCheckRecord" id="TLpgSafeCheckRecordResult">
        <result property="safeCheckId"    column="safe_check_id"    />
        <result property="stationName"    column="station_name"    />
        <result property="gasUser"    column="gas_user"    />
        <result property="gasUserType"    column="gas_user_type"    />
        <result property="gasUserAddress"    column="gas_user_address"    />
        <result property="telNum"    column="tel_num"    />
        <result property="safeCheckDate"    column="safe_check_date"    />
        <result property="safeCheckPerson"    column="safe_check_person"    />
        <result property="bottleNum"    column="bottle_num"    />
        <result property="checkInStatus"    column="check_in_status"    />
        <result property="stoveCheckStatus"    column="stove_check_status"    />
        <result property="stoveCheckPic"    column="stove_check_pic"    />
        <result property="hoseCheckStatus"    column="hose_check_status"    />
        <result property="hoseCheckPic"    column="hose_check_pic"    />
        <result property="valveCheckStatus"    column="valve_check_status"    />
        <result property="valveCheckPic"    column="valve_check_pic"    />
        <result property="bottleCheckStatus"    column="bottle_check_status"    />
        <result property="bottleCheckPic"    column="bottle_check_pic"    />
        <result property="alarmCheckStatus"    column="alarm_check_status"    />
        <result property="alarmCheckPic"    column="alarm_check_pic"    />
        <result property="placeCheckStatus"    column="place_check_status"    />
        <result property="placeCheckPic"    column="place_check_pic"    />
        <result property="checkPersonSign"    column="check_person_sign"    />
        <result property="gasUserSign"    column="gas_user_sign"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTLpgSafeCheckRecordVo">
        select safe_check_id, station_name, gas_user, gas_user_type, gas_user_address, tel_num, safe_check_date, safe_check_person, bottle_num, check_in_status, stove_check_status, stove_check_pic, hose_check_status, hose_check_pic, valve_check_status, valve_check_pic, bottle_check_status, bottle_check_pic, alarm_check_status, alarm_check_pic, place_check_status, place_check_pic, check_person_sign, gas_user_sign, create_time, update_time, is_del, remark from t_lpg_safe_check_record
    </sql>

    <select id="selectTLpgSafeCheckRecordList" parameterType="TLpgSafeCheckRecord" resultMap="TLpgSafeCheckRecordResult">
        <include refid="selectTLpgSafeCheckRecordVo"/>
        <where>  
            <if test="stationName != null "> and station_name like concat('%', #{stationName}, '%')</if>
            <if test="gasUser != null  and gasUser != ''"> and gas_user = #{gasUser}</if>
            <if test="gasUserType != null  and gasUserType != ''"> and gas_user_type = #{gasUserType}</if>
            <if test="gasUserAddress != null  and gasUserAddress != ''"> and gas_user_address = #{gasUserAddress}</if>
            <if test="telNum != null  and telNum != ''"> and tel_num = #{telNum}</if>
            <if test="safeCheckDate != null "> and safe_check_date = #{safeCheckDate}</if>
            <if test="safeCheckPerson != null  and safeCheckPerson != ''"> and safe_check_person = #{safeCheckPerson}</if>
            <if test="bottleNum != null "> and bottle_num = #{bottleNum}</if>
            <if test="checkInStatus != null  and checkInStatus != ''"> and check_in_status = #{checkInStatus}</if>
            <if test="stoveCheckStatus != null  and stoveCheckStatus != ''"> and stove_check_status = #{stoveCheckStatus}</if>
            <if test="stoveCheckPic != null  and stoveCheckPic != ''"> and stove_check_pic = #{stoveCheckPic}</if>
            <if test="hoseCheckStatus != null  and hoseCheckStatus != ''"> and hose_check_status = #{hoseCheckStatus}</if>
            <if test="hoseCheckPic != null  and hoseCheckPic != ''"> and hose_check_pic = #{hoseCheckPic}</if>
            <if test="valveCheckStatus != null  and valveCheckStatus != ''"> and valve_check_status = #{valveCheckStatus}</if>
            <if test="valveCheckPic != null  and valveCheckPic != ''"> and valve_check_pic = #{valveCheckPic}</if>
            <if test="bottleCheckStatus != null  and bottleCheckStatus != ''"> and bottle_check_status = #{bottleCheckStatus}</if>
            <if test="bottleCheckPic != null  and bottleCheckPic != ''"> and bottle_check_pic = #{bottleCheckPic}</if>
            <if test="alarmCheckStatus != null  and alarmCheckStatus != ''"> and alarm_check_status = #{alarmCheckStatus}</if>
            <if test="alarmCheckPic != null  and alarmCheckPic != ''"> and alarm_check_pic = #{alarmCheckPic}</if>
            <if test="placeCheckStatus != null  and placeCheckStatus != ''"> and place_check_status = #{placeCheckStatus}</if>
            <if test="placeCheckPic != null  and placeCheckPic != ''"> and place_check_pic = #{placeCheckPic}</if>
            <if test="checkPersonSign != null  and checkPersonSign != ''"> and check_person_sign = #{checkPersonSign}</if>
            <if test="gasUserSign != null  and gasUserSign != ''"> and gas_user_sign = #{gasUserSign}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectTLpgSafeCheckRecordById" parameterType="Long" resultMap="TLpgSafeCheckRecordResult">
        <include refid="selectTLpgSafeCheckRecordVo"/>
        where safe_check_id = #{safeCheckId}
    </select>
        
    <insert id="insertTLpgSafeCheckRecord" parameterType="TLpgSafeCheckRecord" useGeneratedKeys="true" keyProperty="safeCheckId">
        insert into t_lpg_safe_check_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stationName != null">station_name,</if>
            <if test="gasUser != null">gas_user,</if>
            <if test="gasUserType != null">gas_user_type,</if>
            <if test="telNum != null">tel_num,</if>
            <if test="gasUserAddress != null">gas_user_address,</if>
            <if test="safeCheckDate != null">safe_check_date,</if>
            <if test="safeCheckPerson != null">safe_check_person,</if>
            <if test="bottleNum != null">bottle_num,</if>
            <if test="checkInStatus != null">check_in_status,</if>
            <if test="stoveCheckStatus != null">stove_check_status,</if>
            <if test="stoveCheckPic != null">stove_check_pic,</if>
            <if test="hoseCheckStatus != null">hose_check_status,</if>
            <if test="hoseCheckPic != null">hose_check_pic,</if>
            <if test="valveCheckStatus != null">valve_check_status,</if>
            <if test="valveCheckPic != null">valve_check_pic,</if>
            <if test="bottleCheckStatus != null">bottle_check_status,</if>
            <if test="bottleCheckPic != null">bottle_check_pic,</if>
            <if test="alarmCheckStatus != null">alarm_check_status,</if>
            <if test="alarmCheckPic != null">alarm_check_pic,</if>
            <if test="placeCheckStatus != null">place_check_status,</if>
            <if test="placeCheckPic != null">place_check_pic,</if>
            <if test="checkPersonSign != null">check_person_sign,</if>
            <if test="gasUserSign != null">gas_user_sign,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stationName != null">#{stationName},</if>
            <if test="gasUser != null">#{gasUser},</if>
            <if test="gasUserType != null">#{gasUserType},</if>
            <if test="telNum != null">#{telNum},</if>
            <if test="gasUserAddress != null">#{gasUserAddress},</if>
            <if test="safeCheckDate != null">#{safeCheckDate},</if>
            <if test="safeCheckPerson != null">#{safeCheckPerson},</if>
            <if test="bottleNum != null">#{bottleNum},</if>
            <if test="checkInStatus != null">#{checkInStatus},</if>
            <if test="stoveCheckStatus != null">#{stoveCheckStatus},</if>
            <if test="stoveCheckPic != null">#{stoveCheckPic},</if>
            <if test="hoseCheckStatus != null">#{hoseCheckStatus},</if>
            <if test="hoseCheckPic != null">#{hoseCheckPic},</if>
            <if test="valveCheckStatus != null">#{valveCheckStatus},</if>
            <if test="valveCheckPic != null">#{valveCheckPic},</if>
            <if test="bottleCheckStatus != null">#{bottleCheckStatus},</if>
            <if test="bottleCheckPic != null">#{bottleCheckPic},</if>
            <if test="alarmCheckStatus != null">#{alarmCheckStatus},</if>
            <if test="alarmCheckPic != null">#{alarmCheckPic},</if>
            <if test="placeCheckStatus != null">#{placeCheckStatus},</if>
            <if test="placeCheckPic != null">#{placeCheckPic},</if>
            <if test="checkPersonSign != null">#{checkPersonSign},</if>
            <if test="gasUserSign != null">#{gasUserSign},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTLpgSafeCheckRecord" parameterType="TLpgSafeCheckRecord">
        update t_lpg_safe_check_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="stationName != null">station_name = #{stationName},</if>
            <if test="gasUser != null">gas_user = #{gasUser},</if>
            <if test="gasUserType != null">gas_user_type = #{gasUserType},</if>
            <if test="telNum != null">tel_num = #{telNum},</if>
            <if test="gasUserAddress != null">gas_user_address = #{gasUserAddress},</if>
            <if test="safeCheckDate != null">safe_check_date = #{safeCheckDate},</if>
            <if test="safeCheckPerson != null">safe_check_person = #{safeCheckPerson},</if>
            <if test="bottleNum != null">bottle_num = #{bottleNum},</if>
            <if test="checkInStatus != null">check_in_status = #{checkInStatus},</if>
            <if test="stoveCheckStatus != null">stove_check_status = #{stoveCheckStatus},</if>
            <if test="stoveCheckPic != null">stove_check_pic = #{stoveCheckPic},</if>
            <if test="hoseCheckStatus != null">hose_check_status = #{hoseCheckStatus},</if>
            <if test="hoseCheckPic != null">hose_check_pic = #{hoseCheckPic},</if>
            <if test="valveCheckStatus != null">valve_check_status = #{valveCheckStatus},</if>
            <if test="valveCheckPic != null">valve_check_pic = #{valveCheckPic},</if>
            <if test="bottleCheckStatus != null">bottle_check_status = #{bottleCheckStatus},</if>
            <if test="bottleCheckPic != null">bottle_check_pic = #{bottleCheckPic},</if>
            <if test="alarmCheckStatus != null">alarm_check_status = #{alarmCheckStatus},</if>
            <if test="alarmCheckPic != null">alarm_check_pic = #{alarmCheckPic},</if>
            <if test="placeCheckStatus != null">place_check_status = #{placeCheckStatus},</if>
            <if test="placeCheckPic != null">place_check_pic = #{placeCheckPic},</if>
            <if test="checkPersonSign != null">check_person_sign = #{checkPersonSign},</if>
            <if test="gasUserSign != null">gas_user_sign = #{gasUserSign},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where safe_check_id = #{safeCheckId}
    </update>

    <delete id="deleteTLpgSafeCheckRecordById" parameterType="Long">
        delete from t_lpg_safe_check_record where safe_check_id = #{safeCheckId}
    </delete>

    <delete id="deleteTLpgSafeCheckRecordByIds" parameterType="String">
        delete from t_lpg_safe_check_record where safe_check_id in 
        <foreach item="safeCheckId" collection="array" open="(" separator="," close=")">
            #{safeCheckId}
        </foreach>
    </delete>
</mapper>