报警模块工具类冲突导致问题修改
This commit is contained in:
parent
aad350fe9c
commit
e01beceacf
jeecg-boot-base-core/src/main/java/org/jeecg/common/util
jeecg-module-abnormal-alarm/src/main/java/org/jeecg
|
@ -1,18 +1,12 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.modules.base.dto.RuleDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmRule;
|
||||
import org.jeecg.modules.entity.AlarmRuleAbnormal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.stream.*;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -21,7 +15,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class RedisStreamUtil{
|
||||
public class RedisStreamUtil {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,Object> redisTemplate;
|
||||
|
@ -167,25 +161,6 @@ public class RedisStreamUtil{
|
|||
return putRecord(record);
|
||||
}
|
||||
|
||||
public void setRules(Map<String, AlarmRuleAbnormal> ruleMap){
|
||||
Jackson2JsonRedisSerializer jacksonSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 使Jackson支持Java8的新日期API
|
||||
// objectMapper.registerModule(new JavaTimeModule());
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jacksonSerializer.setObjectMapper(objectMapper);
|
||||
// 返回批处理的执行结果
|
||||
List<Object> execResult = redisTemplate.executePipelined((RedisConnection connection) -> {
|
||||
Set<String> keySet = ruleMap.keySet();
|
||||
for (String key : keySet) {
|
||||
AlarmRule rule = ruleMap.get(key);
|
||||
connection.set(key.getBytes(),jacksonSerializer.serialize(rule));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public void setSilence(Map<String, Long> silenceMap){
|
||||
// 返回批处理的执行结果
|
||||
List<Object> execResult = redisTemplate.executePipelined((RedisConnection connection) -> {
|
|
@ -0,0 +1,43 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmRule;
|
||||
import org.jeecg.modules.entity.AlarmRuleAbnormal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class RedisStreamAlarmUtil extends RedisStreamUtil {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,Object> redisTemplate;
|
||||
|
||||
public void setRules(Map<String, AlarmRuleAbnormal> ruleMap){
|
||||
Jackson2JsonRedisSerializer jacksonSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 使Jackson支持Java8的新日期API
|
||||
// objectMapper.registerModule(new JavaTimeModule());
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jacksonSerializer.setObjectMapper(objectMapper);
|
||||
// 返回批处理的执行结果
|
||||
List<Object> execResult = redisTemplate.executePipelined((RedisConnection connection) -> {
|
||||
Set<String> keySet = ruleMap.keySet();
|
||||
for (String key : keySet) {
|
||||
AlarmRule rule = ruleMap.get(key);
|
||||
connection.set(key.getBytes(),jacksonSerializer.serialize(rule));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import org.jeecg.common.api.vo.Result;
|
|||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.util.RedisStreamUtil;
|
||||
import org.jeecg.common.util.RedisStreamAlarmUtil;
|
||||
import org.jeecg.modules.base.dto.AlarmRuleDto;
|
||||
import org.jeecg.modules.base.dto.AlarmRuleInfo;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
|
@ -37,7 +37,7 @@ import static org.jeecg.modules.base.enums.SourceType.*;
|
|||
public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRuleAbnormal> implements IAlarmRuleService {
|
||||
|
||||
@Autowired
|
||||
private RedisStreamUtil redisStreamUtil;
|
||||
private RedisStreamAlarmUtil redisStreamUtil;
|
||||
|
||||
@Autowired
|
||||
private ISysEmailService emailService;
|
||||
|
|
Loading…
Reference in New Issue
Block a user