From 7d112072ac41b588556bc0bbb938a14e6ad3ced4 Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Sat, 7 May 2022 17:22:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E7=BB=84=E7=BB=87=E5=88=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=20=E5=AF=BC=E5=87=BA=E9=80=9A?= =?UTF-8?q?=E9=81=93=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitormanage/entity/CameraChannel.java | 2 ++ .../monitormanage/entity/CameraOrgan.java | 22 ++++++++++++++ .../mapper/CameraOrgenMapper.java | 7 +++++ .../monitormanage/service/MonitorService.java | 29 +++++++++++-------- .../resources/mapper/CameraOrganMapper.xml | 5 ++++ .../MonitorManageApplicationTests.java | 2 +- 6 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/hisense/monitormanage/entity/CameraOrgan.java create mode 100644 src/main/java/com/hisense/monitormanage/mapper/CameraOrgenMapper.java create mode 100644 src/main/resources/mapper/CameraOrganMapper.xml diff --git a/src/main/java/com/hisense/monitormanage/entity/CameraChannel.java b/src/main/java/com/hisense/monitormanage/entity/CameraChannel.java index a2b5e3a..1ffa86b 100644 --- a/src/main/java/com/hisense/monitormanage/entity/CameraChannel.java +++ b/src/main/java/com/hisense/monitormanage/entity/CameraChannel.java @@ -27,4 +27,6 @@ public class CameraChannel { private Integer checkStatus;//1正常;0异常 + private String parentId; + } diff --git a/src/main/java/com/hisense/monitormanage/entity/CameraOrgan.java b/src/main/java/com/hisense/monitormanage/entity/CameraOrgan.java new file mode 100644 index 0000000..5aa716a --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/entity/CameraOrgan.java @@ -0,0 +1,22 @@ +package com.hisense.monitormanage.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("t_camera_organ") +public class CameraOrgan { + @TableId + private String id; + + private String name; + + private String parentId; + + private Integer sort; + + private Integer subCount; + + +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/CameraOrgenMapper.java b/src/main/java/com/hisense/monitormanage/mapper/CameraOrgenMapper.java new file mode 100644 index 0000000..112facb --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/mapper/CameraOrgenMapper.java @@ -0,0 +1,7 @@ +package com.hisense.monitormanage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hisense.monitormanage.entity.CameraOrgan; + +public interface CameraOrgenMapper extends BaseMapper { +} diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index 1519659..e5b265f 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -2,14 +2,8 @@ package com.hisense.monitormanage.service; import cn.hutool.crypto.SecureUtil; import com.alibaba.fastjson.JSONObject; -import com.hisense.monitormanage.entity.Camera; -import com.hisense.monitormanage.entity.CameraChannel; -import com.hisense.monitormanage.entity.CameraScenic; -import com.hisense.monitormanage.entity.Result; -import com.hisense.monitormanage.mapper.CameraChannelMapper; -import com.hisense.monitormanage.mapper.CameraMapper; -import com.hisense.monitormanage.mapper.CameraScenicMapper; -import com.hisense.monitormanage.mapper.ScenicMapper; +import com.hisense.monitormanage.entity.*; +import com.hisense.monitormanage.mapper.*; import lombok.extern.log4j.Log4j2; import org.bytedeco.javacv.FFmpegFrameGrabber; import org.bytedeco.javacv.Frame; @@ -53,6 +47,9 @@ public class MonitorService { @Autowired private CameraChannelMapper cameraChannelMapper; + @Autowired + private CameraOrgenMapper cameraOrgenMapper; + @Value("${hwx.file.work-path}") private String fileDir; @Value("${hwx.file.pic-host}") @@ -361,7 +358,7 @@ public class MonitorService { } static public List cameras = new LinkedList(); - public void videoService(String parentId, String path)throws IOException{ + public void videoService(String parentId, String path) throws IOException, InterruptedException { String url = monitorDomain + "/videoService/devicesManager/deviceTree?nodeType=1&typeCode=01;0;ALL;ALL&id=" + parentId; @@ -370,13 +367,14 @@ public class MonitorService { headers.add("X-Subject-Token",token); ResponseEntity forEntity = null; - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 10; i++) { try { forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), List.class ); break; }catch (Exception e){ log.error("重试次数:{} url:{}",i,url); log.error(e); + Thread.sleep(5*1000); } } @@ -392,21 +390,28 @@ public class MonitorService { Boolean isParent = (Boolean) result.get("isParent"); if (isParent){ + CameraOrgan cameraOrgan = JSONObject.parseObject(JSONObject.toJSONString(result), CameraOrgan.class); + + cameraOrgenMapper.insert(cameraOrgan); + videoService((String) result.get("id"),path + sep + result.get("name")); }else { if (result.get("channelId") != null){ CameraChannel cameraChannel = JSONObject.parseObject(JSONObject.toJSONString(result), CameraChannel.class); + String id = (String)result.get("parentId"); + if (path != null && path.startsWith(sep)) { path = path.substring(sep.length()); } cameraChannel.setNodeName(path); + + cameraChannel.setParentId(id); + cameraChannelMapper.insert(cameraChannel); - } - } } diff --git a/src/main/resources/mapper/CameraOrganMapper.xml b/src/main/resources/mapper/CameraOrganMapper.xml new file mode 100644 index 0000000..88e2420 --- /dev/null +++ b/src/main/resources/mapper/CameraOrganMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/test/java/com/hisense/monitormanage/MonitorManageApplicationTests.java b/src/test/java/com/hisense/monitormanage/MonitorManageApplicationTests.java index 5c100ac..50f0744 100644 --- a/src/test/java/com/hisense/monitormanage/MonitorManageApplicationTests.java +++ b/src/test/java/com/hisense/monitormanage/MonitorManageApplicationTests.java @@ -29,7 +29,7 @@ class MonitorManageApplicationTests { } @Test - void videoService()throws IOException { + void videoService()throws IOException ,InterruptedException{ monitorService.videoService("","");