DeviceLocationMapper.xml 1.87 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.DeviceLocationMapper">
    <resultMap id="BaseMap" type="cn.com.glsx.stdinterface.modules.model.DeviceLocation">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="sn" property="sn" jdbcType="VARCHAR"/>
        <result column="last_gps_time" property="lastGpsTime" jdbcType="TIMESTAMP"/>
        <result column="last_bs_track" property="lastBsTrack" jdbcType="TIMESTAMP"/>
        <result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
        <result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="BaseColumns">
	  a.id, a.sn, a.last_gps_time, a.last_bs_track, a.created_time, a.updated_time
	</sql>

    <select id="getAllSnInNewEshield" resultType="java.lang.String">
        select distinct sn from t_device where del_flag = 0;
    </select>

    <select id="getDeviceLocationBySn" resultMap="BaseMap">
       select * from t_device_location where sn = #{sn}
   </select>

    <insert id="saveOrUpdateDeviceLocationData">
        INSERT INTO t_device_location (sn,last_gps_time,last_bs_time,created_time,updated_time)
        values
        <foreach collection="deviceLocationDtoList" item="deviceLocation" separator=",">
            (#{deviceLocation.sn},
            #{deviceLocation.lastGpsTime},
            #{deviceLocation.lastBsTime},
            #{deviceLocation.createdTime},
            #{deviceLocation.updatedTime})
        </foreach>
        ON DUPLICATE KEY UPDATE
        sn=values(sn),
        last_gps_time=values(last_gps_time),
        last_bs_time=values(last_bs_time),
        created_time=values(created_time),
        updated_time=values(updated_time)
    </insert>
</mapper>