From 57df7588b14e3ecc1c5b42f2c7bbd13d82e0932b Mon Sep 17 00:00:00 2001 From: 沈斌 <bluelazysb@hotmail.com> Date: Tue, 07 Nov 2017 22:04:13 +0800 Subject: [PATCH] test --- src/main/resources/mapper/HistoryEntityMapper.xml | 38 ++++++++++++++++++++++++-------------- 1 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/resources/mapper/HistoryEntityMapper.xml b/src/main/resources/mapper/HistoryEntityMapper.xml index 956888a..cddc593 100644 --- a/src/main/resources/mapper/HistoryEntityMapper.xml +++ b/src/main/resources/mapper/HistoryEntityMapper.xml @@ -239,27 +239,38 @@ <select id="getAverageByAll" resultType="map"> SELECT - h.mac_key, + <if test="macKey != null and macKey != 'all'"> + e.name, + </if> + <if test="macKey == 'all'"> + h.mac_key, + </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} - GROUP BY - h.mac_key + <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 != null and macKey != 'all'"> + AND h.mac_key = #{macKey} + GROUP BY e.id + ORDER BY avg + </if> + <if test="macKey == 'all'"> + GROUP BY h.mac_key + </if> </select> <select id="getEquipmentStates" resultType="map"> @@ -269,14 +280,13 @@ 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> </if> - GROUP BY - state + GROUP BY state </select> <select id="getMacLogByLast" resultType="string"> -- Gitblit v1.8.0