FakeOfflineVinMapper.xml 3.67 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.admin.modules.mapper.FakeOfflineVinMapper">
    <resultMap id="BaseMap" type="cn.com.glsx.admin.modules.entity.FakeOfflineVin">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="vin" property="vin" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="TINYINT"/>
        <result column="del_flag" property="delFlag" jdbcType="TINYINT"/>
        <result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
        <result column="created_by" property="createdBy" jdbcType="INTEGER"/>
        <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
        <result column="updated_by" property="updatedBy" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="BaseColumns">
	  a.id, a.vin, a.status, a.del_flag, a.created_date, a.created_by, a.updated_date,
	  a.updated_by
	</sql>

    <select id="getFakeOfflineVinByFence" resultType="String">
        SELECT DISTINCT tfov.vin FROM t_fake_offline_vin tfov WHERE tfov.del_flag = 0 AND tfov.`status` = 1;
    </select>

    <select id="getVehicleNumMap" resultType="java.util.HashMap">
        select tv.vin   as vin,
               count(1) as num
        from t_vehicle tv
                 left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
        where tv.del_flag = 0
          and tvd.bind_status = 1
          and tvd.del_flag = 0
        group by tv.vin;
    </select>

    <select id="getOfflineVehicleNumMap" resultType="java.util.HashMap">
        select tv.vin        as vin,
               count(tdl.sn) as num
        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_device_location tdl on tdl.sn = td.sn
        where tv.del_flag = 0
          and tvd.bind_status = 1
          and tvd.del_flag = 0
          and ((timestampdiff(SECOND, tdl.last_gps_time, now()) > 259200 and
                timestampdiff(SECOND, tdl.last_bs_time, now()) > 259200 and td.source = 1)
            or (timestampdiff(SECOND, tdl.last_bs_time, now()) > 259200 and td.source = 0))
        group by tv.vin;
    </select>

    <select id="searchFakeOfficeList">
        select tw.partner_order_no bizOrderNo,
        tv.owner_name ,
        group_concat(tvd.sn) sns,
        tv.vin as vin
        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_device_location tdl on tdl.sn = td.sn
        left join t_workorder tw on tw.id = tv.workorder_id
        where tv.del_flag = 0
        and tvd.bind_status = 1
        and tvd.del_flag = 0
        and ((timestampdiff(SECOND, tdl.last_gps_time, now()) > 259200 and
        timestampdiff(SECOND, tdl.last_bs_time, now()) > 259200 and td.source = 1)
        or (timestampdiff(SECOND, tdl.last_bs_time, now()) > 259200 and td.source = 0))
        and tv.vin in
        <foreach collection="vinList" separator="," open="(" close=")" item="item">
        #{item}
        </foreach>
        <if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
            and find_in_set(tv.created_by,#{checkedUserIdsStr})
        </if>
        <if test="keywords != null and keywords !=''">
            and(
            tw.partner_order_no like '%${keywords}%'
            or tv.vin like '%${keywords}%'
            or tv.owner_name like '%${keywords}%'
            or tvd.sn like '%${keywords}%'
            )
        </if>
        group by tv.vin;
    </select>
</mapper>