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 190e1d0..209a88d 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 @@ -1,9 +1,59 @@ package com.hnac.hzims.alarm.constants; +import com.sun.org.apache.bcel.internal.generic.NEW; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * @author ysj */ public interface AlarmConstants { - public final static String APP_NAME = "hzims-alarm"; + String APP_NAME = "hzims-alarm"; + + // 1-集中监控右侧列表 + Integer IS_RIGHT_TABULATION = 1; + // 2-集中监控弹窗 + Integer IS_SHOW_ALERT = 2; + // 3-集中监控铃铛 + Integer IS_SMALL_BELL = 3; + // 4-集中监控遮罩 + Integer IS_MASK = 4; + // 5-语音播报 + Integer IS_BROADCAST = 5; + // 6-WEB/APP消息推送 + Integer IS_PLATFORM_MESSAGE = 6; + // 7-短信推送 + Integer IS_SHORT_MESSAGE = 7; + // 8-微信公众号消息推送 + Integer IS_WX_MESSAGE = 8; + + + // 告警来源 : 0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 + Integer HZ3000_ALARM = 0; + 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); + + // 子类告警 + // HZ3000告警 : 2-告警 3-故障 5-遥测越限 13-通讯中断 14-数据异常 + // 等级告警 : 21-一级告警 22-二级告警 23-三级告警 + // 智能预警 : 30-智能预警 + // 条件告警 : 40-条件告警 + Integer WARNING = 2; + Integer FAULT = 3; + Integer OFFSIDE = 5; + Integer INTERRUPT = 13; + Integer ABNORMAL = 14; + List HZ3000_ALARAM = Arrays.asList(WARNING,FAULT,OFFSIDE,INTERRUPT,ABNORMAL); + Integer ONE_LEVEL = 21; + Integer TWO_LEVEL = 22; + Integer THREE_LEVEL = 23; + List LEVEL_ALARAM = Arrays.asList(ONE_LEVEL,TWO_LEVEL,THREE_LEVEL); + Integer EARLY = 30; + Integer CONDITION = 40; + } diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmCountVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmCountVo.java index 2645d1d..20cd0e6 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmCountVo.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmCountVo.java @@ -5,17 +5,23 @@ import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * @author ysj */ @Data public class AlarmCountVo { - @ApiModelProperty(value = "告警子类") + @ApiModelProperty(value = "告警类型") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer type; + + @ApiModelProperty(value = "告警条目数量") @JsonSerialize(nullsUsing = NullSerializer.class) - private Long type; + private Long count; - @ApiModelProperty(value = "告警条码数量") + @ApiModelProperty(value = "子类告警数量集合") @JsonSerialize(nullsUsing = NullSerializer.class) - private Integer count; + private List childs; } \ No newline at end of file diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/ChildAlarmCountVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/ChildAlarmCountVo.java new file mode 100644 index 0000000..b97e89c --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/ChildAlarmCountVo.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.alarm.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class ChildAlarmCountVo { + + @ApiModelProperty(value = "告警子类") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer type; + + @ApiModelProperty(value = "告警条目数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long count; +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigDetailMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigDetailMapper.java index adc3877..1759832 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigDetailMapper.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigDetailMapper.java @@ -2,11 +2,12 @@ package com.hnac.hzims.alarm.config.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; +import org.apache.ibatis.annotations.Param; /** * @author ysj */ public interface AlarmConfigDetailMapper extends BaseMapper { - + AlarmConfigDetailEntity isSupport(@Param(value = "code") String code, @Param(value = "source") Integer source, @Param(value = "type") Integer type); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigMapper.java index 104bbd6..5742381 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigMapper.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigMapper.java @@ -2,11 +2,14 @@ package com.hnac.hzims.alarm.config.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hnac.hzims.alarm.entity.AlarmConfigEntity; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @author ysj */ public interface AlarmConfigMapper extends BaseMapper { - -} + List exclude(@Param(value = "operate") Integer operate); +} \ 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 f97d9d6..daf7fb2 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 @@ -1,6 +1,7 @@ package com.hnac.hzims.alarm.config.service; import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; +import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import org.springblade.core.mp.base.BaseService; /** @@ -8,4 +9,5 @@ import org.springblade.core.mp.base.BaseService; */ public interface AlarmConfigDetailService extends BaseService { + 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/AlarmConfigService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigService.java index bee58ab..17ef3eb 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigService.java @@ -3,10 +3,14 @@ package com.hnac.hzims.alarm.config.service; import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import org.springblade.core.mp.base.BaseService; +import java.util.List; + /** * @author ysj */ public interface AlarmConfigService extends BaseService { + List exclude(Integer operate); + boolean isSupport(String code,Integer source,Integer type,Integer operate); } \ 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 944a7e5..0edcd3f 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 @@ -16,4 +16,15 @@ import org.springframework.stereotype.Service; @Slf4j public class AlarmConfigDetailServiceImpl extends BaseServiceImpl implements AlarmConfigDetailService { + /** + * 查询告警配置对象 + * @param code : 站点编码 + * @param source : 告警来源 + * @param type : 告警子类 + * @return + */ + @Override + public AlarmConfigDetailEntity isSupport(String code, Integer source, Integer type) { + return this.baseMapper.isSupport(code,source,type); + } } \ No newline at end of file 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 d1ed03f..cb5aac1 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,13 +1,21 @@ package com.hnac.hzims.alarm.config.service.impl; import com.hnac.hzims.alarm.config.mapper.AlarmConfigMapper; +import com.hnac.hzims.alarm.config.service.AlarmConfigDetailService; import com.hnac.hzims.alarm.config.service.AlarmConfigService; +import com.hnac.hzims.alarm.constants.AlarmConstants; +import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; import com.hnac.hzims.alarm.entity.AlarmConfigEntity; +import io.swagger.models.auth.In; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.util.List; + /** * @author ysj */ @@ -16,6 +24,18 @@ import org.springframework.stereotype.Service; @Slf4j public class AlarmConfigServiceImpl extends BaseServiceImpl implements AlarmConfigService { + private final AlarmConfigDetailService detailService; + + /** + * 排除站点 + * @param operate : 操作类型 + * @return + */ + @Override + public List exclude(Integer operate) { + return this.baseMapper.exclude(operate); + } + /** * 是否支持操作 * @param code : 站点编码 @@ -26,10 +46,45 @@ public class AlarmConfigServiceImpl extends BaseServiceImpl> counts(@RequestParam Integer type) { - return R.data(alarmService.counts(type)); + @ApiOperation(value = "告警分类数量", notes = "不需要传入参数") + public R> counts() { + return R.data(alarmService.counts()); } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index ae4e5dc..2f2ed5e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -14,5 +14,5 @@ public interface AlarmService extends BaseService { IPage alarms(AlarmEntity alarm, IPage page); - List counts(Integer type); + List counts(); } \ No newline at end of file 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 791b43a..69ff394 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 @@ -1,16 +1,25 @@ package com.hnac.hzims.alarm.show.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.alarm.config.service.AlarmConfigService; +import com.hnac.hzims.alarm.constants.AlarmConstants; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.vo.AlarmCountVo; +import com.hnac.hzims.alarm.vo.ChildAlarmCountVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; /** * @author ysj @@ -20,6 +29,8 @@ import java.util.List; @Slf4j public class AlarmServiceImpl extends BaseServiceImpl implements AlarmService { + private final AlarmConfigService configService; + /** * 查询告警列表 * @param alarm @@ -28,26 +39,110 @@ public class AlarmServiceImpl extends BaseServiceImpl */ @Override public IPage alarms(AlarmEntity alarm, IPage page) { - // 参数过滤 :站点、时间、告警来源、告警子类 - // 排除站点 + List codes = configService.exclude(AlarmConstants.IS_RIGHT_TABULATION); + // 参数过滤 :站点、告警来源、告警子类 + QueryWrapper wrapper = new QueryWrapper<>(); + if(!StringUtil.isEmpty(alarm.getStationId())){ + wrapper.eq("STATION_ID",alarm.getStationId()); + } + if(!StringUtil.isEmpty(alarm.getAlarmSource())){ + wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); + } + if(!StringUtil.isEmpty(alarm.getAlarmType())){ + wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); + } + if(!CollectionUtil.isEmpty(codes)){ + wrapper.notIn("STATION_ID",codes); + } // 查询数据 - return null; + return this.page(page,wrapper); } /** * 查询告警数量 - * @param type * @return */ @Override - public List counts(Integer type) { - // 参数过滤 :站点、时间、告警来源、告警子类 - + public List counts() { // 排除站点 + List codes = configService.exclude(AlarmConstants.IS_RIGHT_TABULATION); + + // 查询告警数据 + QueryWrapper wrapper = new QueryWrapper<>(); + if(CollectionUtil.isNotEmpty(codes)){ + wrapper.notIn("STATION_ID",codes); + } + List alarms = this.list(wrapper); // 查询数量 - return null; + return AlarmConstants.ALARAM_SOURCES.stream().map(source->{ + AlarmCountVo count = new AlarmCountVo(); + count.setType(source); + if(CollectionUtil.isNotEmpty(alarms)){ + count.setCount(0L); + }else{ + count.setCount(alarms.stream().filter(o->o.getAlarmSource().equals(source)).count()); + } + count.setChilds(this.childs(source,alarms.stream().filter(o->o.getAlarmSource().equals(source)).collect(Collectors.toList()))); + return count; + }).collect(Collectors.toList()); + } + + + /** + * 子类型数量集合 + * @param source : 源类型 + * @param collect : 源类型告警数据 + * @return + */ + private List childs(Integer source, List collect) { + // HZ3000告警 + if(AlarmConstants.HZ3000_ALARM.equals(source)){ + return AlarmConstants.HZ3000_ALARAM.stream().map(type->{ + ChildAlarmCountVo count = new ChildAlarmCountVo(); + count.setType(type); + if(CollectionUtil.isEmpty(collect)){ + count.setCount(0L); + }else{ + count.setCount(collect.stream().filter(o->o.getAlarmType().equals(type)).count()); + } + return count; + }).collect(Collectors.toList()); + // 等级告警 + }else if(AlarmConstants.LEVEL_ALARM.equals(source)){ + return AlarmConstants.LEVEL_ALARAM.stream().map(type->{ + ChildAlarmCountVo count = new ChildAlarmCountVo(); + count.setType(type); + if(CollectionUtil.isEmpty(collect)){ + count.setCount(0L); + }else{ + count.setCount(collect.stream().filter(o->o.getAlarmType().equals(type)).count()); + } + return count; + }).collect(Collectors.toList()); + // 条件告警 + }else if(AlarmConstants.CONDITION_ALARM.equals(source)){ + ChildAlarmCountVo count = new ChildAlarmCountVo(); + count.setType(AlarmConstants.CONDITION); + if(CollectionUtil.isEmpty(collect)){ + count.setCount(0L); + }else{ + count.setCount((long) collect.size()); + } + return Collections.singletonList(count); + // 智能预警 + }else if(AlarmConstants.EARLY_WARNING.equals(source)){ + ChildAlarmCountVo count = new ChildAlarmCountVo(); + count.setType(AlarmConstants.EARLY); + if(CollectionUtil.isEmpty(collect)){ + count.setCount(0L); + }else{ + count.setCount((long) collect.size()); + } + return Collections.singletonList(count); + } + return new ArrayList<>(); } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigDetatilMapper.xml b/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigDetatilMapper.xml index 7604d5f..d29dafa 100644 --- a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigDetatilMapper.xml +++ b/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigDetatilMapper.xml @@ -2,4 +2,15 @@ + diff --git a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigMapper.xml b/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigMapper.xml index 93ea6b4..7692ae7 100644 --- a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigMapper.xml +++ b/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigMapper.xml @@ -2,4 +2,22 @@ +