parent
81773d9216
commit
7d112072ac
|
@ -27,4 +27,6 @@ public class CameraChannel {
|
|||
|
||||
private Integer checkStatus;//1正常;0异常
|
||||
|
||||
private String parentId;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
|
@ -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<CameraOrgan> {
|
||||
}
|
|
@ -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<Map>();
|
||||
|
||||
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<List> 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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hisense.monitormanage.mapper.CameraOrgenMapper">
|
||||
|
||||
</mapper>
|
|
@ -29,7 +29,7 @@ class MonitorManageApplicationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void videoService()throws IOException {
|
||||
void videoService()throws IOException ,InterruptedException{
|
||||
|
||||
monitorService.videoService("","");
|
||||
|
||||
|
|
Loading…
Reference in New Issue