|
@@ -1,7 +1,11 @@
|
|
|
package com.persagy.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.persagy.cache.AlarmInfoCache;
|
|
|
import com.persagy.entity.AlarmDefine;
|
|
@@ -11,12 +15,10 @@ import com.persagy.entity.ZktAlarmRecordDO;
|
|
|
import com.persagy.job.ExpireAlarmQueue;
|
|
|
import com.persagy.repository.AlarmRecordRepository;
|
|
|
import com.persagy.service.AlarmDefineService;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
/**
|
|
|
* @description:报警定义逻辑实现类(项目报警定义全量获取,报警定义添加修改删除同步更新)
|
|
@@ -28,63 +30,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class AlarmDefineServiceImpl implements AlarmDefineService {
|
|
|
- @Autowired
|
|
|
+
|
|
|
+ @Autowired
|
|
|
AlarmInfoCache alarmInfoCache;
|
|
|
- @Autowired
|
|
|
+
|
|
|
+ @Autowired
|
|
|
AlarmRecordRepository alarmRecordRepository;
|
|
|
|
|
|
@Override
|
|
|
public List listAllAlarmDefine(List<AlarmDefine> alarmDefineList) {
|
|
|
-// String ad = "{\n" +
|
|
|
-// " \"streamId\": \"\",\n" +
|
|
|
-// " \"opCode\": \"\",\n" +
|
|
|
-// " \"content\": [\n" +
|
|
|
-// " {\n" +
|
|
|
-// " \"id\": 1,\n" +
|
|
|
-// " \"objId\": \"obj1\",\n" +
|
|
|
-// " \"itemCode\": \"1055\",\n" +
|
|
|
-// " \"projectId\": \"xxx\",\n" +
|
|
|
-// " \"name\": \"室内高温\",\n" +
|
|
|
-// " \"dealFunc\": \"point\",\n" +
|
|
|
-// " \"category\": \"环境报警\",\n" +
|
|
|
-// " \"level\": \"B\",\n" +
|
|
|
-// " \"remark\": \"我是备注哈\",\n" +
|
|
|
-// " \"open\": 1,\n" +
|
|
|
-// " \"condition\": {\n" +
|
|
|
-// " \"infoCode\": [\n" +
|
|
|
-// " \"$infoCode1\",\n" +
|
|
|
-// " \"$infoCode1\"\n" +
|
|
|
-// " ],\n" +
|
|
|
-// " \"infoCodeId\": [\n" +
|
|
|
-// " {\n" +
|
|
|
-// " \"infoCode\": \"infoCode1\",\n" +
|
|
|
-// " \"meterId\": \"11\",\n" +
|
|
|
-// " \"funcId\": \"12\"\n" +
|
|
|
-// " },\n" +
|
|
|
-// " {\n" +
|
|
|
-// " \"infoCode\": \"infoCode2\",\n" +
|
|
|
-// " \"meterId\": \"21\",\n" +
|
|
|
-// " \"funcId\": \"22\"\n" +
|
|
|
-// " }\n" +
|
|
|
-// " ],\n" +
|
|
|
-// " \"trigger\": \"($infoCode1 > 10 && $infoCode1 < 20) && ($infoCode2 < 20)\",\n" +
|
|
|
-// " \"end\": \"!($infoCode1 < 20 && $infoCode1 > 10)\",\n" +
|
|
|
-// " \"$triggerUphold\": 10,\n" +
|
|
|
-// " \"$endUphold\": 5,\n" +
|
|
|
-// " \"$time\": {\n" +
|
|
|
-// " \"type\": \"period\",\n" +
|
|
|
-// " \"period\": {\n" +
|
|
|
-// " \"$gt\": \"090000\",\n" +
|
|
|
-// " \"$lt\": \"210000\"\n" +
|
|
|
-// " }\n" +
|
|
|
-// " }\n" +
|
|
|
-// " }\n" +
|
|
|
-// " }\n" +
|
|
|
-// " ]\n" +
|
|
|
-// "}";
|
|
|
-// NettyMessage<AlarmDefine> message = JSONObject.parseObject(ad, new TypeReference<NettyMessage<AlarmDefine>>(){});
|
|
|
-// List<AlarmDefine> alarmDefineList =message.getContent();
|
|
|
- alarmInfoCache.clearAllAlarmDefine();
|
|
|
+ alarmInfoCache.clearAllAlarmDefine();
|
|
|
for (AlarmDefine alarmDefine : alarmDefineList) {
|
|
|
alarmInfoCache.putAlarmDefinitionById(alarmDefine);
|
|
|
}
|
|
@@ -189,4 +144,11 @@ public class AlarmDefineServiceImpl implements AlarmDefineService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void isolationAlarmDefine(List<JSONObject> alarmConfigs) {
|
|
|
+ for (JSONObject alarmConfig : alarmConfigs) {
|
|
|
+ alarmInfoCache.isolationAlarmDefinitionById(alarmConfig);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|