From eb48246d98cdf77e7ef65b64a2349d2974c6538a Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Fri, 03 Nov 2017 15:02:35 +0800 Subject: [PATCH] 更新 代码 --- src/main/resources/mapper/HistoryEntityMapper.xml | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/resources/mapper/HistoryEntityMapper.xml b/src/main/resources/mapper/HistoryEntityMapper.xml index 956888a..c0d79d5 100644 --- a/src/main/resources/mapper/HistoryEntityMapper.xml +++ b/src/main/resources/mapper/HistoryEntityMapper.xml @@ -239,27 +239,37 @@ <select id="getAverageByAll" resultType="map"> SELECT + <if test="macKey == 'all'"> h.mac_key, + </if> + <if test="macKey != null and macKey != 'all'"> + e.name, + </if> AVG(h.mac_value) avg FROM history h, monitorpoint m, equipment e - <if test="orgIds != null and orgIds.size > 0"> - JOIN org_equ oe ON e.id = oe.equid - AND oe.orgid IN - <foreach collection="orgIds" item="listItem" open="(" separator="," close=")" > - #{listItem} - </foreach> - </if> WHERE m.areacode = #{areaCode} AND m.id = e.monitorpoint AND e.mac = h.mac AND h.time > #{start} AND h.time < #{end} + <if test="orgIds != null and orgIds.size > 0"> + <!-- JOIN org_equ oe ON e.id = oe.equid --> + AND e.owner_id IN + <foreach collection="orgIds" item="listItem" open="(" separator="," close=")" > + #{listItem} + </foreach> + </if> + <if test="macKey == 'all'"> GROUP BY h.mac_key + </if> + <if test="macKey != null and macKey != 'all'"> + AND h.mac_key = #{macKey} + </if> </select> <select id="getEquipmentStates" resultType="map"> @@ -269,8 +279,8 @@ FROM equipment <if test="orgIds != null and orgIds.size > 0"> - JOIN org_equ oe ON e.id = oe.equid - AND oe.orgid IN + <!-- JOIN org_equ oe ON e.id = oe.equid --> + where owner_id IN <foreach collection="orgIds" item="listItem" open="(" separator="," close=")" > #{listItem} </foreach> -- Gitblit v1.8.0