<?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.gxwebsoft.hjm.mapper.HjmGpsLogMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM hjm_gps_log a
        <where>
            <if test="param.id != null">
                AND a.id = #{param.id}
            </if>
            <if test="param.carId != null">
                AND a.car_id = #{param.carId}
            </if>
            <if test="param.gpsNo != null">
                AND a.gps_no = #{param.gpsNo}
            </if>
            <if test="param.longitude != null">
                AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%')
            </if>
            <if test="param.latitude != null">
                AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%')
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.ddmmyy != null">
              AND a.ddmmyy LIKE CONCAT('%', #{param.ddmmyy}, '%')
            </if>
            <if test="param.hhmmss != null">
              AND a.hhmmss LIKE CONCAT(#{param.hhmmss}, '%')
            </if>
            <if test="param.speed != null">
              AND a.speed = #{param.speed}
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
            <if test="param.dateTime != null">
              AND a.create_time LIKE CONCAT('%', #{param.dateTime}, '%')
            </if>
            <if test="param.keywords != null">
              AND a.gps_no = #{param.keywords}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.hjm.entity.HjmGpsLog">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.hjm.entity.HjmGpsLog">
        <include refid="selectSql"></include>
    </select>

</mapper>
