DeviceLocationMapper.xml 2.64 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.app.modules.mapper.DeviceLocationMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.DeviceLocation">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="sn" jdbcType="VARCHAR" property="sn"/>
        <result column="last_gps_time" jdbcType="TIMESTAMP" property="lastGpsTime"/>
        <result column="last_bs_time" jdbcType="TIMESTAMP" property="lastBsTime"/>
        <result column="speed" jdbcType="INTEGER" property="speed"/>
        <result column="stay_status" jdbcType="TINYINT" property="stayStatus"/>
        <result column="stay_status_updatetime" jdbcType="TIMESTAMP" property="stayStatusUpdatetime"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, sn, last_gps_time, last_bs_time, speed, stay_status, stay_status_updatetime,
        created_time, updated_time
    </sql>

    <select id="getOfflineAlarmInfo" resultType="cn.com.glsx.app.modules.model.view.OfflineAlarmVO">
        select
        tv.id as vehicleId,
        tvd.id as vdId,
        tv.owner_name as ownerName,
        tvd.sn as sn,
        tv.vin as vin,
        tvd.created_date as activeDate,
        tdl.last_gps_time as lastGpsTime,
        tdl.last_bs_time as lastBsTime,
        tv.license_plate as licensePlate
        from t_vehicle tv
        left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
        left join t_device td on td.sn = tvd.sn
        left join t_workorder tw on tw.id = tv.workorder_id and tw.del_flag = 0
        left join t_user tu on tu.id = tv.created_by and tu.del_flag = 0
        left join t_device_location tdl on tdl.sn = td.sn
        where tv.del_flag = 0
        and tvd.bind_status = 1
        and tvd.del_flag = 0
        <if test="offlineStartTime != null and offlineStartTime != ''">
            and ((tdl.last_gps_time &lt; #{offlineStartTime} and tdl.last_bs_time &lt; #{offlineStartTime})
            or (tdl.last_gps_time is null and tdl.last_bs_time is null)
            or (tdl.last_gps_time is null and tdl.last_bs_time &lt; #{offlineStartTime})
            or (tdl.last_gps_time &lt; #{offlineStartTime} and tdl.last_bs_time is null)
            )
        </if>
        order by activeDate desc,vdId desc
    </select>
</mapper>