From 8573059fc326887f0a8062b7774d0bdce9e118be Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 27 Jun 2024 15:24:12 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E8=A7=86=E9=A2=91=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/show/service/impl/AlarmServiceImpl.java | 90 ++++++++++++++++++++-- 1 file changed, 83 insertions(+), 7 deletions(-) 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 f822a0a..5459860 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 @@ -20,9 +20,13 @@ import com.hnac.hzims.equipment.feign.IEmVideoClient; import com.hnac.hzims.message.dto.MailMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; 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.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -30,6 +34,7 @@ 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; @@ -59,10 +64,15 @@ public class AlarmServiceImpl extends BaseServiceImpl private final IStationClient stationClient; private final IMessageClient messageClient; + private final IEmInfoClient emInfoClient; + private final DeviceClient deviceClient; + private final IEmVideoClient emVideoClient; + private final IStationVideoTypeClient stationVideoTypeClient; + /** * 查询告警列表 * @param alarm @@ -274,9 +284,20 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return 绑定结果 */ private Boolean isRealIdBanding(String realId,String emCode) { - R> deviceAttrR = deviceClient.getOnlineAttr(emCode); - if(deviceAttrR.isSuccess() && CollectionUtil.isNotEmpty(deviceAttrR.getData())) { - return deviceAttrR.getData().stream().anyMatch(attr -> realId.equals(attr.getFacDeviceAttrId())); + // 属性 + R> attrs = deviceClient.getOnlineAttr(emCode); + if(attrs.isSuccess() && CollectionUtil.isNotEmpty(attrs.getData())) { + return attrs.getData().stream().anyMatch(attr -> realId.equals(attr.getFacDeviceAttrId())); + } + // 事件 + R> events = deviceClient.getOnlineEvent(emCode); + if(events.isSuccess() && CollectionUtil.isNotEmpty(events.getData())) { + return events.getData().stream().anyMatch(event -> realId.equals(event.getFacDeviceEventId())); + } + // 功能 + R> funcs = deviceClient.getOnlineFunc(emCode); + if(funcs.isSuccess() && CollectionUtil.isNotEmpty(funcs.getData())) { + return funcs.getData().stream().anyMatch(func -> realId.equals(func.getSourceAttrSignage())); } return false; } @@ -409,16 +430,71 @@ public class AlarmServiceImpl extends BaseServiceImpl public List alarmVideos(String stationCode, String deviceCode, String realId) { // 根据realId查找 if(StringUtil.isNotBlank(realId)){ - + // 查询站点 + R station = stationClient.getStationByCode(stationCode); + if(station.isSuccess() && ObjectUtil.isNotEmpty(station)){ + EmInfoEntity param = new EmInfoEntity(); + param.setDepartment(station.getData().getRefDept()); + // 查询设备 + R> devices = emInfoClient.emInfoList(param); + if(devices.isSuccess() && CollectionUtil.isNotEmpty(devices.getData())){ + 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.isNotBlank(deviceCodes)){ + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCodes); + if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + 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()); + } + } + } + } } // 根据设备编号查找 if(StringUtil.isNotBlank(deviceCode)){ - + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCode); + if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + 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()); + } } // 根据站点编号查找 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()); + } } - return new ArrayList<>(); + throw new ServiceException("未查询到告警视频信息!"); } + + } \ No newline at end of file