<?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.ho.business.mapper.EmsMetricMapper">

    <insert id="insert" parameterType="com.ho.business.entity.EmsMetric">
        insert into ems_metrics
            (station_id, cpu_ratio, memory_ratio, disk_ratio, day, create_time, sn)
            values
            (#{stationId},#{cpuRatio},#{memoryRatio},#{diskRatio},#{day},#{createTime},#{sn})
    </insert>

    <update id="updateByStationIdAndDay" parameterType="com.ho.business.entity.EmsMetric">
        update ems_metrics set cpu_ratio=#{cpuRatio}, memory_ratio=#{memoryRatio}, disk_ratio=#{diskRatio}, create_time=#{createTime}, sn=#{sn}
        where station_id=#{stationId} and day=#{day}
    </update>

    <select id="selectByStationIdAndDay" resultType="com.ho.business.entity.EmsMetric">
        select id, station_id, cpu_ratio, memory_ratio, disk_ratio, day, create_time, sn from ems_metrics
        where station_id = #{stationId} and day = #{day}
    </select>

    <select id="listByStationId" resultType="com.ho.business.entity.EmsMetric"
            parameterType="java.lang.Integer">
        select id, station_id, cpu_ratio, memory_ratio, disk_ratio, day, create_time, sn from ems_metrics
        where
        station_id = #{id}
        order by day desc limit 1
    </select>

</mapper>
