|
|
@@ -654,13 +654,14 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
|
|
|
log.info("日志组id不为空时,预警消息记录,groupId = {}", groupId);
|
|
|
//记录通知
|
|
|
recordNotice(subFunction, labRiskPlanLevel, groupId);
|
|
|
- //向前端发送mqtt预案触发提示
|
|
|
- messageSendService.riskPlanTriggerNotice();
|
|
|
//打开喇叭
|
|
|
openLoudSpeaker(subFunction.getSubId(), labRiskPlanLevel.getFloorId(), labRiskPlanLevel.getRiskPlanId());
|
|
|
//远程调用开始录制视频接口
|
|
|
startVideo(subFunction.getSubId());
|
|
|
+ //向前端发送mqtt预案触发提示
|
|
|
+ messageSendService.riskPlanTriggerNotice();
|
|
|
}
|
|
|
+ log.info("groupId为空!");
|
|
|
|
|
|
} else {
|
|
|
if (redisService.getCacheObject("subjectByYa" + subFunction.getSubId()) != null) {
|
|
|
@@ -865,12 +866,16 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
|
|
|
* @param labRiskPlanLevel
|
|
|
*/
|
|
|
private void getFloorInfo(SubFunction<SensorFunctionStatus> subFunction, LabRiskPlanLevel labRiskPlanLevel) {
|
|
|
- LabRiskPlan labRiskPlan = labRiskPlanMapper.selectLabRiskPlanByRiskPlanId(subFunction.getSubId());
|
|
|
- LabBuildFloorLayout labBuildFloorLayout = new LabBuildFloorLayout();
|
|
|
- labBuildFloorLayout.setSubId(subFunction.getSubId());
|
|
|
- List<LabBuildFloorLayoutVo> list = labBuildFloorLayoutService.selectLabBuildFloorLayoutList(labBuildFloorLayout);
|
|
|
- labRiskPlanLevel.setFloorId(list.get(0).getFloorId());
|
|
|
- labRiskPlanLevel.setTopName(labRiskPlan.getTopName());
|
|
|
+ try {
|
|
|
+ LabRiskPlan labRiskPlan = labRiskPlanMapper.selectLabRiskPlanByRiskPlanId(subFunction.getSubId());
|
|
|
+ LabBuildFloorLayout labBuildFloorLayout = new LabBuildFloorLayout();
|
|
|
+ labBuildFloorLayout.setSubId(subFunction.getSubId());
|
|
|
+ List<LabBuildFloorLayoutVo> list = labBuildFloorLayoutService.selectLabBuildFloorLayoutList(labBuildFloorLayout);
|
|
|
+ labRiskPlanLevel.setFloorId(list.get(0).getFloorId());
|
|
|
+ labRiskPlanLevel.setTopName(labRiskPlan.getTopName());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取园区楼栋信息异常!{}",e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -879,37 +884,45 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
|
|
|
* @param labRiskPlanLevel
|
|
|
*/
|
|
|
private void getConfigNoticeTemplate(LabRiskPlanLevel labRiskPlanLevel) {
|
|
|
- //获取通知配置信息
|
|
|
- List<LabNoticeconfig> noticeconfigList = labNoticeconfigMapper.selectLabNoticeconfigList(new LabNoticeconfig());
|
|
|
- if (!noticeconfigList.isEmpty()) {
|
|
|
- LabNoticeconfig labNoticeconfig = noticeconfigList.get(0);
|
|
|
- StringBuffer radioStr = new StringBuffer();
|
|
|
- radioStr.append(noticeconfigList.get(0).getRiskRadio());
|
|
|
- labRiskPlanLevel.setMessage(labNoticeconfig.getRiskMessage());
|
|
|
- labRiskPlanLevel.setVoicebroadcast(labNoticeconfig.getRiskVoice());
|
|
|
- labRiskPlanLevel.setInformation(labNoticeconfig.getRiskPhone());
|
|
|
+ try {
|
|
|
+ //获取通知配置信息
|
|
|
+ List<LabNoticeconfig> noticeconfigList = labNoticeconfigMapper.selectLabNoticeconfigList(new LabNoticeconfig());
|
|
|
+ if (!noticeconfigList.isEmpty()) {
|
|
|
+ LabNoticeconfig labNoticeconfig = noticeconfigList.get(0);
|
|
|
+ StringBuffer radioStr = new StringBuffer();
|
|
|
+ radioStr.append(noticeconfigList.get(0).getRiskRadio());
|
|
|
+ labRiskPlanLevel.setMessage(labNoticeconfig.getRiskMessage());
|
|
|
+ labRiskPlanLevel.setVoicebroadcast(labNoticeconfig.getRiskVoice());
|
|
|
+ labRiskPlanLevel.setInformation(labNoticeconfig.getRiskPhone());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取通知配置信息异常!{}",e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@NotNull
|
|
|
private JSONArray getSensorInfo(SubFunction<SensorFunctionStatus> subFunction, LabRiskPlanLevel labRiskPlanLevel) {
|
|
|
- Map<SenseType, List<SensorFunctionStatus>> sensorFunctionStatusListMap = hardwareFunctionStatusConfig.getSensorFunctionStatusListMap();
|
|
|
- //处理预案下的传感器翻译
|
|
|
JSONArray riskPlanJson = new JSONArray();
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- for (LabRiskPlanSensorRelation rps : labRiskPlanLevel.getRiskPlanSensorList()) {
|
|
|
- //硬件社保统一传入的传感器设备列表
|
|
|
- for (SensorFunctionStatus sensorFunc : subFunction.getFunctionStatuses()) {
|
|
|
- String funNum1 = sensorFunctionStatusListMap.get(SenseType.getByCode(rps.getSensorType())).get(0).getFunNum();
|
|
|
- if (funNum1.equals(sensorFunc.getFunNum())) {
|
|
|
- getJsonStr(riskPlanJson, sensorFunc);
|
|
|
- labRiskPlanLevel.setTopName(labRiskPlanLevel.getTopName() + "-" + sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
|
|
|
- sb.append(sensorFunc.getDescribe()).append("、");
|
|
|
+ try {
|
|
|
+ Map<SenseType, List<SensorFunctionStatus>> sensorFunctionStatusListMap = hardwareFunctionStatusConfig.getSensorFunctionStatusListMap();
|
|
|
+ //处理预案下的传感器翻译
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (LabRiskPlanSensorRelation rps : labRiskPlanLevel.getRiskPlanSensorList()) {
|
|
|
+ //硬件社保统一传入的传感器设备列表
|
|
|
+ for (SensorFunctionStatus sensorFunc : subFunction.getFunctionStatuses()) {
|
|
|
+ String funNum1 = sensorFunctionStatusListMap.get(SenseType.getByCode(rps.getSensorType())).get(0).getFunNum();
|
|
|
+ if (funNum1.equals(sensorFunc.getFunNum())) {
|
|
|
+ getJsonStr(riskPlanJson, sensorFunc);
|
|
|
+ labRiskPlanLevel.setTopName(labRiskPlanLevel.getTopName() + "-" + sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
|
|
|
+ sb.append(sensorFunc.getDescribe()).append("、");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(sb)) {
|
|
|
- labRiskPlanLevel.setDescribe(sb.substring(0, sb.length() - 1) + "异常");
|
|
|
+ if (StringUtils.isNotBlank(sb)) {
|
|
|
+ labRiskPlanLevel.setDescribe(sb.substring(0, sb.length() - 1) + "异常");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("传感器数据翻译异常!{}",e);
|
|
|
}
|
|
|
return riskPlanJson;
|
|
|
}
|
|
|
@@ -1114,90 +1127,95 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
|
|
|
|
|
|
|
|
|
public Long insertPlanAbnormalLog(LabRiskPlanLevel labRiskPlanLevel, JSONArray riskPlanJson, List<LabRiskPlanAbnormalGroupVO> groupList, Long riskStatus, SubFunction<SensorFunctionStatus> subFunction, Integer riskAttribute) {
|
|
|
- LabRiskPlanAbnormalGroup labRiskPlanAbnormalGroup;
|
|
|
- Long groupId;
|
|
|
- //将风险预案写入日志表
|
|
|
- LabRiskPlanAbnormalLog labRiskPlanAbnormalLog = new LabRiskPlanAbnormalLog();
|
|
|
- labRiskPlanAbnormalLog.setRiskPlanId(labRiskPlanLevel.getRiskPlanId());
|
|
|
- labRiskPlanAbnormalLog.setRiskPlanName(labRiskPlanLevel.getRiskName());
|
|
|
- labRiskPlanAbnormalLog.setCreateTime(new Date());
|
|
|
- labRiskPlanAbnormalLog.setSensorJson(riskPlanJson.toString());
|
|
|
- labRiskPlanAbnormalLog.setRiskStatus(riskStatus);
|
|
|
- labRiskPlanAbnormalLog.setSubjectId(subFunction.getSubId());
|
|
|
- labRiskPlanAbnormalLog.setRiskAttribute(labRiskPlanLevel.getRiskAttribute());
|
|
|
- labRiskPlanAbnormalLog.setRiskPlanLevelId(labRiskPlanLevel.getId());
|
|
|
- labRiskPlanAbnormalLog.setRiskPlanLevelName(RiskPlanLevelEnum.getValue(labRiskPlanLevel.getRiskPlanLevel()));
|
|
|
- labRiskPlanAbnormalLog.setRiskPlanLevel(labRiskPlanLevel.getRiskPlanLevel());
|
|
|
- if (groupList == null || groupList.size() == 0) {
|
|
|
- labRiskPlanAbnormalGroup = insertPlanAbnormalGroup(labRiskPlanLevel, subFunction.getSubId(), riskAttribute, labRiskPlanLevel.getRiskPlanLevel());
|
|
|
- groupId = labRiskPlanAbnormalGroup.getId();
|
|
|
- //给风险日志表关联组
|
|
|
- labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
|
|
|
- //处理预案下的传感器翻译
|
|
|
- for (LabRiskPlanSensorRelation rps : labRiskPlanLevel.getRiskPlanSensorList()) {
|
|
|
- //硬件社保统一传入的传感器设备列表
|
|
|
- for (SensorFunctionStatus sensorFunc : subFunction.getFunctionStatuses()) {
|
|
|
- if (rps.getFunNum().equals(sensorFunc.getFunNum())) {
|
|
|
- if (StringUtils.isNotNull(labRiskPlanAbnormalLog.getRemark())) {
|
|
|
- labRiskPlanAbnormalLog.setRemark(labRiskPlanAbnormalLog.getRemark() + " " + sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
|
|
|
- } else {
|
|
|
- labRiskPlanAbnormalLog.setRemark(sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
|
|
|
+ try {
|
|
|
+ LabRiskPlanAbnormalGroup labRiskPlanAbnormalGroup;
|
|
|
+ Long groupId;
|
|
|
+ //将风险预案写入日志表
|
|
|
+ LabRiskPlanAbnormalLog labRiskPlanAbnormalLog = new LabRiskPlanAbnormalLog();
|
|
|
+ labRiskPlanAbnormalLog.setRiskPlanId(labRiskPlanLevel.getRiskPlanId());
|
|
|
+ labRiskPlanAbnormalLog.setRiskPlanName(labRiskPlanLevel.getRiskName());
|
|
|
+ labRiskPlanAbnormalLog.setCreateTime(new Date());
|
|
|
+ labRiskPlanAbnormalLog.setSensorJson(riskPlanJson.toString());
|
|
|
+ labRiskPlanAbnormalLog.setRiskStatus(riskStatus);
|
|
|
+ labRiskPlanAbnormalLog.setSubjectId(subFunction.getSubId());
|
|
|
+ labRiskPlanAbnormalLog.setRiskAttribute(labRiskPlanLevel.getRiskAttribute());
|
|
|
+ labRiskPlanAbnormalLog.setRiskPlanLevelId(labRiskPlanLevel.getId());
|
|
|
+ labRiskPlanAbnormalLog.setRiskPlanLevelName(RiskPlanLevelEnum.getValue(labRiskPlanLevel.getRiskPlanLevel()));
|
|
|
+ labRiskPlanAbnormalLog.setRiskPlanLevel(labRiskPlanLevel.getRiskPlanLevel());
|
|
|
+ if (groupList == null || groupList.size() == 0) {
|
|
|
+ labRiskPlanAbnormalGroup = insertPlanAbnormalGroup(labRiskPlanLevel, subFunction.getSubId(), riskAttribute, labRiskPlanLevel.getRiskPlanLevel());
|
|
|
+ groupId = labRiskPlanAbnormalGroup.getId();
|
|
|
+ //给风险日志表关联组
|
|
|
+ labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
|
|
|
+ //处理预案下的传感器翻译
|
|
|
+ for (LabRiskPlanSensorRelation rps : labRiskPlanLevel.getRiskPlanSensorList()) {
|
|
|
+ //硬件社保统一传入的传感器设备列表
|
|
|
+ for (SensorFunctionStatus sensorFunc : subFunction.getFunctionStatuses()) {
|
|
|
+ if (rps.getFunNum().equals(sensorFunc.getFunNum())) {
|
|
|
+ if (StringUtils.isNotNull(labRiskPlanAbnormalLog.getRemark())) {
|
|
|
+ labRiskPlanAbnormalLog.setRemark(labRiskPlanAbnormalLog.getRemark() + " " + sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
|
|
|
+ } else {
|
|
|
+ labRiskPlanAbnormalLog.setRemark(sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //插入风险日志
|
|
|
- labRiskPlanAbnormalLogMapper.insertLabRiskPlanAbnormalLog(labRiskPlanAbnormalLog);
|
|
|
- // 后面放入老柴的事件中 或者订阅老柴的事件处理
|
|
|
- //增加预警缓存
|
|
|
- Optional.ofNullable(labRiskPlanLevel.getRiskPlanSensorList()).ifPresent(f -> {
|
|
|
- Set<String> funSet = labRiskPlanLevel.getRiskPlanSensorList().stream().map(d -> d.getFunNum()).collect(Collectors.toSet());
|
|
|
- redisService.setCacheSetV2(BaseConstants.WRAN_KEY + subFunction.getSubId(), funSet);
|
|
|
- });
|
|
|
- try {
|
|
|
- //插入风险硬件日志
|
|
|
- operateHardWareInfo(labRiskPlanLevel, labRiskPlanAbnormalGroup.getSubjectId(), labRiskPlanAbnormalLog.getGroupId(), riskPlanJson.toString());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("操作硬件设备异常::::" + e);
|
|
|
- } finally {
|
|
|
- return groupId;
|
|
|
- }
|
|
|
- } else {
|
|
|
- labRiskPlanAbnormalGroup = groupList.get(0);
|
|
|
- //如果查询到是当前组,那么就给日志表插入的时候,补上组id
|
|
|
- labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
|
|
|
- //查询风险日志,启动的预案是不是同一个,如果不是,执行插入日志
|
|
|
- LabRiskPlanAbnormalLog labRiskPlanAbnormalLogByGroupId = new LabRiskPlanAbnormalLog();
|
|
|
- labRiskPlanAbnormalLogByGroupId.setGroupId(groupList.get(0).getId());
|
|
|
- List<LabRiskPlanAbnormalLog> newPlanAbnormalLogList = labRiskPlanAbnormalLogMapper.selectLabRiskPlanAbnormalLogOrderByList(labRiskPlanAbnormalLogByGroupId);
|
|
|
- if (newPlanAbnormalLogList.size() > 0) {
|
|
|
- LabRiskPlanAbnormalLog checkLog = newPlanAbnormalLogList.get(0);
|
|
|
- //判断如果当前传感器匹配预案和日志表的预案相同,则不插入日志。过滤重复预案
|
|
|
- if (!labRiskPlanLevel.getId().equals(checkLog.getRiskPlanLevelId())) {
|
|
|
- //这里调用旧预案结束动作的方法
|
|
|
- overRiskPlanAction(checkLog.getRiskPlanId(), checkLog.getSubjectId());
|
|
|
- groupId = labRiskPlanAbnormalGroup.getId();
|
|
|
- //插入风险日志
|
|
|
- labRiskPlanAbnormalLogMapper.insertLabRiskPlanAbnormalLog(labRiskPlanAbnormalLog);
|
|
|
- try {
|
|
|
- //插入风险硬件日志
|
|
|
- operateHardWareInfo(labRiskPlanLevel, labRiskPlanAbnormalGroup.getSubjectId(), groupList.get(0).getId(), riskPlanJson.toString());
|
|
|
- //todo 后面放入老柴的事件中 或者订阅老柴的事件处理
|
|
|
- //增加预警缓存
|
|
|
- Optional.ofNullable(labRiskPlanLevel.getRiskPlanSensorList()).ifPresent(f -> {
|
|
|
- Set<String> funSet = labRiskPlanLevel.getRiskPlanSensorList().stream().map(d -> d.getFunNum()).collect(Collectors.toSet());
|
|
|
- redisService.setCacheSetV2(BaseConstants.WRAN_KEY + subFunction.getSubId(), funSet);
|
|
|
- });
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("操作硬件设备异常::::" + e);
|
|
|
- } finally {
|
|
|
- return groupId;
|
|
|
+ //插入风险日志
|
|
|
+ labRiskPlanAbnormalLogMapper.insertLabRiskPlanAbnormalLog(labRiskPlanAbnormalLog);
|
|
|
+ // 后面放入老柴的事件中 或者订阅老柴的事件处理
|
|
|
+ //增加预警缓存
|
|
|
+ Optional.ofNullable(labRiskPlanLevel.getRiskPlanSensorList()).ifPresent(f -> {
|
|
|
+ Set<String> funSet = labRiskPlanLevel.getRiskPlanSensorList().stream().map(d -> d.getFunNum()).collect(Collectors.toSet());
|
|
|
+ redisService.setCacheSetV2(BaseConstants.WRAN_KEY + subFunction.getSubId(), funSet);
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ //插入风险硬件日志
|
|
|
+ operateHardWareInfo(labRiskPlanLevel, labRiskPlanAbnormalGroup.getSubjectId(), labRiskPlanAbnormalLog.getGroupId(), riskPlanJson.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("操作硬件设备异常::::" + e);
|
|
|
+ } finally {
|
|
|
+ return groupId;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ labRiskPlanAbnormalGroup = groupList.get(0);
|
|
|
+ //如果查询到是当前组,那么就给日志表插入的时候,补上组id
|
|
|
+ labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
|
|
|
+ //查询风险日志,启动的预案是不是同一个,如果不是,执行插入日志
|
|
|
+ LabRiskPlanAbnormalLog labRiskPlanAbnormalLogByGroupId = new LabRiskPlanAbnormalLog();
|
|
|
+ labRiskPlanAbnormalLogByGroupId.setGroupId(groupList.get(0).getId());
|
|
|
+ List<LabRiskPlanAbnormalLog> newPlanAbnormalLogList = labRiskPlanAbnormalLogMapper.selectLabRiskPlanAbnormalLogOrderByList(labRiskPlanAbnormalLogByGroupId);
|
|
|
+ if (newPlanAbnormalLogList.size() > 0) {
|
|
|
+ LabRiskPlanAbnormalLog checkLog = newPlanAbnormalLogList.get(0);
|
|
|
+ //判断如果当前传感器匹配预案和日志表的预案相同,则不插入日志。过滤重复预案
|
|
|
+ if (!labRiskPlanLevel.getId().equals(checkLog.getRiskPlanLevelId())) {
|
|
|
+ //这里调用旧预案结束动作的方法
|
|
|
+ overRiskPlanAction(checkLog.getRiskPlanId(), checkLog.getSubjectId());
|
|
|
+ groupId = labRiskPlanAbnormalGroup.getId();
|
|
|
+ //插入风险日志
|
|
|
+ labRiskPlanAbnormalLogMapper.insertLabRiskPlanAbnormalLog(labRiskPlanAbnormalLog);
|
|
|
+ try {
|
|
|
+ //插入风险硬件日志
|
|
|
+ operateHardWareInfo(labRiskPlanLevel, labRiskPlanAbnormalGroup.getSubjectId(), groupList.get(0).getId(), riskPlanJson.toString());
|
|
|
+ //todo 后面放入老柴的事件中 或者订阅老柴的事件处理
|
|
|
+ //增加预警缓存
|
|
|
+ Optional.ofNullable(labRiskPlanLevel.getRiskPlanSensorList()).ifPresent(f -> {
|
|
|
+ Set<String> funSet = labRiskPlanLevel.getRiskPlanSensorList().stream().map(d -> d.getFunNum()).collect(Collectors.toSet());
|
|
|
+ redisService.setCacheSetV2(BaseConstants.WRAN_KEY + subFunction.getSubId(), funSet);
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("操作硬件设备异常::::" + e);
|
|
|
+ } finally {
|
|
|
+ return groupId;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //插入风险日志
|
|
|
+ return null;
|
|
|
}
|
|
|
- //插入风险日志
|
|
|
- return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("插入风险日志异常!{}",e);
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
public void insertPlanAbnormalLogByHard(LabRiskPlanLevel labRiskPlanLevel, LabRiskPlanHardwareRelation hardRelation, Long subjectId, Long groupId, String riskPlanJson) {
|