<?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.uml.tech.mapper.OfflineStatisticsMapper" >

    <insert id="insertFromList" parameterType="com.uml.tech.bean.OfflineStatistics" >
        replace into ${tb_name} (id, did, vin,
            lpn, offline_days, last_date, 
            first_stat_date, end_stat_date, owner_mobile, 
            offline_days_threshold)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.id},#{item.did},#{item.vin},#{item.lpn},#{item.offlineDays},
            #{item.lastDate},#{item.firstStatDate},#{item.endStatDate},#{item.ownerMobile},#{item.offlineDaysThreshold})
        </foreach>
    </insert>


    <select id="selectAll" resultType="com.uml.tech.bean.OfflineStatistics">
        SELECT t.lpn, t.vin, t.did, t.owner_mobile AS ownerMobile, t.stat_date_num AS offlineDaysThreshold, st.lastGpsTime
  		  FROM business_info t
  		  JOIN statistics st
  		    ON t.did = st.did
    </select>

</mapper>