Browse Source

#云服务告警弹框

zhongwei
yang_shj 5 months ago
parent
commit
30a7f8f152
  1. 28
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java
  2. 21
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java
  3. 14
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java
  4. 10
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java
  5. 59
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
  6. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java
  7. 7
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java
  8. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java
  9. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java

28
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java

@ -0,0 +1,28 @@
package com.hnac.hzims.alarm.show.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author ysj
* @date 2023/03/17 10:02:33
* @version 4.0.0
*/
@Data
public class ShowQueryVo {
@ApiModelProperty(value = "站点编号")
private String stationId;
@ApiModelProperty(value = "站点类型")
private Integer serveType;
@ApiModelProperty(value = "告警类型 :0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 4-视频预警 5-开关机告警")
private Integer alarmSource;
@ApiModelProperty(value = "告警子类")
private Integer alarmType;
}

21
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java

@ -0,0 +1,21 @@
package com.hnac.hzims.business.ws.alart.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "告警弹框参数", description = "")
public class AlartParamVo {
@ApiModelProperty("站点类型: 2-云服务 1-代运维")
private Integer serveType;
@ApiModelProperty("用户权限机构集合")
private List<Long> depts;
}

14
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java

@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.show.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.show.vo.ShowQueryVo;
import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.source.service.SystemAlarmService;
import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.alarm.config.vo.AlarmCountVo; import com.hnac.hzims.alarm.config.vo.AlarmCountVo;
@ -36,22 +37,23 @@ public class ShowAlarmController extends BladeController {
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "播报告警", notes = "传入:时间区间") @ApiOperation(value = "播报告警", notes = "传入:时间区间")
public R<List<AlarmEntity>> broadcast(@ApiParam(value = "开始时间") String startTime, public R<List<AlarmEntity>> broadcast(@ApiParam(value = "开始时间") String startTime,
@ApiParam(value = "结束时间", required = true) String endTime) { @ApiParam(value = "结束时间", required = true) String endTime,
return R.data(alarmService.broadcast(startTime,endTime)); @ApiParam(value = "站点类型") Integer serveType) {
return R.data(alarmService.broadcast(startTime,endTime,serveType));
} }
@PostMapping("/show") @PostMapping("/show")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
@ApiOperation(value = "告警列表分页", notes = "传入: AlarmConfigEntity对象,分页参数") @ApiOperation(value = "告警列表分页", notes = "传入: AlarmConfigEntity对象,分页参数")
public R<IPage<AlarmEntity>> alarms(AlarmEntity alarm, Query query) { public R<IPage<AlarmEntity>> alarms(ShowQueryVo showQuery, Query query) {
return R.data(alarmService.alarms(alarm,Condition.getPage(query))); return R.data(alarmService.alarms(showQuery,Condition.getPage(query)));
} }
@PostMapping("/count") @PostMapping("/count")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
@ApiOperation(value = "告警分类数量", notes = "不需要传入参数") @ApiOperation(value = "告警分类数量", notes = "不需要传入参数")
public R<List<AlarmCountVo>> counts(@RequestBody AlarmEntity alarm) { public R<List<AlarmCountVo>> counts(@RequestBody ShowQueryVo showCount) {
return R.data(alarmService.counts(alarm)); return R.data(alarmService.counts(showCount));
} }
@GetMapping("/getVideosByStationAndRealId") @GetMapping("/getVideosByStationAndRealId")

10
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java

@ -3,6 +3,8 @@ package com.hnac.hzims.alarm.show.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.config.vo.AlarmCountVo; import com.hnac.hzims.alarm.config.vo.AlarmCountVo;
import com.hnac.hzims.alarm.show.vo.ShowQueryVo;
import com.hnac.hzims.business.ws.alart.vo.AlartParamVo;
import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.TextMessage;
@ -14,13 +16,13 @@ import java.util.List;
*/ */
public interface AlarmService extends BaseService<AlarmEntity> { public interface AlarmService extends BaseService<AlarmEntity> {
IPage<AlarmEntity> alarms(AlarmEntity alarm, IPage<AlarmEntity> page); IPage<AlarmEntity> alarms(ShowQueryVo showQuery, IPage<AlarmEntity> page);
List<AlarmCountVo> counts(AlarmEntity alarm); List<AlarmCountVo> counts(ShowQueryVo showCount);
List<AlarmEntity> broadcast(String startTime, String endTime); List<AlarmEntity> broadcast(String startTime, String endTime,Integer serveType);
TextMessage majorAlarm(List<Long> depts); TextMessage majorAlarm(AlartParamVo param);
/** /**
* 根据站点realId 获取视频列表 * 根据站点realId 获取视频列表

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

@ -9,9 +9,11 @@ import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.mapper.AlarmMapper;
import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmHandleService;
import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.alarm.show.vo.ShowQueryVo;
import com.hnac.hzims.alarm.source.service.MessageService; import com.hnac.hzims.alarm.source.service.MessageService;
import com.hnac.hzims.alarm.config.vo.AlarmCountVo; import com.hnac.hzims.alarm.config.vo.AlarmCountVo;
import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo; import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo;
import com.hnac.hzims.business.ws.alart.vo.AlartParamVo;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IEmInfoClient;
@ -31,6 +33,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
@ -66,13 +69,13 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
/** /**
* 查询告警列表 * 查询告警列表
* @param alarm * @param showQuery
* @param page * @param page
* @return * @return
*/ */
@Override @Override
public IPage<AlarmEntity> alarms(AlarmEntity alarm, IPage<AlarmEntity> page) { public IPage<AlarmEntity> alarms(ShowQueryVo showQuery, IPage<AlarmEntity> page) {
List<StationEntity> stations = this.stations(); List<StationEntity> stations = this.stations(showQuery.getServeType());
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return page; return page;
} }
@ -83,14 +86,14 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
wrapper.eq("IS_RIGHT_TABULATION",0); wrapper.eq("IS_RIGHT_TABULATION",0);
wrapper.eq("STATUS",0); wrapper.eq("STATUS",0);
wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
if(!StringUtil.isEmpty(alarm.getStationId())){ if(!StringUtil.isEmpty(showQuery.getStationId())){
wrapper.eq("STATION_ID",alarm.getStationId()); wrapper.eq("STATION_ID",showQuery.getStationId());
} }
if(!StringUtil.isEmpty(alarm.getAlarmSource())){ if(!StringUtil.isEmpty(showQuery.getAlarmSource())){
wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); wrapper.eq("ALARM_SOURCE",showQuery.getAlarmSource());
} }
if(!StringUtil.isEmpty(alarm.getAlarmType())){ if(!StringUtil.isEmpty(showQuery.getAlarmType())){
wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); wrapper.eq("ALARM_TYPE",showQuery.getAlarmType());
} }
// 处理告警过滤 :当天处理告警 // 处理告警过滤 :当天处理告警
@ -107,9 +110,11 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
* 获取权限站点 * 获取权限站点
* @return * @return
*/ */
private List<StationEntity> stations() { private List<StationEntity> stations(Integer serveType) {
StationEntity station = new StationEntity(); StationEntity station = new StationEntity();
//station.setServeType("2"); if(ObjectUtil.isNotEmpty(serveType)){
station.setServeType(String.valueOf(serveType));
}
station.setType(0); station.setType(0);
R<List<StationEntity>> result = stationClient.list(station); R<List<StationEntity>> result = stationClient.list(station);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
@ -123,9 +128,9 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
* @return * @return
*/ */
@Override @Override
public List<AlarmCountVo> counts(AlarmEntity alarm) { public List<AlarmCountVo> counts(ShowQueryVo showCount) {
// 站点查询 // 站点查询
List<StationEntity> stations = this.stations(); List<StationEntity> stations = this.stations(showCount.getServeType());
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return AlarmConstants.ALARAM_SOURCE.stream().map(source->{ return AlarmConstants.ALARAM_SOURCE.stream().map(source->{
AlarmCountVo count = new AlarmCountVo(); AlarmCountVo count = new AlarmCountVo();
@ -140,14 +145,14 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
wrapper.eq("IS_RIGHT_TABULATION",0); wrapper.eq("IS_RIGHT_TABULATION",0);
wrapper.eq("STATUS",0); wrapper.eq("STATUS",0);
wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
if(!StringUtil.isEmpty(alarm.getStationId())){ if(!StringUtil.isEmpty(showCount.getStationId())){
wrapper.eq("STATION_ID",alarm.getStationId()); wrapper.eq("STATION_ID",showCount.getStationId());
} }
if(!StringUtil.isEmpty(alarm.getAlarmSource())){ if(!StringUtil.isEmpty(showCount.getAlarmSource())){
wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); wrapper.eq("ALARM_SOURCE",showCount.getAlarmSource());
} }
if(!StringUtil.isEmpty(alarm.getAlarmType())){ if(!StringUtil.isEmpty(showCount.getAlarmType())){
wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); wrapper.eq("ALARM_TYPE",showCount.getAlarmType());
} }
// 处理告警过滤 :当天处理告警 // 处理告警过滤 :当天处理告警
List<String> handles = alarmHandleService.handles(); List<String> handles = alarmHandleService.handles();
@ -177,9 +182,9 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
* @return * @return
*/ */
@Override @Override
public List<AlarmEntity> broadcast(String startTime, String endTime) { public List<AlarmEntity> broadcast(String startTime, String endTime,Integer serveType) {
// 站点查询 // 站点查询
List<StationEntity> stations = this.stations(); List<StationEntity> stations = this.stations(serveType);
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -197,17 +202,17 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
/** /**
* 弹框告警 * 弹框告警
* @param depts * @param param
* @return * @return
*/ */
@Override @Override
public TextMessage majorAlarm(List<Long> depts) { public TextMessage majorAlarm(AlartParamVo param) {
// 站点查询 // 站点查询
List<StationEntity> stations = this.stations(); List<StationEntity> stations = this.stations(param.getServeType());
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){
return new TextMessage(new ArrayList().toString()); return new TextMessage(new ArrayList().toString());
} }
List<String> effectives = stations.stream().filter(station->depts.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); List<String> effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList());
if(CollectionUtil.isEmpty(effectives)){ if(CollectionUtil.isEmpty(effectives)){
return new TextMessage(new ArrayList().toString()); return new TextMessage(new ArrayList().toString());
} }
@ -245,8 +250,8 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
String emCodes = emInfoList.stream().parallel() String emCodes = emInfoList.stream().parallel()
.filter(this::isBandingVideoByEmCode) .filter(this::isBandingVideoByEmCode)
.filter(this::isDeviceCodeExist) .filter(this::isDeviceCodeExist)
.filter(em -> this.isRealIdBanding(realId, em.getNumber()))
.map(EmInfoEntity::getNumber) .map(EmInfoEntity::getNumber)
.filter(number -> this.isRealIdBanding(realId, number))
.collect(Collectors.joining(",")); .collect(Collectors.joining(","));
Assert.isTrue(StringUtil.isNotBlank(emCodes) && Func.isNotEmpty(emCodes), () -> { Assert.isTrue(StringUtil.isNotBlank(emCodes) && Func.isNotEmpty(emCodes), () -> {
throw new ServiceException("未获取到设备!"); throw new ServiceException("未获取到设备!");

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java

@ -82,11 +82,7 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
if (CollectionUtil.isEmpty(alarms)) { if (CollectionUtil.isEmpty(alarms)) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<AlarmEntity> res = alarms.stream().map(s -> { return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList());
AlarmEntity entity = getAlarmEntity(s);
return entity;
}).collect(Collectors.toList());
return res;
} }
private AlarmEntity getAlarmEntity(LevelVo level) { private AlarmEntity getAlarmEntity(LevelVo level) {

7
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java

@ -2,6 +2,7 @@ package com.hnac.hzims.alarm.ws.alart;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.business.ws.alart.vo.AlartParamVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
@ -57,11 +58,11 @@ public class AlarmHandler extends TextWebSocketHandler {
if(StringUtil.isBlank(message)){ if(StringUtil.isBlank(message)){
return; return;
} }
List<Long> depts = JSONObject.parseArray(message,Long.class); AlartParamVo param = JSONObject.parseObject(message,AlartParamVo.class);
if(CollectionUtil.isEmpty(depts)){ if(ObjectUtil.isEmpty(param)){
return; return;
} }
TextMessage sendMessage = alarmService.majorAlarm(depts); TextMessage sendMessage = alarmService.majorAlarm(param);
session.sendMessage(sendMessage); session.sendMessage(sendMessage);
} }
} }

3
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java

@ -32,6 +32,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -165,7 +166,7 @@ public class AlarmServiceImpl implements AlarmService {
alarm.setAlarmContext(station.getName() + "." + real.getDeviceName() + "_开机"); alarm.setAlarmContext(station.getName() + "." + real.getDeviceName() + "_开机");
} }
alarm.setStatus(0); alarm.setStatus(0);
alarm.setAlarmTime(new Date()); //alarm.setAlarmTime(new Date());
if(ObjectUtil.isEmpty(defaultConfig)){ if(ObjectUtil.isEmpty(defaultConfig)){
alarm.setIsRightTabulation(0); alarm.setIsRightTabulation(0);
alarm.setIsShowAlert(1); alarm.setIsShowAlert(1);

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java

@ -138,9 +138,7 @@ public class DeptServiceImpl implements IDeptService {
*/ */
@Override @Override
public List<Long> alarmDeptByCurrentUser() { public List<Long> alarmDeptByCurrentUser() {
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getType,HomePageConstant.HYDROPOWER));
.eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE)
);
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>(); return new ArrayList<>();
} }

Loading…
Cancel
Save