From 9009798abd7abfd726bcda80267c7d53dd3b8da3 Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Wed, 12 Jun 2019 14:33:25 +0800
Subject: [PATCH] Merge branch 'master' of http://blit.7drlb.com:8888/r/screen_api_v2

---
 src/main/resources/mapper/DemoMapper.xml |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/src/main/resources/mapper/DemoMapper.xml b/src/main/resources/mapper/DemoMapper.xml
index 8403e41..5d37761 100644
--- a/src/main/resources/mapper/DemoMapper.xml
+++ b/src/main/resources/mapper/DemoMapper.xml
@@ -1,4 +1,36 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.moral.mapper.DemoMapper" >
+<mapper namespace="com.moral.mapper.DemoMapper">
+	<select id="getDatas" resultType="map">
+		SELECT *
+		FROM hangzhou_aqi
+		<where>
+			<if test="timeList != null and timeList.size &gt; 0">
+				time IN
+				<foreach collection="timeList" open="(" separator="," close=")"
+					item="listItem">
+					#{listItem}
+				</foreach>
+			</if>
+		</where>
+		ORDER BY time
+		<if test="size != null">
+			DESC 
+			LIMIT #{size}
+		</if>
+	</select>
+	<select id="selectByTimeZones" resultType="map">
+		select * from hangzhou_aqi where time in (
+			SELECT max(time) from (
+			 select time,cast(aqi_json->"$.AQI" as SIGNED INTEGER) as aqi from hangzhou_aqi
+			) hz where EXISTS ( select *  from (
+						select max(cast(aqi_json->"$.AQI" as SIGNED INTEGER)) as max_aqi,
+						DATE_FORMAT(time,'%Y-%m-%d') as day_time
+						from hangzhou_aqi
+						where time >= #{startTime} and time <![CDATA[<=]]> #{endTime}
+						GROUP BY day_time
+					) as max_result where day_time = DATE_FORMAT(hz.time,'%Y-%m-%d') and  max_aqi = hz.aqi
+			) GROUP BY DATE_FORMAT(time,'%Y-%m-%d') ORDER BY time ASC
+		)
+	</select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0