Pārlūkot izejas kodu

fix:修改报警出发条件和报警信息

lbingyu 2 nedēļas atpakaļ
vecāks
revīzija
73c1b4b318

+ 6 - 6
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/core/alarm/config/ColdChainAlarmMessageProperties.java

@@ -8,11 +8,11 @@ import org.springframework.stereotype.Component;
 @ConfigurationProperties(prefix = "cold-chain.alarm.message")
 @Data
 public class ColdChainAlarmMessageProperties {
-    private String temperatureOverLimit = "温度报警:{deviceName}的温度超标!\n" +
+    private String temperatureOverLimit = "{deviceName}的温度超标!\n" +
             "当前温度:{value} {unit},已超出上限(阈值:{threshold})。\n" +
             "报警时间:{time}";
 
-    private String temperatureBelowLimit = "温度报警:{deviceName}的温度过低!\n" +
+    private String temperatureBelowLimit = "{deviceName}的温度过低!\n" +
             "当前温度:{value} {unit},已低于下限(阈值:{threshold})。\n" +
             "报警时间:{time}";
 
@@ -20,11 +20,11 @@ public class ColdChainAlarmMessageProperties {
             "当前温度:{value} {unit},阈值:{threshold}。\n" +
             "恢复时间:{time}";
 
-    private String humidityOverLimit = "湿度报警:{deviceName}的湿度超标!\n" +
+    private String humidityOverLimit = "{deviceName}的湿度超标!\n" +
             "当前湿度:{value} {unit},已超出上限(阈值:{threshold})。\n" +
             "报警时间:{time}";
 
-    private String humidityBelowLimit = "湿度报警:{deviceName}的湿度过低!\n" +
+    private String humidityBelowLimit = "{deviceName}的湿度过低!\n" +
             "当前湿度:{value} {unit},已低于下限(阈值:{threshold})。\n" +
             "报警时间:{time}";
 
@@ -32,11 +32,11 @@ public class ColdChainAlarmMessageProperties {
             "当前湿度:{value} {unit},阈值:{threshold}。\n" +
             "恢复时间:{time}";
 
-    private String co2OverLimit = "二氧化碳报警:{deviceName}的二氧化碳浓度超标!\n" +
+    private String co2OverLimit = "{deviceName}的二氧化碳浓度超标!\n" +
             "当前浓度:{value} {unit},已超出上限(阈值:{threshold})。\n" +
             "报警时间:{time}";
 
-    private String co2BelowLimit = "二氧化碳报警:{deviceName}的二氧化碳浓度过低!\n" +
+    private String co2BelowLimit = "{deviceName}的二氧化碳浓度过低!\n" +
             "当前浓度:{value} {unit},已低于下限(阈值:{threshold})。\n" +
             "报警时间:{time}";
 

+ 2 - 2
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/core/alarm/service/check/DefaultSensorAlarmChecker.java

@@ -105,12 +105,12 @@ public class DefaultSensorAlarmChecker implements SensorAlarmChecker {
         boolean alarmTriggered = false;
         String time = DATE_FORMAT.format(new Date()); // 获取当前时间
         String unit = getUnit(type);
-        if (noNull(upperThreshold) && value >= upperThreshold) {
+        if (noNull(upperThreshold) && value > upperThreshold) {
             // 超过上限,触发超标报警
             publishAlarm(type + "超标", value, unit, time, upperThreshold, monitorTargetRegion
                     , SensorAlarmType.DATA_ALARM.getDeviceCode());
             alarmTriggered = true;
-        } else if (noNull(lowerThreshold) && value <= lowerThreshold) {
+        } else if (noNull(lowerThreshold) && value < lowerThreshold) {
             // 低于下限,触发低于阈值报警
             publishAlarm(type + "过低", value, unit, time, lowerThreshold, monitorTargetRegion
                     , SensorAlarmType.DATA_ALARM.getDeviceCode());