|
@@ -3,6 +3,7 @@ package com.gyee.runeconomy.service.WindDirection;
|
|
|
|
|
|
import com.gyee.runeconomy.init.CacheContext;
|
|
import com.gyee.runeconomy.init.CacheContext;
|
|
import com.gyee.runeconomy.model.auto.*;
|
|
import com.gyee.runeconomy.model.auto.*;
|
|
|
|
+import com.gyee.runeconomy.service.auto.IStationInfoDayService;
|
|
import com.gyee.runeconomy.service.auto.ITurbineInfoDayService;
|
|
import com.gyee.runeconomy.service.auto.ITurbineInfoDayService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -20,6 +21,8 @@ public class WindMachineService {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private ITurbineInfoDayService turbineInfoDayService;
|
|
private ITurbineInfoDayService turbineInfoDayService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IStationInfoDayService stationInfoDayService;
|
|
|
|
|
|
|
|
|
|
public Object machine(String wpid) throws Exception {
|
|
public Object machine(String wpid) throws Exception {
|
|
@@ -32,6 +35,7 @@ public class WindMachineService {
|
|
|
|
|
|
Map<String, List> monthlyData = new LinkedHashMap<>();
|
|
Map<String, List> monthlyData = new LinkedHashMap<>();
|
|
|
|
|
|
|
|
+
|
|
// 风机循环:每台风机每个月一个 WindData 对象
|
|
// 风机循环:每台风机每个月一个 WindData 对象
|
|
for (ProBasicEquipment eq : collect) {
|
|
for (ProBasicEquipment eq : collect) {
|
|
|
|
|
|
@@ -49,6 +53,7 @@ public class WindMachineService {
|
|
String endOfYearStr = endOfYear.format(formatter);
|
|
String endOfYearStr = endOfYear.format(formatter);
|
|
|
|
|
|
List<TurbineInfoDay> turbineList = turbineInfoDayService.getTurbineList(eq.getId(), startOfYearStr, endOfYearStr);
|
|
List<TurbineInfoDay> turbineList = turbineInfoDayService.getTurbineList(eq.getId(), startOfYearStr, endOfYearStr);
|
|
|
|
+ List<StationInfoDay> infoDays = stationInfoDayService.getTurbineList(wpid, startOfYearStr, endOfYearStr);
|
|
List<String> zb = new ArrayList<>();
|
|
List<String> zb = new ArrayList<>();
|
|
zb.add("fsavg");
|
|
zb.add("fsavg");
|
|
zb.add("cftfsavg");
|
|
zb.add("cftfsavg");
|
|
@@ -81,30 +86,44 @@ public class WindMachineService {
|
|
})
|
|
})
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- //风速
|
|
|
|
|
|
+ List<StationInfoDay> dayfilteredList = infoDays.stream()
|
|
|
|
+ .filter(turbine -> {
|
|
|
|
+ // 获取 turbineInfoDay 的 recordDate(类型为 LocalDate)
|
|
|
|
+ LocalDate dateFromTurbine = turbine.getRecordDate();
|
|
|
|
+
|
|
|
|
+ // 获取记录的月份(注意,月份从 1 开始,1 表示1月)
|
|
|
|
+ int recordMonth = dateFromTurbine.getMonthValue();
|
|
|
|
+
|
|
|
|
+ // 判断记录的月份是否等于给定的 time
|
|
|
|
+ return recordMonth == finalMonth; // 比较 int 类型的月份和 time 变量
|
|
|
|
+ })
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 风速
|
|
double fsaverage = filteredList.stream()
|
|
double fsaverage = filteredList.stream()
|
|
- .mapToDouble(turbineInfoDay -> turbineInfoDay.getPjfs().doubleValue())
|
|
|
|
|
|
+ .mapToDouble(turbineInfoDay -> Optional.ofNullable(turbineInfoDay.getPjfs()).map(Number::doubleValue).orElse(0.0))
|
|
.average()
|
|
.average()
|
|
.orElse(0.0); // 默认值0.0
|
|
.orElse(0.0); // 默认值0.0
|
|
|
|
|
|
- //风向
|
|
|
|
|
|
+ // 风向
|
|
double fxaverage = filteredList.stream()
|
|
double fxaverage = filteredList.stream()
|
|
- .mapToDouble(turbineInfoDay -> turbineInfoDay.getPjfs().doubleValue())
|
|
|
|
|
|
+ .mapToDouble(turbineInfoDay -> Optional.ofNullable(turbineInfoDay.getFx()).map(Number::doubleValue).orElse(0.0))
|
|
.average()
|
|
.average()
|
|
.orElse(0.0); // 默认值0.0
|
|
.orElse(0.0); // 默认值0.0
|
|
|
|
|
|
- //测风塔风速
|
|
|
|
- double cftfsaverage = filteredList.stream()
|
|
|
|
- .mapToDouble(turbineInfoDay -> turbineInfoDay.getPjfs().doubleValue())
|
|
|
|
|
|
+ // 测风塔风速
|
|
|
|
+ double cftfsaverage = dayfilteredList.stream()
|
|
|
|
+ .mapToDouble(turbineInfoDay -> Optional.ofNullable(turbineInfoDay.getCftfs()).map(Number::doubleValue).orElse(0.0))
|
|
.average()
|
|
.average()
|
|
- .orElse(0.0); // 默认值0.0
|
|
|
|
|
|
+ .orElse(0.0); // 默认值0.0
|
|
|
|
|
|
- //测风塔风向
|
|
|
|
- double cftfxaverage = filteredList.stream()
|
|
|
|
- .mapToDouble(turbineInfoDay -> turbineInfoDay.getPjfs().doubleValue())
|
|
|
|
|
|
+ // 测风塔风向
|
|
|
|
+ double cftfxaverage = dayfilteredList.stream()
|
|
|
|
+ .mapToDouble(turbineInfoDay -> Optional.ofNullable(turbineInfoDay.getCftfx()).map(Number::doubleValue).orElse(0.0))
|
|
.average()
|
|
.average()
|
|
.orElse(0.0); // 默认值0.0
|
|
.orElse(0.0); // 默认值0.0
|
|
|
|
|
|
|
|
+
|
|
double zbsj = 0.0;
|
|
double zbsj = 0.0;
|
|
|
|
|
|
if (z.toString().equals("fsavg")) {
|
|
if (z.toString().equals("fsavg")) {
|