Browse Source

[101903] 源表 mapper 增加 selectLatestByWindow 窗口取数

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
taosj 2 weeks ago
parent
commit
fb21463410

+ 12 - 0
forecast-backend-server/src/main/java/com/ufo/project/forecast/shortterm/power/mapper/DataShortTermPowerForecastCorrectMapper.java

@@ -1,6 +1,7 @@
 package com.ufo.project.forecast.shortterm.power.mapper;
 
 import java.util.List;
+import org.apache.ibatis.annotations.Param;
 import com.ufo.project.forecast.shortterm.power.domain.DataShortTermPowerForecastCorrect;
 
 /**
@@ -58,4 +59,15 @@ public interface DataShortTermPowerForecastCorrectMapper
      * @return 结果
      */
     public int deleteDataShortTermPowerForecastCorrectByIds(Long[] Ids);
+
+    /**
+     * 查询场站指定窗口内每个预测时刻的最新一条修正数据(窗口起点不含、终点含)
+     *
+     * @param entityId 实体ID
+     * @param windowStart 窗口起点(unix秒,不含)
+     * @param windowEnd 窗口终点(unix秒,含)
+     * @return 预测功率修正数据集合(按 forecast_time 升序)
+     */
+    public List<DataShortTermPowerForecastCorrect> selectLatestByWindow(@Param("entityId") String entityId,
+            @Param("windowStart") Long windowStart, @Param("windowEnd") Long windowEnd);
 }

+ 11 - 0
forecast-backend-server/src/main/java/com/ufo/project/forecast/shortterm/power/mapper/DataShortTermPowerForecastIssuedMapper.java

@@ -93,4 +93,15 @@ public interface DataShortTermPowerForecastIssuedMapper
      */
     public List<DataShortTermPowerForecastIssued> selectLatestByTimeRange(@Param("entityId") String entityId,
             @Param("startTime") Long startTime, @Param("endTime") Long endTime);
+
+    /**
+     * 查询场站指定窗口内每个预测时刻的最新一条下发数据(窗口起点不含、终点含)
+     *
+     * @param entityId 实体ID
+     * @param windowStart 窗口起点(unix秒,不含)
+     * @param windowEnd 窗口终点(unix秒,含)
+     * @return 预测功率下发数据集合(按 forecast_time 升序)
+     */
+    public List<DataShortTermPowerForecastIssued> selectLatestByWindow(@Param("entityId") String entityId,
+            @Param("windowStart") Long windowStart, @Param("windowEnd") Long windowEnd);
 }

+ 12 - 0
forecast-backend-server/src/main/java/com/ufo/project/forecast/supershort/mapper/DataSuperShortTermForecastCorrectMapper.java

@@ -1,6 +1,7 @@
 package com.ufo.project.forecast.supershort.mapper;
 
 import java.util.List;
+import org.apache.ibatis.annotations.Param;
 import com.ufo.project.forecast.supershort.domain.DataSuperShortTermForecastCorrect;
 
 /**
@@ -58,4 +59,15 @@ public interface DataSuperShortTermForecastCorrectMapper
      * @return 结果
      */
     public int deleteDataSuperShortTermForecastCorrectByIds(Long[] Ids);
+
+    /**
+     * 查询场站指定窗口内每个预测时刻的最新一条修正数据(窗口起点不含、终点含)
+     *
+     * @param entityId 实体ID
+     * @param windowStart 窗口起点(unix秒,不含)
+     * @param windowEnd 窗口终点(unix秒,含)
+     * @return 预测功率修正数据集合(按 forecast_time 升序)
+     */
+    public List<DataSuperShortTermForecastCorrect> selectLatestByWindow(@Param("entityId") String entityId,
+            @Param("windowStart") Long windowStart, @Param("windowEnd") Long windowEnd);
 }

+ 11 - 0
forecast-backend-server/src/main/java/com/ufo/project/forecast/supershort/mapper/DataSuperShortTermForecastIssuedMapper.java

@@ -70,4 +70,15 @@ public interface DataSuperShortTermForecastIssuedMapper
      */
     public List<DataSuperShortTermForecastIssued> selectLatestByTimeRange(@Param("entityId") String entityId,
             @Param("startTime") Long startTime, @Param("endTime") Long endTime);
+
+    /**
+     * 查询场站指定窗口内每个预测时刻的最新一条下发数据(窗口起点不含、终点含)
+     *
+     * @param entityId 实体ID
+     * @param windowStart 窗口起点(unix秒,不含)
+     * @param windowEnd 窗口终点(unix秒,含)
+     * @return 预测功率下发数据集合(按 forecast_time 升序)
+     */
+    public List<DataSuperShortTermForecastIssued> selectLatestByWindow(@Param("entityId") String entityId,
+            @Param("windowStart") Long windowStart, @Param("windowEnd") Long windowEnd);
 }

+ 11 - 0
forecast-backend-server/src/main/resources/mybatis/power/DataShortTermPowerForecastCorrectMapper.xml

@@ -50,6 +50,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectDataShortTermPowerForecastCorrectVo"/>
         where _id = #{Id}
     </select>
+
+    <!-- 按预测时刻取窗口内最新一条修正数据,起点不含、终点含 -->
+    <select id="selectLatestByWindow" resultMap="DataShortTermPowerForecastCorrectResult">
+        select distinct on (forecast_time)
+        _id, data_sourcegrab_id, data_sourcegrab_pattern_name, entity_id, entity_type, entity_name, to_timestamp(create_time) AS create_time, start_time, forecast_time, predays, power
+        from data_short_term_power_forecast_correct
+        where entity_id = #{entityId}
+          and forecast_time &gt; #{windowStart}
+          and forecast_time &lt;= #{windowEnd}
+        order by forecast_time asc, start_time desc, _id desc
+    </select>
         
     <insert id="insertDataShortTermPowerForecastCorrect" parameterType="DataShortTermPowerForecastCorrect" useGeneratedKeys="true" keyProperty="Id">
         insert into data_short_term_power_forecast_correct

+ 11 - 0
forecast-backend-server/src/main/resources/mybatis/power/DataShortTermPowerForecastIssuedMapper.xml

@@ -122,6 +122,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by forecast_time, start_time desc
     </select>
 
+    <!-- 按预测时刻取窗口内最新一条下发数据,起点不含、终点含 -->
+    <select id="selectLatestByWindow" resultMap="DataShortTermPowerForecastIssuedResult">
+        select distinct on (forecast_time)
+        _id, data_sourcegrab_id, data_sourcegrab_pattern_name, entity_id, entity_type, entity_name, to_timestamp(create_time) AS create_time, start_time, forecast_time, predays, power
+        from data_short_term_power_forecast_issued
+        where entity_id = #{entityId}
+          and forecast_time &gt; #{windowStart}
+          and forecast_time &lt;= #{windowEnd}
+        order by forecast_time asc, start_time desc, _id desc
+    </select>
+
     <!-- 按预测时间分组查询平均功率 -->
     <resultMap type="ForecastPowerAverage" id="ForecastPowerAverageResult">
         <result property="forecastTime" column="forecast_time" />

+ 11 - 0
forecast-backend-server/src/main/resources/mybatis/supershort/DataSuperShortTermForecastCorrectMapper.xml

@@ -45,6 +45,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectDataSuperShortTermForecastCorrectVo"/>
         where _id = #{Id}
     </select>
+
+    <!-- 按预测时刻取窗口内最新一条修正数据,起点不含、终点含 -->
+    <select id="selectLatestByWindow" resultMap="DataSuperShortTermForecastCorrectResult">
+        select distinct on (forecast_time)
+        _id, data_sourcegrab_id, data_sourcegrab_pattern_name, entity_id, entity_type, entity_name, to_timestamp(create_time) AS create_time, start_time, forecast_time, pre_qrts, power
+        from data_super_short_term_forecast_correct
+        where entity_id = #{entityId}
+          and forecast_time &gt; #{windowStart}
+          and forecast_time &lt;= #{windowEnd}
+        order by forecast_time asc, start_time desc, _id desc
+    </select>
         
     <insert id="insertDataSuperShortTermForecastCorrect" parameterType="DataSuperShortTermForecastCorrect" useGeneratedKeys="true" keyProperty="Id">
         insert into data_super_short_term_forecast_correct

+ 11 - 0
forecast-backend-server/src/main/resources/mybatis/supershort/DataSuperShortTermForecastIssuedMapper.xml

@@ -104,6 +104,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by forecast_time, start_time desc
     </select>
 
+    <!-- 按预测时刻取窗口内最新一条下发数据,起点不含、终点含 -->
+    <select id="selectLatestByWindow" resultMap="DataSuperShortTermForecastIssuedResult">
+        select distinct on (forecast_time)
+        _id, data_sourcegrab_id, data_sourcegrab_pattern_name, entity_id, entity_type, entity_name, to_timestamp(create_time) AS create_time, start_time, forecast_time, pre_qrts, power
+        from data_super_short_term_forecast_issued
+        where entity_id = #{entityId}
+          and forecast_time &gt; #{windowStart}
+          and forecast_time &lt;= #{windowEnd}
+        order by forecast_time asc, start_time desc, _id desc
+    </select>
+
     <delete id="deleteDataSuperShortTermForecastIssuedByIds" parameterType="String">
         delete from data_super_short_term_forecast_issued where _id in 
         <foreach item="Id" collection="array" open="(" separator="," close=")">