导出组织到数据库

导出通道添加字段
This commit is contained in:
wuweida 2022-05-07 17:22:15 +08:00
parent 81773d9216
commit 7d112072ac
6 changed files with 54 additions and 13 deletions

View File

@ -27,4 +27,6 @@ public class CameraChannel {
private Integer checkStatus;//1正常0异常
private String parentId;
}

View File

@ -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;
}

View File

@ -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> {
}

View File

@ -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);
}
}
}

View File

@ -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>

View File

@ -29,7 +29,7 @@ class MonitorManageApplicationTests {
}
@Test
void videoService()throws IOException {
void videoService()throws IOException ,InterruptedException{
monitorService.videoService("","");