From dc9091d686b412eab84d461d13d0611f79e65810 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Tue, 01 Dec 2020 16:18:09 +0800
Subject: [PATCH] PM2.5,PM10预测

---
 src/main/resources/mapper/WeatherMapper.xml |   67 +++++++++++++++++++++++++--------
 1 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/src/main/resources/mapper/WeatherMapper.xml b/src/main/resources/mapper/WeatherMapper.xml
index 11c492c..9dda41b 100644
--- a/src/main/resources/mapper/WeatherMapper.xml
+++ b/src/main/resources/mapper/WeatherMapper.xml
@@ -1,6 +1,7 @@
 <?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">
+
     <select id="getCityWeatherConfig" resultType="java.util.Map">
         select city_code AS cityCode,
         city_id AS cityId
@@ -119,6 +120,15 @@
         from history_weather_${timeUnits}
         <where>
             city_code=#{cityCode}
+
+            <if test="windDir != null">
+                and value->'$.windDir' = #{windDir}
+            </if>
+
+            <if test="windScale != null">
+                and value->'$.windScale' = #{windScale}
+            </if>
+
             <if test="condition == 0">
                 and cast(value->'$.condition' as UNSIGNED integer) > #{score}
             </if>
@@ -128,11 +138,11 @@
             </if>
 
             <if test="startTemp != null">
-                and cast(value->'$.temp' as decimal(10, 1)) >= #{startTemp}
+                and cast(value->'$.temp' as decimal(10, 0)) >= #{startTemp}
             </if>
 
             <if test="endTemp != null">
-                and cast(value->'$.temp' as decimal(10, 1)) <![CDATA[<=]]> #{endTemp}
+                and cast(value->'$.temp' as decimal(10, 0)) <![CDATA[<=]]> #{endTemp}
             </if>
 
             <if test="startPressure != null">
@@ -143,12 +153,20 @@
                 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>
 
@@ -157,6 +175,15 @@
         from real_weather
         <where>
             city_code=#{cityCode}
+
+            <if test="windDir != null">
+                and json->'$.windDir' = #{windDir}
+            </if>
+
+            <if test="windScale != null">
+                and json->'$.windScale' = #{windScale}
+            </if>
+
             <if test="condition == 0">
                 and cast(json->'$.condition' as UNSIGNED integer) > #{score}
             </if>
@@ -166,11 +193,11 @@
             </if>
 
             <if test="startTemp != null">
-                and cast(json->'$.temp' as decimal(10, 1)) >= #{startTemp}
+                and cast(json->'$.temp' as decimal(10, 0)) >= #{startTemp}
             </if>
 
             <if test="endTemp != null">
-                and cast(json->'$.temp' as decimal(10, 1)) <![CDATA[<=]]> #{endTemp}
+                and cast(json->'$.temp' as decimal(10, 0)) <![CDATA[<=]]> #{endTemp}
             </if>
 
             <if test="startPressure != null">
@@ -181,12 +208,20 @@
                 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>
         </where>
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0