|
@@ -0,0 +1,35 @@
|
|
|
+package com.gyee.wisdom.alarm.rule;
|
|
|
+
|
|
|
+import com.gyee.wisdom.alarm.model.TagInfo;
|
|
|
+import com.gyee.wisdom.alarm.rule.expression.AlarmExpression;
|
|
|
+
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+
|
|
|
+public class AlarmFunctionMIN extends AlarmFunction {
|
|
|
+ public AlarmFunctionMIN(AlarmExpression alarmExpression, ThingType tType, String tId) {
|
|
|
+ super(alarmExpression, tType, tId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object explain() {
|
|
|
+ if (this.getAlarmExpression().getVarList() == null || this.getAlarmExpression().getVarList().size() < 1)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ Optional<Double> minValue = Optional.empty();
|
|
|
+
|
|
|
+ for (int i = 0; i < this.getAlarmExpression().getVarList().size(); i++) {
|
|
|
+ TagInfo tagInfo = this.getTagInfo(this.getAlarmExpression().getVarList().get(i));
|
|
|
+ if (!minValue.isPresent()) {
|
|
|
+ minValue = Optional.of(tagInfo.getDoubleTsData().getDoubleValue());
|
|
|
+ } else {
|
|
|
+ if (minValue.get() >= tagInfo.getDoubleTsData().getDoubleValue()) {
|
|
|
+ minValue = Optional.of(tagInfo.getDoubleTsData().getDoubleValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return minValue.get().doubleValue();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|