Browse Source

#告警代码修改

zhongwei
yang_shj 1 year ago
parent
commit
69951ba9e5
  1. 2
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java
  2. 2
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java
  3. 19
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigChildVo.java
  4. 19
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigSourceVo.java
  5. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java
  6. 55
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigDetailController.java
  7. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java
  8. 67
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java
  9. 16
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java
  10. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

2
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java

@ -33,7 +33,7 @@ public interface AlarmConstants {
Integer LEVEL_ALARM = 1;
Integer CONDITION_ALARM = 2;
Integer EARLY_WARNING = 3;
List<Integer> ALARAM_SOURCES = Arrays.asList(HZ3000_ALARM,LEVEL_ALARM,CONDITION_ALARM,EARLY_WARNING);
List<Integer> ALARAM_SOURCE = Arrays.asList(HZ3000_ALARM,LEVEL_ALARM,CONDITION_ALARM,EARLY_WARNING);
// 子类告警
// HZ3000告警 : 2-告警 3-故障 5-遥测越限 13-通讯中断 14-数据异常

2
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java

@ -24,7 +24,7 @@ public class AlarmConfigDetailEntity extends TenantEntity {
private Long strategyId;
@ApiModelProperty(value = "告警大类")
private String alarmtype;
private Integer alarmType;
@ApiModelProperty(value = "告警子类")
private Integer alarmChiledType;

19
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigChildVo.java

@ -0,0 +1,19 @@
package com.hnac.hzims.alarm.vo;
import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class AlarmConfigChildVo {
@ApiModelProperty(value = "告警类型")
private Integer type;
@ApiModelProperty(value = "告警类型")
private AlarmConfigDetailEntity detail;
}

19
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigSourceVo.java

@ -0,0 +1,19 @@
package com.hnac.hzims.alarm.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
public class AlarmConfigSourceVo {
@ApiModelProperty(value = "告警来源")
private Integer source;
@ApiModelProperty(value = "告警子类")
private List<AlarmConfigChildVo> childs;
}

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java

@ -54,7 +54,7 @@ public class AlarmConfigController extends BladeController {
@GetMapping("/list")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "分页", notes = "传入AlarmConfigEntity对象")
public R<IPage<AlarmConfigVo>> list(@ApiIgnore @RequestParam AlarmConfigEntity params, Query query) {
public R<IPage<AlarmConfigVo>> list(AlarmConfigEntity params, Query query) {
return R.data(alarmConfigService.pageCondition(Condition.getPage(query), params));
}

55
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigDetailController.java

@ -1,24 +1,17 @@
package com.hnac.hzims.alarm.config.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity;
import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.Map;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ysj
@ -31,43 +24,11 @@ public class AlarmConfigDetailController extends BladeController {
private final AlarmConfigDetailService detailService;
@PostMapping("/save")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "新增", notes = "传入AlarmConfigEntity对象")
public R save(@Valid @RequestBody AlarmConfigDetailEntity entity) {
return R.status(detailService.save(entity));
}
@PostMapping("/update")
@GetMapping("/details")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "修改", notes = "传入AlarmConfigEntity对象")
public R update(@Valid @RequestBody AlarmConfigDetailEntity entity) {
return R.status(detailService.updateById(entity));
}
@PostMapping("/remove")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(detailService.deleteLogic(Func.toLongList(ids)));
@ApiOperation(value = "告警配置详情", notes = "传入告警配置id")
public R details(@ApiParam(value = "主键集合", required = true) @RequestParam Long configId) {
return R.data(detailService.details(configId));
}
@GetMapping("/list")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "分页", notes = "传入AlarmConfigEntity对象")
public R<IPage<AlarmConfigDetailEntity>> list(@ApiIgnore @RequestParam Map<String,Object> params, Query query) {
QueryWrapper<AlarmConfigDetailEntity> queryWrapper = Condition.getQueryWrapper( params, AlarmConfigDetailEntity.class);
IPage<AlarmConfigDetailEntity> pages = detailService.page(Condition.getPage(query), queryWrapper);
return R.data(pages);
}
@GetMapping("/detail")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "详情", notes = "传入AlarmConfigEntity对象")
public R<AlarmConfigDetailEntity> detail(AlarmConfigDetailEntity entity) {
AlarmConfigDetailEntity detail = detailService.getOne(Condition.getQueryWrapper(entity));
return R.data(detail);
}
}

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java

@ -2,8 +2,11 @@ package com.hnac.hzims.alarm.config.service;
import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity;
import com.hnac.hzims.alarm.entity.AlarmConfigEntity;
import com.hnac.hzims.alarm.vo.AlarmConfigSourceVo;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* @author ysj
*/
@ -11,6 +14,7 @@ public interface AlarmConfigDetailService extends BaseService<AlarmConfigDetailE
boolean defaults(AlarmConfigEntity entity);
AlarmConfigDetailEntity isSupport(String code, Integer source, Integer type);
List<AlarmConfigSourceVo> details(Long configId);
AlarmConfigDetailEntity isSupport(String code, Integer source, Integer type);
}

67
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java

@ -1,20 +1,27 @@
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.service.AlarmConfigDetailService;
import com.hnac.hzims.alarm.constants.AlarmConstants;
import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity;
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.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
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.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author ysj
@ -31,23 +38,23 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl<AlarmConfigDet
@Override
public boolean defaults(AlarmConfigEntity entity) {
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告警
if(AlarmConstants.HZ3000_ALARM.equals(sources)){
AlarmConstants.HZ3000_ALARAM_LIST.forEach(type->{
batchs.add(this.superposition(entity,type));
});
if(AlarmConstants.HZ3000_ALARM.toString().equals(source.getDictValue())){
AlarmConstants.HZ3000_ALARAM_LIST.forEach(type-> batchs.add(this.superposition(entity,Integer.valueOf(source.getDictValue()),type)));
// 等级告警
}else if(AlarmConstants.LEVEL_ALARM.equals(sources)){
AlarmConstants.LEVEL_ALARAM.forEach(type->{
batchs.add(this.superposition(entity,type));
});
}else if(AlarmConstants.LEVEL_ALARM.toString().equals(source.getDictValue())){
AlarmConstants.LEVEL_ALARAM.forEach(type-> batchs.add(this.superposition(entity,Integer.valueOf(source.getDictValue()),type)));
// 条件告警
}else if(AlarmConstants.CONDITION_ALARM.equals(sources)){
batchs.add(this.superposition(entity,AlarmConstants.CONDITION));
}else if(AlarmConstants.CONDITION_ALARM.toString().equals(source.getDictValue())){
batchs.add(this.superposition(entity, Integer.valueOf(source.getDictValue()),AlarmConstants.CONDITION));
// 智能预警
}else if(AlarmConstants.EARLY_WARNING.equals(sources)){
batchs.add(this.superposition(entity,AlarmConstants.EARLY));
}else if(AlarmConstants.EARLY_WARNING.toString().equals(source.getDictValue())){
batchs.add(this.superposition(entity,Integer.valueOf(source.getDictValue()),AlarmConstants.EARLY));
}
});
if(CollectionUtil.isEmpty(batchs)){
@ -62,11 +69,12 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl<AlarmConfigDet
* @param type
* @return
*/
private AlarmConfigDetailEntity superposition(AlarmConfigEntity entity, Integer type) {
private AlarmConfigDetailEntity superposition(AlarmConfigEntity entity,Integer source, Integer type) {
AlarmConfigDetailEntity detail = new AlarmConfigDetailEntity();
BeanUtils.copyProperties(entity,detail);
detail.setId(null);
detail.setStrategyId(entity.getId());
detail.setAlarmType(source);
detail.setAlarmChiledType(type);
detail.setIsRightTabulation(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 source : 告警来源

16
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java

@ -1,8 +1,7 @@
package com.hnac.hzims.alarm.config.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.alarm.config.mapper.AlarmConfigMapper;
import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService;
import com.hnac.hzims.alarm.config.service.AlarmConfigService;
@ -11,13 +10,11 @@ import com.hnac.hzims.alarm.constants.AlarmConstants;
import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity;
import com.hnac.hzims.alarm.entity.AlarmConfigEntity;
import com.hnac.hzims.alarm.vo.AlarmConfigVo;
import com.hnac.hzims.operational.alert.vo.AlarmHandleVo;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
@ -41,6 +38,15 @@ public class AlarmConfigServiceImpl extends BaseServiceImpl<AlarmConfigMapper, A
*/
@Override
public boolean add(AlarmConfigEntity entity) {
if(ObjectUtil.isEmpty(entity) || StringUtil.isEmpty(entity.getStationId())){
throw new ServiceException("请选择站点再进行添加告警配置!");
}
// 查询站点是否保存记录
AlarmConfigEntity config = this.getOne(Wrappers.<AlarmConfigEntity>lambdaQuery()
.eq(AlarmConfigEntity::getStationId,entity.getStationId()));
if(ObjectUtil.isNotEmpty(config)){
throw new ServiceException("站点已添加告警配置!");
}
// 保存配置
this.save(entity);
// 创建各类型告警配置

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

@ -77,7 +77,7 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
List<AlarmEntity> alarms = this.list(wrapper);
// 查询数量
return AlarmConstants.ALARAM_SOURCES.stream().map(source->{
return AlarmConstants.ALARAM_SOURCE.stream().map(source->{
AlarmCountVo count = new AlarmCountVo();
count.setType(source);
if(CollectionUtil.isNotEmpty(alarms)){

Loading…
Cancel
Save