From aed7e2e6ba8da5b7931a0a97293ba57f57d1a8cd Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Tue, 03 Apr 2018 10:31:38 +0800 Subject: [PATCH] 报表 优化 --- src/main/resources/mapper/HistoryMapper.xml | 23 ++++++++--------------- 1 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/resources/mapper/HistoryMapper.xml b/src/main/resources/mapper/HistoryMapper.xml index 2527cdf..620c6e0 100644 --- a/src/main/resources/mapper/HistoryMapper.xml +++ b/src/main/resources/mapper/HistoryMapper.xml @@ -3,13 +3,12 @@ <mapper namespace="com.moral.mapper.HistoryMapper"> <select id="getAreaAllDataByAccount" resultType="java.util.LinkedHashMap"> SELECT - <if test="macKey == 'all'"> - ${queryColumns} - </if> - <if test="macKey != 'all'"> - d.`name`, - AVG( h.`value` -> ${macKey}) avg - </if> + <if test="macKey != null"> + d.`name`, + </if> + <foreach collection="sensorKeys" separator="," item="sensorKey"> + AVG(h.`value` ->'$.${sensorKey}[0]') AS '${sensorKey}' + </foreach> FROM history h, device d, @@ -26,15 +25,9 @@ #{listItem} </foreach> </if> - <if test="deviceVersionId != null"> - AND d.device_version_id = #{deviceVersionId} - </if> - <if test="macKey != 'all'"> + <if test="macKey != null"> GROUP BY d.id - ORDER BY avg desc + ORDER BY ${macKey} desc </if> </select> - - - </mapper> \ No newline at end of file -- Gitblit v1.8.0