|
@@ -14,6 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
@@ -54,20 +55,26 @@ public class ZhiBiaoCalculation {
|
|
queryWrapper.eq("uniformCode", "AI066");
|
|
queryWrapper.eq("uniformCode", "AI066");
|
|
List<PointInfo> pointInfos = pointInfo.selectList(queryWrapper);
|
|
List<PointInfo> pointInfos = pointInfo.selectList(queryWrapper);
|
|
|
|
|
|
|
|
+ //定义切入风速map集合
|
|
|
|
+ HashMap<String, HashMap<String, Double>> mapIn = new HashMap<>();
|
|
|
|
+ //定义切出风速集合
|
|
|
|
+ HashMap<String, HashMap<String, Double>> mapOut = new HashMap<>();
|
|
|
|
+
|
|
|
|
|
|
//遍历每台风机,取出每台风机的pointDatas
|
|
//遍历每台风机,取出每台风机的pointDatas
|
|
turbineZt.forEach(turbine -> {
|
|
turbineZt.forEach(turbine -> {
|
|
List<PointData> pointDatas = turbine.getPointDatas();
|
|
List<PointData> pointDatas = turbine.getPointDatas();
|
|
|
|
|
|
//风速测点key
|
|
//风速测点key
|
|
- AtomicReference<String> windSpeedKey = null;
|
|
|
|
|
|
+ String windSpeedKey = null;
|
|
|
|
|
|
//遍历pointInfos,找出pointData1的id和pointInfos中相等的,取出pointInfo的pointKey
|
|
//遍历pointInfos,找出pointData1的id和pointInfos中相等的,取出pointInfo的pointKey
|
|
- pointInfos.forEach(pointInfo -> {
|
|
|
|
- if (Objects.equals(turbine.getTurbineId(), pointInfo.getTurbineId())) {
|
|
|
|
- windSpeedKey.set(pointInfo.getPointKey());
|
|
|
|
|
|
+ for (int i = 0; i < pointInfos.size(); i++) {
|
|
|
|
+ if (Objects.equals(turbine.getTurbineId(), pointInfos.get(i).getTurbineId())) {
|
|
|
|
+ windSpeedKey = pointInfos.get(i).getPointKey();
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
//遍历pointDatas,取出当前状态和后一个状态
|
|
//遍历pointDatas,取出当前状态和后一个状态
|
|
for (int i = 1; i < pointDatas.size(); i++) {
|
|
for (int i = 1; i < pointDatas.size(); i++) {
|
|
@@ -88,10 +95,17 @@ public class ZhiBiaoCalculation {
|
|
//切入时间前5分钟
|
|
//切入时间前5分钟
|
|
long ts11 = ts1 - 300000;
|
|
long ts11 = ts1 - 300000;
|
|
//根据风速key,从适配器取切入前5分钟的所有风速
|
|
//根据风速key,从适配器取切入前5分钟的所有风速
|
|
- List<PointData> pointDatas1 = adapter.getHistorySnap(javaFunctionJobHandler.goldenUri(), windSpeedKey.get(), ts11, ts1, 10);
|
|
|
|
|
|
+ List<PointData> pointDatas1 = adapter.getHistorySnap(javaFunctionJobHandler.goldenUri(), windSpeedKey, ts11, ts1, 10);
|
|
//平均所有风速即为平均切入风速
|
|
//平均所有风速即为平均切入风速
|
|
double avgCutInWindSpeed = pointDatas1.stream().mapToDouble(PointData::getValue).average().orElse(0);
|
|
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>() {{
|
|
|
|
+ put(String.valueOf(ts1), avgCutInWindSpeed);
|
|
|
|
+ }});
|
|
|
|
+
|
|
|
|
+ //TODO: 存数据库
|
|
}
|
|
}
|
|
|
|
|
|
//切出
|
|
//切出
|
|
@@ -101,10 +115,17 @@ public class ZhiBiaoCalculation {
|
|
System.out.println(turbine.getTurbineId() + "切出" + stringDate);
|
|
System.out.println(turbine.getTurbineId() + "切出" + stringDate);
|
|
//切出时间前5分钟
|
|
//切出时间前5分钟
|
|
long ts22 = ts2 - 300000;
|
|
long ts22 = ts2 - 300000;
|
|
- List<PointData> pointDatas2 = adapter.getHistorySnap(javaFunctionJobHandler.goldenUri(), windSpeedKey.get(), ts22, ts2, 10);
|
|
|
|
|
|
+ List<PointData> pointDatas2 = adapter.getHistorySnap(javaFunctionJobHandler.goldenUri(), windSpeedKey, ts22, ts2, 10);
|
|
double avgCutOutWindSpeed = pointDatas2.stream().mapToDouble(PointData::getValue).average().orElse(0);
|
|
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>() {{
|
|
|
|
+ put(String.valueOf(ts2), avgCutOutWindSpeed);
|
|
|
|
+ }});
|
|
|
|
+
|
|
|
|
+ //TODO: 存数据库
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|