<?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="vip.xiaonuo.modular.env.envDeviceOnline.mapper.EnvDeviceOnlineMapper">

    <select id="listSevenDay" resultType="vip.xiaonuo.modular.env.envDeviceOnline.entity.EnvDeviceOnline">
        SELECT
            ROUND(AVG(device_on), 0) AS deviceOn,
            ROUND(AVG(online_rate), 2) AS onlineRate,
            DATE(creat_time) AS creatTime
        FROM
            `env_device_online`
        WHERE
            org_id = #{orgId} AND creat_time BETWEEN CURDATE() - INTERVAL 6 DAY AND CURDATE()
        GROUP BY
            DATE(creat_time);
    </select>
</mapper>