Browse Source

alarmCondition中增加configs字段

lixing 3 years ago
parent
commit
9af0449f77

+ 5 - 0
AlarmEngineStarter/src/main/java/com/persagy/apm/energyalarmstarter/alarmengine/feign/AlarmCondition.java

@@ -82,4 +82,9 @@ public class AlarmCondition {
      * 生效时间详情
      */
     private JSONObject effectTimeDetail;
+
+    /**
+     * 数据中台中需要展示给前端的内容
+     */
+    private JSONObject configs;
 }

+ 6 - 15
AlarmEngineStarter/src/main/java/com/persagy/apm/energyalarmstarter/alarmengine/jms/AlarmEngineMsgHandler.java

@@ -9,15 +9,13 @@ import com.persagy.apm.energyalarmstarter.alarmengine.feign.AlarmCondition;
 import com.persagy.apm.energyalarmstarter.alarmengine.feign.ObjConditionRel;
 import com.persagy.apm.energyalarmstarter.alarmengine.jms.model.ItemCodeCondition;
 import com.persagy.apm.energyalarmstarter.alarmengine.jms.model.ObjConditionInfo;
-import com.persagy.apm.energyalarmstarter.alarmengine.redis.RedisUtil;
+import com.persagy.apm.energyalarmstarter.alarmengine.redis.RedisUtil4EngineStater;
 import com.persagy.apm.energyalarmstarter.alarmengine.service.AlarmRecordMsgHandler;
 import io.netty.channel.ChannelHandler;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
 
-import javax.annotation.Resource;
 import org.springframework.util.CollectionUtils;
 
 import java.util.List;
@@ -36,11 +34,8 @@ public class AlarmEngineMsgHandler {
     @Autowired
     private AlarmRecordMsgHandler alarmRecordMsgHandler;
 
-    @Resource(name = "alarmRedisTemplate")
-    private RedisTemplate<String, String> alarmRedisTemplate;
-
     @Autowired
-    private RedisUtil redisUtil;
+    private RedisUtil4EngineStater redisUtil;
 
     @SneakyThrows
     public String getAlarmCategory(DmpMessage dmpMessage) {
@@ -106,8 +101,7 @@ public class AlarmEngineMsgHandler {
      */
     public void syncNewCondition(DmpMessage msg) {
         AlarmCondition alarmCondition = JSONObject.parseObject(msg.getStr1(), AlarmCondition.class);
-        // TODO: 2021/11/16  更新redis
-        alarmRedisTemplate.opsForHash().put("ALARM_CONDITION", alarmCondition.getId(), JSON.toJSONString(alarmCondition));
+        redisUtil.put(RedisConstants.ALARM_CONDITIONS, alarmCondition.getId(), JSON.toJSONString(alarmCondition));
     }
 
     /**
@@ -119,9 +113,7 @@ public class AlarmEngineMsgHandler {
      */
     public void syncUpdatedCondition(DmpMessage msg) {
         AlarmCondition alarmCondition = JSONObject.parseObject(msg.getStr1(), AlarmCondition.class);
-        // TODO: 2021/11/16  更新redis
-        alarmRedisTemplate.opsForHash().delete("ALARM_CONDITION",alarmCondition.getId());
-        alarmRedisTemplate.opsForHash().put("ALARM_CONDITION", alarmCondition.getId(), JSON.toJSONString(alarmCondition));
+        redisUtil.put(RedisConstants.ALARM_CONDITIONS, alarmCondition.getId(), JSON.toJSONString(alarmCondition));
     }
 
     /**
@@ -132,9 +124,8 @@ public class AlarmEngineMsgHandler {
      * @version V1.0 2021/10/26 7:51 下午
      */
     public void syncDeletedCondition(DmpMessage msg) {
-        // TODO: 2021/11/16 更新redis
-        alarmRedisTemplate.opsForHash().delete("ALARM_CONDITION",msg.getStr1());
-
+        String conditionId = msg.getStr1();
+        redisUtil.delete(RedisConstants.ALARM_CONDITIONS, conditionId);
     }
 
     /**

+ 2 - 3
AlarmEngineStarter/src/main/java/com/persagy/apm/energyalarmstarter/alarmengine/jms/JmsConfig.java

@@ -3,7 +3,7 @@ package com.persagy.apm.energyalarmstarter.alarmengine.jms;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Sets;
 import com.persagy.apm.energyalarmstarter.alarmdata.mq.model.DmpMessage;
-import com.persagy.apm.energyalarmstarter.alarmengine.redis.RedisUtil;
+import com.persagy.apm.energyalarmstarter.alarmengine.redis.RedisUtil4EngineStater;
 import com.rabbitmq.client.Channel;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.core.RedisTemplate;
 
 import java.util.HashSet;
 import java.util.List;
@@ -47,7 +46,7 @@ public class JmsConfig {
     private AlarmEngineMsgHandler msgHandler;
 
     @Autowired
-    private RedisUtil redisUtil;
+    private RedisUtil4EngineStater redisUtil;
 
     /**
      * 交换机

+ 2 - 5
AlarmEngineStarter/src/main/java/com/persagy/apm/energyalarmstarter/alarmengine/redis/RedisUtil.java

@@ -1,22 +1,19 @@
 package com.persagy.apm.energyalarmstarter.alarmengine.redis;
 
 import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
 import lombok.SneakyThrows;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
 /**
- * redis工具类
+ * redis工具类(因为要注册到spring boot,要注意名称不能重复)
  *
  * @author lixing
  * @version V1.0 2021/11/20 5:00 下午
  **/
 @Service
-public class RedisUtil {
+public class RedisUtil4EngineStater {
     @Autowired
     RedisTemplate redisTemplate;