Browse Source

修改mq发送报警消息的key

xujiaheng 3 năm trước cách đây
mục cha
commit
be7cb49c51

+ 5 - 5
src/main/java/com/persagy/cache/AlarmRedisCache.java

@@ -40,7 +40,7 @@ public class AlarmRedisCache implements RedisCache {
 	public AlarmConditionState getAlarmDefineState(String defineId) {
 		AlarmConditionState alarmConditionState = null;
 		try {
-			Object obj = alarmRedisTemplate.opsForHash().get(RedisConstant.DEFINE_ID, defineId);
+			Object obj = alarmRedisTemplate.opsForHash().get(RedisConstant.ALARM_CONDITION_STATE, defineId);
 			if (null != obj && StringUtils.isNotBlank(obj.toString())) {
 				try {
 					alarmConditionState =JSONUtil.toBean(obj.toString(), AlarmConditionState.class);
@@ -70,13 +70,13 @@ public class AlarmRedisCache implements RedisCache {
 	}
 
 	public void setAlarmState(String defineId, AlarmConditionState alarmConditionState) {
-		alarmRedisTemplate.opsForHash().put(RedisConstant.DEFINE_ID, defineId, JSON.toJSONString(alarmConditionState));
+		alarmRedisTemplate.opsForHash().put(RedisConstant.ALARM_CONDITION_STATE, defineId, JSON.toJSONString(alarmConditionState));
 	}
 
 	public AlarmCondition getAlarmConditionRedis(String conditionId) {
 		String str = alarmRedisTemplate.execute((RedisCallback<String>) conn -> {
 			conn.select(14);
-			byte[] condition = conn.hGet(RedisConstant.ALARMCONDITION_ID.getBytes(), conditionId.getBytes());
+			byte[] condition = conn.hGet(RedisConstant.ALARM_CONDITIONS.getBytes(), conditionId.getBytes());
 			return new String(condition);
 		});
 		JSONObject object = JSONObject.parseObject(str);
@@ -86,7 +86,7 @@ public class AlarmRedisCache implements RedisCache {
 
 	public ObjConditionInfo getAlarmConditionsByObjId(String meterId) {
 		try {
-			String str = alarmRedisTemplate.opsForHash().get(RedisConstant.METER_ID, meterId).toString();
+			String str = alarmRedisTemplate.opsForHash().get(RedisConstant.OBJ_CONDITION_REL, meterId).toString();
 			if (StringUtils.isNotBlank(str)) {
 				JSONObject object = JSONObject.parseObject(str);
 				JSONArray conditions = object.getJSONArray("conditions");
@@ -106,7 +106,7 @@ public class AlarmRedisCache implements RedisCache {
 
 	public AlarmCondition getAlarmCondition(String conditionId) {
 		try {
-			Object obj = alarmRedisTemplate.opsForHash().get(RedisConstant.ALARMCONDITION_ID, conditionId);
+			Object obj = alarmRedisTemplate.opsForHash().get(RedisConstant.ALARM_CONDITIONS, conditionId);
 			if (null != obj && StringUtils.isNotBlank(obj.toString())) {
 				JSONObject object = JSONObject.parseObject(obj.toString());
 				AlarmCondition alarmCondition = JSON.toJavaObject(object, AlarmCondition.class);

+ 3 - 3
src/main/java/com/persagy/constant/RedisConstant.java

@@ -66,17 +66,17 @@ public class RedisConstant {
     /**
      * itemCode-objId拼接,用于根据defineId获取报警定义状态
      */
-    public static final String DEFINE_ID = "ALARM_CONDITION_STATE";
+    public static final String ALARM_CONDITION_STATE = "ALARM_CONDITION_STATE";
 
     /**
      * 报警条件Id REDIS hash 的 id
      */
-    public static final String ALARMCONDITION_ID = "ALARM_CONDITION";
+    public static final String ALARM_CONDITIONS = "ALARM_CONDITIONS";
 
 
     /**
      * 设备仪表ID
      */
-    public static final String METER_ID = "OBJ_CONDITION_REL";
+    public static final String OBJ_CONDITION_REL = "OBJ_CONDITION_REL";
 
 }