lizijie
2020-12-31 ed3870b7841c630f98fd35faadf72a3992585663
src/main/resources/mapper/WeatherMapper.xml
@@ -115,42 +115,22 @@
        )
    </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="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}
                and cast(value->'$.condition' as SIGNED) > #{score}
            </if>
            <if test="condition == 1">
                and cast(value->'$.condition' as UNSIGNED integer) <![CDATA[<=]]> #{score}
            </if>
            <if test="startTemp != null">
                and cast(value->'$.temp' as decimal(10, 1)) >= #{startTemp}
            </if>
            <if test="endTemp != null">
                and cast(value->'$.temp' as decimal(10, 1)) <![CDATA[<=]]> #{endTemp}
            </if>
            <if test="startPressure != null">
                and cast(value->'$.pressure' as UNSIGNED integer) >= #{startPressure}
            </if>
            <if test="endPressure != null">
                and cast(value->'$.pressure' as UNSIGNED integer) <![CDATA[<=]]> #{endPressure}
                and cast(value->'$.condition' as SIGNED) <![CDATA[<=]]> #{score}
            </if>
            <if test="start != null">
@@ -161,55 +141,39 @@
                and time <![CDATA[<]]> #{end}
            </if>
            <if test="startTemp != null">
                and cast(value->'$.temp' as SIGNED) >= #{startTemp}
            </if>
            <if test="endTemp != null">
                and cast(value->'$.temp' as SIGNED) <![CDATA[<=]]> #{endTemp}
            </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>
    <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="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}
                and cast(json->'$.condition' as SIGNED) > #{score}
            </if>
            <if test="condition == 1">
                and cast(json->'$.condition' as UNSIGNED integer) <![CDATA[<=]]> #{score}
            </if>
            <if test="startTemp != null">
                and cast(json->'$.temp' as decimal(10, 1)) >= #{startTemp}
            </if>
            <if test="endTemp != null">
                and cast(json->'$.temp' as decimal(10, 1)) <![CDATA[<=]]> #{endTemp}
            </if>
            <if test="startPressure != null">
                and cast(json->'$.pressure' as UNSIGNED integer) >= #{startPressure}
            </if>
            <if test="endPressure != null">
                and cast(json->'$.pressure' as UNSIGNED integer) <![CDATA[<=]]> #{endPressure}
                and cast(json->'$.condition' as SIGNED) <![CDATA[<=]]> #{score}
            </if>
            <if test="start != null">
@@ -220,15 +184,19 @@
                and time <![CDATA[<]]> #{end}
            </if>
            <if test="startTemp != null">
                and cast(json->'$.temp' as SIGNED) >= #{startTemp}
            </if>
            <if test="endTemp != null">
                and cast(json->'$.temp' as SIGNED) <![CDATA[<=]]> #{endTemp}
            </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>