From dcd78a1cfa0c929403d51a347e43414f6aa5f0d8 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: Mon, 4 Jan 2021 18:30:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=82=A8=E9=83=A8=E5=88=86=E4=BD=BF?= =?UTF-8?q?=E7=94=A8sqlite=E4=BB=A3=E6=9B=BFredis-3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 59 +-- .../genersoft/iot/vmp/common/PageResult.java | 45 -- .../iot/vmp/gb28181/bean/Device.java | 53 ++- .../cmd/SIPRequestHeaderProvider.java | 13 +- .../impl/RegisterRequestProcessor.java | 8 +- .../vmp/storager/IVideoManagerStorager.java | 18 +- .../iot/vmp/storager/VodeoMannagerTask.java | 17 - .../vmp/storager/dao/DeviceChannelMapper.java | 40 +- .../iot/vmp/storager/dao/DeviceMapper.java | 50 ++- .../storager/impl/RedisCatchStorageImpl.java | 4 - .../impl/VideoManagerStoragerImpl.java | 281 ++---------- .../vmp/vmanager/device/DeviceController.java | 40 +- .../vmp/vmanager/device/entity/Device.java | 401 ------------------ .../vmanager/device/entity/DeviceChannel.java | 385 ----------------- .../iot/vmp/web/ApiDeviceController.java | 19 +- src/main/resources/application-dev.yml | 1 + src/main/resources/application.yml | 2 +- src/main/resources/wvp.sqlite | Bin 32768 -> 32768 bytes web_src/src/components/channelList.vue | 6 +- web_src/src/components/videoList.vue | 5 +- 20 files changed, 222 insertions(+), 1225 deletions(-) delete mode 100644 src/main/java/com/genersoft/iot/vmp/common/PageResult.java delete mode 100644 src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java delete mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/Device.java delete mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/DeviceChannel.java diff --git a/pom.xml b/pom.xml index ae4d6666..2f45a6d4 100644 --- a/pom.xml +++ b/pom.xml @@ -45,9 +45,6 @@ UTF-8 - 4.1.5 - 3.5.5 - 2.0.5 5.2.0 ${project.build.directory}/generated-snippets ${project.basedir}/docs/asciidoc @@ -59,30 +56,16 @@ org.springframework.boot - spring-boot-starter-jdbc - - - org.springframework.boot - spring-boot-starter-tomcat + spring-boot-starter-data-redis org.springframework.boot spring-boot-starter-web - org.springframework - spring-context - - - - - org.springframework.data - spring-data-redis - - - redis.clients - jedis - 3.3.0 + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.1.4 @@ -106,36 +89,18 @@ 3.32.3.2 - - - org.mybatis - mybatis - ${mybatis.version} - - - org.mybatis - mybatis-spring - ${mybatis.spring.version} - - - + com.github.pagehelper - pagehelper - ${pagehelper.version} + pagehelper-spring-boot-starter + 1.2.10 - - - tk.mybatis - mapper - ${mapper.version} - - - org.apache.commons - commons-lang3 - 3.11 - + + + + + diff --git a/src/main/java/com/genersoft/iot/vmp/common/PageResult.java b/src/main/java/com/genersoft/iot/vmp/common/PageResult.java deleted file mode 100644 index 6d7c89e6..00000000 --- a/src/main/java/com/genersoft/iot/vmp/common/PageResult.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.genersoft.iot.vmp.common; - - -import java.util.List; - -public class PageResult { - - private int page; - private int count; - private int total; - - private List data; - - public List 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 data) { - this.data = data; - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java index 12b8a007..9393106e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java +++ b/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 setHost(Host host) { - this.host = host; + 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 setHostAddress(String hostAddress) { + this.hostAddress = hostAddress; } public int getOnline() { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java index a606171a..8f2c0ddb 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java +++ b/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 viaHeaders = new ArrayList(); 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 viaHeaders = new ArrayList(); - 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 viaHeaders = new ArrayList(); - 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 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java index bcd44825..4faab0ef 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java +++ b/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; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java index 4174507b..c601f7e5 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java +++ b/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 设备对象数组 */ - public PageResult queryVideoDeviceList(String[] deviceIds, int page, int count); + public PageInfo 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); /** diff --git a/src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java b/src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java deleted file mode 100644 index c2074843..00000000 --- a/src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java +++ /dev/null @@ -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(); - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index bf67095f..072b1bfe 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/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 { + + @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 queryChannelsByDeviceId(String deviceId); - - List queryChannelsByDeviceId(String deviceId, String parentChannelId); + @Select(value = {" "}) + List 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); + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java index da455fbe..3c10618e 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java +++ b/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 getDevices(); + @Delete("DELETE FROM device WHERE deviceId=#{deviceId}") int del(String deviceId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 96b55b09..cebb30b8 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/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; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java index 1288efc1..01ed247e 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java +++ b/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>()); -// } - // 更新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> channelMap = deviceMap.get(deviceId); -// if (channelMap == null) return; -// // 作为父设备, 确定自己的子节点数 -// if (channelMap.get(channelId) == null) { -// channelMap.put(channelId, new HashSet()); -// }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()); -// } -// 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 result = new ArrayList<>(); - PageResult pageResult = new PageResult(); - - 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 deviceChannelList = redis.scan(queryStr); -// //对查询结果排序,避免出现通道排列顺序乱序的情况 -// Collections.sort(deviceChannelList,new Comparator(){ -// @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 all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, null, query, hasSubChannel, online); + return new PageInfo<>(all); } @Override public List queryChannelsByDeviceId(String deviceId) { -// List result = new ArrayList<>(); -//// List deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*"); -// List 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 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 deviceChannelList = redis.keys(queryStr); -// List 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(); -// 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 querySubChannels(String deviceId, String parentChannelId) { - List allDeviceChannels = new ArrayList<>(); -// List deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*"); -// List 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 querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) { + PageHelper.startPage(page, count); + List 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 deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + -// List 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 设备对象数组 + * @param page 当前页数 + * @param count 每页数量 + * @return PageInfo 分页设备对象数组 */ @Override - public PageResult queryVideoDeviceList(String[] deviceIds, int page, int count) { - List devices = new ArrayList<>(); - PageResult pageResult = new PageResult(); -// pageResult.setPage(page); -// pageResult.setCount(count); -// Device device = null; -// -// if (deviceIds == null || deviceIds.length == 0) { -// -//// List deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*"); -// List 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 queryVideoDeviceList(int page, int count) { + PageHelper.startPage(page, count); + List all = deviceMapper.getDevices(); + return new PageInfo<>(all); } /** @@ -323,26 +144,6 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { @Override public List queryVideoDeviceList() { -// if (deviceIds == null || deviceIds.length == 0) { -//// List deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*"); -// List 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 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; } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java index 65e294a5..d64b6327 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java +++ b/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 devices(int page, int count){ + public PageInfo 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 channels(@PathVariable String deviceId, + public ResponseEntity 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 subChannels(@PathVariable String deviceId, + public ResponseEntity 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 deviceChannelPageResult = new PageResult<>(); + PageInfo 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 updateChannel(@PathVariable String deviceId,DeviceChannel channel){ + public ResponseEntity 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 updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ + public ResponseEntity updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ Device device = storager.queryVideoDevice(deviceId); device.setStreamMode(streamMode); storager.updateDevice(device); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/Device.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/Device.java deleted file mode 100644 index e47f796c..00000000 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/Device.java +++ /dev/null @@ -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-ACTIVE:tcp主动模式 - * TCP-PASSIVE:tcp被动模式 - */ - @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 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 getChannelList() { - return channelList; - } - - public void setChannelList(List channelList) { - this.channelList = channelList; - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/DeviceChannel.java deleted file mode 100644 index bedd0755..00000000 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/DeviceChannel.java +++ /dev/null @@ -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离线 - * 默认在线 - * 信令: - * ON - * OFF - * 遇到过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; - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java index def98d80..199a9e69 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java +++ b/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 deviceList = storager.queryVideoDeviceList(null, start/limit, limit); + PageInfo 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 pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start/limit, limit); + PageInfo 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(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 34f615ac..6cee0cb6 100644 --- a/src/main/resources/application-dev.yml +++ b/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 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index caf4dfcd..ef46c2ad 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: dev \ No newline at end of file + active: local \ No newline at end of file diff --git a/src/main/resources/wvp.sqlite b/src/main/resources/wvp.sqlite index e781bbcb2e1cb49bb62d2328d56d99fb190437ff..ab68634ccb6fa74bb0b623e28126efafc9832f55 100644 GIT binary patch delta 423 zcmZo@U}|V!njj^_c$9&Gfdh!yfS3u0H%`lTFJo5&d9*a#u>poot=^A zBu^br-Nwcb%;H=tS>6E^BLkq&?TL;e0zeuWZQs}!#sm~(ie+GE2`OL~*VJU}NS?fz zOOcUz@>Q-37AGHnr_GMs`izrXc|s=J@C))4Bo?LSl_cgUafY}?giLDde6k_J#=K%^Z^D};# z*!W?Qfxu=30d@gaMqq%k0>!`ZPYU2*{`34VfFj5E84V{k G>H+}2Ic<{w delta 322 zcmZo@U}|V!njj^_z{$YCzyZZfKss!qj*$#dRL}kh2n( z;O8Hr;1}xSGufI`b}}1p5DT9kL(as;3?^&y$)|a&*x9r-*u?E6C!gn$pS*{ci;3af z#Ku!xO^oX7;*ye#&9Re{I3G@)z$L{Ba*4p^kM?2$n;f3-FES9AB*3xxv;7bLNeRgG Pe|}a*ph{+-$}ju?RlrP6 diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue index b46f1d96..2867d7b7 100644 --- a/web_src/src/components/channelList.vue +++ b/web_src/src/components/channelList.vue @@ -21,8 +21,8 @@ 在线状态: - - + + @@ -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(); diff --git a/web_src/src/components/videoList.vue b/web_src/src/components/videoList.vue index 50767cc4..9e036961 100644 --- a/web_src/src/components/videoList.vue +++ b/web_src/src/components/videoList.vue @@ -21,7 +21,7 @@ @@ -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) {