From de5eee7861e2bc6d6805b358b1818c5922c8a438 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Jul 2024 14:02:16 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=85=B3=E8=81=94=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/show/controller/ShowAlarmController.java | 4 +- .../hzims/alarm/show/service/AlarmService.java | 2 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 134 ++++++++++++++++----- 3 files changed, 110 insertions(+), 30 deletions(-) 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 4ebda2b..42f8dd8 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 @@ -61,8 +61,8 @@ public class ShowAlarmController extends BladeController { public R> alarmVideos(@ApiParam("站点编号") @RequestParam(required = false) String stationCode, @ApiParam("设备编号") @RequestParam(required = false) String deviceCode, @ApiParam("监测点ID") @RequestParam(required = false) String realId, - @ApiParam("告警类型") @RequestParam Integer alarmSource) { - return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId,alarmSource)); + @ApiParam("告警类型") @RequestParam Integer alarmType) { + return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId,alarmType)); } } \ 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 e4cf0d6..e37fbfa 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 @@ -23,5 +23,5 @@ public interface AlarmService extends BaseService { TextMessage majorAlarm(List depts); - List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmSource); + 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 5f77527..1758414 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,6 +1,7 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.constants.AlarmConstants; @@ -17,6 +18,7 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IEmVideoClient; +import com.hnac.hzims.fdp.util.HttpRequestUtil; import com.hnac.hzims.message.dto.MailMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -28,7 +30,9 @@ 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; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.api.R; @@ -38,6 +42,7 @@ 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; @@ -48,7 +53,7 @@ import java.util.stream.Collectors; /** * @author ysj */ -@AllArgsConstructor +@RequiredArgsConstructor @Service @Slf4j public class AlarmServiceImpl extends BaseServiceImpl implements AlarmService { @@ -73,6 +78,9 @@ public class AlarmServiceImpl extends BaseServiceImpl private final IStationVideoTypeClient stationVideoTypeClient; + @Value("${hzims.url.getFaultGraphInfo}") + private String FAULTGRAPH_INFO_PATH; + /** * 查询告警列表 * @param alarm @@ -427,7 +435,7 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmSource) { + public List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType) { // 步骤1、根据设备编号查询视频信息 if(StringUtil.isNotBlank(deviceCode)){ return this.deviceVideos(stationCode,deviceCode); @@ -435,33 +443,44 @@ public class AlarmServiceImpl extends BaseServiceImpl // 步骤2、根据采集点查询视频信息 if(StringUtil.isNotBlank(realId)){ // 智能预警 - if(AlarmConstants.EARLY.equals(alarmSource)){ - this.earlyVideos(stationCode,realId); + if(AlarmConstants.EARLY.equals(alarmType)){ + return this.earlyVideos(stationCode,realId); + // 通讯中断、通讯异常查询站点视频 + }else if(AlarmConstants.INTERRUPT.equals(alarmType) || AlarmConstants.ABNORMAL.equals(alarmType)){ + return this.stationVideos(stationCode); + // 其他告警 }else{ - + return this.realIdVideos(stationCode,realId); } } - - // 根据站点编号查找 - else if(StringUtil.isNotBlank(stationCode)){ - List videos = stationVideoTypeClient.listByStationId(stationCode); - if(CollectionUtil.isNotEmpty(videos)){ - return videos.stream().distinct().map(video->{ - AlarmVideoVo alarmVideo = new AlarmVideoVo(); - alarmVideo.setVideoHost(video.getVideoHost()); - alarmVideo.setVideoName(video.getName()); - alarmVideo.setVideoAppKey(video.getAppKey()); - alarmVideo.setVideoAppSecret(video.getAppSecret()); - alarmVideo.setPointCode(video.getPointCode()); - return alarmVideo; - }).collect(Collectors.toList()); - }else{ - // 站点不存在视频 - } + // 步骤3.根据站点编号查询视频信息 + if(StringUtil.isNotBlank(stationCode)){ + return this.stationVideos(stationCode); } throw new ServiceException("未查询到告警视频信息!"); } + /** + *查询站点绑定视频信息 + * @param stationCode + */ + private List stationVideos(String stationCode) { + List videos = stationVideoTypeClient.listByStationId(stationCode); + if(CollectionUtil.isEmpty(videos)){ + throw new ServiceException("站点暂无视频信息!"); + + } + return videos.stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getName()); + alarmVideo.setVideoAppKey(video.getAppKey()); + alarmVideo.setVideoAppSecret(video.getAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } + /** * 查询设备绑定视频信息 @@ -498,12 +517,73 @@ public class AlarmServiceImpl extends BaseServiceImpl /** * 查询智能预警视频信息 * @param stationCode - * @param realId + * @param faultId */ - private void earlyVideos(String stationCode, String realId) { - - + private List earlyVideos(String stationCode, String faultId) { + // 调用FDP接口查询设备编号 + Map param = new HashMap<>(); + param.put("faultId", faultId); + String result = HttpRequestUtil.postCall(param, FAULTGRAPH_INFO_PATH, "POST"); + if (StringUtil.isNotBlank(result)) { + throw new ServiceException("未查询到智能预警设备信息!"); + } + HashMap map = JSONObject.parseObject(result, new TypeReference>() { + }); + if (ObjectUtil.isEmpty(map)) { + throw new ServiceException("未查询到智能预警设备信息!"); + } + List> data = JSONObject.parseObject(MapUtils.getString(map, "data"), new TypeReference>>() { + }); + if (CollectionUtil.isEmpty(data)) { + throw new ServiceException("未查询到智能预警设备信息!"); + } + String deviceCode = (String) data.get(0).get("TAOS_INSTANCE"); + if(StringUtil.isNotBlank(deviceCode)){ + throw new ServiceException("未查询到智能预警设备信息!"); + } + return this.deviceVideos(stationCode,deviceCode); } - + /** + * 查询采集点绑定视频信息 + * @param stationCode + * @param realId + */ + private List realIdVideos(String stationCode, String realId) { + // 查询站点 + R station = stationClient.getStationByCode(stationCode); + if(!station.isSuccess() || ObjectUtil.isEmpty(station)){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); + } + EmInfoEntity param = new EmInfoEntity(); + param.setDepartment(station.getData().getRefDept()); + // 查询设备 + R> devices = emInfoClient.emInfoList(param); + if(!devices.isSuccess() || CollectionUtil.isEmpty(devices.getData())){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); + } + String deviceCodes = devices.getData().stream().parallel() + .filter(this::isBandingVideoByEmCode) + .filter(this::isDeviceCodeExist) + .map(EmInfoEntity::getNumber) + .filter(number -> this.isRealIdBanding(realId, number)) + .collect(Collectors.joining(",")); + if(StringUtil.isEmpty(deviceCodes)){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); + } + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCodes); + if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "的设备视频绑定信息!"); + } + return videos.getData().stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getVideoName()); + alarmVideo.setVideoAppKey(video.getVideoAppKey()); + alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } } \ No newline at end of file