lizijie
2019-08-30 5fed7b486fea656ae9878166e3530b7e29eae7eb
src/main/resources/mapper/HistoryMapper.xml
@@ -193,5 +193,19 @@
        ORDER BY
        time
    </select>
    <select id="getAVGSensorRankByMonitorPointIdList" resultType="java.util.Map">
       SELECT mp.name, AVG(JSON_EXTRACT(h.value,'$.${sensor}[0]')) sensor
      FROM device d, history h, monitor_point mp
      WHERE d.mac=h.mac
      And mp.id=d.monitor_point_id
      AND d.monitor_point_id IN
         <foreach collection="monitorPointIdList" index="index" item="monitorPointId" open="(" separator="," close=")">
               #{monitorPointId}
           </foreach>
      AND h.time BETWEEN #{before5Time} AND #{endTime}
      GROUP BY d.monitor_point_id
      ORDER BY AVG(JSON_EXTRACT(h.value,'$.${sensor}[0]')) DESC
    </select>
</mapper>