|
@@ -11,7 +11,6 @@ import com.jjt.common.utils.IntervalUtil;
|
|
|
import com.jjt.common.utils.StringUtils;
|
|
|
import com.jjt.push.service.IPushConfigService;
|
|
|
import com.jjt.system.service.ISysDictDataService;
|
|
|
-import javafx.util.Pair;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -144,8 +143,11 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
|
|
|
// 3.如果该指标有告警,但告警等级不同,则上一次告警结束,新增一条告警。
|
|
|
// 4.如果之前没有告警,当前告警,则新增告警。
|
|
|
AlarmRecord record = recordMap.get(om.getObjMetricsId());
|
|
|
- Pair<String, String> pair = getAlarmLevel(om.getDValue().floatValue(), om);
|
|
|
- String alarmLevel = pair.getKey();
|
|
|
+ Map<String, String> pair = getAlarmLevel(om.getDValue().floatValue(), om);
|
|
|
+ if (pair == null) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ String alarmLevel = pair.get("key");
|
|
|
if (alarmLevel == null) {
|
|
|
//如果没有告警,且之前有告警记录,则结束之前告警
|
|
|
if (record != null) {
|
|
@@ -180,7 +182,7 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
|
|
|
record.setAlarmValue(om.getDValue());
|
|
|
record.setAlarmType("1");
|
|
|
record.setAlarmTime(date);
|
|
|
- record.setRemark(pair.getValue());
|
|
|
+ record.setRemark(pair.get("value"));
|
|
|
record.setCreateTime(new Date());
|
|
|
result.put("add", record);
|
|
|
pushConfigService.push(record);
|
|
@@ -354,13 +356,20 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
|
|
|
* @param bizObjMetrics 指标对象
|
|
|
* @return
|
|
|
*/
|
|
|
- private Pair<String, String> getAlarmLevel(Float value, BizObjMetrics bizObjMetrics) {
|
|
|
+ private Map<String, String> getAlarmLevel(Float value, BizObjMetrics bizObjMetrics) {
|
|
|
+ Map<String, String> result = new HashMap<>();
|
|
|
if (StringUtils.isNotEmpty(bizObjMetrics.getAlarmLow()) && IntervalUtil.inNumRange(value, bizObjMetrics.getAlarmLow())) {
|
|
|
- return new Pair<>("low", bizObjMetrics.getAlarmLow());
|
|
|
+ result.put("key", "low");
|
|
|
+ result.put("value", bizObjMetrics.getAlarmLow());
|
|
|
+ return result;
|
|
|
} else if (StringUtils.isNotEmpty(bizObjMetrics.getAlarmMid()) && IntervalUtil.inNumRange(value, bizObjMetrics.getAlarmMid())) {
|
|
|
- return new Pair<>("mid", bizObjMetrics.getAlarmHigh());
|
|
|
+ result.put("key", "mid");
|
|
|
+ result.put("value", bizObjMetrics.getAlarmMid());
|
|
|
+ return result;
|
|
|
} else if (StringUtils.isNotEmpty(bizObjMetrics.getAlarmHigh()) && IntervalUtil.inNumRange(value, bizObjMetrics.getAlarmHigh())) {
|
|
|
- return new Pair<>("high", bizObjMetrics.getAlarmHigh());
|
|
|
+ result.put("key", "high");
|
|
|
+ result.put("value", bizObjMetrics.getAlarmHigh());
|
|
|
+ return result;
|
|
|
}
|
|
|
return null;
|
|
|
}
|