|
|
@@ -3,8 +3,10 @@ package com.shkpr.service.customgateway.zhscada.domain;
|
|
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
|
import com.shkpr.service.customgateway.core.constants.InfluxdbMetadata;
|
|
|
+import com.shkpr.service.customgateway.core.constants.LogFlagBusiType;
|
|
|
import com.shkpr.service.customgateway.core.domain.Device;
|
|
|
import com.shkpr.service.customgateway.core.domain.DeviceTag;
|
|
|
+import com.shkpr.service.customgateway.core.utils.ExpressionUtil;
|
|
|
import lombok.Data;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
@@ -28,6 +30,11 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Data
|
|
|
public class ScadaPlatformData {
|
|
|
/**
|
|
|
+ * log
|
|
|
+ */
|
|
|
+ private final static String mStrClassName = "PersonnelInfoServiceImpl";
|
|
|
+ private final static String mBizType = LogFlagBusiType.ZAO_YANG_DMA.toStrValue();
|
|
|
+ /**
|
|
|
* 采集标签
|
|
|
*/
|
|
|
@JsonAlias("N")
|
|
|
@@ -68,6 +75,16 @@ public class ScadaPlatformData {
|
|
|
.filter(t -> Objects.equals(n, t.getTag()))
|
|
|
.findFirst().orElse(null);
|
|
|
if (tag == null) return null;
|
|
|
+
|
|
|
+ //值
|
|
|
+ Double value = Double.parseDouble(v);
|
|
|
+ //应用公式计算
|
|
|
+ if (StringUtils.isNotBlank(tag.getCalcFormula()))
|
|
|
+ value = ExpressionUtil.evaluateFormula(value, tag.getCalcFormula());
|
|
|
+ //数值范围校验
|
|
|
+ if (tag.getMinValue() != null && value < tag.getMinValue()) value = tag.getMinValue();
|
|
|
+ if (tag.getMaxValue() != null && value > tag.getMaxValue()) value = tag.getMaxValue();
|
|
|
+
|
|
|
//获取时间戳
|
|
|
long timestamp = LocalDateTime.now()
|
|
|
.truncatedTo(ChronoUnit.MINUTES)
|
|
|
@@ -83,7 +100,7 @@ public class ScadaPlatformData {
|
|
|
//时间
|
|
|
.time(timestamp, TimeUnit.MILLISECONDS)
|
|
|
//值
|
|
|
- .addField(tag.getField(), Double.parseDouble(v))
|
|
|
+ .addField(tag.getField(), value)
|
|
|
.build();
|
|
|
}
|
|
|
}
|