|
|
@@ -10,6 +10,8 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -108,35 +110,17 @@ public class ShortTermPowerForecastingController extends BaseController
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- BigDecimal sum = BigDecimal.ZERO;
|
|
|
- int validCount = 0;
|
|
|
- for (DataShortTermPowerForecastIssued issued : items)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (issued.getPower() != null && !issued.getPower().isEmpty())
|
|
|
- {
|
|
|
- sum = sum.add(new BigDecimal(issued.getPower()));
|
|
|
- validCount++;
|
|
|
- }
|
|
|
- }
|
|
|
- catch (NumberFormatException ignored)
|
|
|
- {
|
|
|
+ BigDecimal power = BigDecimal.ZERO;
|
|
|
+ for (DataShortTermPowerForecastIssued issued : items){
|
|
|
+ if(StringUtils.isEmpty(issued.getPower())) continue;
|
|
|
+ BigDecimal itemPower = new BigDecimal(issued.getPower());
|
|
|
+ if(itemPower.compareTo(power) > 0){
|
|
|
+ power = itemPower;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ShortTermPowerForecastData data = new ShortTermPowerForecastData();
|
|
|
- data.setTime(TimeUtils.utcToGmt8Format(entry.getKey()));
|
|
|
- // 计算平均值,保留3位小数(四舍五入)
|
|
|
- if (validCount > 0)
|
|
|
- {
|
|
|
- BigDecimal avg = sum.divide(BigDecimal.valueOf(validCount), 3, RoundingMode.HALF_UP);
|
|
|
- data.setPower(avg.doubleValue());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- data.setPower(0.0);
|
|
|
- }
|
|
|
+ ShortTermPowerForecastData data = new ShortTermPowerForecastData().setTime(TimeUtils.utcToGmt8Format(entry.getKey()))
|
|
|
+ .setPower(power.doubleValue());
|
|
|
data.setTheoreticalPower(0.0);
|
|
|
data.setCurtailmentPower(0.0);
|
|
|
result.add(data);
|