From 6e0611662068b11c2f02b1f767178481f78e9fb7 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 2 Jul 2024 08:39:40 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=A2=9E=E5=8A=A0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=B1=BB=E5=9E=8B=E7=AB=99=E7=82=B9=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/show/vo/ShowQueryVo.java | 28 ++++++++++ .../hzims/business/ws/alart/vo/AlartParamVo.java | 21 ++++++++ .../alarm/show/controller/ShowAlarmController.java | 14 ++--- .../hzims/alarm/show/service/AlarmService.java | 10 ++-- .../alarm/show/service/impl/AlarmServiceImpl.java | 59 +++++++++++----------- .../hnac/hzims/alarm/ws/alart/AlarmHandler.java | 9 ++-- 6 files changed, 97 insertions(+), 44 deletions(-) create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java new file mode 100644 index 0000000..bee063e --- /dev/null +++ b/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; +} + diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java new file mode 100644 index 0000000..06123de --- /dev/null +++ b/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 depts; +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index 42f8dd8..b8aec8c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; +import com.hnac.hzims.alarm.show.vo.ShowQueryVo; import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; @@ -37,22 +38,23 @@ public class ShowAlarmController extends BladeController { @ApiOperationSupport(order = 1) @ApiOperation(value = "播报告警", notes = "传入:时间区间") public R> broadcast(@ApiParam(value = "开始时间") String startTime, - @ApiParam(value = "结束时间", required = true) String endTime) { - return R.data(alarmService.broadcast(startTime,endTime)); + @ApiParam(value = "结束时间", required = true) String endTime, + @ApiParam(value = "站点类型") Integer serveType) { + return R.data(alarmService.broadcast(startTime,endTime,serveType)); } @PostMapping("/show") @ApiOperationSupport(order = 2) @ApiOperation(value = "告警列表分页", notes = "传入: AlarmConfigEntity对象,分页参数") - public R> alarms(AlarmEntity alarm, Query query) { - return R.data(alarmService.alarms(alarm,Condition.getPage(query))); + public R> alarms(ShowQueryVo showQuery, Query query) { + return R.data(alarmService.alarms(showQuery,Condition.getPage(query))); } @PostMapping("/count") @ApiOperationSupport(order = 3) @ApiOperation(value = "告警分类数量", notes = "不需要传入参数") - public R> counts(@RequestBody AlarmEntity alarm) { - return R.data(alarmService.counts(alarm)); + public R> counts(@RequestBody ShowQueryVo showCount) { + return R.data(alarmService.counts(showCount)); } @GetMapping("/alarmVideos") 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 e37fbfa..064489d 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 @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; +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 org.springblade.core.mp.base.BaseService; import org.springframework.web.socket.TextMessage; @@ -15,13 +17,13 @@ import java.util.List; */ public interface AlarmService extends BaseService { - IPage alarms(AlarmEntity alarm, IPage page); + IPage alarms(ShowQueryVo showQuery, IPage page); - List counts(AlarmEntity alarm); + List counts(ShowQueryVo showCount); - List broadcast(String startTime, String endTime); + List broadcast(String startTime, String endTime,Integer serveType); - TextMessage majorAlarm(List depts); + TextMessage majorAlarm(AlartParamVo param); List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType); } \ 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 10aa732..2e69bc6 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 @@ -13,7 +13,9 @@ import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; +import com.hnac.hzims.alarm.show.vo.ShowQueryVo; import com.hnac.hzims.alarm.source.service.MessageService; +import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; @@ -29,7 +31,6 @@ import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceEventVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; -import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -37,14 +38,12 @@ import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import org.springframework.util.Assert; import org.springframework.web.socket.TextMessage; import java.util.*; @@ -83,13 +82,13 @@ public class AlarmServiceImpl extends BaseServiceImpl /** * 查询告警列表 - * @param alarm + * @param showQuery * @param page * @return */ @Override - public IPage alarms(AlarmEntity alarm, IPage page) { - List stations = this.stations(); + public IPage alarms(ShowQueryVo showQuery, IPage page) { + List stations = this.stations(showQuery.getServeType()); if(CollectionUtil.isEmpty(stations)){ return page; } @@ -100,14 +99,14 @@ public class AlarmServiceImpl extends BaseServiceImpl wrapper.eq("IS_RIGHT_TABULATION",0); wrapper.eq("STATUS",0); wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - if(!StringUtil.isEmpty(alarm.getStationId())){ - wrapper.eq("STATION_ID",alarm.getStationId()); + if(!StringUtil.isEmpty(showQuery.getStationId())){ + wrapper.eq("STATION_ID",showQuery.getStationId()); } - if(!StringUtil.isEmpty(alarm.getAlarmSource())){ - wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); + if(!StringUtil.isEmpty(showQuery.getAlarmSource())){ + wrapper.eq("ALARM_SOURCE",showQuery.getAlarmSource()); } - if(!StringUtil.isEmpty(alarm.getAlarmType())){ - wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); + if(!StringUtil.isEmpty(showQuery.getAlarmType())){ + wrapper.eq("ALARM_TYPE",showQuery.getAlarmType()); } // 处理告警过滤 :当天处理告警 @@ -124,9 +123,11 @@ public class AlarmServiceImpl extends BaseServiceImpl * 获取权限站点 * @return */ - private List stations() { + private List stations(Integer serveType) { StationEntity station = new StationEntity(); - station.setServeType("2"); + if(ObjectUtil.isNotEmpty(serveType)){ + station.setServeType(String.valueOf(serveType)); + } station.setType(0); R> result = stationClient.list(station); if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ @@ -140,9 +141,9 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List counts(AlarmEntity alarm) { + public List counts(ShowQueryVo showCount) { // 站点查询 - List stations = this.stations(); + List stations = this.stations(showCount.getServeType()); if(CollectionUtil.isEmpty(stations)){ return AlarmConstants.ALARAM_SOURCE.stream().map(source->{ AlarmCountVo count = new AlarmCountVo(); @@ -157,14 +158,14 @@ public class AlarmServiceImpl extends BaseServiceImpl wrapper.eq("IS_RIGHT_TABULATION",0); wrapper.eq("STATUS",0); wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - if(!StringUtil.isEmpty(alarm.getStationId())){ - wrapper.eq("STATION_ID",alarm.getStationId()); + if(!StringUtil.isEmpty(showCount.getStationId())){ + wrapper.eq("STATION_ID",showCount.getStationId()); } - if(!StringUtil.isEmpty(alarm.getAlarmSource())){ - wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); + if(!StringUtil.isEmpty(showCount.getAlarmSource())){ + wrapper.eq("ALARM_SOURCE",showCount.getAlarmSource()); } - if(!StringUtil.isEmpty(alarm.getAlarmType())){ - wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); + if(!StringUtil.isEmpty(showCount.getAlarmType())){ + wrapper.eq("ALARM_TYPE",showCount.getAlarmType()); } // 处理告警过滤 :当天处理告警 List handles = alarmHandleService.handles(); @@ -194,9 +195,9 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List broadcast(String startTime, String endTime) { + public List broadcast(String startTime, String endTime,Integer serveType) { // 站点查询 - List stations = this.stations(); + List stations = this.stations(serveType); if(CollectionUtil.isEmpty(stations)){ return new ArrayList<>(); } @@ -214,17 +215,17 @@ public class AlarmServiceImpl extends BaseServiceImpl /** * 弹框告警 - * @param depts + * @param param * @return */ @Override - public TextMessage majorAlarm(List depts) { + public TextMessage majorAlarm(AlartParamVo param) { // 站点查询 - List stations = this.stations(); - if(CollectionUtil.isEmpty(stations)){ + List stations = this.stations(param.getServeType()); + if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){ return new TextMessage(new ArrayList().toString()); } - List effectives = stations.stream().filter(station->depts.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); + List effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); if(CollectionUtil.isEmpty(effectives)){ return new TextMessage(new ArrayList().toString()); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java index 373ef43..f6052a0 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java @@ -2,8 +2,8 @@ package com.hnac.hzims.alarm.ws.alart; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -13,7 +13,6 @@ import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; -import java.util.List; /** * @author ysj @@ -57,11 +56,11 @@ public class AlarmHandler extends TextWebSocketHandler { if(StringUtil.isBlank(message)){ return; } - List depts = JSONObject.parseArray(message,Long.class); - if(CollectionUtil.isEmpty(depts)){ + AlartParamVo param = JSONObject.parseObject(message,AlartParamVo.class); + if(ObjectUtil.isEmpty(param)){ return; } - TextMessage sendMessage = alarmService.majorAlarm(depts); + TextMessage sendMessage = alarmService.majorAlarm(param); session.sendMessage(sendMessage); } }