|
@@ -62,24 +62,25 @@ public class ZhiBiaoCalculation {
|
|
|
|
|
|
|
|
|
//遍历每台风机,取出每台风机的pointDatas
|
|
|
- turbineZt.forEach(turbine -> {
|
|
|
+ for (PointInfo turbine : turbineZt) {
|
|
|
+
|
|
|
List<PointData> pointDatas = turbine.getPointDatas();
|
|
|
|
|
|
//风速测点key
|
|
|
String windSpeedKey = null;
|
|
|
|
|
|
//遍历pointInfos,找出pointData1的id和pointInfos中相等的,取出pointInfo的pointKey
|
|
|
- for (int i = 0; i < pointInfos.size(); i++) {
|
|
|
- if (Objects.equals(turbine.getTurbineId(), pointInfos.get(i).getTurbineId())) {
|
|
|
- windSpeedKey = pointInfos.get(i).getPointKey();
|
|
|
+ for (PointInfo info : pointInfos) {
|
|
|
+ if (Objects.equals(turbine.getTurbineId(), info.getTurbineId())) {
|
|
|
+ windSpeedKey = info.getPointKey();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//遍历pointDatas,取出当前状态和后一个状态
|
|
|
- for (int i = 1; i < pointDatas.size(); i++) {
|
|
|
- PointData pointData1 = pointDatas.get(i);
|
|
|
- PointData pointData2 = pointDatas.get(i + 1);
|
|
|
+ for (int k = 1; k < pointDatas.size(); k++) {
|
|
|
+ PointData pointData1 = pointDatas.get(k - 1);
|
|
|
+ PointData pointData2 = pointDatas.get(k);
|
|
|
double value1 = pointData1.getValue();
|
|
|
double value2 = pointData2.getValue();
|
|
|
//切入时间
|
|
@@ -91,14 +92,14 @@ public class ZhiBiaoCalculation {
|
|
|
if (value1 == 0 && value2 == 2) {
|
|
|
ts1 = pointData2.getTs();
|
|
|
String stringDate = DateUtil.date(ts1).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
- System.out.println(turbine.getTurbineId() + "切入" + stringDate);
|
|
|
+// System.out.println(turbine.getTurbineId() + "切入" + stringDate);
|
|
|
//切入时间前5分钟
|
|
|
long ts11 = ts1 - 300000;
|
|
|
//根据风速key,从适配器取切入前5分钟的所有风速
|
|
|
List<PointData> pointDatas1 = adapter.getHistorySnap(javaFunctionJobHandler.goldenUri(), windSpeedKey, ts11, ts1, 10);
|
|
|
//平均所有风速即为平均切入风速
|
|
|
double avgCutInWindSpeed = pointDatas1.stream().mapToDouble(PointData::getValue).average().orElse(0);
|
|
|
- System.out.println(turbine.getTurbineId() + "切入风速" + avgCutInWindSpeed);
|
|
|
+// System.out.println(turbine.getTurbineId() + "切入风速" + avgCutInWindSpeed);
|
|
|
|
|
|
//存入map集合,外层key为turbineId,内层key为ts1,value为平均切入风速
|
|
|
mapIn.put(turbine.getTurbineId(), new HashMap<String, Double>() {{
|
|
@@ -112,12 +113,12 @@ public class ZhiBiaoCalculation {
|
|
|
if (value1 == 2 && value2 != 2) {
|
|
|
ts2 = pointData2.getTs();
|
|
|
String stringDate = DateUtil.date(ts2).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
- System.out.println(turbine.getTurbineId() + "切出" + stringDate);
|
|
|
+// System.out.println(turbine.getTurbineId() + "切出" + stringDate);
|
|
|
//切出时间前5分钟
|
|
|
long ts22 = ts2 - 300000;
|
|
|
List<PointData> pointDatas2 = adapter.getHistorySnap(javaFunctionJobHandler.goldenUri(), windSpeedKey, ts22, ts2, 10);
|
|
|
double avgCutOutWindSpeed = pointDatas2.stream().mapToDouble(PointData::getValue).average().orElse(0);
|
|
|
- System.out.println(turbine.getTurbineId() + "切出风速" + avgCutOutWindSpeed);
|
|
|
+// System.out.println(turbine.getTurbineId() + "切出风速" + avgCutOutWindSpeed);
|
|
|
|
|
|
//存入map集合,外层key为turbineId,内层key为ts2,value为平均切出风速
|
|
|
mapOut.put(turbine.getTurbineId(), new HashMap<String, Double>() {{
|
|
@@ -125,12 +126,30 @@ public class ZhiBiaoCalculation {
|
|
|
}});
|
|
|
|
|
|
//TODO: 存数据库
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- });
|
|
|
+ //遍历map集合,取出每个风机的所有切入风速,算一个平均值
|
|
|
+ HashMap<String, Double> mapTurbineValues = mapIn.get(turbine.getTurbineId());
|
|
|
+ if (mapTurbineValues != null) {
|
|
|
+ AtomicReference<Double> sum = new AtomicReference<>(0.0);
|
|
|
+ mapTurbineValues.forEach((k, v) -> {
|
|
|
+ sum.updateAndGet(v1 -> v1 + v);
|
|
|
+ });
|
|
|
+ double avgCutInWindSpeed = sum.get() / mapTurbineValues.size();
|
|
|
+ System.out.println(turbine.getTurbineId() + "切入平均风速" + avgCutInWindSpeed+ timeBegin);
|
|
|
+ }
|
|
|
+ //遍历map集合,取出每个风机的所有切出风速,算一个平均值
|
|
|
+ HashMap<String, Double> mapTurbineValues2 = mapOut.get(turbine.getTurbineId());
|
|
|
+
|
|
|
+ if (mapTurbineValues2 != null) {
|
|
|
+ AtomicReference<Double> sum = new AtomicReference<>(0.0);
|
|
|
+ mapTurbineValues2.forEach((k, v) -> {
|
|
|
+ sum.updateAndGet(v1 -> v1 + v);
|
|
|
+ });
|
|
|
+ double avgCutOutWindSpeed = sum.get() / mapTurbineValues2.size();
|
|
|
+ System.out.println(turbine.getTurbineId() + "切出平均风速" + avgCutOutWindSpeed + timeBegin);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|