报警模块实体类引入修改
redis缓存工具类移动
This commit is contained in:
parent
8194e89326
commit
566e11aaf3
|
@ -7,6 +7,7 @@ import org.jeecg.common.constant.CommonConstant;
|
||||||
import org.jeecg.common.constant.SymbolConstant;
|
import org.jeecg.common.constant.SymbolConstant;
|
||||||
import org.jeecg.modules.base.dto.RuleDto;
|
import org.jeecg.modules.base.dto.RuleDto;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmRule;
|
import org.jeecg.modules.base.entity.postgre.AlarmRule;
|
||||||
|
import org.jeecg.modules.entity.AlarmRuleAbnormal;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.connection.RedisConnection;
|
import org.springframework.data.redis.connection.RedisConnection;
|
||||||
import org.springframework.data.redis.connection.stream.*;
|
import org.springframework.data.redis.connection.stream.*;
|
||||||
|
@ -166,7 +167,7 @@ public class RedisStreamUtil{
|
||||||
return putRecord(record);
|
return putRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRules(Map<String, AlarmRule> ruleMap){
|
public void setRules(Map<String, AlarmRuleAbnormal> ruleMap){
|
||||||
Jackson2JsonRedisSerializer jacksonSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
Jackson2JsonRedisSerializer jacksonSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
// 使Jackson支持Java8的新日期API
|
// 使Jackson支持Java8的新日期API
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmContactGroup;
|
import org.jeecg.modules.base.entity.postgre.AlarmContactGroup;
|
||||||
|
import org.jeecg.modules.entity.AlarmContactGroupAbnormal;
|
||||||
|
|
||||||
public interface AlarmContactGroupMapper extends BaseMapper<AlarmContactGroup> {
|
public interface AlarmContactGroupMapper extends BaseMapper<AlarmContactGroupAbnormal> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,12 @@ package org.jeecg.modules.mapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.jeecg.modules.base.dto.AlarmRuleDto;
|
import org.jeecg.modules.base.dto.AlarmRuleDto;
|
||||||
import org.jeecg.modules.base.dto.AlarmRuleInfo;
|
import org.jeecg.modules.base.dto.AlarmRuleInfo;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmRule;
|
import org.jeecg.modules.entity.AlarmRuleAbnormal;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface AlarmRuleMapper extends BaseMapper<AlarmRule> {
|
public interface AlarmRuleMapper extends BaseMapper<AlarmRuleAbnormal> {
|
||||||
|
|
||||||
List<AlarmRuleDto> findPage(Map<String, Object> params);
|
List<AlarmRuleDto> findPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
|
|
@ -4,20 +4,21 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.jeecg.common.api.QueryRequest;
|
import org.jeecg.common.api.QueryRequest;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmContactGroup;
|
import org.jeecg.modules.base.entity.postgre.AlarmContactGroup;
|
||||||
|
import org.jeecg.modules.entity.AlarmContactGroupAbnormal;
|
||||||
|
|
||||||
public interface IAlarmContactGroupService extends IService<AlarmContactGroup> {
|
public interface IAlarmContactGroupService extends IService<AlarmContactGroupAbnormal> {
|
||||||
|
|
||||||
Result findPage(QueryRequest queryRequest, AlarmContactGroup alarmContactGroup);
|
Result findPage(QueryRequest queryRequest, AlarmContactGroupAbnormal alarmContactGroup);
|
||||||
|
|
||||||
Result findInfo(String id);
|
Result findInfo(String id);
|
||||||
|
|
||||||
Result create(AlarmContactGroup alarmContactGroup);
|
Result create(AlarmContactGroupAbnormal alarmContactGroup);
|
||||||
|
|
||||||
Result update(AlarmContactGroup alarmContactGroup);
|
Result update(AlarmContactGroupAbnormal alarmContactGroup);
|
||||||
|
|
||||||
Result deleteById(String id);
|
Result deleteById(String id);
|
||||||
|
|
||||||
Result deleteUserById(String id, String userId);
|
Result deleteUserById(String id, String userId);
|
||||||
|
|
||||||
AlarmContactGroup getByName(String groupName);
|
AlarmContactGroupAbnormal getByName(String groupName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,18 @@ package org.jeecg.modules.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmRule;
|
|
||||||
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
||||||
|
import org.jeecg.modules.entity.AlarmRuleAbnormal;
|
||||||
|
|
||||||
public interface IAlarmRuleService extends IService<AlarmRule> {
|
public interface IAlarmRuleService extends IService<AlarmRuleAbnormal> {
|
||||||
|
|
||||||
Result findPage(AlarmRuleVo alarmRuleVo);
|
Result findPage(AlarmRuleVo alarmRuleVo);
|
||||||
|
|
||||||
Result findInfo(String alarmRuleId);
|
Result findInfo(String alarmRuleId);
|
||||||
|
|
||||||
Result create(AlarmRule alarmRule);
|
Result create(AlarmRuleAbnormal alarmRule);
|
||||||
|
|
||||||
Result update(AlarmRule alarmRule);
|
Result update(AlarmRuleAbnormal alarmRule);
|
||||||
|
|
||||||
Result deleteById(String alarmRuleId);
|
Result deleteById(String alarmRuleId);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.jeecg.common.util.SpringContextUtils;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmContactGroup;
|
import org.jeecg.modules.base.entity.postgre.AlarmContactGroup;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmContactGroupMember;
|
import org.jeecg.modules.base.entity.postgre.AlarmContactGroupMember;
|
||||||
import org.jeecg.modules.base.entity.postgre.SysUser;
|
import org.jeecg.modules.base.entity.postgre.SysUser;
|
||||||
|
import org.jeecg.modules.entity.AlarmContactGroupAbnormal;
|
||||||
import org.jeecg.modules.feignclient.SystemClient;
|
import org.jeecg.modules.feignclient.SystemClient;
|
||||||
import org.jeecg.modules.mapper.AlarmContactGroupMapper;
|
import org.jeecg.modules.mapper.AlarmContactGroupMapper;
|
||||||
import org.jeecg.modules.mapper.AlarmContactGroupMemberMapper;
|
import org.jeecg.modules.mapper.AlarmContactGroupMemberMapper;
|
||||||
|
@ -30,7 +31,7 @@ import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service("alarmContactGroupService")
|
@Service("alarmContactGroupService")
|
||||||
public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupMapper, AlarmContactGroup> implements IAlarmContactGroupService {
|
public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupMapper, AlarmContactGroupAbnormal> implements IAlarmContactGroupService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AlarmContactGroupMemberMapper alarmContactGroupMemberMapper;
|
private AlarmContactGroupMemberMapper alarmContactGroupMemberMapper;
|
||||||
|
@ -38,14 +39,14 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
||||||
private SystemClient systemClient;
|
private SystemClient systemClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result findPage(QueryRequest queryRequest, AlarmContactGroup alarmContactGroup) {
|
public Result findPage(QueryRequest queryRequest, AlarmContactGroupAbnormal alarmContactGroup) {
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
//获取用户信息
|
//获取用户信息
|
||||||
Map<String ,SysUser> userList = systemClient.findUserMap();
|
Map<String ,SysUser> userList = systemClient.findUserMap();
|
||||||
Page<AlarmContactGroup> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
Page<AlarmContactGroupAbnormal> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||||
LambdaQueryWrapper<AlarmContactGroup> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AlarmContactGroupAbnormal> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.orderByDesc(AlarmContactGroup::getCreateTime);
|
queryWrapper.orderByDesc(AlarmContactGroupAbnormal::getCreateTime);
|
||||||
Page<AlarmContactGroup> alarmContactGroupPage = this.baseMapper.selectPage(page, queryWrapper);
|
Page<AlarmContactGroupAbnormal> alarmContactGroupPage = this.baseMapper.selectPage(page, queryWrapper);
|
||||||
LambdaQueryWrapper<AlarmContactGroupMember> contactGroupMemberQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AlarmContactGroupMember> contactGroupMemberQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
List<AlarmContactGroupMember> alarmContactGroupMembers = alarmContactGroupMemberMapper.selectList(contactGroupMemberQueryWrapper);
|
List<AlarmContactGroupMember> alarmContactGroupMembers = alarmContactGroupMemberMapper.selectList(contactGroupMemberQueryWrapper);
|
||||||
alarmContactGroupPage.getRecords().forEach(item->{
|
alarmContactGroupPage.getRecords().forEach(item->{
|
||||||
|
@ -77,9 +78,9 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
||||||
public Result findInfo(String id) {
|
public Result findInfo(String id) {
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
//根据id查询对应的数据 判断数据是否在数据库中
|
//根据id查询对应的数据 判断数据是否在数据库中
|
||||||
LambdaQueryWrapper<AlarmContactGroup> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AlarmContactGroupAbnormal> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(AlarmContactGroup::getId, id);
|
queryWrapper.eq(AlarmContactGroupAbnormal::getId, id);
|
||||||
AlarmContactGroup alarmContactGroup = this.baseMapper.selectOne(queryWrapper);
|
AlarmContactGroupAbnormal alarmContactGroup = this.baseMapper.selectOne(queryWrapper);
|
||||||
if (Objects.isNull(alarmContactGroup)){
|
if (Objects.isNull(alarmContactGroup)){
|
||||||
result.error500("Failed to query the data because the corresponding data does not exist!");
|
result.error500("Failed to query the data because the corresponding data does not exist!");
|
||||||
return result;
|
return result;
|
||||||
|
@ -98,7 +99,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result create(AlarmContactGroup alarmContactGroup) {
|
public Result create(AlarmContactGroupAbnormal alarmContactGroup) {
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
//获取request
|
//获取request
|
||||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||||
|
@ -132,7 +133,7 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result update(AlarmContactGroup alarmContactGroup) {
|
public Result update(AlarmContactGroupAbnormal alarmContactGroup) {
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
//获取request
|
//获取request
|
||||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||||
|
@ -149,9 +150,9 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
||||||
|
|
||||||
//获取当前操作人用户名
|
//获取当前操作人用户名
|
||||||
String username = JwtUtil.getUserNameByToken(request);
|
String username = JwtUtil.getUserNameByToken(request);
|
||||||
LambdaQueryWrapper<AlarmContactGroup> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AlarmContactGroupAbnormal> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(AlarmContactGroup::getId, alarmContactGroup.getId());
|
queryWrapper.eq(AlarmContactGroupAbnormal::getId, alarmContactGroup.getId());
|
||||||
AlarmContactGroup contactGroup = this.baseMapper.selectOne(queryWrapper);
|
AlarmContactGroupAbnormal contactGroup = this.baseMapper.selectOne(queryWrapper);
|
||||||
if (Objects.isNull(contactGroup)){
|
if (Objects.isNull(contactGroup)){
|
||||||
result.error500("The corresponding data does not exist!");
|
result.error500("The corresponding data does not exist!");
|
||||||
return result;
|
return result;
|
||||||
|
@ -205,9 +206,9 @@ public class AlarmContactGroupServiceImpl extends ServiceImpl<AlarmContactGroupM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlarmContactGroup getByName(String groupName) {
|
public AlarmContactGroupAbnormal getByName(String groupName) {
|
||||||
LambdaQueryWrapper<AlarmContactGroup> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AlarmContactGroupAbnormal> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(AlarmContactGroup::getName,groupName);
|
wrapper.eq(AlarmContactGroupAbnormal::getName,groupName);
|
||||||
return getOne(wrapper);
|
return getOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ import org.jeecg.modules.base.dto.AlarmRuleDto;
|
||||||
import org.jeecg.modules.base.dto.AlarmRuleInfo;
|
import org.jeecg.modules.base.dto.AlarmRuleInfo;
|
||||||
import org.jeecg.modules.base.dto.SourceDto;
|
import org.jeecg.modules.base.dto.SourceDto;
|
||||||
import org.jeecg.modules.base.entity.Rule;
|
import org.jeecg.modules.base.entity.Rule;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmRule;
|
|
||||||
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
||||||
|
import org.jeecg.modules.entity.AlarmRuleAbnormal;
|
||||||
import org.jeecg.modules.mapper.AlarmRuleMapper;
|
import org.jeecg.modules.mapper.AlarmRuleMapper;
|
||||||
import org.jeecg.modules.service.IAlarmRuleService;
|
import org.jeecg.modules.service.IAlarmRuleService;
|
||||||
import org.jeecg.modules.service.ISysDatabaseService;
|
import org.jeecg.modules.service.ISysDatabaseService;
|
||||||
|
@ -34,7 +34,7 @@ import java.util.Map;
|
||||||
import static org.jeecg.modules.base.enums.SourceType.*;
|
import static org.jeecg.modules.base.enums.SourceType.*;
|
||||||
|
|
||||||
@Service("alarmRuleService")
|
@Service("alarmRuleService")
|
||||||
public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule> implements IAlarmRuleService {
|
public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRuleAbnormal> implements IAlarmRuleService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisStreamUtil redisStreamUtil;
|
private RedisStreamUtil redisStreamUtil;
|
||||||
|
@ -73,7 +73,7 @@ public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result create(AlarmRule alarmRule) {
|
public Result create(AlarmRuleAbnormal alarmRule) {
|
||||||
Rule rule = alarmRule.getRule();
|
Rule rule = alarmRule.getRule();
|
||||||
if (ObjectUtil.isNotNull(rule)){
|
if (ObjectUtil.isNotNull(rule)){
|
||||||
String operator = JSON.toJSONString(rule);
|
String operator = JSON.toJSONString(rule);
|
||||||
|
@ -85,10 +85,10 @@ public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result update(AlarmRule alarmRule) {
|
public Result update(AlarmRuleAbnormal alarmRule) {
|
||||||
LambdaQueryWrapper<AlarmRule> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AlarmRuleAbnormal> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(AlarmRule::getId, alarmRule.getId());
|
wrapper.eq(AlarmRuleAbnormal::getId, alarmRule.getId());
|
||||||
AlarmRule alarmRuleOld = this.baseMapper.selectOne(wrapper);
|
AlarmRuleAbnormal alarmRuleOld = this.baseMapper.selectOne(wrapper);
|
||||||
if (ObjectUtil.isNull(alarmRuleOld)){
|
if (ObjectUtil.isNull(alarmRuleOld)){
|
||||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
return Result.error(Prompt.DATA_NOT_EXITS);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result updateStatus(String alarmRuleId,Integer enabled) {
|
public Result updateStatus(String alarmRuleId,Integer enabled) {
|
||||||
AlarmRule alarmRule = new AlarmRule();
|
AlarmRuleAbnormal alarmRule = new AlarmRuleAbnormal();
|
||||||
alarmRule.setId(alarmRuleId);
|
alarmRule.setId(alarmRuleId);
|
||||||
alarmRule.setEnabled(enabled);
|
alarmRule.setEnabled(enabled);
|
||||||
if (updateById(alarmRule))
|
if (updateById(alarmRule))
|
||||||
|
@ -142,12 +142,12 @@ public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule
|
||||||
String colon = SymbolConstant.COLON;
|
String colon = SymbolConstant.COLON;
|
||||||
String prefixRule = CommonConstant.PREFIX_RULE;
|
String prefixRule = CommonConstant.PREFIX_RULE;
|
||||||
String prefixSilence = CommonConstant.PREFIX_SILENCE;
|
String prefixSilence = CommonConstant.PREFIX_SILENCE;
|
||||||
LambdaQueryWrapper<AlarmRule> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AlarmRuleAbnormal> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(AlarmRule::getEnabled,1);
|
wrapper.eq(AlarmRuleAbnormal::getEnabled,1);
|
||||||
List<AlarmRule> alarmRules = this.list(wrapper);
|
List<AlarmRuleAbnormal> alarmRules = this.list(wrapper);
|
||||||
Map<String, AlarmRule> ruleMap = new HashMap<>();
|
Map<String, AlarmRuleAbnormal> ruleMap = new HashMap<>();
|
||||||
Map<String, Long> silenceMap = new HashMap<>();
|
Map<String, Long> silenceMap = new HashMap<>();
|
||||||
for (AlarmRule alarmRule : alarmRules) {
|
for (AlarmRuleAbnormal alarmRule : alarmRules) {
|
||||||
String sourceType = alarmRule.getSourceType();
|
String sourceType = alarmRule.getSourceType();
|
||||||
String ruleId = alarmRule.getId();
|
String ruleId = alarmRule.getId();
|
||||||
Long silence = alarmRule.getSilenceCycle();
|
Long silence = alarmRule.getSilenceCycle();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user