Parcourir la source

报警类型修改

hanzhiwei il y a 2 ans
Parent
commit
56cfe37e2c

+ 72 - 63
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisExpiredPhotographListener.java

@@ -187,7 +187,7 @@ public class RedisExpiredPhotographListener extends KeyExpirationEventMessageLis
                             warningNoticeLogDto.setWarningType(1);
                             warningNoticeLogDto.setWarningContent("未穿戴实验服");
                             warningNoticeLogDto.setWarningTime(LocalDateTime.now());
-                            warningNoticeLogDto.setWarningWay("1,2,3");
+                            //warningNoticeLogDto.setWarningWay("1,2,3");
                             //查询到实验室负责人id 安全责任人id
                             List<CheckSubjectDto> subjectInfoList = labSubjectService.findSubjectInfoList(String.valueOf(warningNoticeLog.getSubId()));
                             if (subjectInfoList.size() > 0) {
@@ -207,71 +207,80 @@ public class RedisExpiredPhotographListener extends KeyExpirationEventMessageLis
                             if (HttpStatus.SUCCESS == result.getCode()) {
                                 log.info("未穿戴实验服保存日志成功!");
                             }
-                        }
-                    }
 
-                    //是否通知
-                    ResultData urlScheme = remoteMessageService.getUrlScheme(warningNoticeLog.getId());
-                    if(urlScheme.getCode() != HttpStatus.SUCCESS){
-                        log.error("获取urlScheme失败!");
-                    }
-                    String systemText = "【实验室安全系统】"+warningNoticeLog.getSubName()+"-监测到实验人员违规未穿戴实验服,请尽快确认。";
-                    String text = "【实验室安全系统】"+warningNoticeLog.getSubName()+"-监测到实验人员违规未穿戴实验服,请尽快确认。点击查看:https://lab.zjznai.com/labAppTest/earlyWarning/index.html?id="+warningNoticeLog.getId()+"&urlScheme="+urlScheme.getData();
-                    //系统 短信 语音通知
-                    long systemNoticeCount = warningNoticeLogService.count(new LambdaQueryWrapper<WarningNoticeLog>().eq(WarningNoticeLog::getSubId, warningNoticeLog.getSubId())
-                            .eq(WarningNoticeLog::getWarningType,1).like(WarningNoticeLog::getWarningWay,"1").eq(WarningNoticeLog::getIsDeleted,Boolean.FALSE));
-                    if (warningConfig.getSystemNotice() != null && systemNoticeCount >= warningConfig.getSystemNotice()) {
-                        //系统通知
-                        LabMessageContent labMessageContent = new LabMessageContent();
-                        labMessageContent.setSendMode(2);
-                        labMessageContent.setSendRange(3);
-                        labMessageContent.setMessClass(1);
-                        labMessageContent.setMessType(13);
-                        labMessageContent.setSubIds(String.valueOf(warningNoticeLog.getSubId()));
-                        labMessageContent.setUserIds(userIds.toString());
-                        labMessageContent.setContent(systemText);
-                        labMessageContentService.sendMessage(labMessageContent);
-                    }
-                    long messageNoticeCount = warningNoticeLogService.count(new LambdaQueryWrapper<WarningNoticeLog>().eq(WarningNoticeLog::getSubId, warningNoticeLog.getSubId())
-                            .eq(WarningNoticeLog::getWarningType,1).like(WarningNoticeLog::getWarningWay,"2").eq(WarningNoticeLog::getIsDeleted,Boolean.FALSE));
-                    if (warningConfig.getMessageNotice() != null && messageNoticeCount >= warningConfig.getMessageNotice()) {
-                        //短信通知
-                        String[] strings = Stream.of(phones.toString().split(",")).filter(a -> StrUtil.isNotBlank(a)).collect(Collectors.joining(",")).split(",");
-                        if (strings != null) {
-                            AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(), text);
-                            remoteAlarmService.send(alarmEntrty);
-                            log.info("未穿戴实验服发送短信打电话消息推送完成!");
-                            log.info("未穿戴实验服发送短信内容:{}",text);
-                        }
-                    }
-                    long voiceNoticeCount = warningNoticeLogService.count(new LambdaQueryWrapper<WarningNoticeLog>().eq(WarningNoticeLog::getSubId, warningNoticeLog.getSubId())
-                            .eq(WarningNoticeLog::getWarningType,1).like(WarningNoticeLog::getWarningWay,"3").eq(WarningNoticeLog::getIsDeleted,Boolean.FALSE));
-                    if (warningConfig.getVoiceNotcie() != null && voiceNoticeCount >= warningConfig.getVoiceNotcie()) {
-                        //语音播报
-                        log.info("打开喇叭-远程调用查询喇叭列表,实验室id={}", warningNoticeLog.getSubId());
-                        Integer count = labSparseHardwareService.selectSpeakerCount();
-                        R deviceList = remoteSpeakService.getDeviceList(1, count + 10, -99L, warningNoticeLog.getSubId());
-                        log.info("打开喇叭-远程调用喇叭列表返回内容: deviceList={}", JSON.toJSONString(deviceList));
-                        if (deviceList.getCode() == 200) {
-                            List<PlayVo> playVoList = new ArrayList<>();
-                            List<Map<String, Object>> mapList = (List<Map<String, Object>>) deviceList.getData();
-                            for (Map<String, Object> map : mapList) {
-                                if (com.zd.common.core.utils.StringUtils.isNotNull(map.get("deviceSn")) && com.zd.common.core.utils.StringUtils.isNotNull(map.get("port"))) {
-                                    PlayVo playVo = new PlayVo();
-                                    playVo.setSn(map.get("deviceSn") + "");
-                                    playVo.setDeviceIp(map.get("deviceIp") + "");
-                                    playVo.setPort(Integer.parseInt(map.get("port") + ""));
-                                    ParamVo paramVo = new ParamVo();
-                                    paramVo.setVol(Integer.parseInt(map.get("deviceVol").toString()));
-                                    playVo.setParams(paramVo);
-                                    playVoList.add(playVo);
-                                } else {
-                                    log.info("打开喇叭-喇叭deviceSn/port为空!");
+                            //是否通知
+                            StringBuffer warningWay = new StringBuffer();
+                            ResultData urlScheme = remoteMessageService.getUrlScheme(warningNoticeLog.getId());
+                            if(urlScheme.getCode() != HttpStatus.SUCCESS){
+                                log.error("获取urlScheme失败!");
+                            }
+                            String systemText = "【实验室安全系统】"+warningNoticeLog.getSubName()+"-监测到实验人员违规未穿戴实验服,请尽快确认。";
+                            String text = "【实验室安全系统】"+warningNoticeLog.getSubName()+"-监测到实验人员违规未穿戴实验服,请尽快确认。点击查看:https://lab.zjznai.com/labAppTest/earlyWarning/index.html?id="+warningNoticeLog.getId()+"&urlScheme="+urlScheme.getData();
+                            //系统 短信 语音通知
+                            long systemNoticeCount = warningNoticeLogService.count(new LambdaQueryWrapper<WarningNoticeLog>().eq(WarningNoticeLog::getSubId, warningNoticeLog.getSubId())
+                                    .eq(WarningNoticeLog::getWarningType,1).like(WarningNoticeLog::getWarningWay,"1").eq(WarningNoticeLog::getIsDeleted,Boolean.FALSE));
+                            if (warningConfig.getSystemNotice() != null && systemNoticeCount >= warningConfig.getSystemNotice()) {
+                                //系统通知
+                                warningWay.append("1,");
+                                LabMessageContent labMessageContent = new LabMessageContent();
+                                labMessageContent.setSendMode(2);
+                                labMessageContent.setSendRange(3);
+                                labMessageContent.setMessClass(1);
+                                labMessageContent.setMessType(13);
+                                labMessageContent.setSubIds(String.valueOf(warningNoticeLog.getSubId()));
+                                labMessageContent.setUserIds(userIds.toString());
+                                labMessageContent.setContent(systemText);
+                                labMessageContentService.sendMessage(labMessageContent);
+                            }
+                            long messageNoticeCount = warningNoticeLogService.count(new LambdaQueryWrapper<WarningNoticeLog>().eq(WarningNoticeLog::getSubId, warningNoticeLog.getSubId())
+                                    .eq(WarningNoticeLog::getWarningType,1).like(WarningNoticeLog::getWarningWay,"2").eq(WarningNoticeLog::getIsDeleted,Boolean.FALSE));
+                            if (warningConfig.getMessageNotice() != null && messageNoticeCount >= warningConfig.getMessageNotice()) {
+                                //短信通知
+                                warningWay.append("2,");
+                                String[] strings = Stream.of(phones.toString().split(",")).filter(a -> StrUtil.isNotBlank(a)).collect(Collectors.joining(",")).split(",");
+                                if (strings != null) {
+                                    AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(), text);
+                                    remoteAlarmService.send(alarmEntrty);
+                                    log.info("未穿戴实验服发送短信打电话消息推送完成!");
+                                    log.info("未穿戴实验服发送短信内容:{}",text);
                                 }
                             }
-                            log.info("打开喇叭-远程调用喇叭播放音乐,playVoList={}", JSON.toJSONString(playVoList));
-                            R r = remoteSpeakService.textParseUrlIps(systemText, playVoList);
-                            log.info("打开喇叭-远程调用喇叭播放音乐返回信息:{}", JSON.toJSONString(r));
+                            long voiceNoticeCount = warningNoticeLogService.count(new LambdaQueryWrapper<WarningNoticeLog>().eq(WarningNoticeLog::getSubId, warningNoticeLog.getSubId())
+                                    .eq(WarningNoticeLog::getWarningType,1).like(WarningNoticeLog::getWarningWay,"3").eq(WarningNoticeLog::getIsDeleted,Boolean.FALSE));
+                            if (warningConfig.getVoiceNotcie() != null && voiceNoticeCount >= warningConfig.getVoiceNotcie()) {
+                                //
+                                warningWay.append("3,");
+                                log.info("打开喇叭-远程调用查询喇叭列表,实验室id={}", warningNoticeLog.getSubId());
+                                Integer count = labSparseHardwareService.selectSpeakerCount();
+                                R deviceList = remoteSpeakService.getDeviceList(1, count + 10, -99L, warningNoticeLog.getSubId());
+                                log.info("打开喇叭-远程调用喇叭列表返回内容: deviceList={}", JSON.toJSONString(deviceList));
+                                if (deviceList.getCode() == 200) {
+                                    List<PlayVo> playVoList = new ArrayList<>();
+                                    List<Map<String, Object>> mapList = (List<Map<String, Object>>) deviceList.getData();
+                                    for (Map<String, Object> map : mapList) {
+                                        if (com.zd.common.core.utils.StringUtils.isNotNull(map.get("deviceSn")) && com.zd.common.core.utils.StringUtils.isNotNull(map.get("port"))) {
+                                            PlayVo playVo = new PlayVo();
+                                            playVo.setSn(map.get("deviceSn") + "");
+                                            playVo.setDeviceIp(map.get("deviceIp") + "");
+                                            playVo.setPort(Integer.parseInt(map.get("port") + ""));
+                                            ParamVo paramVo = new ParamVo();
+                                            paramVo.setVol(Integer.parseInt(map.get("deviceVol").toString()));
+                                            playVo.setParams(paramVo);
+                                            playVoList.add(playVo);
+                                        } else {
+                                            log.info("打开喇叭-喇叭deviceSn/port为空!");
+                                        }
+                                    }
+                                    log.info("打开喇叭-远程调用喇叭播放音乐,playVoList={}", JSON.toJSONString(playVoList));
+                                    R r = remoteSpeakService.textParseUrlIps(systemText, playVoList);
+                                    log.info("打开喇叭-远程调用喇叭播放音乐返回信息:{}", JSON.toJSONString(r));
+                                }
+                            }
+                            warningNoticeLog.setWarningWay(warningWay.toString());
+                            ResultData updateResult = remoteLaboratoryService.updateWarningNoticeLog(warningNoticeLogDto);
+                            if (HttpStatus.SUCCESS == updateResult.getCode()) {
+                                log.info("未穿戴实验服修改报警方式日志成功!");
+                            }
                         }
                     }
                 }