From 69951ba9e5f9bd7e59ba71520fec19eb59c0b2cb Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 14 Sep 2023 17:17:09 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E4=BB=A3=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/alarm/constants/AlarmConstants.java | 2 +- .../alarm/entity/AlarmConfigDetailEntity.java | 2 +- .../hnac/hzims/alarm/vo/AlarmConfigChildVo.java | 19 ++++++ .../hnac/hzims/alarm/vo/AlarmConfigSourceVo.java | 19 ++++++ .../config/controller/AlarmConfigController.java | 2 +- .../controller/AlarmConfigDetailController.java | 57 +++--------------- .../config/service/AlarmConfigDetailService.java | 6 +- .../service/impl/AlarmConfigDetailServiceImpl.java | 67 +++++++++++++++++----- .../service/impl/AlarmConfigServiceImpl.java | 16 ++++-- .../alarm/show/service/impl/AlarmServiceImpl.java | 2 +- 10 files changed, 119 insertions(+), 73 deletions(-) create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigChildVo.java create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigSourceVo.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java index 0a8e725..2b2c366 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java +++ b/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 ALARAM_SOURCES = Arrays.asList(HZ3000_ALARM,LEVEL_ALARM,CONDITION_ALARM,EARLY_WARNING); + List ALARAM_SOURCE = Arrays.asList(HZ3000_ALARM,LEVEL_ALARM,CONDITION_ALARM,EARLY_WARNING); // 子类告警 // HZ3000告警 : 2-告警 3-故障 5-遥测越限 13-通讯中断 14-数据异常 diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java index d662706..8f7bc65 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/entity/AlarmConfigDetailEntity.java +++ b/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; diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigChildVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigChildVo.java new file mode 100644 index 0000000..cec0bfb --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigSourceVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmConfigSourceVo.java new file mode 100644 index 0000000..ca11fd6 --- /dev/null +++ b/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 childs; +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java index 5e17b6f..925b8e3 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigController.java +++ b/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> list(@ApiIgnore @RequestParam AlarmConfigEntity params, Query query) { + public R> list(AlarmConfigEntity params, Query query) { return R.data(alarmConfigService.pageCondition(Condition.getPage(query), params)); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigDetailController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigDetailController.java index c8d82ab..a81f12d 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/controller/AlarmConfigDetailController.java +++ b/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> list(@ApiIgnore @RequestParam Map params, Query query) { - QueryWrapper queryWrapper = Condition.getQueryWrapper( params, AlarmConfigDetailEntity.class); - IPage pages = detailService.page(Condition.getPage(query), queryWrapper); - return R.data(pages); - } - - @GetMapping("/detail") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "详情", notes = "传入AlarmConfigEntity对象") - public R detail(AlarmConfigDetailEntity entity) { - AlarmConfigDetailEntity detail = detailService.getOne(Condition.getQueryWrapper(entity)); - return R.data(detail); - } - -} +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java index 4627afa..d5b6bbc 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java +++ b/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 details(Long configId); + AlarmConfigDetailEntity isSupport(String code, Integer source, Integer type); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java index 9bb0635..8fa344d 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java +++ b/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 batchs = new ArrayList<>(); - AlarmConstants.ALARAM_SOURCES.forEach(sources->{ + List 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 details(Long configId) { + if(ObjectUtil.isEmpty(configId)){ + throw new ServiceException("请选择告警配置查看详情!"); + } + List details = this.list(Wrappers.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 : 告警来源 diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java index 59365e0..6bc0e46 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigServiceImpl.java +++ b/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 BaseServiceImpllambdaQuery() + .eq(AlarmConfigEntity::getStationId,entity.getStationId())); + if(ObjectUtil.isNotEmpty(config)){ + throw new ServiceException("站点已添加告警配置!"); + } // 保存配置 this.save(entity); // 创建各类型告警配置 diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 98c364c..c5df876 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/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 List 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)){