<?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.SoundVibrationParamsMapper">


    <select id="findLatestResult" resultType="com.huatek.busi.vo.SoundVibrationParamsVo">
        select
         id,main_tree_id as mainTreeId,
        high_point as highPoint,
        low_point as lowPoint,
        center_point as centerPoint,
        noise_point as noisePoint,
        create_time as createTime
        from sound_vibration_params t
        where main_tree_id = #{mainTreeId}
        order by create_time desc
        LIMIT 1
    </select>



    <select id="getEvaluatData" resultType="com.huatek.busi.vo.SoundVibrationParamsVo">
        SELECT
        t.main_tree_id as mainTreeId,
        CONVERT(AVG(CAST(t.high_point AS DECIMAL (10, 4))), DECIMAL(10,2)) AS highPoint,
        CONVERT(AVG(CAST(t.low_point AS DECIMAL (10, 4))), DECIMAL(10,2)) AS lowPoint,
        CONVERT(AVG(CAST(t.center_point AS DECIMAL (10, 4))), DECIMAL(10,2)) AS centerPoint,
        CONVERT(AVG(CAST(t.noise_point AS DECIMAL (10, 4))), DECIMAL(10,2)) AS noisePoint
        FROM
        `sound_vibration_params` t
        WHERE
        t.main_tree_id = #{mainTreeId}
        AND t.create_time &gt; #{startDate}
        AND t.create_time &lt; #{endDate}
    </select>

</mapper>
