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. 57
      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 LEVEL_ALARM = 1;
Integer CONDITION_ALARM = 2; Integer CONDITION_ALARM = 2;
Integer EARLY_WARNING = 3; 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-数据异常 // 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; private Long strategyId;
@ApiModelProperty(value = "告警大类") @ApiModelProperty(value = "告警大类")
private String alarmtype; private Integer alarmType;
@ApiModelProperty(value = "告警子类") @ApiModelProperty(value = "告警子类")
private Integer alarmChiledType; 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") @GetMapping("/list")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
@ApiOperation(value = "分页", notes = "传入AlarmConfigEntity对象") @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)); return R.data(alarmConfigService.pageCondition(Condition.getPage(query), params));
} }

57
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; 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.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity;
import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService; import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController; 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.api.R;
import org.springblade.core.tool.utils.Func; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import springfox.documentation.annotations.ApiIgnore; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.Map;
/** /**
* @author ysj * @author ysj
@ -31,43 +24,11 @@ public class AlarmConfigDetailController extends BladeController {
private final AlarmConfigDetailService detailService; 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) @ApiOperationSupport(order = 2)
@ApiOperation(value = "修改", notes = "传入AlarmConfigEntity对象") @ApiOperation(value = "告警配置详情", notes = "传入告警配置id")
public R update(@Valid @RequestBody AlarmConfigDetailEntity entity) { public R details(@ApiParam(value = "主键集合", required = true) @RequestParam Long configId) {
return R.status(detailService.updateById(entity)); return R.data(detailService.details(configId));
}
@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)));
} }
}
@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.AlarmConfigDetailEntity;
import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import com.hnac.hzims.alarm.entity.AlarmConfigEntity;
import com.hnac.hzims.alarm.vo.AlarmConfigSourceVo;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import java.util.List;
/** /**
* @author ysj * @author ysj
*/ */
@ -11,6 +14,7 @@ public interface AlarmConfigDetailService extends BaseService<AlarmConfigDetailE
boolean defaults(AlarmConfigEntity entity); 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; 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 : 告警来源

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; 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.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.mapper.AlarmConfigMapper;
import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService; import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService;
import com.hnac.hzims.alarm.config.service.AlarmConfigService; 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.AlarmConfigDetailEntity;
import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import com.hnac.hzims.alarm.entity.AlarmConfigEntity;
import com.hnac.hzims.alarm.vo.AlarmConfigVo; 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.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.mp.support.Condition; 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.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -41,6 +38,15 @@ public class AlarmConfigServiceImpl extends BaseServiceImpl<AlarmConfigMapper, A
*/ */
@Override @Override
public boolean add(AlarmConfigEntity entity) { 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); 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); List<AlarmEntity> alarms = this.list(wrapper);
// 查询数量 // 查询数量
return AlarmConstants.ALARAM_SOURCES.stream().map(source->{ return AlarmConstants.ALARAM_SOURCE.stream().map(source->{
AlarmCountVo count = new AlarmCountVo(); AlarmCountVo count = new AlarmCountVo();
count.setType(source); count.setType(source);
if(CollectionUtil.isNotEmpty(alarms)){ if(CollectionUtil.isNotEmpty(alarms)){

Loading…
Cancel
Save