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 01/11] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=9F=A5=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 From 4cf2644b02f034171539214deb2d160005344d34 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 28 Jun 2024 11:06:57 +0800 Subject: [PATCH 02/11] =?UTF-8?q?#=E6=99=BA=E8=83=BD=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=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/controller/ShowAlarmController.java | 6 +++--- .../com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java | 5 ++++- 2 files changed, 7 insertions(+), 4 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 8deca55..d2988ee 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 @@ -58,9 +58,9 @@ public class ShowAlarmController extends BladeController { @GetMapping("/alarmVideos") @ApiOperationSupport(order = 4) @ApiOperation(value = "站点") - public R> alarmVideos(@ApiParam("站点编号") @RequestParam String stationCode, - @ApiParam("设备编号") @RequestParam String deviceCode, - @ApiParam("监测点ID") @RequestParam String realId) { + public R> alarmVideos(@ApiParam("站点编号") @RequestParam(required = false) String stationCode, + @ApiParam("设备编号") @RequestParam(required = false) String deviceCode, + @ApiParam("监测点ID") @RequestParam(required = false) String realId) { return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId)); } 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 5459860..51c8aa0 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 @@ -458,6 +458,9 @@ public class AlarmServiceImpl extends BaseServiceImpl return alarmVideo; }).collect(Collectors.toList()); } + }else{ + // FIXME 查询FDP设备编号 + } } } @@ -466,7 +469,7 @@ public class AlarmServiceImpl extends BaseServiceImpl if(StringUtil.isNotBlank(deviceCode)){ // 查询设备绑定视频点位 R> videos = emVideoClient.getEmBandingVideos(deviceCode); - if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + if(videos.isSuccess() && CollectionUtil.isNotEmpty(videos.getData())){ return videos.getData().stream().distinct().map(video->{ AlarmVideoVo alarmVideo = new AlarmVideoVo(); alarmVideo.setVideoHost(video.getVideoHost()); From c578b6817b57a971c249e59c23917c79a7c64918 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 28 Jun 2024 11:34:50 +0800 Subject: [PATCH 03/11] =?UTF-8?q?#=E9=99=90=E5=88=B6=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=9C=88=E5=86=85=E5=B7=A1=E6=A3=80=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java index 378ce44..8fd6d64 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java @@ -334,9 +334,12 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { List fileJson = new ArrayList<>(); // 查询当天数据(条件) String currentDate = DateUtil.formatDateTime(DateUtil.now()); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH,-1); // 巡检任务ID集合 List taskUsers = this.taskUserService.list(new LambdaQueryWrapper() {{ eq(TaskUserEntity::getUserId, user.getUserId()); + ge(TaskUserEntity::getCreateTime, DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE)); }}); if(CollectionUtil.isEmpty(taskUsers)){ throw new ServiceException("巡检用户数据不存在!"); From fb97f63f59cb51b2468da04e6b846bb25027ef75 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Jul 2024 08:16:14 +0800 Subject: [PATCH 04/11] =?UTF-8?q?#=E9=99=90=E5=88=B6=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=9C=88=E5=86=85=E5=B7=A1=E6=A3=80=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspect/offline/service/impl/InspectOfflineServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java index 8fd6d64..a2266d6 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java @@ -401,10 +401,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { // 离线任务任务 List offlines = this.tasksData(taskId,fileList); fileJson.add(JsonUtil.toJson(offlines)); - if(fileJson.isEmpty()){ - return; - } - // 文件写入 + // 文件写入 for (int i=0; i < fileJson.size();i++){ TableJsonUtils.createJsonFile(fileJson.get(i), download, tableNames.get(i)); } From 9036bf5556da1b1a949d813502f12554e22c1035 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Jul 2024 11:37:30 +0800 Subject: [PATCH 05/11] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=85=B3=E8=81=94?= =?UTF-8?q?=E8=A7=86=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 | 5 +- .../hzims/alarm/show/service/AlarmService.java | 2 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 110 +++++++++++---------- 3 files changed, 62 insertions(+), 55 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 d2988ee..4ebda2b 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 @@ -60,8 +60,9 @@ public class ShowAlarmController extends BladeController { @ApiOperation(value = "站点") public R> alarmVideos(@ApiParam("站点编号") @RequestParam(required = false) String stationCode, @ApiParam("设备编号") @RequestParam(required = false) String deviceCode, - @ApiParam("监测点ID") @RequestParam(required = false) String realId) { - return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId)); + @ApiParam("监测点ID") @RequestParam(required = false) String realId, + @ApiParam("告警类型") @RequestParam Integer alarmSource) { + return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId,alarmSource)); } } \ 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 0bc7f77..e4cf0d6 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); + List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmSource); } \ 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 51c8aa0..5f77527 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 @@ -427,62 +427,23 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - 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()); - } - }else{ - // FIXME 查询FDP设备编号 - - } - } - } - } - // 根据设备编号查找 + public List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmSource) { + // 步骤1、根据设备编号查询视频信息 if(StringUtil.isNotBlank(deviceCode)){ - // 查询设备绑定视频点位 - R> videos = emVideoClient.getEmBandingVideos(deviceCode); - if(videos.isSuccess() && CollectionUtil.isNotEmpty(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()); + return this.deviceVideos(stationCode,deviceCode); + } + // 步骤2、根据采集点查询视频信息 + if(StringUtil.isNotBlank(realId)){ + // 智能预警 + if(AlarmConstants.EARLY.equals(alarmSource)){ + this.earlyVideos(stationCode,realId); + }else{ + } } + // 根据站点编号查找 - if(StringUtil.isNotBlank(stationCode)){ + else if(StringUtil.isNotBlank(stationCode)){ List videos = stationVideoTypeClient.listByStationId(stationCode); if(CollectionUtil.isNotEmpty(videos)){ return videos.stream().distinct().map(video->{ @@ -494,10 +455,55 @@ public class AlarmServiceImpl extends BaseServiceImpl alarmVideo.setPointCode(video.getPointCode()); return alarmVideo; }).collect(Collectors.toList()); + }else{ + // 站点不存在视频 } } throw new ServiceException("未查询到告警视频信息!"); } + /** + * 查询设备绑定视频信息 + * @param deviceCode + * @return + */ + private List deviceVideos(String stationCode,String deviceCode) { + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCode); + if(!videos.isSuccess() || CollectionUtil.isEmpty(videos.getData())){ + // 查询站点 + R station = stationClient.getStationByCode(stationCode); + if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ + throw new ServiceException("未查询到设备绑定视频信息!"); + } + // 查询设备 + R device = emInfoClient.getEmInfoByEmCode(deviceCode); + if(!device.isSuccess() || ObjectUtil.isEmpty(device.getData())){ + throw new ServiceException("未查询到设备绑定视频信息!"); + } + throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "-" + device.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()); + } + + /** + * 查询智能预警视频信息 + * @param stationCode + * @param realId + */ + private void earlyVideos(String stationCode, String realId) { + + + } + + } \ No newline at end of file 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 06/11] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=85=B3=E8=81=94?= =?UTF-8?q?=E8=A7=86=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 From 75be1bf2db998e52d38bfbfdc5ab7eb7fbaac1df Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Jul 2024 16:41:52 +0800 Subject: [PATCH 07/11] =?UTF-8?q?#=E6=8C=87=E6=A0=87=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0try/catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/show/service/impl/AlarmServiceImpl.java | 6 +- .../operation/home/impl/RealTargetServiceImpl.java | 76 +++++++++++++--------- 2 files changed, 50 insertions(+), 32 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 1758414..10aa732 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 @@ -524,7 +524,7 @@ public class AlarmServiceImpl extends BaseServiceImpl Map param = new HashMap<>(); param.put("faultId", faultId); String result = HttpRequestUtil.postCall(param, FAULTGRAPH_INFO_PATH, "POST"); - if (StringUtil.isNotBlank(result)) { + if (StringUtil.isBlank(result)) { throw new ServiceException("未查询到智能预警设备信息!"); } HashMap map = JSONObject.parseObject(result, new TypeReference>() { @@ -538,7 +538,7 @@ public class AlarmServiceImpl extends BaseServiceImpl throw new ServiceException("未查询到智能预警设备信息!"); } String deviceCode = (String) data.get(0).get("TAOS_INSTANCE"); - if(StringUtil.isNotBlank(deviceCode)){ + if(StringUtil.isBlank(deviceCode)){ throw new ServiceException("未查询到智能预警设备信息!"); } return this.deviceVideos(stationCode,deviceCode); @@ -573,7 +573,7 @@ public class AlarmServiceImpl extends BaseServiceImpl } // 查询设备绑定视频点位 R> videos = emVideoClient.getEmBandingVideos(deviceCodes); - if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + if(!videos.isSuccess() || CollectionUtil.isEmpty(videos.getData())){ throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "的设备视频绑定信息!"); } return videos.getData().stream().distinct().map(video->{ diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index dfca1da..834ec1c 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -127,7 +127,7 @@ public class RealTargetServiceImpl implements RealTargetService { private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; // 创建线程池 - private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(20, 20, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); @Override public void loadEmInfo(String param) { @@ -281,24 +281,38 @@ public class RealTargetServiceImpl implements RealTargetService { // 水电站设备 List devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); if(CollectionUtil.isNotEmpty(devices)){ - targets.addAll(devices.stream().map(device->{ - HydropowerUnitTargetVo target = new HydropowerUnitTargetVo(); - target.setDeptId(device.getCreateDept()); - target.setDeviceCode(device.getEmCode()); - target.setDeviceName(device.getName()); - target.setDeptName(device.getName()); - // 当年发电量 - target.setPowerYear(this.getGenerationPower(device,0)); - // 当月发电量 - target.setPowerMon(this.getGenerationPower(device,1)); - // 当日发电量 - target.setPowerDay(this.getGenerationPower(device,2)); - // 当天有功功率 - target.setActivePowerVoList(this.getLoadsByDay(device)); - // 30天发电量 - target.setGenerationPowerVoList(this.getGenerationPowerList(device)); - return target; - }).collect(Collectors.toList())); + CountDownLatch countDownLatch = new CountDownLatch(devices.size()); + for(EminfoAndEmParamVo device : devices) { + pool.submit(() -> { + try{ + HydropowerUnitTargetVo target = new HydropowerUnitTargetVo(); + target.setDeptId(device.getCreateDept()); + target.setDeviceCode(device.getEmCode()); + target.setDeviceName(device.getName()); + target.setDeptName(device.getName()); + // 当年发电量 + target.setPowerYear(this.getGenerationPower(device, 0)); + // 当月发电量 + target.setPowerMon(this.getGenerationPower(device, 1)); + // 当日发电量 + target.setPowerDay(this.getGenerationPower(device, 2)); + // 当天有功功率 + target.setActivePowerVoList(this.getLoadsByDay(device)); + // 30天发电量 + target.setGenerationPowerVoList(this.getGenerationPowerList(device)); + targets.add(target); + countDownLatch.countDown(); + }catch (Exception exception){ + countDownLatch.countDown(); + } + }); + } + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } } // 站点指标数据为空 if(CollectionUtil.isEmpty(targets)){ @@ -1253,16 +1267,20 @@ public class RealTargetServiceImpl implements RealTargetService { CountDownLatch countDownLatch = new CountDownLatch(limits.size()); for(List item : limits){ pool.submit(()->{ - item.forEach(station->{ - // 站点设备集合 - List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); - Map generateMap = this.getGenerateYear(station,stationDevices,start,end); - if(MapUtils.isEmpty(generateMap)){ - return; - } - powerMap.put(station.getId(),generateMap); - }); - countDownLatch.countDown(); + try{ + item.forEach(station->{ + // 站点设备集合 + List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + Map generateMap = this.getGenerateYear(station,stationDevices,start,end); + if(MapUtils.isEmpty(generateMap)){ + return; + } + powerMap.put(station.getId(),generateMap); + }); + countDownLatch.countDown(); + }catch (Exception exception){ + countDownLatch.countDown(); + } log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); }); 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 08/11] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=B1=BB=E5=9E=8B=E7=AB=99=E7=82=B9=E6=9F=A5?= =?UTF-8?q?=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); } } From 64a292f39cd13b6e508335ca91e1264a3428bdf2 Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 1 Jul 2024 16:48:38 +0800 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=BD=A6?= =?UTF-8?q?=E8=BE=86=E5=B9=B4=E5=BA=A6=E9=87=8C=E7=A8=8B=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java | 4 ++++ .../main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml | 5 ++--- .../hnac/hzims/safeproduct/service/impl/CarServiceImpl.java | 11 ++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java index c73f78e..b9355a2 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; +import java.util.Date; /** * @author liwen @@ -78,4 +79,7 @@ public class CarMilesYearVO { @ExcelProperty(value = "合计里程/km", order = 15) @ApiModelProperty("合计里程数") private BigDecimal sumMiles; + + @ApiModelProperty("创建时间") + private Date createTime; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml index 6080ea6..61bea9f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml @@ -4,7 +4,7 @@ SELECT - t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles, - t1.create_user, t1.create_dept + t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles FROM hzims_car t1 LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java index a46457a..90fadf4 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java @@ -15,6 +15,7 @@ import com.hnac.hzims.safeproduct.entity.CarEntity; import com.hnac.hzims.safeproduct.mapper.CarMapper; import com.hnac.hzims.safeproduct.service.*; import com.hnac.hzims.safeproduct.vo.CarMilesYearVO; +import org.apache.commons.collections4.map.HashedMap; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -29,6 +30,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -71,7 +73,7 @@ public class CarServiceImpl extends ServiceImpl implements } List carList = records.stream().map(CarMilesYearVO::getPlateNumber).collect(Collectors.toList()); List milesList = baseMapper.selectMilesByCar(carList, year); - List res = new ArrayList<>(); + HashedMap map = new HashedMap<>(); milesList.forEach(data -> { CarMilesYearVO carMilesYearVO = records.stream().filter(x -> x.getPlateNumber().equals(data.getPlateNumber())) .collect(Collectors.toList()).get(0); @@ -127,11 +129,14 @@ public class CarServiceImpl extends ServiceImpl implements carMilesYearVO.setSumMiles(sum.add(data.getMiles())); } if (!carMilesYearVO.getSumMiles().equals(new BigDecimal(0))) { - res.add(carMilesYearVO); + map.put(carMilesYearVO.getPlateNumber(), carMilesYearVO); } }); + List list = new ArrayList<>(map.values()); + List res = list.stream().sorted(Comparator.comparing(CarMilesYearVO::getCreateTime).reversed()) + .collect(Collectors.toList()); page.setRecords(res); - page.setTotal(res.size()); + page.setTotal(carPage.getTotal()); return page; } From 09de77d57eb8584334b3a803bd1a02c27399c764 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 2 Jul 2024 14:34:01 +0800 Subject: [PATCH 10/11] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=8D=AB?= =?UTF-8?q?=E7=94=9F=E8=A1=A8=E5=AF=BC=E5=87=BA=E5=86=85=E5=AE=B9=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/HygieneRecordServiceImpl.java | 4 ++-- .../com/hnac/hzims/safeproduct/utils/BaseUtil.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 5392c0a..18a3297 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -194,8 +194,8 @@ public class HygieneRecordServiceImpl extends ServiceImpl params = BaseUtil.obj2Map(hygieneRecordDetailVO); String templateFile = "template/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; - String wordPath = savePath + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; - String pdfPath = savePath + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX; + String wordPath = "D:/" + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; + String pdfPath = "D:/" + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX; BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, "",response); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index c80b1ba..2c1755e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -144,10 +144,10 @@ public class BaseUtil { } } // 表格处理 - if (templatePath.equals("template/卫生自查表.docx")) { + if ("template/卫生自查表.docx".equals(templatePath)) { formatHygieneRecordTable(xwpfDocument); } - if (templatePath.equals("template/车辆检查表.docx")) { + if ("template/车辆检查表.docx".equals(templatePath)) { formatCarCheckRecordTable(xwpfDocument); } } catch (Exception e) { @@ -225,13 +225,18 @@ public class BaseUtil { List rows = table.getRows(); // 第三行到倒数第二行为需合并区域 for (int row = 3; row < rows.size() - 1;) { - XWPFTableCell startCell = rows.get(row).getCell(0); - String startText = startCell.getText(); + // 判断责任区和责任人是否完全一致,一致则合并 + XWPFTableCell startFirstCell = rows.get(row).getCell(0); + String startFirstText = startFirstCell.getText(); + XWPFTableCell startSecondCell = rows.get(row).getCell(1); + String startSecondText = startSecondCell.getText(); int index = row + 1; for (; index < rows.size(); index++) { - XWPFTableCell endCell = rows.get(index).getCell(0); - String endText = endCell.getText(); - if (!startText.equals(endText)) { + XWPFTableCell endFirstCell = rows.get(index).getCell(0); + String endFirstText = endFirstCell.getText(); + XWPFTableCell endSecondCell = rows.get(index).getCell(1); + String endSecondText = endSecondCell.getText(); + if (!startFirstText.equals(endFirstText) || !startSecondText.equals(endSecondText)) { break; } } From 0fec9dbd61170780acb6c8878701245422865c76 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 2 Jul 2024 15:59:57 +0800 Subject: [PATCH 11/11] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=8D=AB?= =?UTF-8?q?=E7=94=9F=E8=A1=A8=E5=AF=BC=E5=87=BA=E5=86=85=E5=AE=B9=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 18a3297..5392c0a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -194,8 +194,8 @@ public class HygieneRecordServiceImpl extends ServiceImpl params = BaseUtil.obj2Map(hygieneRecordDetailVO); String templateFile = "template/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; - String wordPath = "D:/" + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; - String pdfPath = "D:/" + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX; + String wordPath = savePath + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; + String pdfPath = savePath + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX; BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, "",response); }