From 33d898d8146223184fcaab82a9e16649434a1ab6 Mon Sep 17 00:00:00 2001 From: lizijie <lzjiiie@163.com> Date: Fri, 09 Sep 2022 17:47:54 +0800 Subject: [PATCH] 千灯数据转发bug修改 --- src/main/resources/mapper/WeatherMapper.xml | 87 ++++++++++++++++++++++++------------------- 1 files changed, 49 insertions(+), 38 deletions(-) diff --git a/src/main/resources/mapper/WeatherMapper.xml b/src/main/resources/mapper/WeatherMapper.xml index 11c492c..aec50d0 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 @@ -114,79 +115,89 @@ ) </select> - <select id="getSampleFromHistoryWeather" resultType="java.lang.String"> - select DATE_FORMAT(time, #{typeFormat}) as time + <select id="getSampleFromHistoryWeather" resultType="java.util.Map"> + select DATE_FORMAT(time, #{typeFormat}) as `time`, + cast(value->'$.temp' as SIGNED) as 'temp', + cast(value->'$.pressure' as SIGNED) as 'pressure', + value->'$.windDir' as 'windDir', + cast(value->'$.windScale' as SIGNED) as 'windScale' from history_weather_${timeUnits} <where> city_code=#{cityCode} + <if test="condition == 0"> - and cast(value->'$.condition' as UNSIGNED integer) > #{score} + and cast(value->'$.condition' as SIGNED) > #{score} </if> <if test="condition == 1"> - and cast(value->'$.condition' as UNSIGNED integer) <![CDATA[<=]]> #{score} + and cast(value->'$.condition' as SIGNED) <![CDATA[<=]]> #{score} + </if> + + <if test="start != null"> + and time >= #{start} + </if> + + <if test="end != null"> + and time <![CDATA[<]]> #{end} </if> <if test="startTemp != null"> - and cast(value->'$.temp' as decimal(10, 1)) >= #{startTemp} + and cast(value->'$.temp' as SIGNED) >= #{startTemp} </if> <if test="endTemp != null"> - and cast(value->'$.temp' as decimal(10, 1)) <![CDATA[<=]]> #{endTemp} + and cast(value->'$.temp' as SIGNED) <![CDATA[<=]]> #{endTemp} </if> - <if test="startPressure != null"> - and cast(value->'$.pressure' as UNSIGNED integer) >= #{startPressure} + <if test="hours != null"> + and DATE_FORMAT(time, '%H') in + <foreach collection="hours" open="(" separator="," close=")" item="hour"> + #{hour} + </foreach> </if> - - <if test="endPressure != null"> - 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> </where> </select> - <select id="getSampleFromRealWeather" resultType="java.lang.String"> - select DATE_FORMAT(time, #{typeFormat}) as time + <select id="getSampleFromRealWeather" resultType="java.util.Map"> + select DATE_FORMAT(time, #{typeFormat}) as `time`, + cast(json->'$.temp' as SIGNED) as 'temp', + cast(json->'$.pressure' as SIGNED) as 'pressure', + json->'$.windDir' as 'windDir', + cast(json->'$.windScale' as SIGNED) as 'windScale' from real_weather <where> city_code=#{cityCode} + <if test="condition == 0"> - and cast(json->'$.condition' as UNSIGNED integer) > #{score} + and cast(json->'$.condition' as SIGNED) > #{score} </if> <if test="condition == 1"> - and cast(json->'$.condition' as UNSIGNED integer) <![CDATA[<=]]> #{score} + and cast(json->'$.condition' as SIGNED) <![CDATA[<=]]> #{score} + </if> + + <if test="start != null"> + and time >= #{start} + </if> + + <if test="end != null"> + and time <![CDATA[<]]> #{end} </if> <if test="startTemp != null"> - and cast(json->'$.temp' as decimal(10, 1)) >= #{startTemp} + and cast(json->'$.temp' as SIGNED) >= #{startTemp} </if> <if test="endTemp != null"> - and cast(json->'$.temp' as decimal(10, 1)) <![CDATA[<=]]> #{endTemp} + and cast(json->'$.temp' as SIGNED) <![CDATA[<=]]> #{endTemp} </if> - <if test="startPressure != null"> - and cast(json->'$.pressure' as UNSIGNED integer) >= #{startPressure} + <if test="hours != null"> + and DATE_FORMAT(time, '%H') in + <foreach collection="hours" open="(" separator="," close=")" item="hour"> + #{hour} + </foreach> </if> - - <if test="endPressure != null"> - 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> </where> </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0