<?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.dcsoft.system.car.mapper.TbCarRecordMapper">

    <resultMap type="TbCarRecord" id="TbCarRecordResult">
        <result property="id"    column="id"    />
        <result property="parkCode"    column="park_code"    />
        <result property="uniqueNo"    column="unique_no"    />
        <result property="direction"    column="direction"    />
        <result property="plateNo"    column="plate_no"    />
        <result property="cardNo"    column="card_no"    />
        <result property="passTime"    column="pass_time"    />
        <result property="vehType"    column="veh_type"    />
        <result property="vehColor"    column="veh_color"    />
        <result property="operatorName"    column="operator_name"    />
        <result property="terminalNo"    column="terminal_no"    />
        <result property="gateName"    column="gate_name"    />
        <result property="laneName"    column="lane_name"    />
        <result property="inPassTime"    column="in_pass_time"    />
        <result property="inUniqueNo"    column="in_unique_no"    />
        <result property="shouldPay"    column="should_pay"    />
        <result property="actualPay"    column="actual_pay"    />
        <result property="picFilePath"    column="pic_file_path"    />
        <result property="picPlateFilePath"    column="pic_plate_file_path"    />
        <result property="picVehicleFileData"    column="pic_vehicle_file_data"    />
        <result property="picPlateFileData"    column="pic_plate_file_data"    />
        <result property="dataType"    column="data_type"    />
    </resultMap>

    <sql id="selectTbCarRecordVo">
        select id, park_code, unique_no, direction, plate_no, card_no, pass_time, veh_type, veh_color, operator_name, terminal_no, gate_name, lane_name, in_pass_time, in_unique_no, should_pay, actual_pay, pic_file_path, pic_plate_file_path, pic_vehicle_file_data, pic_plate_file_data, data_type from tb_car_record
    </sql>

    <select id="selectTbCarRecordList" parameterType="TbCarRecord" resultMap="TbCarRecordResult">
        <include refid="selectTbCarRecordVo"/>
        <where>
            <if test="plateNo != null  and plateNo != ''"> and plate_no = #{plateNo}</if>
            <if test="passTime != null "> and pass_time = #{passTime}</if>
            <if test="vehType != null  and vehType != ''"> and veh_type = #{vehType}</if>
            <if test="vehColor != null  and vehColor != ''"> and veh_color = #{vehColor}</if>
        </where>
    </select>

    <select id="selectTbCarRecordById" parameterType="Long" resultMap="TbCarRecordResult">
        <include refid="selectTbCarRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertTbCarRecord" parameterType="TbCarRecord">
        insert into tb_car_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="parkCode != null and parkCode != ''">park_code,</if>
            <if test="uniqueNo != null and uniqueNo != ''">unique_no,</if>
            <if test="direction != null">direction,</if>
            <if test="plateNo != null and plateNo != ''">plate_no,</if>
            <if test="cardNo != null and cardNo != ''">card_no,</if>
            <if test="passTime != null">pass_time,</if>
            <if test="vehType != null">veh_type,</if>
            <if test="vehColor != null">veh_color,</if>
            <if test="operatorName != null and operatorName != ''">operator_name,</if>
            <if test="terminalNo != null and terminalNo != ''">terminal_no,</if>
            <if test="gateName != null and gateName != ''">gate_name,</if>
            <if test="laneName != null and laneName != ''">lane_name,</if>
            <if test="inPassTime != null">in_pass_time,</if>
            <if test="inUniqueNo != null and inUniqueNo != ''">in_unique_no,</if>
            <if test="shouldPay != null and shouldPay != ''">should_pay,</if>
            <if test="actualPay != null">actual_pay,</if>
            <if test="picFilePath != null">pic_file_path,</if>
            <if test="picPlateFilePath != null">pic_plate_file_path,</if>
            <if test="picVehicleFileData != null">pic_vehicle_file_data,</if>
            <if test="picPlateFileData != null">pic_plate_file_data,</if>
            <if test="dataType != null">data_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="parkCode != null and parkCode != ''">#{parkCode},</if>
            <if test="uniqueNo != null and uniqueNo != ''">#{uniqueNo},</if>
            <if test="direction != null">#{direction},</if>
            <if test="plateNo != null and plateNo != ''">#{plateNo},</if>
            <if test="cardNo != null and cardNo != ''">#{cardNo},</if>
            <if test="passTime != null">#{passTime},</if>
            <if test="vehType != null">#{vehType},</if>
            <if test="vehColor != null">#{vehColor},</if>
            <if test="operatorName != null and operatorName != ''">#{operatorName},</if>
            <if test="terminalNo != null and terminalNo != ''">#{terminalNo},</if>
            <if test="gateName != null and gateName != ''">#{gateName},</if>
            <if test="laneName != null and laneName != ''">#{laneName},</if>
            <if test="inPassTime != null">#{inPassTime},</if>
            <if test="inUniqueNo != null and inUniqueNo != ''">#{inUniqueNo},</if>
            <if test="shouldPay != null and shouldPay != ''">#{shouldPay},</if>
            <if test="actualPay != null">#{actualPay},</if>
            <if test="picFilePath != null">#{picFilePath},</if>
            <if test="picPlateFilePath != null">#{picPlateFilePath},</if>
            <if test="picVehicleFileData != null">#{picVehicleFileData},</if>
            <if test="picPlateFileData != null">#{picPlateFileData},</if>
            <if test="dataType != null">#{dataType},</if>
         </trim>
    </insert>

    <update id="updateTbCarRecord" parameterType="TbCarRecord">
        update tb_car_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="parkCode != null and parkCode != ''">park_code = #{parkCode},</if>
            <if test="uniqueNo != null and uniqueNo != ''">unique_no = #{uniqueNo},</if>
            <if test="direction != null">direction = #{direction},</if>
            <if test="plateNo != null and plateNo != ''">plate_no = #{plateNo},</if>
            <if test="cardNo != null and cardNo != ''">card_no = #{cardNo},</if>
            <if test="passTime != null">pass_time = #{passTime},</if>
            <if test="vehType != null">veh_type = #{vehType},</if>
            <if test="vehColor != null">veh_color = #{vehColor},</if>
            <if test="operatorName != null and operatorName != ''">operator_name = #{operatorName},</if>
            <if test="terminalNo != null and terminalNo != ''">terminal_no = #{terminalNo},</if>
            <if test="gateName != null and gateName != ''">gate_name = #{gateName},</if>
            <if test="laneName != null and laneName != ''">lane_name = #{laneName},</if>
            <if test="inPassTime != null">in_pass_time = #{inPassTime},</if>
            <if test="inUniqueNo != null and inUniqueNo != ''">in_unique_no = #{inUniqueNo},</if>
            <if test="shouldPay != null and shouldPay != ''">should_pay = #{shouldPay},</if>
            <if test="actualPay != null">actual_pay = #{actualPay},</if>
            <if test="picFilePath != null">pic_file_path = #{picFilePath},</if>
            <if test="picPlateFilePath != null">pic_plate_file_path = #{picPlateFilePath},</if>
            <if test="picVehicleFileData != null">pic_vehicle_file_data = #{picVehicleFileData},</if>
            <if test="picPlateFileData != null">pic_plate_file_data = #{picPlateFileData},</if>
            <if test="dataType != null">data_type = #{dataType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTbCarRecordById" parameterType="Long">
        delete from tb_car_record where id = #{id}
    </delete>

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