|
|
@@ -2,6 +2,7 @@ package com.ufo.project.data.service.impl;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.time.Instant;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.YearMonth;
|
|
|
@@ -290,7 +291,7 @@ public class UltraShortTermPowerForecastReportServiceImpl extends AbstractPowerF
|
|
|
private BigDecimal getAccForecastReportPower(List<DataSuperShortTermForecastReport> rawForecastList, long timestamp)
|
|
|
{
|
|
|
List<BigDecimal> matchPowers = rawForecastList.stream()
|
|
|
- .filter(r -> null != r.getPower() && r.getForecastTime() != null && r.getStartTime() != null && r.getForecastTime() == timestamp && is4HourBeforeTo15MinuteBefore(timestamp, r.getStartTime()))
|
|
|
+ .filter(r -> null != r.getPower() && r.getForecastTime() != null && r.getStartTime() != null && r.getForecastTime() == timestamp && is4HoursBefore(timestamp, r.getStartTime()))
|
|
|
.map(r -> new BigDecimal(r.getPower()))
|
|
|
.filter(power -> power != null)
|
|
|
.collect(Collectors.toList());
|
|
|
@@ -308,12 +309,12 @@ public class UltraShortTermPowerForecastReportServiceImpl extends AbstractPowerF
|
|
|
* @param datTimestamp
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean is4HourBeforeTo15MinuteBefore(long timestamp, long datTimestamp)
|
|
|
+ private boolean is4HoursBefore(long timestamp, long datTimestamp)
|
|
|
{
|
|
|
- long fourHoursAgo = timestamp - 4 * 3600; // 4小时前
|
|
|
- long fifteenHoursAgo = timestamp - 15 * 3600; // 15小时前
|
|
|
- // 注意:4小时前 > 15小时前,所以 startTime 应该在这两者之间
|
|
|
- return datTimestamp >= fifteenHoursAgo && datTimestamp <= fourHoursAgo;
|
|
|
+ // 4小时的秒数
|
|
|
+ long fourHoursInSeconds = 4 * 60 * 60;
|
|
|
+ // 判断两者差值的绝对值是否刚好等于4小时
|
|
|
+ return Math.abs(timestamp - datTimestamp) == fourHoursInSeconds;
|
|
|
}
|
|
|
|
|
|
// ==================== 辅助方法 ====================
|