<?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.ningdatech.carapi.company.mapper.CompanyVehicleNotGetOnMapper">
<insert id="saveBatchNotGetOnList">
        insert into nd_company_vehicle_not_get_on
        (id,create_on,create_by,update_on,update_by,car_plate,company_id,time)
        values
        <foreach collection="singleList" separator="," item="notGetOn">
            (null,now(),null,now(),null,#{notGetOn.carPlate},#{notGetOn.companyId},#{notGetOn.time})
        </foreach>
</insert>

<select id="getNotOnCarList" resultType="com.ningdatech.carapi.company.entity.po.CompanyVehicleNotGetOnPO">
        SELECT
            ndag.car_plate,
            nvbi.company_id,
            ndag.status
        FROM
            nd_vehicle_base_info AS nvbi
                right join nd_data_access_gps_${param.tableNameStr} AS ndag ON nvbi.car_plate = ndag.car_plate
        WHERE
            nvbi.company_id is not null and
            not exists
                (select nvgo.car_plate from nd_vehicle_get_on as nvgo where nvbi.car_plate = nvgo.car_plate and date_format(create_on,'%Y-%m-%d') = #{param.queryTime})
        GROUP BY
            ndag.car_plate,
            nvbi.company_id,
            ndag.status
</select>
<select id="checkDataExistByDay" resultType="java.lang.String">
        SELECT
            table_name
        FROM
            information_schema.TABLES
        WHERE
            table_name =  Concat('nd_data_access_gps_',DATE_FORMAT(#{queryTime},'%Y_%m_%d'))
</select>
</mapper>
