From 9a46347d03f06ca89e0d12f0dcc10ade753d5b40 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期二, 04 一月 2022 14:10:49 +0800
Subject: [PATCH] 大气数据查询
---
dao/src/main/resources/mapper/AirDataMapper.xml | 77 ++++++++++++++++----------------------
1 files changed, 33 insertions(+), 44 deletions(-)
diff --git a/dao/src/main/resources/mapper/AirDataMapper.xml b/dao/src/main/resources/mapper/AirDataMapper.xml
index 9541df0..aae87cf 100644
--- a/dao/src/main/resources/mapper/AirDataMapper.xml
+++ b/dao/src/main/resources/mapper/AirDataMapper.xml
@@ -38,54 +38,43 @@
air_data
</select>
- <select id="listAirData" resultType="com.sandu.ximon.dao.bo.AirDataBo">
+
+ <select id="listAirId" resultType="java.lang.Long">
SELECT
- t1.*, t2.pole_id,
- t3.pole_name
+ MAX(t1.id) AS air_id
FROM
- air_data t1
- JOIN (
- SELECT
- MAX(t1.id) a1
- FROM
- air_data t1
- LEFT JOIN pole_binding t2 ON t1.device_mac = t2.device_code
- AND t2.device_type = 3
- LEFT JOIN pole t3 ON t3.id = t2.pole_id
- GROUP BY
- t1.device_mac
- LIMIT 0,
- 10
- ) t ON t.a1 = t1.id
+ air_data t1
+ <if test="keyword != null and keyword != ''">
+ LEFT JOIN pole_binding t2 ON t1.device_mac = t2.device_code
+ AND t2.device_type = 3
+ LEFT JOIN pole t3 ON t3.id = t2.pole_id
+ </if>
+ <where>
+ <if test="keyword != null and keyword != ''">
+ AND t3.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
+ </if>
+ <if test="clientId != null">
+ AND t3.client_id = #{clientId}
+ </if>
+ </where>
+ GROUP BY
+ t1.device_mac
+ </select>
+
+ <select id="listAirDataByIds" resultType="com.sandu.ximon.dao.bo.AirDataBo">
+ SELECT
+ t1.*, t2.pole_id,
+ t3.pole_name
+ FROM
+ air_data t1
LEFT JOIN pole_binding t2 ON t1.device_mac = t2.device_code
AND t2.device_type = 3
LEFT JOIN pole t3 ON t3.id = t2.pole_id
+ <where>
+ t1.id IN
+ <foreach collection="airIdList" open="(" close=")" item="airId" separator=",">
+ #{airId}
+ </foreach>
+ </where>
</select>
-
- <select id="listAirDataByKeyword" resultType="com.sandu.ximon.dao.bo.AirDataBo">
- SELECT
- t1.*, t2.pole_id,
- t3.pole_name
- FROM
- air_data t1
- JOIN (
- SELECT
- MAX(t1.id) a1
- FROM
- air_data t1
- LEFT JOIN pole_binding t2 ON t1.device_mac = t2.device_code
- AND t2.device_type = 3
- LEFT JOIN pole t3 ON t3.id = t2.pole_id
- WHERE
- t3.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
- GROUP BY
- t1.device_mac
- LIMIT 0,
- 10
- ) t ON t.a1 = t1.id
- LEFT JOIN pole_binding t2 ON t1.device_mac = t2.device_code
- AND t2.device_type = 3
- LEFT JOIN pole t3 ON t3.id = t2.pole_id
- </select>
-
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3