Explorar o código

修改预案时长, 对接摄像头摄像功能

hanzhiwei %!s(int64=3) %!d(string=hai) anos
pai
achega
a242070428

+ 5 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/constant/RiskPlanConstants.java

@@ -28,4 +28,9 @@ public interface RiskPlanConstants {
      */
      */
     String SMOKE_FUN_NUM = "yangan";
     String SMOKE_FUN_NUM = "yangan";
 
 
+    /**
+     * 消息推送公司名称
+     */
+    String LAB_SAFETY_MANAGEMENT_SYSTEM = "【实验室安全系统】";
+
 }
 }

+ 60 - 59
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabRiskPlanServiceImpl.java

@@ -17,6 +17,7 @@ import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.utils.SecurityUtils;
 import com.zd.common.core.utils.SecurityUtils;
 import com.zd.common.core.utils.StringUtils;
 import com.zd.common.core.utils.StringUtils;
+import com.zd.laboratory.api.constant.RiskPlanConstants;
 import com.zd.laboratory.api.entity.FunctionStatus;
 import com.zd.laboratory.api.entity.FunctionStatus;
 import com.zd.laboratory.api.entity.LabMessageContent;
 import com.zd.laboratory.api.entity.LabMessageContent;
 import com.zd.laboratory.api.entity.SensorFunctionStatus;
 import com.zd.laboratory.api.entity.SensorFunctionStatus;
@@ -1071,8 +1072,8 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
             });
             });
             //有效预案延长一分钟
             //有效预案延长一分钟
 //            if(redisService.getCacheObject("subjectByYa"+subFunction.getSubId())==null){
 //            if(redisService.getCacheObject("subjectByYa"+subFunction.getSubId())==null){
-            redisService.setCacheObject("subjectByYa" + subFunction.getSubId(), subFunction.getSubId(), 10L, TimeUnit.SECONDS);
-//            redisService.setCacheObject("subjectByYa" + subFunction.getSubId(), subFunction.getSubId(), 2L, TimeUnit.MINUTES);
+//            redisService.setCacheObject("subjectByYa" + subFunction.getSubId(), subFunction.getSubId(), 10L, TimeUnit.SECONDS);
+            redisService.setCacheObject("subjectByYa" + subFunction.getSubId(), subFunction.getSubId(), 2L, TimeUnit.MINUTES);
             log.info("@@@@@@@@@@@@@@@@@@@@预案延长3分钟@@@@@@@@@@@@@@@@@@@@");
             log.info("@@@@@@@@@@@@@@@@@@@@预案延长3分钟@@@@@@@@@@@@@@@@@@@@");
 //            }
 //            }
             Map<SenseType, List<SensorFunctionStatus>> sensorFunctionStatusListMap = hardwareFunctionStatusConfig.getSensorFunctionStatusListMap();
             Map<SenseType, List<SensorFunctionStatus>> sensorFunctionStatusListMap = hardwareFunctionStatusConfig.getSensorFunctionStatusListMap();
@@ -1085,7 +1086,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                     String funNum1 = sensorFunctionStatusListMap.get(SenseType.getByCode(rps.getSensorType())).get(0).getFunNum();
                     String funNum1 = sensorFunctionStatusListMap.get(SenseType.getByCode(rps.getSensorType())).get(0).getFunNum();
                     if (funNum1.equals(sensorFunc.getFunNum())) {
                     if (funNum1.equals(sensorFunc.getFunNum())) {
                         getJsonStr(riskPlanJson, sensorFunc);
                         getJsonStr(riskPlanJson, sensorFunc);
-                        labRiskPlanLevel.setTopName(labRiskPlanLevel.getTopName() + " " + sensorFunc.getDescribe());
+                        labRiskPlanLevel.setTopName("【实验室安全系统】"+labRiskPlanLevel.getTopName() + "-" + sensorFunc.getDescribe()+":"+sensorFunc.getVal());
                         sb.append(sensorFunc.getDescribe()).append("、");
                         sb.append(sensorFunc.getDescribe()).append("、");
                     }
                     }
                 }
                 }
@@ -1115,8 +1116,9 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
 
 
                 //向一体机推送语音播报
                 //向一体机推送语音播报
                 log.error("向一体机推送语音播报开始=======================================================");
                 log.error("向一体机推送语音播报开始=======================================================");
+                String str = StringUtils.isBlank(labRiskPlanLevel.getVoicebroadcast()) ? "" : labRiskPlanLevel.getVoicebroadcast();
                 try {
                 try {
-                    messageSendService.sendOnepcSubNews(subFunction.getSubId(), 2, labRiskPlanLevel.getTopName() + "" + labRiskPlanLevel.getVoicebroadcast());
+                    messageSendService.sendOnepcSubNews(subFunction.getSubId(), 2, RiskPlanConstants.LAB_SAFETY_MANAGEMENT_SYSTEM + labRiskPlanLevel.getTopName() + str);
                 } catch (Exception e) {
                 } catch (Exception e) {
                     log.error("向一体机推送语音播报异常:" + e);
                     log.error("向一体机推送语音播报异常:" + e);
                 }
                 }
@@ -1127,7 +1129,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 log.error("向一体机传感器预警结束=======================================================");
                 log.error("向一体机传感器预警结束=======================================================");
                 //向一体机发送预警消息展示
                 //向一体机发送预警消息展示
                 log.error("向一体机发送预警消息展示开始=======================================================");
                 log.error("向一体机发送预警消息展示开始=======================================================");
-                insertMachineContent(subFunction.getSubId(), labRiskPlanLevel.getTopName() + "" + labRiskPlanLevel.getVoicebroadcast());
+                insertMachineContent(subFunction.getSubId(), RiskPlanConstants.LAB_SAFETY_MANAGEMENT_SYSTEM + labRiskPlanLevel.getTopName() + str);
                 log.error("向一体机发送预警消息展示结束=======================================================");
                 log.error("向一体机发送预警消息展示结束=======================================================");
 
 
                 //首页消息通知
                 //首页消息通知
@@ -1180,20 +1182,6 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 } catch (Exception e) {
                 } catch (Exception e) {
                     log.error("开启喇叭失败!!!!!:" + e);
                     log.error("开启喇叭失败!!!!!:" + e);
                 }
                 }
-
-//                // TODO: 2022/3/26  目前只有c111外的响
-//                List<PlayVo> playVoList = new ArrayList<>();
-//                PlayVo playVo = new PlayVo();
-//                playVo.setSn("ls20://0201BFB9D686");
-//                playVo.setPort(18884);
-//                ParamVo paramVo=new ParamVo();
-//                playVo.setParams(paramVo);
-//                playVoList.add(playVo);
-//                if(radioStr.length()>0){
-//                    remoteSpeakService.textParseUrlAppIps(radioStr.toString(),playVoList);
-//                    log.info("喇叭播放完成!");
-//                }
-
                 //首页预案流程通知
                 //首页预案流程通知
                 messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_LOG);
                 messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_LOG);
                 //首页预案组通知
                 //首页预案组通知
@@ -1204,22 +1192,24 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                     redisService.setCacheObject("subjectByExit" + subFunction.getSubId(), subFunction.getSubId(), 30L, TimeUnit.SECONDS);
                     redisService.setCacheObject("subjectByExit" + subFunction.getSubId(), subFunction.getSubId(), 30L, TimeUnit.SECONDS);
                     messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_EXIT);
                     messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_EXIT);
                 }
                 }
+                //远程调用结束录制视频接口
                 try {
                 try {
                     LabHardware labHardware = labHardwareService.selectLabHardwareCameraBySub(subFunction.getSubId());
                     LabHardware labHardware = labHardwareService.selectLabHardwareCameraBySub(subFunction.getSubId());
-                    if (labHardware != null) {
-                        //开始录制视频
-    //                    remoteCameraService.startRecord("192.168.1.64");
-//                        remoteCameraService.startRecord(labHardware.getIpAddress());
+                    if (labHardware == null) {
+                        log.info("未查询到实验室关联摄像头信息!请检查ip是否为空!");
+                    }
+                    //开始录制视频
+                    log.info("远程调用开始录制视频ip地址={}",labHardware.getIpAddress());
+                    R r = remoteCameraService.startRecord(labHardware.getIpAddress());
+                    log.info("开始录制视频返回结果打印={}", JSON.toJSONString(r));
+                    if (r.getCode() != HttpStatus.SUCCESS){
+                        log.info("开始录制视频失败!");
                     }
                     }
                 } catch (Exception e) {
                 } catch (Exception e) {
-                    throw new RuntimeException(e);
+                    log.error("远程调用开始录制视频接口失败!{}",e);
                 }
                 }
-
-                R r = remoteCameraService.startRecord("192.168.1.64");
-                log.info("摄像头信息={}", JSON.toJSONString(r));
                 //向前端发送mqtt预案触发提示
                 //向前端发送mqtt预案触发提示
                 messageSendService.riskPlanTriggerNotice();
                 messageSendService.riskPlanTriggerNotice();
-
             }
             }
 
 
         } else {
         } else {
@@ -1298,22 +1288,28 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 // todo 操作人和视频结束时候的 url
                 // todo 操作人和视频结束时候的 url
 
 
                 //关闭视频录像
                 //关闭视频录像
-                LabHardware labHardware = labHardwareService.selectLabHardwareCameraBySub(subFunction.getSubId());
-                if (labHardware != null){
-                    //开始录制视频
-//                    remoteCameraService.startRecord("192.168.1.14");
-                    R r = remoteCameraService.stopRecord(labHardware.getIpAddress());
-                    if (r.getCode() == HttpStatus.SUCCESS) {
-
+                String recordVideo = "";
+                try {
+                    LabHardware labHardware = labHardwareService.selectLabHardwareCameraBySub(subFunction.getSubId());
+                    if (labHardware != null) {
+                        //开始录制视频
+                        log.info("远程调用关闭视频ip地址={}",labHardware.getIpAddress());
+                        R r = remoteCameraService.stopRecord(labHardware.getIpAddress());
+                        log.info("录制视频结束返回结果打印={}", JSON.toJSONString(r));
+                        if (r.getCode() == HttpStatus.SUCCESS){
+                            com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(r.getData()));
+                            recordVideo = jsonObject.getString("msg");
+                        }else {
+                            log.info("结束录制视频失败!");
+                        }
+                    }else {
+                        log.info("未查询到实验室关联摄像头信息!请检查ip是否为空!");
                     }
                     }
+                } catch (Exception e) {
+                    log.error("远程调用结束录制视频接口失败!{}",e);
                 }
                 }
-
-                R r = remoteCameraService.stopRecord("192.168.1.64");
-                log.info("摄像头信息2={}", JSON.toJSONString(r));
-
-                //TODO 更新风险概要  recordVideo - 视频记录存放地址
-                String handlePerson = null;
-                String recordVideo = "";
+                //更新风险概要  recordVideo - 视频记录存放地址
+                String handlePerson = tokenService.getLoginUser().getNickName();
                 labRiskPlanAbnormalDescService.updateLabRiskPlanAbnormalDesc(groupVo.getId(),handlePerson, recordVideo);
                 labRiskPlanAbnormalDescService.updateLabRiskPlanAbnormalDesc(groupVo.getId(),handlePerson, recordVideo);
                 log.info("groupId = {}",groupList.get(0).getId());
                 log.info("groupId = {}",groupList.get(0).getId());
                 writerEnterRiskPlan(groupList.get(0).getId(),2);
                 writerEnterRiskPlan(groupList.get(0).getId(),2);
@@ -1413,10 +1409,6 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
             newGroupOP.setStatus(0L);
             newGroupOP.setStatus(0L);
             newGroupOP.setUpdateTime(new Date());
             newGroupOP.setUpdateTime(new Date());
             labRiskPlanAbnormalGroupMapper.updateLabRiskPlanAbnormalGroup(newGroupOP);
             labRiskPlanAbnormalGroupMapper.updateLabRiskPlanAbnormalGroup(newGroupOP);
-            //TODO 更新风险概要
-            String handlePerson = null;
-            String recordVideo = "";
-            labRiskPlanAbnormalDescService.updateLabRiskPlanAbnormalDesc(groupVo.getId(),handlePerson, recordVideo);
             //插入预案结束日志
             //插入预案结束日志
             insertPlanAbnormalLogByOver(groupVo, allRiskPlanJson, subFunction);
             insertPlanAbnormalLogByOver(groupVo, allRiskPlanJson, subFunction);
             //向一体机传感器预警
             //向一体机传感器预警
@@ -1427,21 +1419,29 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
             messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_LOG);
             messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_LOG);
             //首页预案是否同步疏散线路
             //首页预案是否同步疏散线路
             messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_EXIT);
             messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_EXIT);
-            //关闭视频录像
-            LabHardware labHardware = labHardwareService.selectLabHardwareCameraBySub(subFunction.getSubId());
-            if (labHardware != null){
+            //远程调用结束录制视频接口
+            String recordVideo = "";
+            try {
+                LabHardware labHardware = labHardwareService.selectLabHardwareCameraBySub(subFunction.getSubId());
+                if (labHardware == null) {
+                    log.info("未查询到实验室关联摄像头信息!请检查ip是否为空!");
+                }
                 //开始录制视频
                 //开始录制视频
-//                    remoteCameraService.startRecord("192.168.1.14");
-                R r = remoteCameraService.stopRecord(labHardware.getIpAddress());
-                if (r.getCode() == HttpStatus.SUCCESS) {
-
+                log.info("远程调用开始录制视频ip地址={}",labHardware.getIpAddress());
+                R r = remoteCameraService.startRecord(labHardware.getIpAddress());
+                log.info("结束录制视频返回结果打印={}", JSON.toJSONString(r));
+                if (r.getCode() == HttpStatus.SUCCESS){
+                    com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(r.getData()));
+                    recordVideo = jsonObject.getString("msg");
+                }else {
+                    log.info("结束录制视频失败!");
                 }
                 }
+            } catch (Exception e) {
+                log.error("远程调用开始录制视频接口失败!{}",e);
             }
             }
-            R r = remoteCameraService.stopRecord("192.168.1.64");
-            if (r.getCode()== HttpStatus.SUCCESS){
-
-            }
-            log.info("assddd");
+            //更新风险概要
+            String handlePerson = tokenService.getLoginUser().getNickName();
+            labRiskPlanAbnormalDescService.updateLabRiskPlanAbnormalDesc(groupVo.getId(),handlePerson, recordVideo);
         }
         }
         return 0;
         return 0;
     }
     }
@@ -1608,7 +1608,8 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
         //这里给消息记录表插入数据(给一体机设备发送语音通知)
         //这里给消息记录表插入数据(给一体机设备发送语音通知)
         LabWarnPushMessage labWarnPushMessage = new LabWarnPushMessage();
         LabWarnPushMessage labWarnPushMessage = new LabWarnPushMessage();
         labWarnPushMessage.setRiskGroup(groupId);
         labWarnPushMessage.setRiskGroup(groupId);
-        labWarnPushMessage.setContext(labRiskPlanLevel.getTopName() + "" + labRiskPlanLevel.getInformation());
+        String string = StringUtils.isBlank(labRiskPlanLevel.getInformation()) ? "" : labRiskPlanLevel.getInformation();
+        labWarnPushMessage.setContext(RiskPlanConstants.LAB_SAFETY_MANAGEMENT_SYSTEM + labRiskPlanLevel.getTopName() + string);
         labWarnPushMessage.setPushType(WarnMessageTypeEnum.voice);
         labWarnPushMessage.setPushType(WarnMessageTypeEnum.voice);
         labWarnPushMessage.setWarnId(labRiskPlanLevel.getRiskPlanId());
         labWarnPushMessage.setWarnId(labRiskPlanLevel.getRiskPlanId());
         labWarnPushMessage.setSubId(subjectId);
         labWarnPushMessage.setSubId(subjectId);

+ 4 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabWarnPushMessageServiceImpl.java

@@ -1,6 +1,8 @@
 package com.zd.laboratory.service.impl;
 package com.zd.laboratory.service.impl;
 
 
 import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.utils.DateUtils;
+import com.zd.common.core.utils.StringUtils;
+import com.zd.laboratory.api.constant.RiskPlanConstants;
 import com.zd.laboratory.domain.LabRiskPlanLevel;
 import com.zd.laboratory.domain.LabRiskPlanLevel;
 import com.zd.laboratory.domain.LabWarnPushMessage;
 import com.zd.laboratory.domain.LabWarnPushMessage;
 import com.zd.laboratory.domain.vo.LabWarnPushMessageVO;
 import com.zd.laboratory.domain.vo.LabWarnPushMessageVO;
@@ -72,7 +74,8 @@ public class LabWarnPushMessageServiceImpl implements ILabWarnPushMessageService
             try {
             try {
                 LabWarnPushMessage labWarnPushMessage = new LabWarnPushMessage();
                 LabWarnPushMessage labWarnPushMessage = new LabWarnPushMessage();
                 labWarnPushMessage.setRiskGroup(groupId);
                 labWarnPushMessage.setRiskGroup(groupId);
-                labWarnPushMessage.setContext(labRiskPlanLevel.getTopName()+""+labRiskPlanLevel.getMessage());
+                String str= StringUtils.isBlank(labRiskPlanLevel.getMessage()) ? "" : labRiskPlanLevel.getMessage();
+                labWarnPushMessage.setContext(RiskPlanConstants.LAB_SAFETY_MANAGEMENT_SYSTEM + labRiskPlanLevel.getTopName() + str);
                 labWarnPushMessage.setPushType(WarnMessageTypeEnum.SMS);
                 labWarnPushMessage.setPushType(WarnMessageTypeEnum.SMS);
                 labWarnPushMessage.setWarnId(labRiskPlanLevel.getRiskPlanId());
                 labWarnPushMessage.setWarnId(labRiskPlanLevel.getRiskPlanId());
                 labWarnPushMessage.setSubId(subId);
                 labWarnPushMessage.setSubId(subId);