<?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.huatek.busi.mapper.RptGisMonitorMapper">
  <resultMap id="BaseResultMap" type="com.huatek.busi.entity.RptGisMonitor">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="site_id" jdbcType="VARCHAR" property="siteId" />
    <result column="main_tree_id" jdbcType="VARCHAR" property="mainTreeId" />
    <result column="turnoff_count" jdbcType="BIGINT" property="turnoffCount" />
    <result column="last_turnoff_time" jdbcType="TIMESTAMP" property="lastTurnoffTime" />
    <result column="diff_time" jdbcType="VARCHAR" property="diffTime" />
    <result column="a_sersor_code" jdbcType="VARCHAR" property="aSersorCode" />
    <result column="a_speed" jdbcType="DECIMAL" property="aSpeed" />
    <result column="a_electric" jdbcType="DECIMAL" property="aElectric" />
    <result column="a_sersor_code" jdbcType="VARCHAR" property="aSersorCode" />
    <result column="b_speed" jdbcType="DECIMAL" property="bSpeed" />
    <result column="b_electric" jdbcType="DECIMAL" property="bElectric" />
    <result column="a_sersor_code" jdbcType="VARCHAR" property="aSersorCode" />
    <result column="c_speed" jdbcType="DECIMAL" property="cSpeed" />
    <result column="c_electric" jdbcType="DECIMAL" property="cElectric" />
    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, site_id, main_tree_id, turnoff_count, last_turnoff_time, diff_time, a_sersor_code, 
    a_speed, a_electric, a_sersor_code, b_speed, b_electric, a_sersor_code, c_speed, c_electric, 
    modify_time
  </sql>
  <select id="findRptGisMonitor" parameterType="java.lang.String" resultMap="BaseResultMap">
	    select 
	    <include refid="Base_Column_List" />
	    from rpt_gis_monitor t 
	    where t.site_id = #{siteId} 
	    and t.main_tree_id = #{mainTreeId}
	    ORDER BY t.last_turnoff_time DESC 
	    limit 1  
  </select>
  
  <update id="updaeGisMonitorByDay"> 
	  update rpt_gis_monitor set
	    turnoff_count = #{turnoffCount}
	  where site_id = #{siteId}
	  and main_tree_id = #{mainTreeId}
  </update>
</mapper>