Browse Source

[0924] 优化气象预报取数计算逻辑,提高计算效率

taosj 1 week ago
parent
commit
d00fed99d9

+ 5 - 2
forecast-backend-server/src/main/resources/mybatis/weather/DataShortTermWeatherForecastRawMapper.xml

@@ -75,6 +75,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <sql id="selectDataShortTermWeatherForecastRawVo">
         select _id, latitude, longitude, data_org_type, data_type, business_process_type, data_source, data_sourcegrab_id, data_sourcegrab_pattern_name, data_model_id, data_model_name, source_id, source_name, entity_id, entity_type, to_timestamp(create_time) AS create_time, start_time, forecast_time, pre_days, lead_time, station_id, station_name, subject_id, subject_name, machine_id, machine_name, analyze_his_id, archive_record_id, tcc, hcc, lcc, mcc, tsfc, psfc, rhsfc, diffirr, directirr, tirr, wd_hub, ws_hub, ws, wd10, wd30, wd50, wd70, wd80, wd90, wd100, wd120, wd140, wd160, wd180, wd200, ws10, ws30, ws50, ws70, ws80, ws90, ws100, ws120, ws140, ws160, ws180, ws200 from data_short_term_weather_forecast_raw
     </sql>
+    <sql id="selectDistinctData">
+        select DISTINCT ON (forecast_time) _id, latitude, longitude, data_org_type, data_type, business_process_type, data_source, data_sourcegrab_id, data_sourcegrab_pattern_name, data_model_id, data_model_name, source_id, source_name, entity_id, entity_type, to_timestamp(create_time) AS create_time, start_time, forecast_time, pre_days, lead_time, station_id, station_name, subject_id, subject_name, machine_id, machine_name, analyze_his_id, archive_record_id, tcc, hcc, lcc, mcc, tsfc, psfc, rhsfc, diffirr, directirr, tirr, wd_hub, ws_hub, ws, wd10, wd30, wd50, wd70, wd80, wd90, wd100, wd120, wd140, wd160, wd180, wd200, ws10, ws30, ws50, ws70, ws80, ws90, ws100, ws120, ws140, ws160, ws180, ws200 from data_short_term_weather_forecast_raw
+    </sql>
 
     <select id="selectDataShortTermWeatherForecastRawList" parameterType="DataShortTermWeatherForecastRaw" resultMap="DataShortTermWeatherForecastRawResult">
         <include refid="selectDataShortTermWeatherForecastRawVo"/>
@@ -146,11 +149,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectDataShortTermWeatherForecastRawListByTimeRange" resultMap="DataShortTermWeatherForecastRawResult">
-        <include refid="selectDataShortTermWeatherForecastRawVo"/>
+        <include refid="selectDistinctData"/>
         where station_id = #{stationId}
           and forecast_time &gt;= #{startTime}
           and forecast_time &lt;= #{endTime}
-        order by forecast_time asc
+        order by forecast_time asc, start_time desc, _id DESC
     </select>
 
     <select id="selectDataShortTermWeatherForecastRawById" parameterType="Long" resultMap="DataShortTermWeatherForecastRawResult">