<?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.TLpgVehicleInfoMapper">
    
    <resultMap type="TLpgVehicleInfo" id="TLpgVehicleInfoResult">
        <result property="vehicleId"    column="vehicle_id"    />
        <result property="stationName"    column="station_name"    />
        <result property="carNumber"    column="car_number"    />
        <result property="beyondEnterpriseId"    column="beyond_enterprise_id"    />
        <result property="vehicleCode"    column="vehicle_code"    />
        <result property="carNum"    column="car_num"    />
        <result property="brandModel"    column="brand_model"    />
        <result property="vehicleType"    column="vehicle_type"    />
        <result property="vehicleLoad"    column="vehicle_load"    />
        <result property="vehicleSize"    column="vehicle_size"    />
        <result property="vehicleLimt"    column="vehicle_limt"    />
        <result property="vehicleInspect"    column="vehicle_inspect"    />
        <result property="personLiable"    column="person_liable"    />
        <result property="onState"    column="on_state"    />
        <result property="vehicleUser"    column="vehicle_user"    />
        <result property="phone"    column="phone"    />
        <result property="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTLpgVehicleInfoVo">
        select vehicle_id, station_name, car_number, beyond_enterprise_id, vehicle_code, car_num, brand_model, vehicle_type, vehicle_load, vehicle_size, vehicle_limt, vehicle_inspect, person_liable, on_state, vehicle_user, phone, is_del, remarks from t_lpg_vehicle_info
    </sql>

    <select id="selectTLpgVehicleInfoList" parameterType="TLpgVehicleInfo" resultMap="TLpgVehicleInfoResult">
        <include refid="selectTLpgVehicleInfoVo"/>
        <where>  
            <if test="stationName != null  and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
            <if test="carNumber != null  and carNumber != ''"> and car_number = #{carNumber}</if>
            <if test="beyondEnterpriseId != null "> and beyond_enterprise_id = #{beyondEnterpriseId}</if>
            <if test="vehicleCode != null  and vehicleCode != ''"> and vehicle_code = #{vehicleCode}</if>
            <if test="carNum != null  and carNum != ''"> and car_num like concat('%', #{carNum}, '%')</if>
            <if test="brandModel != null  and brandModel != ''"> and brand_model = #{brandModel}</if>
            <if test="vehicleType != null  and vehicleType != ''"> and vehicle_type = #{vehicleType}</if>
            <if test="vehicleLoad != null  and vehicleLoad != ''"> and vehicle_load = #{vehicleLoad}</if>
            <if test="vehicleSize != null  and vehicleSize != ''"> and vehicle_size = #{vehicleSize}</if>
            <if test="vehicleLimt != null  and vehicleLimt != ''"> and vehicle_limt = #{vehicleLimt}</if>
            <if test="vehicleInspect != null  and vehicleInspect != ''"> and vehicle_inspect = #{vehicleInspect}</if>
            <if test="personLiable != null  and personLiable != ''"> and person_liable like concat('%', #{personLiable}, '%')</if>
            <if test="onState != null  and onState != ''"> and on_state = #{onState}</if>
            <if test="vehicleUser != null "> and vehicle_user = #{vehicleUser}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectTLpgVehicleInfoById" parameterType="Long" resultMap="TLpgVehicleInfoResult">
        <include refid="selectTLpgVehicleInfoVo"/>
        where vehicle_id = #{vehicleId}
    </select>
        
    <insert id="insertTLpgVehicleInfo" parameterType="TLpgVehicleInfo" useGeneratedKeys="true" keyProperty="vehicleId">
        insert into t_lpg_vehicle_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stationName != null">station_name,</if>
            <if test="carNumber != null">car_number,</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id,</if>
            <if test="vehicleCode != null">vehicle_code,</if>
            <if test="carNum != null">car_num,</if>
            <if test="brandModel != null">brand_model,</if>
            <if test="vehicleType != null">vehicle_type,</if>
            <if test="vehicleLoad != null">vehicle_load,</if>
            <if test="vehicleSize != null">vehicle_size,</if>
            <if test="vehicleLimt != null">vehicle_limt,</if>
            <if test="vehicleInspect != null">vehicle_inspect,</if>
            <if test="personLiable != null">person_liable,</if>
            <if test="onState != null">on_state,</if>
            <if test="vehicleUser != null">vehicle_user,</if>
            <if test="phone != null">phone,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stationName != null">#{stationName},</if>
            <if test="carNumber != null">#{carNumber},</if>
            <if test="beyondEnterpriseId != null">#{beyondEnterpriseId},</if>
            <if test="vehicleCode != null">#{vehicleCode},</if>
            <if test="carNum != null">#{carNum},</if>
            <if test="brandModel != null">#{brandModel},</if>
            <if test="vehicleType != null">#{vehicleType},</if>
            <if test="vehicleLoad != null">#{vehicleLoad},</if>
            <if test="vehicleSize != null">#{vehicleSize},</if>
            <if test="vehicleLimt != null">#{vehicleLimt},</if>
            <if test="vehicleInspect != null">#{vehicleInspect},</if>
            <if test="personLiable != null">#{personLiable},</if>
            <if test="onState != null">#{onState},</if>
            <if test="vehicleUser != null">#{vehicleUser},</if>
            <if test="phone != null">#{phone},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTLpgVehicleInfo" parameterType="TLpgVehicleInfo">
        update t_lpg_vehicle_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="stationName != null">station_name = #{stationName},</if>
            <if test="carNumber != null">car_number = #{carNumber},</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id = #{beyondEnterpriseId},</if>
            <if test="vehicleCode != null">vehicle_code = #{vehicleCode},</if>
            <if test="carNum != null">car_num = #{carNum},</if>
            <if test="brandModel != null">brand_model = #{brandModel},</if>
            <if test="vehicleType != null">vehicle_type = #{vehicleType},</if>
            <if test="vehicleLoad != null">vehicle_load = #{vehicleLoad},</if>
            <if test="vehicleSize != null">vehicle_size = #{vehicleSize},</if>
            <if test="vehicleLimt != null">vehicle_limt = #{vehicleLimt},</if>
            <if test="vehicleInspect != null">vehicle_inspect = #{vehicleInspect},</if>
            <if test="personLiable != null">person_liable = #{personLiable},</if>
            <if test="onState != null">on_state = #{onState},</if>
            <if test="vehicleUser != null">vehicle_user = #{vehicleUser},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where vehicle_id = #{vehicleId}
    </update>

    <delete id="deleteTLpgVehicleInfoById" parameterType="Long">
        delete from t_lpg_vehicle_info where vehicle_id = #{vehicleId}
    </delete>

    <delete id="deleteTLpgVehicleInfoByIds" parameterType="String">
        delete from t_lpg_vehicle_info where vehicle_id in 
        <foreach item="vehicleId" collection="array" open="(" separator="," close=")">
            #{vehicleId}
        </foreach>
    </delete>
</mapper>