|
|
@ -1,20 +1,27 @@ |
|
|
|
package com.hnac.hzims.alarm.config.service.impl; |
|
|
|
package com.hnac.hzims.alarm.config.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hnac.hzims.alarm.config.mapper.AlarmConfigDetailMapper; |
|
|
|
import com.hnac.hzims.alarm.config.mapper.AlarmConfigDetailMapper; |
|
|
|
import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService; |
|
|
|
import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService; |
|
|
|
import com.hnac.hzims.alarm.constants.AlarmConstants; |
|
|
|
import com.hnac.hzims.alarm.constants.AlarmConstants; |
|
|
|
import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; |
|
|
|
import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; |
|
|
|
import com.hnac.hzims.alarm.entity.AlarmConfigEntity; |
|
|
|
import com.hnac.hzims.alarm.entity.AlarmConfigEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.alarm.vo.AlarmConfigChildVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.alarm.vo.AlarmConfigSourceVo; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
|
|
|
|
import org.springblade.system.entity.Dict; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author ysj |
|
|
|
* @author ysj |
|
|
@ -31,23 +38,23 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl<AlarmConfigDet |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean defaults(AlarmConfigEntity entity) { |
|
|
|
public boolean defaults(AlarmConfigEntity entity) { |
|
|
|
List<AlarmConfigDetailEntity> batchs = new ArrayList<>(); |
|
|
|
List<AlarmConfigDetailEntity> batchs = new ArrayList<>(); |
|
|
|
AlarmConstants.ALARAM_SOURCES.forEach(sources->{ |
|
|
|
List<Dict> sources = DictCache.getList("alarm_source"); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(sources)){ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sources.forEach(source->{ |
|
|
|
// HZ3000告警
|
|
|
|
// HZ3000告警
|
|
|
|
if(AlarmConstants.HZ3000_ALARM.equals(sources)){ |
|
|
|
if(AlarmConstants.HZ3000_ALARM.toString().equals(source.getDictValue())){ |
|
|
|
AlarmConstants.HZ3000_ALARAM_LIST.forEach(type->{ |
|
|
|
AlarmConstants.HZ3000_ALARAM_LIST.forEach(type-> batchs.add(this.superposition(entity,Integer.valueOf(source.getDictValue()),type))); |
|
|
|
batchs.add(this.superposition(entity,type)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 等级告警
|
|
|
|
// 等级告警
|
|
|
|
}else if(AlarmConstants.LEVEL_ALARM.equals(sources)){ |
|
|
|
}else if(AlarmConstants.LEVEL_ALARM.toString().equals(source.getDictValue())){ |
|
|
|
AlarmConstants.LEVEL_ALARAM.forEach(type->{ |
|
|
|
AlarmConstants.LEVEL_ALARAM.forEach(type-> batchs.add(this.superposition(entity,Integer.valueOf(source.getDictValue()),type))); |
|
|
|
batchs.add(this.superposition(entity,type)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 条件告警
|
|
|
|
// 条件告警
|
|
|
|
}else if(AlarmConstants.CONDITION_ALARM.equals(sources)){ |
|
|
|
}else if(AlarmConstants.CONDITION_ALARM.toString().equals(source.getDictValue())){ |
|
|
|
batchs.add(this.superposition(entity,AlarmConstants.CONDITION)); |
|
|
|
batchs.add(this.superposition(entity, Integer.valueOf(source.getDictValue()),AlarmConstants.CONDITION)); |
|
|
|
// 智能预警
|
|
|
|
// 智能预警
|
|
|
|
}else if(AlarmConstants.EARLY_WARNING.equals(sources)){ |
|
|
|
}else if(AlarmConstants.EARLY_WARNING.toString().equals(source.getDictValue())){ |
|
|
|
batchs.add(this.superposition(entity,AlarmConstants.EARLY)); |
|
|
|
batchs.add(this.superposition(entity,Integer.valueOf(source.getDictValue()),AlarmConstants.EARLY)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
if(CollectionUtil.isEmpty(batchs)){ |
|
|
|
if(CollectionUtil.isEmpty(batchs)){ |
|
|
@ -62,11 +69,12 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl<AlarmConfigDet |
|
|
|
* @param type |
|
|
|
* @param type |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private AlarmConfigDetailEntity superposition(AlarmConfigEntity entity, Integer type) { |
|
|
|
private AlarmConfigDetailEntity superposition(AlarmConfigEntity entity,Integer source, Integer type) { |
|
|
|
AlarmConfigDetailEntity detail = new AlarmConfigDetailEntity(); |
|
|
|
AlarmConfigDetailEntity detail = new AlarmConfigDetailEntity(); |
|
|
|
BeanUtils.copyProperties(entity,detail); |
|
|
|
BeanUtils.copyProperties(entity,detail); |
|
|
|
detail.setId(null); |
|
|
|
detail.setId(null); |
|
|
|
detail.setStrategyId(entity.getId()); |
|
|
|
detail.setStrategyId(entity.getId()); |
|
|
|
|
|
|
|
detail.setAlarmType(source); |
|
|
|
detail.setAlarmChiledType(type); |
|
|
|
detail.setAlarmChiledType(type); |
|
|
|
detail.setIsRightTabulation(1); |
|
|
|
detail.setIsRightTabulation(1); |
|
|
|
detail.setIsShowAlert(1); |
|
|
|
detail.setIsShowAlert(1); |
|
|
@ -80,6 +88,35 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl<AlarmConfigDet |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 告警配置详情 |
|
|
|
|
|
|
|
* @param configId |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<AlarmConfigSourceVo> details(Long configId) { |
|
|
|
|
|
|
|
if(ObjectUtil.isEmpty(configId)){ |
|
|
|
|
|
|
|
throw new ServiceException("请选择告警配置查看详情!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<AlarmConfigDetailEntity> details = this.list(Wrappers.<AlarmConfigDetailEntity>lambdaQuery() |
|
|
|
|
|
|
|
.eq(AlarmConfigDetailEntity::getStrategyId,configId)); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(details)){ |
|
|
|
|
|
|
|
throw new ServiceException("未查询到告警详情配置!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return details.stream().collect(Collectors.groupingBy(AlarmConfigDetailEntity::getAlarmType)).entrySet().stream().map(entry->{ |
|
|
|
|
|
|
|
AlarmConfigSourceVo source = new AlarmConfigSourceVo(); |
|
|
|
|
|
|
|
source.setSource(entry.getKey()); |
|
|
|
|
|
|
|
source.setChilds(entry.getValue().stream().map(value -> { |
|
|
|
|
|
|
|
AlarmConfigChildVo child = new AlarmConfigChildVo(); |
|
|
|
|
|
|
|
child.setType(value.getAlarmChiledType()); |
|
|
|
|
|
|
|
child.setDetail(value); |
|
|
|
|
|
|
|
return child; |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
return source; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询告警配置对象 |
|
|
|
* 查询告警配置对象 |
|
|
|
* @param code : 站点编码 |
|
|
|
* @param code : 站点编码 |
|
|
|
* @param source : 告警来源 |
|
|
|
* @param source : 告警来源 |
|
|
|