From 995a527d6e7d2d0cb141f6853b2b7a2a67b8a1c2 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Fri, 20 Nov 2020 18:00:22 +0800
Subject: [PATCH] Merge branch 'master' of http://blit.7drlb.com:8888/r/screen_job

---
 src/main/resources/mapper/WeatherMapper.xml |   56 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/src/main/resources/mapper/WeatherMapper.xml b/src/main/resources/mapper/WeatherMapper.xml
index 11c492c..06ce0a4 100644
--- a/src/main/resources/mapper/WeatherMapper.xml
+++ b/src/main/resources/mapper/WeatherMapper.xml
@@ -1,6 +1,8 @@
 <?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.WeatherMapper">
+    <cache/>
+
     <select id="getCityWeatherConfig" resultType="java.util.Map">
         select city_code AS cityCode,
         city_id AS cityId
@@ -114,7 +116,7 @@
         )
     </select>
 
-    <select id="getSampleFromHistoryWeather" resultType="java.lang.String">
+    <select id="getSampleFromHistoryWeather" resultType="java.lang.String" useCache="true">
         select DATE_FORMAT(time, #{typeFormat}) as time
         from history_weather_${timeUnits}
         <where>
@@ -143,20 +145,34 @@
                 and cast(value->'$.pressure' as UNSIGNED integer) <![CDATA[<=]]> #{endPressure}
             </if>
 
-            and time >= #{start}
-            and time <![CDATA[<]]> #{end}
-            and DATE_FORMAT(time, '%H') in
-            <foreach collection="hours" open="(" separator="," close=")" item="hour">
-                #{hour}
-            </foreach>
+            <if test="start != null">
+                and time >= #{start}
+            </if>
+
+            <if test="end != null">
+                and time <![CDATA[<]]> #{end}
+            </if>
+
+            <if test="hours != null">
+                and DATE_FORMAT(time, '%H') in
+                <foreach collection="hours" open="(" separator="," close=")" item="hour">
+                    #{hour}
+                </foreach>
+            </if>
+
         </where>
     </select>
 
-    <select id="getSampleFromRealWeather" resultType="java.lang.String">
+    <select id="getSampleFromRealWeather" resultType="java.lang.String" useCache="true">
         select DATE_FORMAT(time, #{typeFormat}) as time
         from real_weather
         <where>
             city_code=#{cityCode}
+
+            <if test="windDir != null">
+                and json->'$.windDir' = #{windDir}
+            </if>
+
             <if test="condition == 0">
                 and cast(json->'$.condition' as UNSIGNED integer) > #{score}
             </if>
@@ -181,12 +197,24 @@
                 and cast(json->'$.pressure' as UNSIGNED integer) <![CDATA[<=]]> #{endPressure}
             </if>
 
-            and time >= #{start}
-            and time <![CDATA[<]]> #{end}
-            and DATE_FORMAT(time, '%H') in
-            <foreach collection="hours" open="(" separator="," close=")" item="hour">
-                #{hour}
-            </foreach>
+            <if test="start != null">
+                and time >= #{start}
+            </if>
+
+            <if test="end != null">
+                and time <![CDATA[<]]> #{end}
+            </if>
+
+            <if test="hours != null">
+                and DATE_FORMAT(time, '%H') in
+                <foreach collection="hours" open="(" separator="," close=")" item="hour">
+                    #{hour}
+                </foreach>
+            </if>
+
+            <if test="month != null">
+                and DATE_FORMAT(time, '%m')=#{month}
+            </if>
         </where>
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0