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("","");