VehicleDeviceMapper.xml 4.5 KB
<?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="cn.com.glsx.stdinterface.modules.mapper.VehicleDeviceMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.modules.entity.VehicleDevice">
        <!--
      WARNING - @mbg.generated
    -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="vehicle_id" jdbcType="INTEGER" property="vehicleId"/>
        <result column="sn" jdbcType="VARCHAR" property="sn"/>
        <result column="bind_status" jdbcType="TINYINT" property="bindStatus"/>
        <result column="trial_type" jdbcType="TINYINT" property="trialType"/>
        <result column="his_type" jdbcType="TINYINT" property="hisType"/>
        <result column="wire_type" jdbcType="TINYINT" property="wireType"/>
        <result column="active_location_date" jdbcType="TIMESTAMP" property="activeLocationDate"/>
        <result column="active_location_lng" jdbcType="VARCHAR" property="activeLocationLng"/>
        <result column="active_location_lat" jdbcType="VARCHAR" property="activeLocationLat"/>
        <result column="active_location_type" jdbcType="TINYINT" property="activeLocationType"/>
        <result column="active_location_address" jdbcType="VARCHAR" property="activeLocationAddress"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, vehicle_id, sn, bind_status, trial_type, his_type, wire_type, active_location_date,
        active_location_lng, active_location_lat, active_location_type, active_location_address,
        del_flag, created_date, created_by, updated_date, updated_by
    </sql>

    <select id="getVdIdbySn" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle_device
        where sn = #{sn}
        and bind_status = 2
        and his_type = 1
        order by id desc limit 1
    </select>

    <select id="selectBindingDeviceBySn" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle_device
        where del_flag = 0
        and sn = #{sn}
        and bind_status = 1
        limit 1
    </select>

    <select id="selectBindingDevices" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle_device
        where del_flag = 0
        and bind_status = 1
        and sn in
        <foreach collection="sns" separator="," open="(" close=")" item="item">
            #{item}
        </foreach>
    </select>

    <select id="selectBindingDevicesByVehicleId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle_device
        where del_flag = 0
        and bind_status = 1
        and vehicle_id = #{vehicleId}
    </select>

    <select id="selectVehicleDevcieBySn" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_vehicle_device
        where del_flag = 0
        and bind_status = 1
        and sn = #{sn}
        order by id desc limit 1
    </select>

    <select id="getUnActiveInfoSnList" resultType="java.lang.String">
        select
        sn
        from t_vehicle_device
        where del_flag = 0
        and bind_status = 1
        and left(created_date,10) <![CDATA[ >= ]]> #{dayTimeFormat}
        and active_location_date is null
    </select>

    <select id="getAllUnActiveInfoSnList" resultType="java.lang.String">
        select sn
        from t_vehicle_device
        where del_flag = 0
        and bind_status = 1
        and active_location_date is null
    </select>

    <update id="updateVehicleDeviceBysn">
         update t_vehicle_device
         set
         active_location_date = #{activeLocationDate},
         active_location_type = #{activeLocationType},
         active_location_lat = #{activeLocationLat},
         active_location_lng = #{activeLocationLng},
         active_location_address = #{activeLocationAddress}
         where sn = #{sn}
         and del_flag = 0
         and bind_status = 1
    </update>
</mapper>