Browse Source

存储部分使用sqlite代替redis-3

pull/31/head
panlinlin 4 years ago
parent
commit
dcd78a1cfa
  1. 59
      pom.xml
  2. 45
      src/main/java/com/genersoft/iot/vmp/common/PageResult.java
  3. 53
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
  4. 13
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
  5. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
  6. 18
      src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
  7. 17
      src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java
  8. 40
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
  9. 50
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
  10. 4
      src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
  11. 281
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  12. 40
      src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java
  13. 401
      src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/Device.java
  14. 385
      src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/DeviceChannel.java
  15. 19
      src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java
  16. 1
      src/main/resources/application-dev.yml
  17. 2
      src/main/resources/application.yml
  18. BIN
      src/main/resources/wvp.sqlite
  19. 6
      web_src/src/components/channelList.vue
  20. 5
      web_src/src/components/videoList.vue

59
pom.xml

@ -45,9 +45,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- 依赖版本 -->
<mapper.version>4.1.5</mapper.version>
<mybatis.version>3.5.5</mybatis.version>
<mybatis.spring.version>2.0.5</mybatis.spring.version>
<pagehelper.version>5.2.0</pagehelper.version>
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
<asciidoctor.input.directory>${project.basedir}/docs/asciidoc</asciidoctor.input.directory>
@ -59,30 +56,16 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.3.0</version>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
<!-- druid数据库连接池 -->
@ -106,36 +89,18 @@
<version>3.32.3.2</version>
</dependency>
<!--Mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<!--分页插件 -->
<!--Mybatis分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.10</version>
</dependency>
<!--通用Mapper -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>${mapper.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.commons</groupId>-->
<!-- <artifactId>commons-lang3</artifactId>-->
<!-- <version>3.11</version>-->
<!-- </dependency>-->
<!--Swagger2 -->
<!--在线文档 -->

45
src/main/java/com/genersoft/iot/vmp/common/PageResult.java

@ -1,45 +0,0 @@
package com.genersoft.iot.vmp.common;
import java.util.List;
public class PageResult<T> {
private int page;
private int count;
private int total;
private List<T> data;
public List<T> getData() {
return data;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public void setData(List<T> data) {
this.data = data;
}
}

53
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java

@ -1,17 +1,8 @@
package com.genersoft.iot.vmp.gb28181.bean;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class Device {
/**
* 数据库存储ID
*/
private int id;
/**
* 设备Id
*/
@ -51,10 +42,20 @@ public class Device {
*/
private String streamMode;
/**
* wan地址_ip
*/
private String ip;
/**
* wan地址_port
*/
private int port;
/**
* wan地址
*/
private Host host;
private String hostAddress;
/**
* 在线
@ -72,14 +73,6 @@ public class Device {
*/
private int channelCount;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDeviceId() {
return deviceId;
}
@ -136,12 +129,28 @@ public class Device {
this.streamMode = streamMode;
}
public Host getHost() {
return host;
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getHostAddress() {
return hostAddress;
}
public void setHost(Host host) {
this.host = host;
public void setHostAddress(String hostAddress) {
this.hostAddress = hostAddress;
}
public int getOnline() {

13
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java

@ -44,9 +44,8 @@ public class SIPRequestHeaderProvider {
public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException, PeerUnavailableException {
Request request = null;
Host host = device.getHost();
// sipuri
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), host.getAddress());
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
// via
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(),
@ -79,12 +78,11 @@ public class SIPRequestHeaderProvider {
public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException {
Request request = null;
Host host = device.getHost();
//请求行
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, host.getAddress());
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
//via
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getHost().getIp(), device.getHost().getPort(), device.getTransport(), viaTag);
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getIp(), device.getPort(), device.getTransport(), viaTag);
viaHeader.setRPort();
viaHeaders.add(viaHeader);
@ -126,12 +124,11 @@ public class SIPRequestHeaderProvider {
public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException, PeerUnavailableException {
Request request = null;
Host host = device.getHost();
//请求行
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), host.getAddress());
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
// via
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getHost().getIp(), device.getHost().getPort(), device.getTransport(), viaTag);
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getIp(), device.getPort(), device.getTransport(), viaTag);
viaHeader.setRPort();
viaHeaders.add(viaHeader);
//from

8
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java

@ -107,17 +107,15 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
rPort = viaHeader.getPort();
}
//
Host host = new Host();
host.setIp(received);
host.setPort(rPort);
host.setAddress(received.concat(":").concat(String.valueOf(rPort)));
AddressImpl address = (AddressImpl) fromHeader.getAddress();
SipUri uri = (SipUri) address.getURI();
String deviceId = uri.getUser();
device = new Device();
device.setStreamMode("UDP");
device.setDeviceId(deviceId);
device.setHost(host);
device.setIp(received);
device.setPort(rPort);
device.setHostAddress(received.concat(":").concat(String.valueOf(rPort)));
// 注销成功
if (expiresHeader != null && expiresHeader.getExpires() == 0) {
registerFlag = 2;

18
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java

@ -1,14 +1,10 @@
package com.genersoft.iot.vmp.storager;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.github.pagehelper.PageInfo;
/**
* @Description:视频设备数据存储接口
@ -65,7 +61,7 @@ public interface IVideoManagerStorager {
* @param count 每页数量
* @return
*/
public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count);
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
/**
* 获取某个设备的通道列表
@ -82,13 +78,13 @@ public interface IVideoManagerStorager {
*/
public DeviceChannel queryChannel(String deviceId, String channelId);
/**
/**
* 获取多个设备
*
* @param deviceIds 设备ID数组
* @param page 当前页数
* @param count 每页数量
* @return List<Device> 设备对象数组
*/
public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count);
public PageInfo<Device> queryVideoDeviceList(int page, int count);
/**
* 获取多个设备
@ -131,7 +127,7 @@ public interface IVideoManagerStorager {
* @param count
* @return
*/
PageResult querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
/**

17
src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java

@ -1,17 +0,0 @@
package com.genersoft.iot.vmp.storager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class VodeoMannagerTask implements CommandLineRunner {
@Autowired
private IVideoManagerStorager redisStorager;
@Override
public void run(String... strings) throws Exception {
redisStorager.updateCatch();
}
}

40
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java

@ -1,20 +1,50 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* 用于存储设备通道信息
*/
@Mapper
public interface DeviceChannelMapper {
int update(DeviceChannel channel);
List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
@Insert("INSERT INTO device_channel (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " +
"address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
"ipAddress, port, password, PTZType, status) " +
"VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
"'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status})")
int add(DeviceChannel channel);
@Update("UPDATE device_channel " +
"SET name=#{name}, manufacture=#{manufacture}, model=#{model}, owner=#{owner}, civilCode=#{civilCode}, " +
"block=#{block}, address=#{address}, parental=#{parental}, parentId=#{parentId}, safetyWay=#{safetyWay}, " +
"registerWay=#{registerWay}, certNum=#{certNum}, certifiable=#{certifiable}, errCode=#{errCode}, secrecy=#{secrecy}, " +
"ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status} " +
"WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
int update(DeviceChannel channel);
List<DeviceChannel> queryChannelsByDeviceId(String deviceId, String parentChannelId);
@Select(value = {" <script>" +
"SELECT * FROM ( "+
" SELECT * , (SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount FROM device_channel dc " +
" WHERE dc.deviceId=#{deviceId} " +
" <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test=\"parentChannelId != null\"> AND dc.parentId=#{parentChannelId} </if> " +
" <if test=\"online == true\" > AND dc.status=1</if>" +
" <if test=\"online == false\" > AND dc.status=0</if>) dcr" +
" WHERE 1=1 " +
" <if test=\"hasSubChannel == true\" > AND subCount >0</if>" +
" <if test=\"hasSubChannel == false\" > AND subCount=0</if>" +
" </script>"})
List<DeviceChannel> queryChannelsByDeviceId(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online);
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
DeviceChannel queryChannel(String deviceId, String channelId);
@Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}")
int cleanChannelsByDeviceId(String deviceId);
}

50
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java

@ -1,24 +1,66 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 用于存储设备信息
*/
@Mapper
@Repository
public interface DeviceMapper {
@Select("SELECT * FROM device WHERE deviceId = #{deviceId}")
Device getDeviceByDeviceId(String deviceId);
@Insert("SELECT * FROM device WHERE deviceId = #{deviceId}")
@Insert("INSERT INTO device (" +
"deviceId, " +
"name, " +
"manufacturer, " +
"model, " +
"firmware, " +
"transport," +
"streamMode," +
"ip," +
"port," +
"hostAddress," +
"online" +
") VALUES (" +
"#{deviceId}," +
"#{name}," +
"#{manufacturer}," +
"#{model}," +
"#{firmware}," +
"#{transport}," +
"#{streamMode}," +
"#{ip}," +
"#{port}," +
"#{hostAddress}," +
"#{online}" +
")")
int add(Device device);
@Update("UPDATE device " +
"SET name=#{name}, " +
"manufacturer=#{manufacturer}," +
"model=#{model}," +
"firmware=#{firmware}, " +
"transport=#{transport}," +
"streamMode=#{streamMode}, " +
"ip=#{ip}, " +
"port=#{port}, " +
"hostAddress=#{hostAddress}, " +
"online=#{online} " +
"WHERE deviceId=#{deviceId}")
int update(Device device);
@Select("SELECT *, (SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de")
List<Device> getDevices();
@Delete("DELETE FROM device WHERE deviceId=#{deviceId}")
int del(String deviceId);
}

4
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java

@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -22,9 +21,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Autowired
private RedisUtil redis;
@Autowired
private DeviceMapper deviceMapper;
@Autowired
private DeviceChannelMapper deviceChannelMapper;

281
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@ -2,19 +2,17 @@ package com.genersoft.iot.vmp.storager.impl;
import java.util.*;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.springframework.util.StringUtils;
/**
@ -50,7 +48,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
* @return true创建成功 false创建失败
*/
@Override
public boolean create(Device device) {
public synchronized boolean create(Device device) {
return deviceMapper.add(device) > 0;
}
@ -63,69 +61,26 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
* @return true更新成功 false更新失败
*/
@Override
public boolean updateDevice(Device device) {
// if (deviceMap.get(device.getDeviceId()) == null) {
// deviceMap.put(device.getDeviceId(), new HashMap<String, HashSet<String>>());
// }
// 更新device中的通道数量
// device.setChannelCount(deviceMap.get(device.getDeviceId()).size());
int result = deviceMapper.update(device);
// 存储device
return result > 0;
public synchronized boolean updateDevice(Device device) {
Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
if (deviceByDeviceId == null) {
return deviceMapper.add(device) > 0;
}else {
return deviceMapper.update(device) > 0;
}
}
@Override
public void updateChannel(String deviceId, DeviceChannel channel) {
public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId();
channel.setDeviceId(deviceId);
deviceChannelMapper.update(channel);
// HashMap<String, HashSet<String>> channelMap = deviceMap.get(deviceId);
// if (channelMap == null) return;
// // 作为父设备, 确定自己的子节点数
// if (channelMap.get(channelId) == null) {
// channelMap.put(channelId, new HashSet<String>());
// }else if (channelMap.get(channelId).size() > 0) {
// channel.setSubCount(channelMap.get(channelId).size());
// }
//
// // 存储通道
// redis.set(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + channel.getChannelId() +
// "_" + (channel.getStatus() == 1 ? "on":"off") +
// "_" + (channelMap.get(channelId).size() > 0)+
// "_" + (StringUtils.isEmpty(channel.getParentId())?null:channel.getParentId()),
// channel);
// // 更新device中的通道数量
// Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
// device.setChannelCount(deviceMap.get(deviceId).size());
// redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
//
//
// // 如果有父设备,更新父设备内子节点数
// String parentId = channel.getParentId();
// if (!StringUtils.isEmpty(parentId) && !parentId.equals(deviceId)) {
//
// if (channelMap.get(parentId) == null) {
// channelMap.put(parentId, new HashSet<String>());
// }
// channelMap.get(parentId).add(channelId);
//
// DeviceChannel deviceChannel = queryChannel(deviceId, parentId);
// if (deviceChannel != null) {
// deviceChannel.setSubCount(channelMap.get(parentId).size());
// redis.set(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + deviceChannel.getChannelId() +
// "_" + (deviceChannel.getStatus() == 1 ? "on":"off") +
// "_" + (channelMap.get(deviceChannel.getChannelId()).size() > 0)+
// "_" + (StringUtils.isEmpty(deviceChannel.getParentId())?null:deviceChannel.getParentId()),
// deviceChannel);
//
// }
// }
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
if (deviceChannel == null) {
deviceChannelMapper.add(channel);
}else {
deviceChannelMapper.update(channel);
}
}
/**
@ -140,179 +95,45 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
}
@Override
public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count) {
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) {
// 获取到所有正在播放的流
List<DeviceChannel> result = new ArrayList<>();
PageResult pageResult = new PageResult<DeviceChannel>();
deviceChannelMapper.queryChannelsByDeviceId(deviceId);
// String queryContent = "*";
// if (!StringUtils.isEmpty(query)) queryContent = String.format("*%S*",query);
// String queryHasSubChannel = "*";
// if (hasSubChannel != null) queryHasSubChannel = hasSubChannel?"true":"false";
// String queryOnline = "*";
// if (!StringUtils.isEmpty(online)) queryOnline = online;
// String queryStr = VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + queryContent + // 搜索编号和名称
// "_" + queryOnline + // 搜索是否在线
// "_" + queryHasSubChannel + // 搜索是否含有子节点
// "_" + "*";
// List<Object> deviceChannelList = redis.scan(queryStr);
// //对查询结果排序,避免出现通道排列顺序乱序的情况
// Collections.sort(deviceChannelList,new Comparator<Object>(){
// @Override
// public int compare(Object o1, Object o2) {
// return o1.toString().compareToIgnoreCase(o2.toString());
// }
// });
// pageResult.setPage(page);
// pageResult.setCount(count);
// pageResult.setTotal(deviceChannelList.size());
// int maxCount = (page + 1 ) * count;
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) {
// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i));
// StreamInfo streamInfo = stringStreamInfoMap.get(deviceId + "_" + deviceChannel.getChannelId());
// deviceChannel.setPlay(streamInfo != null);
// if (streamInfo != null) deviceChannel.setStreamId(streamInfo.getStreamId());
// result.add(deviceChannel);
// }
// pageResult.setData(result);
// }
return pageResult;
PageHelper.startPage(page, count);
List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, null, query, hasSubChannel, online);
return new PageInfo<>(all);
}
@Override
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
// List<DeviceChannel> result = new ArrayList<>();
//// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
//
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// for (int i = 0; i < deviceChannelList.size(); i++) {
// result.add((DeviceChannel)redis.get((String) deviceChannelList.get(i)));
// }
// }
return deviceChannelMapper.queryChannelsByDeviceId(deviceId);
return deviceChannelMapper.queryChannelsByDeviceId(deviceId, null,null, null, null);
}
@Override
public PageResult querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) {
deviceChannelMapper.queryChannelsByDeviceId(deviceId, parentChannelId);
// List<DeviceChannel> allDeviceChannels = new ArrayList<>();
// String queryContent = "*";
// if (!StringUtils.isEmpty(query)) queryContent = String.format("*%S*",query);
// String queryHasSubChannel = "*";
// if (hasSubChannel != null) queryHasSubChannel = hasSubChannel?"true":"false";
// String queryOnline = "*";
// if (!StringUtils.isEmpty(online)) queryOnline = online;
// String queryStr = VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + queryContent + // 搜索编号和名称
// "_" + queryOnline + // 搜索是否在线
// "_" + queryHasSubChannel + // 搜索是否含有子节点
// "_" + parentChannelId;
//
//// List<Object> deviceChannelList = redis.keys(queryStr);
// List<Object> deviceChannelList = redis.scan(queryStr);
//
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// for (int i = 0; i < deviceChannelList.size(); i++) {
// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i));
// if (deviceChannel.getParentId() != null && deviceChannel.getParentId().equals(parentChannelId)) {
// allDeviceChannels.add(deviceChannel);
// }
// }
// }
// int maxCount = (page + 1 ) * count;
PageResult pageResult = new PageResult<DeviceChannel>();
// pageResult.setPage(page);
// pageResult.setCount(count);
// pageResult.setTotal(allDeviceChannels.size());
//
// if (allDeviceChannels.size() > 0) {
// pageResult.setData(allDeviceChannels.subList(
// page * count, pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal()
// ));
// }
return pageResult;
}
public List<DeviceChannel> querySubChannels(String deviceId, String parentChannelId) {
List<DeviceChannel> allDeviceChannels = new ArrayList<>();
// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
//
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// for (int i = 0; i < deviceChannelList.size(); i++) {
// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i));
// if (deviceChannel.getParentId() != null && deviceChannel.getParentId().equals(parentChannelId)) {
// allDeviceChannels.add(deviceChannel);
// }
// }
// }
return allDeviceChannels;
public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) {
PageHelper.startPage(page, count);
List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, parentChannelId, null, null, null);
return new PageInfo<>(all);
}
@Override
public DeviceChannel queryChannel(String deviceId, String channelId) {
DeviceChannel deviceChannel = null;
return deviceChannelMapper.queryChannel(deviceId, channelId);
//// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
// "_" + channelId + "*");
// if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
// deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(0));
// }
// return deviceChannel;
}
/**
* 获取多个设备
*
* @param deviceIds 设备ID数组
* @return List<Device> 设备对象数组
* @param page 当前页数
* @param count 每页数量
* @return PageInfo<Device> 分页设备对象数组
*/
@Override
public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count) {
List<Device> devices = new ArrayList<>();
PageResult pageResult = new PageResult<Device>();
// pageResult.setPage(page);
// pageResult.setCount(count);
// Device device = null;
//
// if (deviceIds == null || deviceIds.length == 0) {
//
//// List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*");
// List<Object> deviceIdList = redis.scan(VideoManagerConstants.DEVICE_PREFIX+"*");
// pageResult.setTotal(deviceIdList.size());
// int maxCount = (page + 1)* count;
// for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) {
// // devices.add((Device)redis.get((String)deviceIdList.get(i)));
// device =(Device)redis.get((String)deviceIdList.get(i));
// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
// // outline(device.getDeviceId());
// }
// devices.add(device);
// }
// } else {
// for (int i = 0; i < deviceIds.length; i++) {
// // devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]));
// device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]);
// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
// // outline(device.getDeviceId());
// }
// devices.add(device);
// }
// }
// pageResult.setData(devices);
return pageResult;
public PageInfo<Device> queryVideoDeviceList(int page, int count) {
PageHelper.startPage(page, count);
List<Device> all = deviceMapper.getDevices();
return new PageInfo<>(all);
}
/**
@ -323,26 +144,6 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Override
public List<Device> queryVideoDeviceList() {
// if (deviceIds == null || deviceIds.length == 0) {
//// List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*");
// List<Object> deviceIdList = redis.scan(VideoManagerConstants.DEVICE_PREFIX+"*");
// for (int i = 0; i < deviceIdList.size(); i++) {
// device =(Device)redis.get((String)deviceIdList.get(i));
// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
// outline(device.getDeviceId());
// }
// devices.add(device);
// }
// } else {
// for (int i = 0; i < deviceIds.length; i++) {
// device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]);
// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
// outline(device.getDeviceId());
// }
// devices.add(device);
// }
// }
List<Device> deviceList = deviceMapper.getDevices();
return deviceList;
}
@ -367,9 +168,13 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
* @return true更新成功 false更新失败
*/
@Override
public boolean online(String deviceId) {
public synchronized boolean online(String deviceId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
device.setOnline(1);
System.out.println("更新设备在线");
if (device == null) {
return false;
}
return deviceMapper.update(device) > 0;
}
@ -380,14 +185,10 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
* @return true更新成功 false更新失败
*/
@Override
public boolean outline(String deviceId) {
// Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
// if (device == null) return false;
// device.setOnline(0);
// return redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
public synchronized boolean outline(String deviceId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
device.setOnline(0);
System.out.println("更新设备离线");
return deviceMapper.update(device) > 0;
}

40
src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java

@ -1,15 +1,14 @@
package com.genersoft.iot.vmp.vmanager.device;
import java.util.List;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
@ -53,13 +52,13 @@ public class DeviceController {
}
@GetMapping("/devices")
public PageResult<Device> devices(int page, int count){
public PageInfo<Device> devices(int page, int count){
if (logger.isDebugEnabled()) {
logger.debug("查询所有视频设备API调用");
}
return storager.queryVideoDeviceList(null, page, count);
return storager.queryVideoDeviceList(page, count);
}
/**
@ -69,18 +68,33 @@ public class DeviceController {
* @param count 每页条数
* @return 通道列表
*/
/**
* 分页查询通道数
*
* @param deviceId 设备id
* @param page 当前页
* @param count 每页条数
* @param query 查询内容
* @param online 是否在线 在线 true / 离线 false
* @param channelType 设备 false/子目录 true
* @return 通道列表
*/
@GetMapping("/devices/{deviceId}/channels")
public ResponseEntity<PageResult> channels(@PathVariable String deviceId,
public ResponseEntity<PageInfo> channels(@PathVariable String deviceId,
int page, int count,
@RequestParam(required = false) String query,
@RequestParam(required = false) String online,
@RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean channelType
){
if (logger.isDebugEnabled()) {
logger.debug("查询所有视频设备API调用");
}
PageResult pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count);
if (StringUtils.isEmpty(query)) {
query = null;
}
PageInfo pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count);
return new ResponseEntity<>(pageResult,HttpStatus.OK);
}
@ -141,7 +155,7 @@ public class DeviceController {
* @return 子通道列表
*/
@GetMapping("/subChannels/{deviceId}/{channelId}/channels")
public ResponseEntity<PageResult> subChannels(@PathVariable String deviceId,
public ResponseEntity<PageInfo> subChannels(@PathVariable String deviceId,
@PathVariable String channelId,
int page,
int count,
@ -154,23 +168,23 @@ public class DeviceController {
}
DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId);
if (deviceChannel == null) {
PageResult<DeviceChannel> deviceChannelPageResult = new PageResult<>();
PageInfo<DeviceChannel> deviceChannelPageResult = new PageInfo<>();
return new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK);
}
PageResult pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count);
PageInfo pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count);
return new ResponseEntity<>(pageResult,HttpStatus.OK);
}
@PostMapping("/channel/update/{deviceId}")
public ResponseEntity<PageResult> updateChannel(@PathVariable String deviceId,DeviceChannel channel){
public ResponseEntity<PageInfo> updateChannel(@PathVariable String deviceId,DeviceChannel channel){
storager.updateChannel(deviceId, channel);
return new ResponseEntity<>(null,HttpStatus.OK);
}
@GetMapping("/devices/{deviceId}/transport/{streamMode}")
@PostMapping("/devices/{deviceId}/transport/{streamMode}")
public ResponseEntity<PageResult> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
Device device = storager.queryVideoDevice(deviceId);
device.setStreamMode(streamMode);
storager.updateDevice(device);

401
src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/Device.java

@ -1,401 +0,0 @@
package com.genersoft.iot.vmp.vmanager.device.entity;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description:视频设备信息
* @author: songww
* @date: 2020年5月8日 下午2:05:56
*/
@ApiModel(value = "视频设备信息", description = "视频设备信息")
@Table(name="VMP_VIDEODEVICES")
public class Device {
/**
* 设备Id
*/
@ApiModelProperty("设备编号")
@Id
@Column(name="DEVICE_ID")
@NotNull(message = "deviceId 不能为 null")
@Size(min = 4, max = 32, message = "deviceId 必须大于 4 位并且小于 32 位")
private String deviceId;
/**
* 设备名称
*/
@ApiModelProperty("设备名称")
@Column(name="DEVICE_NAME")
@Size(max = 32, message = "deviceName 必须小于 32 位")
private String deviceName;
/**
* 生产厂商
*/
@ApiModelProperty("生产厂商")
@Column(name="MANUFACTURER")
@Size(max = 64, message = "manufacturer 必须小于 64 位")
private String manufacturer;
/**
* 型号
*/
@ApiModelProperty("型号")
@Column(name="MODEL")
@Size(max = 64, message = "manufacturer 必须小于 64 位")
private String model;
/**
* 固件版本
*/
@ApiModelProperty("固件版本")
@Column(name="FIRMWARE")
@Size(max = 64, message = "firmware 必须小于 64 位")
private String firmware;
/**
* 通信协议
* GB28181 ONVIF
*/
@ApiModelProperty("通信协议")
@Column(name="PROTOCOL")
@NotNull(message = "protocol 不能为 null")
@Size(max = 16, message = "protocol 必须小于 16 位")
private String protocol;
/**
* SIP 传输协议
* UDP/TCP
*/
@ApiModelProperty("SIP 传输协议")
@Column(name="TRANSPORT")
@Size(min = 3,max = 3 ,message = "transport 必须为 3 位")
private String transport;
/**
* 数据流传输模式
* UDP:udp传输
* TCP-ACTIVEtcp主动模式
* TCP-PASSIVEtcp被动模式
*/
@ApiModelProperty("数据流传输模式")
@Column(name="STREAM_MODE")
@Size(max = 64, message = "streamMode 必须小于 16 位")
private String streamMode;
/**
* IP地址
*/
@ApiModelProperty("IP地址")
@Column(name="IP")
@Size(max = 15, message = "streamMode 必须小于 15 位")
private String ip;
/**
* 端口号
*/
@ApiModelProperty("端口号")
@Column(name="PORT")
@Max(value = 65535,message = "port 最大值为 65535")
private Integer port;
/**
* 在线状态 1在线, 0离线
*/
@ApiModelProperty("在线状态")
@Size(min = 1,max = 1 ,message = "online 必须为 1 位")
@Column(name="ONLINE")
private String online;
/**
* 通道数量
*/
@ApiModelProperty("通道数量")
@Column(name="CHANNEL_SUM")
@Max(value = 1000000000,message = "channelSum 最大值为 1000000000")
private Integer channelSum;
@Override
public String toString() {
return "Device{" +
"deviceId='" + deviceId + '\'' +
", deviceName='" + deviceName + '\'' +
", manufacturer='" + manufacturer + '\'' +
", model='" + model + '\'' +
", firmware='" + firmware + '\'' +
", protocol='" + protocol + '\'' +
", transport='" + transport + '\'' +
", streamMode='" + streamMode + '\'' +
", ip='" + ip + '\'' +
", port=" + port +
", online='" + online + '\'' +
", channelSum=" + channelSum +
", createTime='" + createTime + '\'' +
", registerTime='" + registerTime + '\'' +
", heartbeatTime='" + heartbeatTime + '\'' +
", updateTime='" + updateTime + '\'' +
", updatePerson='" + updatePerson + '\'' +
", syncTime='" + syncTime + '\'' +
", syncPerson='" + syncPerson + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", channelList=" + channelList +
'}';
}
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
@Column(name="CREATE_TIME")
private String createTime;
/**
* 注册时间
*/
@ApiModelProperty("注册时间")
@Column(name="REGISTER_TIME")
private String registerTime;
/**
* 心跳时间
*/
@ApiModelProperty("心跳时间")
@Column(name="HEARTBEAT_TIME")
private String heartbeatTime;
/**
* 修改时间
*/
@ApiModelProperty("更新时间")
@Column(name="UPDATE_TIME")
private String updateTime;
/**
* 修改人
*/
@ApiModelProperty("修改人")
@Column(name="UPDATE_PERSON")
private String updatePerson;
/**
* 同步时间
*/
@ApiModelProperty("同步时间")
@Column(name="SYNC_TIME")
private String syncTime;
/**
* 同步人
*/
@ApiModelProperty("同步人")
@Column(name="SYNC_PERSON")
private String syncPerson;
/**
* ONVIF协议-用户名
*/
@ApiModelProperty("用户名")
@Column(name="USERNAME")
@Size(max = 32, message = "username 必须小于 32 位")
private String username;
/**
* ONVIF协议-密码
*/
@ApiModelProperty("密码")
@Size(max = 32, message = "password 必须小于 32 位")
@Column(name="PASSWORD")
private String password;
@Transient
private List<DeviceChannel> channelList;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getManufacturer() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getFirmware() {
return firmware;
}
public void setFirmware(String firmware) {
this.firmware = firmware;
}
public String getProtocol() {
return protocol;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
public String getTransport() {
return transport;
}
public void setTransport(String transport) {
this.transport = transport;
}
public String getStreamMode() {
return streamMode;
}
public void setStreamMode(String streamMode) {
this.streamMode = streamMode;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getOnline() {
return online;
}
public void setOnline(String online) {
this.online = online;
}
public Integer getChannelSum() {
return channelSum;
}
public void setChannelSum(Integer channelSum) {
this.channelSum = channelSum;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getRegisterTime() {
return registerTime;
}
public void setRegisterTime(String registerTime) {
this.registerTime = registerTime;
}
public String getHeartbeatTime() {
return heartbeatTime;
}
public void setHeartbeatTime(String heartbeatTime) {
this.heartbeatTime = heartbeatTime;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public String getUpdatePerson() {
return updatePerson;
}
public void setUpdatePerson(String updatePerson) {
this.updatePerson = updatePerson;
}
public String getSyncTime() {
return syncTime;
}
public void setSyncTime(String syncTime) {
this.syncTime = syncTime;
}
public String getSyncPerson() {
return syncPerson;
}
public void setSyncPerson(String syncPerson) {
this.syncPerson = syncPerson;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List<DeviceChannel> getChannelList() {
return channelList;
}
public void setChannelList(List<DeviceChannel> channelList) {
this.channelList = channelList;
}
}

385
src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/DeviceChannel.java

@ -1,385 +0,0 @@
package com.genersoft.iot.vmp.vmanager.device.entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description:设备通道信息
* @author: songww
* @date: 2020年5月20日 下午9:00:46
*/
@ApiModel(value = "设备通道信息", description = "设备通道信息")
@Table(name="VMP_VIDEOCHANNELS")
public class DeviceChannel {
/**
* 通道编号
*/
@ApiModelProperty("通道编号")
@Id
@Column(name="CHANNEL_ID")
private String channelId;
/**
* 设备编号
*/
@ApiModelProperty("设备编号")
@Column(name="DEVICE_ID")
private String deviceId;
/**
* 通道名
*/
@ApiModelProperty("通道名")
@Column(name="CHANNEL_NAME")
private String channelName;
/**
* 生产厂商
*/
@ApiModelProperty("生产厂商")
@Column(name="MANUFACTURER")
private String manufacture;
/**
* 型号
*/
@ApiModelProperty("型号")
@Column(name="MODEL")
private String model;
/**
* 设备归属
*/
@ApiModelProperty("设备归属")
@Column(name="OWNER")
private String owner;
/**
* 行政区域
*/
@ApiModelProperty("行政区域")
@Column(name="CIVIL_CODE")
private String civilCode;
/**
* 警区
*/
@ApiModelProperty("警区")
@Column(name="BLOCK")
private String block;
/**
* 安装地址
*/
@ApiModelProperty("安装地址")
@Column(name="ADDRESS")
private String address;
/**
* 是否有子设备 1有, 0没有
*/
@ApiModelProperty("是否有子设备")
@Column(name="PARENTAL")
private String parental;
/**
* 父级id
*/
@ApiModelProperty("父级编码")
@Column(name="PARENT_ID")
private String parentId;
/**
* 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式
*/
@ApiModelProperty("信令安全模式")
@Column(name="SAFETY_WAY")
private String safetyWay;
/**
* 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 ; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式
*/
@ApiModelProperty("注册方式")
@Column(name="REGISTER_WAY")
private String registerWay;
/**
* 证书序列号
*/
@ApiModelProperty("证书序列号")
@Column(name="CERT_NUM")
private String certNum;
/**
* 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效
*/
@ApiModelProperty("证书有效标识")
@Column(name="CERT_VALID")
private String certValid;
/**
* 证书无效原因码
*/
@ApiModelProperty("证书无效原因码")
@Column(name="CERT_ERRCODE")
private String certErrCode;
/**
* 证书终止有效期
*/
@ApiModelProperty("证书终止有效期")
@Column(name="CERT_ENDTIME")
private String certEndTime;
/**
* 保密属性 缺省为0; 0:不涉密, 1:涉密
*/
@ApiModelProperty("保密属性")
@Column(name="SECRECY")
private String secrecy;
/**
* IP地址
*/
@ApiModelProperty("IP地址")
@Column(name="IP")
private String ip;
/**
* 端口号
*/
@ApiModelProperty("端口号")
@Column(name="PORT")
private Integer port;
/**
* 密码
*/
@ApiModelProperty("密码")
@Column(name="PASSWORD")
private String password;
/**
* 在线/离线
* 1在线,0离线
* 默认在线
* 信令:
* <Status>ON</Status>
* <Status>OFF</Status>
* 遇到过NVR下的IPC下发信令可以推流 但是 Status 响应 OFF
*/
@ApiModelProperty("状态")
@Column(name="ONLINE")
private String online;
/**
* 经度
*/
@ApiModelProperty("经度")
@Column(name="LONGITUDE")
private double longitude;
/**
* 纬度
*/
@ApiModelProperty("纬度")
@Column(name="LATITUDE")
private double latitude;
public String getChannelId() {
return channelId;
}
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getChannelName() {
return channelName;
}
public void setChannelName(String channelName) {
this.channelName = channelName;
}
public String getManufacture() {
return manufacture;
}
public void setManufacture(String manufacture) {
this.manufacture = manufacture;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getCivilCode() {
return civilCode;
}
public void setCivilCode(String civilCode) {
this.civilCode = civilCode;
}
public String getBlock() {
return block;
}
public void setBlock(String block) {
this.block = block;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getParental() {
return parental;
}
public void setParental(String parental) {
this.parental = parental;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getSafetyWay() {
return safetyWay;
}
public void setSafetyWay(String safetyWay) {
this.safetyWay = safetyWay;
}
public String getRegisterWay() {
return registerWay;
}
public void setRegisterWay(String registerWay) {
this.registerWay = registerWay;
}
public String getCertNum() {
return certNum;
}
public void setCertNum(String certNum) {
this.certNum = certNum;
}
public String getCertValid() {
return certValid;
}
public void setCertValid(String certValid) {
this.certValid = certValid;
}
public String getCertErrCode() {
return certErrCode;
}
public void setCertErrCode(String certErrCode) {
this.certErrCode = certErrCode;
}
public String getCertEndTime() {
return certEndTime;
}
public void setCertEndTime(String certEndTime) {
this.certEndTime = certEndTime;
}
public String getSecrecy() {
return secrecy;
}
public void setSecrecy(String secrecy) {
this.secrecy = secrecy;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getOnline() {
return online;
}
public void setOnline(String online) {
this.online = online;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
}

19
src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java

@ -1,22 +1,17 @@
package com.genersoft.iot.vmp.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.device.DeviceController;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -68,9 +63,9 @@ public class ApiDeviceController {
devices = storager.queryVideoDeviceList();
result.put("DeviceCount", devices.size());
}else {
PageResult<Device> deviceList = storager.queryVideoDeviceList(null, start/limit, limit);
PageInfo<Device> deviceList = storager.queryVideoDeviceList(start/limit, limit);
result.put("DeviceCount", deviceList.getTotal());
devices = deviceList.getData();
devices = deviceList.getList();
}
JSONArray deviceJSONList = new JSONArray();
@ -86,8 +81,8 @@ public class ApiDeviceController {
deviceJsonObject.put("Online", device.getOnline() == 1);
deviceJsonObject.put("Password", "");
deviceJsonObject.put("MediaTransport", device.getTransport());
deviceJsonObject.put("RemoteIP", device.getHost().getIp());
deviceJsonObject.put("RemotePort", device.getHost().getPort());
deviceJsonObject.put("RemoteIP", device.getIp());
deviceJsonObject.put("RemotePort", device.getPort());
deviceJsonObject.put("LastRegisterAt", "");
deviceJsonObject.put("LastKeepaliveAt", "");
deviceJsonObject.put("UpdatedAt", "");
@ -123,9 +118,9 @@ public class ApiDeviceController {
deviceChannels = storager.queryChannelsByDeviceId(serial);
result.put("ChannelCount", deviceChannels.size());
}else {
PageResult<DeviceChannel> pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start/limit, limit);
PageInfo<DeviceChannel> pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start/limit, limit);
result.put("ChannelCount", pageResult.getTotal());
deviceChannels = pageResult.getData();
deviceChannels = pageResult.getList();
}
JSONArray channleJSONList = new JSONArray();

1
src/main/resources/application-dev.yml

@ -27,6 +27,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
# [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
server:
port: 18080

2
src/main/resources/application.yml

@ -1,3 +1,3 @@
spring:
profiles:
active: dev
active: local

BIN
src/main/resources/wvp.sqlite

Binary file not shown.

6
web_src/src/components/channelList.vue

@ -21,8 +21,8 @@
</el-select>
在线状态: <el-select size="mini" @change="search" v-model="online" placeholder="请选择" default-first-option>
<el-option label="全部" value=""></el-option>
<el-option label="在线" value="on"></el-option>
<el-option label="离线" value="off"></el-option>
<el-option label="在线" value="true"></el-option>
<el-option label="离线" value="false"></el-option>
</el-select>
</div>
@ -161,7 +161,7 @@ export default {
.then(function (res) {
console.log(res);
that.total = res.data.total;
that.deviceChannelList = res.data.data;
that.deviceChannelList = res.data.list;
//
that.$nextTick(() => {
that.$refs.channelListTable.doLayout();

5
web_src/src/components/videoList.vue

@ -21,7 +21,7 @@
<el-table-column label="地址" width="180" align="center">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.host.address }}</el-tag>
<el-tag size="medium">{{ scope.row.hostAddress }}</el-tag>
</div>
</template>
</el-table-column>
@ -140,8 +140,9 @@
} )
.then(function (res) {
console.log(res);
console.log(res.data.list);
that.total = res.data.total;
that.deviceList = res.data.data;
that.deviceList = res.data.list;
that.getDeviceListLoading = false;
})
.catch(function (error) {

Loading…
Cancel
Save