Explorar o código

Merge branch 'dev' of http://192.168.1.43:3000/v2/zd-parents into dev

chaiyunlong %!s(int64=3) %!d(string=hai) anos
pai
achega
fc1167316e

BIN=BIN
zd-modules/zd-algorithm/libs/onvif-java-1.0.2.jar


+ 18 - 0
zd-modules/zd-algorithm/pom.xml

@@ -148,50 +148,67 @@
         <dependency>
             <groupId>com.zd.swagger</groupId>
             <artifactId>common-swagger</artifactId>
+            <version>3.1.0</version>
         </dependency>
 
         <dependency>
             <groupId>com.zd.base</groupId>
             <artifactId>zd-base-api</artifactId>
+            <version>3.1.0</version>
         </dependency>
 
         <dependency>
             <groupId>com.zd.chemical</groupId>
             <artifactId>zd-chemical-api</artifactId>
+            <version>3.1.0</version>
         </dependency>
 
         <dependency>
             <groupId>com.zd.airbottle</groupId>
             <artifactId>zd-airbottle-api</artifactId>
+            <version>3.1.0</version>
         </dependency>
 
         <dependency>
             <groupId>com.zd.laboratory</groupId>
             <artifactId>zd-laboratory-api</artifactId>
+            <version>3.1.0</version>
         </dependency>
 
         <dependency>
             <groupId>com.zd.algorithm</groupId>
             <artifactId>zd-algorithm-api</artifactId>
+            <version>3.1.0</version>
         </dependency>
 
         <dependency>
             <groupId>com.zd.core</groupId>
             <artifactId>common-core</artifactId>
+            <version>3.1.0</version>
         </dependency>
 
         <dependency>
             <groupId>com.zd.mqtt</groupId>
             <artifactId>common-mqtt</artifactId>
+            <version>3.1.0</version>
         </dependency>
 
         <dependency>
             <groupId>com.zd.system</groupId>
             <artifactId>zd-system-api</artifactId>
+            <version>3.1.0</version>
         </dependency>
         <dependency>
             <groupId>com.zd.auth</groupId>
             <artifactId>zd-auth-api</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>be.teletask</groupId>
+            <artifactId>onvif-java</artifactId>
+            <version>1.0.2</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/libs/onvif-java-1.0.2.jar</systemPath>
         </dependency>
     </dependencies>
 
@@ -201,6 +218,7 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot.version}</version>
                 <configuration>
                     <includeSystemScope>true</includeSystemScope>
                 </configuration>

+ 37 - 32
zd-modules/zd-algorithm/src/main/java/com/zd/alg/fire/utils/FireDeviceStatusTask.java

@@ -47,43 +47,48 @@ public class FireDeviceStatusTask {
      *
      */
     @Scheduled(cron = "0/20 * * * * ?")
-    public void getFireDeviceStatus() throws InterruptedException {
-        //redis取值
-        List<HardwareFireDeviceVO> list = JSON.parseArray(redisService.getCacheObject(CacheConstants.FIRE_DEVICE_LIST) + "", HardwareFireDeviceVO.class);
-        if (list == null) {
-            logger.info("====灭火设备集合,redis未取到值,数据库查询======");
-            list = hardwareFireDeviceService.selectHardwareFireDeviceList(new HardwareFireDeviceVO());
-            //redis存值,时效1分钟
-            redisService.setCacheObject(CacheConstants.FIRE_DEVICE_LIST, list, 60L, TimeUnit.MINUTES);
-        }
+    public void getFireDeviceStatus() {
+
+        try {
+            //redis取值
+            List<HardwareFireDeviceVO> list = JSON.parseArray(redisService.getCacheObject(CacheConstants.FIRE_DEVICE_LIST) + "", HardwareFireDeviceVO.class);
+            if (list == null) {
+                logger.info("====灭火设备集合,redis未取到值,数据库查询======");
+                list = hardwareFireDeviceService.selectHardwareFireDeviceList(new HardwareFireDeviceVO());
+                //redis存值,时效1分钟
+                redisService.setCacheObject(CacheConstants.FIRE_DEVICE_LIST, list, 60L, TimeUnit.MINUTES);
+            }
 
-        if (list != null && list.size()>0) {
-            for (HardwareFireDeviceVO vo : list) {
-                //根据主机地址-位获取主机状态指令
-                String activeCode = FireLaborUtil.getFireActiveOrder(vo.getDeviceUrl());
-                //向mqtt发送状态信息
-                //byte[] activeCodeByte=activeCode.getBytes(StandardCharsets.UTF_8);
-                byte[] activeCodeByte =ReUtil.hexStringToByteArray(activeCode);
-                mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE + vo.getDeviceCode(), activeCodeByte);
-                //兼容指令无反应问题
-                Thread.sleep(500);
-                mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE + vo.getDeviceCode(), activeCodeByte);
-                logger.info("集合数量:" + list.size() + ",mqtt消息推送, 灭火装置状态请求,实验室id:" + vo.getSubjectId() + ",采集器编号:" + vo.getDeviceCode()+",继电器编号"+vo.getRelayCode());
+            if (list != null && list.size()>0) {
+                for (HardwareFireDeviceVO vo : list) {
+                    //根据主机地址-位获取主机状态指令
+                    String activeCode = FireLaborUtil.getFireActiveOrder(vo.getDeviceUrl());
+                    //向mqtt发送状态信息
+                    //byte[] activeCodeByte=activeCode.getBytes(StandardCharsets.UTF_8);
+                    byte[] activeCodeByte =ReUtil.hexStringToByteArray(activeCode);
+                    mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE + vo.getDeviceCode(), activeCodeByte);
+                    //兼容指令无反应问题
+                    /*Thread.sleep(500);
+                    mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE + vo.getDeviceCode(), activeCodeByte);*/
+                    logger.info("集合数量:" + list.size() + ",mqtt消息推送, 灭火装置状态请求,实验室id:" + vo.getSubjectId() + ",采集器编号:" + vo.getDeviceCode()+",继电器编号"+vo.getRelayCode());
 
 
-                //获取灭火主机最后一次响应时间,判断响应是否超时
-                Long timeJson = redisService.getCacheObject(CacheConstants.FIRE_DEVICE_RESPOND_TIME+vo.getDeviceCode());
-                if (StringUtils.isNull(timeJson)) {
-                    logger.info("设备掉线,实验室id:"+vo.getSubjectId()+",采集器编号:"+vo.getDeviceCode());
-                    //离线
-                    mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE_ONLINE+vo.getDeviceCode(), "0");
-                }else{
-                    //在线
-                    mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE_ONLINE+vo.getDeviceCode(), "1");
+                    //获取灭火主机最后一次响应时间,判断响应是否超时
+                    Long timeJson = redisService.getCacheObject(CacheConstants.FIRE_DEVICE_RESPOND_TIME+vo.getDeviceCode());
+                    if (StringUtils.isNull(timeJson)) {
+                        logger.info("设备掉线,实验室id:"+vo.getSubjectId()+",采集器编号:"+vo.getDeviceCode());
+                        //离线
+                        mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE_ONLINE+vo.getDeviceCode(), "0");
+                    }else{
+                        //在线
+                        mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE_ONLINE+vo.getDeviceCode(), "1");
+                    }
                 }
+            } else {
+                logger.info("====暂未查询到灭火主机信息====");
             }
-        } else {
-            logger.info("====暂未查询到灭火主机信息====");
+        } catch (Exception e) {
+            logger.info("一键灭火定时任务异常"+e);
         }
     }
 }

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabRiskPlanAbnormalGroupMapper.java

@@ -53,7 +53,7 @@ public interface LabRiskPlanAbnormalGroupMapper {
      * @param subId 实验室ID
      * @return
      */
-    List<String> queryWranFunNumBySubId(Long subId);
+    List<Integer> queryWranFunNumBySubId(Long subId);
 
     /**
      * 批量查询 实验室当前预警

+ 2 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/config/MqttConfig.java

@@ -279,8 +279,8 @@ public class MqttConfig {
             public void handleMessage(Message<?> message) throws MessagingException {
                 MessageHeaders messageHeaders = message.getHeaders();
                 String receivedTopic = (String) messageHeaders.get(MqttHeaders.RECEIVED_TOPIC);
-                logger.info("[通道] - [{}]", receivedTopic);
-                logger.info("[消息] - [{}]", message.getPayload());
+                //logger.info("[通道] - [{}]", receivedTopic);
+                //logger.info("[消息] - [{}]", message.getPayload());
                 String messageStr = message.getPayload().toString();
                 if (receivedTopic.startsWith(devicePrefix)) {
                     if (receivedTopic.contains("788D4C6C6187ABC")) {

+ 14 - 4
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabRiskPlanAbnormalGroupServiceImpl.java

@@ -14,18 +14,19 @@ import com.zd.laboratory.domain.LabRiskPlanAbnormalGroup;
 import com.zd.laboratory.domain.LabRiskPlanAbnormalLog;
 import com.zd.laboratory.domain.vo.LabRiskPlanAbnormalGroupVO;
 import com.zd.laboratory.mapper.LabHardwareMapper;
-import com.zd.laboratory.mapper.LabHardwareStateMapper;
 import com.zd.laboratory.mapper.LabRiskPlanAbnormalGroupMapper;
 import com.zd.laboratory.mapper.LabRiskPlanAbnormalLogMapper;
 import com.zd.laboratory.service.ILabExitLineService;
 import com.zd.laboratory.service.ILabRiskPlanAbnormalDescService;
 import com.zd.laboratory.service.ILabRiskPlanAbnormalGroupService;
 import com.zd.model.enums.HardwareTypeEnum;
+import com.zd.model.enums.SenseType;
 import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -58,6 +59,9 @@ public class LabRiskPlanAbnormalGroupServiceImpl implements ILabRiskPlanAbnormal
     @Autowired
     private RedisService redisService;
 
+    @Autowired
+    public HardwareFunctionStatusConfig hardwareFunctionStatusConfig;
+
 
     @Override
 //    @DataScope(deptAlias = "t")
@@ -107,11 +111,17 @@ public class LabRiskPlanAbnormalGroupServiceImpl implements ILabRiskPlanAbnormal
      */
     @Override
     public List<SensorFunctionStatus> queryWranFunNumBySubId(Long subId) {
-        List<String> strings = labRiskPlanAbnormalGroupMapper.queryWranFunNumBySubId(subId);
-
-        if(CollectionUtils.isEmpty(strings)){
+        List<Integer> sensorTypes = labRiskPlanAbnormalGroupMapper.queryWranFunNumBySubId(subId);
+        if(CollectionUtils.isEmpty(sensorTypes)){
             return new ArrayList<>();
         }
+        List<String> strings = new ArrayList<>();
+        Map<SenseType, List<SensorFunctionStatus>> sensorFunctionStatusListMap = hardwareFunctionStatusConfig.getSensorFunctionStatusListMap();
+        for (Integer sensorType : sensorTypes) {
+            List<SensorFunctionStatus> sensorFunctionStatuses = sensorFunctionStatusListMap.get(SenseType.getByCode(sensorType));
+            String funNum = sensorFunctionStatuses.get(0).getFunNum();
+            strings.add(funNum);
+        }
         logger.info("一体机预案异常类型:" + JSONUtil.toJsonStr(strings) + ", 实验室ID------" + subId);
         List<SensorFunctionStatus> list = labSubjectManagerService.querySenseNewFunctionBySubId(subId);
         logger.info("一体机预案实验室数据:" + JSONUtil.toJsonStr(list));

+ 10 - 4
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabRiskPlanServiceImpl.java

@@ -1069,8 +1069,8 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
             });
             //有效预案延长一分钟
 //            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分钟@@@@@@@@@@@@@@@@@@@@");
 //            }
             Map<SenseType, List<SensorFunctionStatus>> sensorFunctionStatusListMap = hardwareFunctionStatusConfig.getSensorFunctionStatusListMap();
@@ -1206,12 +1206,15 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                     LabHardware labHardware = labHardwareService.selectLabHardwareCameraBySub(subFunction.getSubId());
                     if (labHardware != null) {
                         //开始录制视频
-    //                    remoteCameraService.startRecord("192.168.1.14");
-                        remoteCameraService.startRecord(labHardware.getIpAddress());
+    //                    remoteCameraService.startRecord("192.168.1.64");
+//                        remoteCameraService.startRecord(labHardware.getIpAddress());
                     }
                 } catch (Exception e) {
                     throw new RuntimeException(e);
                 }
+
+                R r = remoteCameraService.startRecord("192.168.1.64");
+                log.info("摄像头信息={}", JSON.toJSONString(r));
                 //向前端发送mqtt预案触发提示
                 messageSendService.riskPlanTriggerNotice();
 
@@ -1303,6 +1306,9 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                     }
                 }
 
+                R r = remoteCameraService.stopRecord("192.168.1.64");
+                log.info("摄像头信息2={}", JSON.toJSONString(r));
+
                 //TODO 更新风险概要  recordVideo - 视频记录存放地址
                 String handlePerson = null;
                 String recordVideo = "";

+ 2 - 2
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabRiskPlanAbnormalGroupMapper.xml

@@ -124,8 +124,8 @@
         where id = #{id}
     </update>
     <!--  根据实验室ID查询当前预警测试功能   -->
-      <select id="queryWranFunNumBySubId" resultType="java.lang.String" >
-          SELECT DISTINCT psr.`fun_num` FROM lab_risk_plan rp INNER JOIN  lab_risk_plan_sensor_relation psr ON rp.id = psr.`risk_plan_id`
+      <select id="queryWranFunNumBySubId" resultType="java.lang.Integer" >
+          SELECT DISTINCT psr.`sensor_type` FROM lab_risk_plan rp INNER JOIN  lab_risk_plan_sensor_relation psr ON rp.id = psr.`risk_plan_id`
           INNER JOIN lab_risk_planjoinsub rpb ON rp.id = rpb.`risk_plan_id`
           INNER JOIN lab_risk_plan_abnormal_log pal ON pal.`risk_plan_id` = rp.`id`
           INNER JOIN lab_risk_plan_abnormal_group pag ON pal.`group_id` = pag.`id`