|
@@ -35,7 +35,7 @@ public class CauseJobHandler implements ApplicationRunner {
|
|
|
@Resource
|
|
|
private ThreadPoolTaskExecutor taskExecutor;
|
|
|
|
|
|
- private Map<String, ArrayDeque<PointData>> pdaqMap = new ConcurrentHashMap<>();
|
|
|
+ private final Map<String, ArrayDeque<PointData>> pdaqMap = new ConcurrentHashMap<>();
|
|
|
|
|
|
private boolean isload = false;
|
|
|
|
|
@@ -63,9 +63,7 @@ public class CauseJobHandler implements ApplicationRunner {
|
|
|
pdaqMap.put(k, pdaq);
|
|
|
});
|
|
|
} else {
|
|
|
- latest.forEach((k, v) -> {
|
|
|
- pdaqMap.get(k).offer(v);
|
|
|
- });
|
|
|
+ latest.forEach((k, v) -> pdaqMap.get(k).offer(v));
|
|
|
}
|
|
|
Thread.sleep(1000);
|
|
|
}
|
|
@@ -73,17 +71,17 @@ public class CauseJobHandler implements ApplicationRunner {
|
|
|
|
|
|
private void refreshQueue() {
|
|
|
|
|
|
- try {
|
|
|
- while (true) {
|
|
|
+ while (true) {
|
|
|
+ try {
|
|
|
Map<String, PointData> latest = adapterApi.getLatest(CacheContext.pointCodes);
|
|
|
latest.forEach((k, v) -> {
|
|
|
pdaqMap.get(k).poll();
|
|
|
pdaqMap.get(k).offer(v);
|
|
|
});
|
|
|
Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -92,7 +90,7 @@ public class CauseJobHandler implements ApplicationRunner {
|
|
|
|
|
|
if (!isload) return;
|
|
|
try {
|
|
|
- String pointCode = null;
|
|
|
+ String pointCode;
|
|
|
RealtimeAverageTarget target;
|
|
|
double v;
|
|
|
//uniformcode,点名
|
|
@@ -113,38 +111,38 @@ public class CauseJobHandler implements ApplicationRunner {
|
|
|
|
|
|
pointCode = entryValue.get(uniformcodeOne.get("wind-speed"));
|
|
|
if (pointCode != null) {
|
|
|
- v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
|
|
|
+ v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
|
|
|
speed = NumberUtil.round(v, 2).doubleValue();
|
|
|
target.setWindSpeed((float) speed);
|
|
|
if (speed < 3) {
|
|
|
- power = Double.valueOf(0);
|
|
|
+ power = 0.0;
|
|
|
} else {
|
|
|
power = CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(entry.getKey())).get(speed);
|
|
|
}
|
|
|
if (power == null) {
|
|
|
- power = Double.valueOf(0);
|
|
|
+ power = 0.0;
|
|
|
System.out.println(entry.getKey() + speed);
|
|
|
}
|
|
|
- target.setTheoryGeneration(NumberUtil.round(power / 60, 3).floatValue());
|
|
|
+ target.setTheoryGeneration(NumberUtil.round(power / 60, 4).floatValue());
|
|
|
}
|
|
|
pointCode = entryValue.get(uniformcodeOne.get("active-power"));
|
|
|
if (pointCode != null) {
|
|
|
- v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
|
|
|
+ v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
|
|
|
target.setPower(NumberUtil.round(v, 2).floatValue());
|
|
|
}
|
|
|
pointCode = entryValue.get(uniformcodeOne.get("generator_speed"));
|
|
|
if (pointCode != null) {
|
|
|
- v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
|
|
|
+ v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
|
|
|
target.setGeneratorSpeed(NumberUtil.round(v, 2).floatValue());
|
|
|
}
|
|
|
pointCode = entryValue.get(uniformcodeOne.get("impeller_speed"));
|
|
|
if (pointCode != null) {
|
|
|
- v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
|
|
|
+ v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
|
|
|
target.setImpellerSpeed(NumberUtil.round(v, 2).floatValue());
|
|
|
}
|
|
|
pointCode = entryValue.get(uniformcodeOne.get("wind_direction"));
|
|
|
if (pointCode != null) {
|
|
|
- v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
|
|
|
+ v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
|
|
|
target.setWindDirection(NumberUtil.round(v, 2).floatValue());
|
|
|
}
|
|
|
targets.add(target);
|