From d25428db61153c4bc2e1df17089f0f4e3e90fade Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Wed, 23 Nov 2022 10:45:16 +0800 Subject: [PATCH] 解决设备类状态型转换异常 --- screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java b/screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java index 0064a49..3071566 100644 --- a/screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java +++ b/screen-manage/src/main/java/com/moral/api/util/AdjustDataUtils.java @@ -5,6 +5,7 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; +import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -77,14 +78,15 @@ if (aqiMap != null) { aqiValue = aqiMap.get(key); } - env.put("aqi", ObjectUtils.isEmpty(aqiValue) ? 0F : Float.parseFloat((String) aqiValue)); + env.put("aqi", ObjectUtils.isEmpty(aqiValue) ? 0F : new BigDecimal(String.valueOf(aqiValue)).floatValue()); } if (formula.contains("vocs")) { Object vocsValue = ObjectUtils.isEmpty(deviceData.get(Constants.SENSOR_CODE_VOCS)) ? 0F : deviceData.get(Constants.SENSOR_CODE_VOCS); env.put("vocs", vocsValue); } if (formula.contains("cel")) { - env.put("cel", Float.parseFloat((String) measuredValue)); + //env.put("cel", Float.parseFloat((String) measuredValue)); + env.put("cel", new BigDecimal(String.valueOf(measuredValue)).floatValue()); } //������ measuredValue = expression.execute(env); -- Gitblit v1.8.0