Commit dcd78a1cfa0c929403d51a347e43414f6aa5f0d8
1 parent
a25f7e4f
存储部分使用sqlite代替redis-3
Showing
20 changed files
with
222 additions
and
1225 deletions
pom.xml
| ... | ... | @@ -45,9 +45,6 @@ |
| 45 | 45 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| 46 | 46 | |
| 47 | 47 | <!-- 依赖版本 --> |
| 48 | - <mapper.version>4.1.5</mapper.version> | |
| 49 | - <mybatis.version>3.5.5</mybatis.version> | |
| 50 | - <mybatis.spring.version>2.0.5</mybatis.spring.version> | |
| 51 | 48 | <pagehelper.version>5.2.0</pagehelper.version> |
| 52 | 49 | <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory> |
| 53 | 50 | <asciidoctor.input.directory>${project.basedir}/docs/asciidoc</asciidoctor.input.directory> |
| ... | ... | @@ -59,30 +56,16 @@ |
| 59 | 56 | <dependencies> |
| 60 | 57 | <dependency> |
| 61 | 58 | <groupId>org.springframework.boot</groupId> |
| 62 | - <artifactId>spring-boot-starter-jdbc</artifactId> | |
| 63 | - </dependency> | |
| 64 | - <dependency> | |
| 65 | - <groupId>org.springframework.boot</groupId> | |
| 66 | - <artifactId>spring-boot-starter-tomcat</artifactId> | |
| 59 | + <artifactId>spring-boot-starter-data-redis</artifactId> | |
| 67 | 60 | </dependency> |
| 68 | 61 | <dependency> |
| 69 | 62 | <groupId>org.springframework.boot</groupId> |
| 70 | 63 | <artifactId>spring-boot-starter-web</artifactId> |
| 71 | 64 | </dependency> |
| 72 | 65 | <dependency> |
| 73 | - <groupId>org.springframework</groupId> | |
| 74 | - <artifactId>spring-context</artifactId> | |
| 75 | - </dependency> | |
| 76 | - | |
| 77 | - <!-- redis --> | |
| 78 | - <dependency> | |
| 79 | - <groupId>org.springframework.data</groupId> | |
| 80 | - <artifactId>spring-data-redis</artifactId> | |
| 81 | - </dependency> | |
| 82 | - <dependency> | |
| 83 | - <groupId>redis.clients</groupId> | |
| 84 | - <artifactId>jedis</artifactId> | |
| 85 | - <version>3.3.0</version> | |
| 66 | + <groupId>org.mybatis.spring.boot</groupId> | |
| 67 | + <artifactId>mybatis-spring-boot-starter</artifactId> | |
| 68 | + <version>2.1.4</version> | |
| 86 | 69 | </dependency> |
| 87 | 70 | |
| 88 | 71 | <!-- druid数据库连接池 --> |
| ... | ... | @@ -106,36 +89,18 @@ |
| 106 | 89 | <version>3.32.3.2</version> |
| 107 | 90 | </dependency> |
| 108 | 91 | |
| 109 | - <!--Mybatis --> | |
| 110 | - <dependency> | |
| 111 | - <groupId>org.mybatis</groupId> | |
| 112 | - <artifactId>mybatis</artifactId> | |
| 113 | - <version>${mybatis.version}</version> | |
| 114 | - </dependency> | |
| 115 | - <dependency> | |
| 116 | - <groupId>org.mybatis</groupId> | |
| 117 | - <artifactId>mybatis-spring</artifactId> | |
| 118 | - <version>${mybatis.spring.version}</version> | |
| 119 | - </dependency> | |
| 120 | - | |
| 121 | - <!--分页插件 --> | |
| 92 | + <!--Mybatis分页插件 --> | |
| 122 | 93 | <dependency> |
| 123 | 94 | <groupId>com.github.pagehelper</groupId> |
| 124 | - <artifactId>pagehelper</artifactId> | |
| 125 | - <version>${pagehelper.version}</version> | |
| 95 | + <artifactId>pagehelper-spring-boot-starter</artifactId> | |
| 96 | + <version>1.2.10</version> | |
| 126 | 97 | </dependency> |
| 127 | 98 | |
| 128 | - <!--通用Mapper --> | |
| 129 | - <dependency> | |
| 130 | - <groupId>tk.mybatis</groupId> | |
| 131 | - <artifactId>mapper</artifactId> | |
| 132 | - <version>${mapper.version}</version> | |
| 133 | - </dependency> | |
| 134 | - <dependency> | |
| 135 | - <groupId>org.apache.commons</groupId> | |
| 136 | - <artifactId>commons-lang3</artifactId> | |
| 137 | - <version>3.11</version> | |
| 138 | - </dependency> | |
| 99 | +<!-- <dependency>--> | |
| 100 | +<!-- <groupId>org.apache.commons</groupId>--> | |
| 101 | +<!-- <artifactId>commons-lang3</artifactId>--> | |
| 102 | +<!-- <version>3.11</version>--> | |
| 103 | +<!-- </dependency>--> | |
| 139 | 104 | |
| 140 | 105 | <!--Swagger2 --> |
| 141 | 106 | <!--在线文档 --> | ... | ... |
src/main/java/com/genersoft/iot/vmp/common/PageResult.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.common; | |
| 2 | - | |
| 3 | - | |
| 4 | -import java.util.List; | |
| 5 | - | |
| 6 | -public class PageResult<T> { | |
| 7 | - | |
| 8 | - private int page; | |
| 9 | - private int count; | |
| 10 | - private int total; | |
| 11 | - | |
| 12 | - private List<T> data; | |
| 13 | - | |
| 14 | - public List<T> getData() { | |
| 15 | - return data; | |
| 16 | - } | |
| 17 | - | |
| 18 | - public int getPage() { | |
| 19 | - return page; | |
| 20 | - } | |
| 21 | - | |
| 22 | - public void setPage(int page) { | |
| 23 | - this.page = page; | |
| 24 | - } | |
| 25 | - | |
| 26 | - public int getCount() { | |
| 27 | - return count; | |
| 28 | - } | |
| 29 | - | |
| 30 | - public void setCount(int count) { | |
| 31 | - this.count = count; | |
| 32 | - } | |
| 33 | - | |
| 34 | - public int getTotal() { | |
| 35 | - return total; | |
| 36 | - } | |
| 37 | - | |
| 38 | - public void setTotal(int total) { | |
| 39 | - this.total = total; | |
| 40 | - } | |
| 41 | - | |
| 42 | - public void setData(List<T> data) { | |
| 43 | - this.data = data; | |
| 44 | - } | |
| 45 | -} |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.bean; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import java.util.Date; | |
| 5 | -import java.util.List; | |
| 6 | -import java.util.Map; | |
| 7 | - | |
| 8 | 4 | public class Device { |
| 9 | 5 | |
| 10 | 6 | /** |
| 11 | - * 数据库存储ID | |
| 12 | - */ | |
| 13 | - private int id; | |
| 14 | - | |
| 15 | - /** | |
| 16 | 7 | * 设备Id |
| 17 | 8 | */ |
| 18 | 9 | private String deviceId; |
| ... | ... | @@ -52,9 +43,19 @@ public class Device { |
| 52 | 43 | private String streamMode; |
| 53 | 44 | |
| 54 | 45 | /** |
| 46 | + * wan地址_ip | |
| 47 | + */ | |
| 48 | + private String ip; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * wan地址_port | |
| 52 | + */ | |
| 53 | + private int port; | |
| 54 | + | |
| 55 | + /** | |
| 55 | 56 | * wan地址 |
| 56 | 57 | */ |
| 57 | - private Host host; | |
| 58 | + private String hostAddress; | |
| 58 | 59 | |
| 59 | 60 | /** |
| 60 | 61 | * 在线 |
| ... | ... | @@ -72,14 +73,6 @@ public class Device { |
| 72 | 73 | */ |
| 73 | 74 | private int channelCount; |
| 74 | 75 | |
| 75 | - public int getId() { | |
| 76 | - return id; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public void setId(int id) { | |
| 80 | - this.id = id; | |
| 81 | - } | |
| 82 | - | |
| 83 | 76 | public String getDeviceId() { |
| 84 | 77 | return deviceId; |
| 85 | 78 | } |
| ... | ... | @@ -136,12 +129,28 @@ public class Device { |
| 136 | 129 | this.streamMode = streamMode; |
| 137 | 130 | } |
| 138 | 131 | |
| 139 | - public Host getHost() { | |
| 140 | - return host; | |
| 132 | + public String getIp() { | |
| 133 | + return ip; | |
| 134 | + } | |
| 135 | + | |
| 136 | + public void setIp(String ip) { | |
| 137 | + this.ip = ip; | |
| 138 | + } | |
| 139 | + | |
| 140 | + public int getPort() { | |
| 141 | + return port; | |
| 142 | + } | |
| 143 | + | |
| 144 | + public void setPort(int port) { | |
| 145 | + this.port = port; | |
| 146 | + } | |
| 147 | + | |
| 148 | + public String getHostAddress() { | |
| 149 | + return hostAddress; | |
| 141 | 150 | } |
| 142 | 151 | |
| 143 | - public void setHost(Host host) { | |
| 144 | - this.host = host; | |
| 152 | + public void setHostAddress(String hostAddress) { | |
| 153 | + this.hostAddress = hostAddress; | |
| 145 | 154 | } |
| 146 | 155 | |
| 147 | 156 | public int getOnline() { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| ... | ... | @@ -44,9 +44,8 @@ public class SIPRequestHeaderProvider { |
| 44 | 44 | |
| 45 | 45 | public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 46 | 46 | Request request = null; |
| 47 | - Host host = device.getHost(); | |
| 48 | 47 | // sipuri |
| 49 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), host.getAddress()); | |
| 48 | + SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 50 | 49 | // via |
| 51 | 50 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 52 | 51 | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), |
| ... | ... | @@ -79,12 +78,11 @@ public class SIPRequestHeaderProvider { |
| 79 | 78 | |
| 80 | 79 | public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 81 | 80 | Request request = null; |
| 82 | - Host host = device.getHost(); | |
| 83 | 81 | //请求行 |
| 84 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, host.getAddress()); | |
| 82 | + SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 85 | 83 | //via |
| 86 | 84 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 87 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getHost().getIp(), device.getHost().getPort(), device.getTransport(), viaTag); | |
| 85 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getIp(), device.getPort(), device.getTransport(), viaTag); | |
| 88 | 86 | viaHeader.setRPort(); |
| 89 | 87 | viaHeaders.add(viaHeader); |
| 90 | 88 | |
| ... | ... | @@ -126,12 +124,11 @@ public class SIPRequestHeaderProvider { |
| 126 | 124 | |
| 127 | 125 | public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 128 | 126 | Request request = null; |
| 129 | - Host host = device.getHost(); | |
| 130 | 127 | //请求行 |
| 131 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), host.getAddress()); | |
| 128 | + SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 132 | 129 | // via |
| 133 | 130 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 134 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getHost().getIp(), device.getHost().getPort(), device.getTransport(), viaTag); | |
| 131 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getIp(), device.getPort(), device.getTransport(), viaTag); | |
| 135 | 132 | viaHeader.setRPort(); |
| 136 | 133 | viaHeaders.add(viaHeader); |
| 137 | 134 | //from | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
| ... | ... | @@ -107,17 +107,15 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { |
| 107 | 107 | rPort = viaHeader.getPort(); |
| 108 | 108 | } |
| 109 | 109 | // |
| 110 | - Host host = new Host(); | |
| 111 | - host.setIp(received); | |
| 112 | - host.setPort(rPort); | |
| 113 | - host.setAddress(received.concat(":").concat(String.valueOf(rPort))); | |
| 114 | 110 | AddressImpl address = (AddressImpl) fromHeader.getAddress(); |
| 115 | 111 | SipUri uri = (SipUri) address.getURI(); |
| 116 | 112 | String deviceId = uri.getUser(); |
| 117 | 113 | device = new Device(); |
| 118 | 114 | device.setStreamMode("UDP"); |
| 119 | 115 | device.setDeviceId(deviceId); |
| 120 | - device.setHost(host); | |
| 116 | + device.setIp(received); | |
| 117 | + device.setPort(rPort); | |
| 118 | + device.setHostAddress(received.concat(":").concat(String.valueOf(rPort))); | |
| 121 | 119 | // 注销成功 |
| 122 | 120 | if (expiresHeader != null && expiresHeader.getExpires() == 0) { |
| 123 | 121 | registerFlag = 2; | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
| 1 | 1 | package com.genersoft.iot.vmp.storager; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | -import java.util.Map; | |
| 5 | 4 | |
| 6 | -import com.alibaba.fastjson.JSONObject; | |
| 7 | -import com.genersoft.iot.vmp.common.PageResult; | |
| 8 | -import com.genersoft.iot.vmp.common.StreamInfo; | |
| 9 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | |
| 10 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 11 | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 7 | +import com.github.pagehelper.PageInfo; | |
| 12 | 8 | |
| 13 | 9 | /** |
| 14 | 10 | * @Description:视频设备数据存储接口 |
| ... | ... | @@ -65,7 +61,7 @@ public interface IVideoManagerStorager { |
| 65 | 61 | * @param count 每页数量 |
| 66 | 62 | * @return |
| 67 | 63 | */ |
| 68 | - public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count); | |
| 64 | + public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count); | |
| 69 | 65 | |
| 70 | 66 | /** |
| 71 | 67 | * 获取某个设备的通道列表 |
| ... | ... | @@ -82,13 +78,13 @@ public interface IVideoManagerStorager { |
| 82 | 78 | */ |
| 83 | 79 | public DeviceChannel queryChannel(String deviceId, String channelId); |
| 84 | 80 | |
| 85 | - /** | |
| 81 | + /** | |
| 86 | 82 | * 获取多个设备 |
| 87 | - * | |
| 88 | - * @param deviceIds 设备ID数组 | |
| 83 | + * @param page 当前页数 | |
| 84 | + * @param count 每页数量 | |
| 89 | 85 | * @return List<Device> 设备对象数组 |
| 90 | 86 | */ |
| 91 | - public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count); | |
| 87 | + public PageInfo<Device> queryVideoDeviceList(int page, int count); | |
| 92 | 88 | |
| 93 | 89 | /** |
| 94 | 90 | * 获取多个设备 |
| ... | ... | @@ -131,7 +127,7 @@ public interface IVideoManagerStorager { |
| 131 | 127 | * @param count |
| 132 | 128 | * @return |
| 133 | 129 | */ |
| 134 | - PageResult querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count); | |
| 130 | + PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count); | |
| 135 | 131 | |
| 136 | 132 | |
| 137 | 133 | /** | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.storager; | |
| 2 | - | |
| 3 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | -import org.springframework.boot.CommandLineRunner; | |
| 5 | -import org.springframework.stereotype.Component; | |
| 6 | - | |
| 7 | -@Component | |
| 8 | -public class VodeoMannagerTask implements CommandLineRunner { | |
| 9 | - | |
| 10 | - @Autowired | |
| 11 | - private IVideoManagerStorager redisStorager; | |
| 12 | - | |
| 13 | - @Override | |
| 14 | - public void run(String... strings) throws Exception { | |
| 15 | - redisStorager.updateCatch(); | |
| 16 | - } | |
| 17 | -} |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| 1 | 1 | package com.genersoft.iot.vmp.storager.dao; |
| 2 | 2 | |
| 3 | -import com.genersoft.iot.vmp.common.PageResult; | |
| 4 | 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 5 | -import org.apache.ibatis.annotations.Mapper; | |
| 4 | +import org.apache.ibatis.annotations.*; | |
| 6 | 5 | |
| 7 | 6 | import java.util.List; |
| 8 | 7 | |
| 8 | +/** | |
| 9 | + * 用于存储设备通道信息 | |
| 10 | + */ | |
| 9 | 11 | @Mapper |
| 10 | 12 | public interface DeviceChannelMapper { |
| 11 | - int update(DeviceChannel channel); | |
| 12 | 13 | |
| 13 | - List<DeviceChannel> queryChannelsByDeviceId(String deviceId); | |
| 14 | + @Insert("INSERT INTO device_channel (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " + | |
| 15 | + "address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " + | |
| 16 | + "ipAddress, port, password, PTZType, status) " + | |
| 17 | + "VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," + | |
| 18 | + "'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " + | |
| 19 | + "'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status})") | |
| 20 | + int add(DeviceChannel channel); | |
| 21 | + | |
| 22 | + @Update("UPDATE device_channel " + | |
| 23 | + "SET name=#{name}, manufacture=#{manufacture}, model=#{model}, owner=#{owner}, civilCode=#{civilCode}, " + | |
| 24 | + "block=#{block}, address=#{address}, parental=#{parental}, parentId=#{parentId}, safetyWay=#{safetyWay}, " + | |
| 25 | + "registerWay=#{registerWay}, certNum=#{certNum}, certifiable=#{certifiable}, errCode=#{errCode}, secrecy=#{secrecy}, " + | |
| 26 | + "ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status} " + | |
| 27 | + "WHERE deviceId=#{deviceId} AND channelId=#{channelId}") | |
| 28 | + int update(DeviceChannel channel); | |
| 14 | 29 | |
| 15 | - List<DeviceChannel> queryChannelsByDeviceId(String deviceId, String parentChannelId); | |
| 30 | + @Select(value = {" <script>" + | |
| 31 | + "SELECT * FROM ( "+ | |
| 32 | + " SELECT * , (SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount FROM device_channel dc " + | |
| 33 | + " WHERE dc.deviceId=#{deviceId} " + | |
| 34 | + " <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " + | |
| 35 | + " <if test=\"parentChannelId != null\"> AND dc.parentId=#{parentChannelId} </if> " + | |
| 36 | + " <if test=\"online == true\" > AND dc.status=1</if>" + | |
| 37 | + " <if test=\"online == false\" > AND dc.status=0</if>) dcr" + | |
| 38 | + " WHERE 1=1 " + | |
| 39 | + " <if test=\"hasSubChannel == true\" > AND subCount >0</if>" + | |
| 40 | + " <if test=\"hasSubChannel == false\" > AND subCount=0</if>" + | |
| 41 | + " </script>"}) | |
| 42 | + List<DeviceChannel> queryChannelsByDeviceId(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online); | |
| 16 | 43 | |
| 44 | + @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}") | |
| 17 | 45 | DeviceChannel queryChannel(String deviceId, String channelId); |
| 18 | 46 | |
| 47 | + @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}") | |
| 19 | 48 | int cleanChannelsByDeviceId(String deviceId); |
| 49 | + | |
| 20 | 50 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
| 1 | 1 | package com.genersoft.iot.vmp.storager.dao; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 4 | -import org.apache.ibatis.annotations.Insert; | |
| 5 | -import org.apache.ibatis.annotations.Mapper; | |
| 6 | -import org.apache.ibatis.annotations.Select; | |
| 4 | +import org.apache.ibatis.annotations.*; | |
| 5 | +import org.springframework.stereotype.Repository; | |
| 7 | 6 | |
| 8 | 7 | import java.util.List; |
| 9 | 8 | |
| 9 | +/** | |
| 10 | + * 用于存储设备信息 | |
| 11 | + */ | |
| 10 | 12 | @Mapper |
| 13 | +@Repository | |
| 11 | 14 | public interface DeviceMapper { |
| 12 | 15 | |
| 13 | 16 | @Select("SELECT * FROM device WHERE deviceId = #{deviceId}") |
| 14 | 17 | Device getDeviceByDeviceId(String deviceId); |
| 15 | 18 | |
| 16 | - @Insert("SELECT * FROM device WHERE deviceId = #{deviceId}") | |
| 19 | + @Insert("INSERT INTO device (" + | |
| 20 | + "deviceId, " + | |
| 21 | + "name, " + | |
| 22 | + "manufacturer, " + | |
| 23 | + "model, " + | |
| 24 | + "firmware, " + | |
| 25 | + "transport," + | |
| 26 | + "streamMode," + | |
| 27 | + "ip," + | |
| 28 | + "port," + | |
| 29 | + "hostAddress," + | |
| 30 | + "online" + | |
| 31 | + ") VALUES (" + | |
| 32 | + "#{deviceId}," + | |
| 33 | + "#{name}," + | |
| 34 | + "#{manufacturer}," + | |
| 35 | + "#{model}," + | |
| 36 | + "#{firmware}," + | |
| 37 | + "#{transport}," + | |
| 38 | + "#{streamMode}," + | |
| 39 | + "#{ip}," + | |
| 40 | + "#{port}," + | |
| 41 | + "#{hostAddress}," + | |
| 42 | + "#{online}" + | |
| 43 | + ")") | |
| 17 | 44 | int add(Device device); |
| 18 | 45 | |
| 46 | + | |
| 47 | + @Update("UPDATE device " + | |
| 48 | + "SET name=#{name}, " + | |
| 49 | + "manufacturer=#{manufacturer}," + | |
| 50 | + "model=#{model}," + | |
| 51 | + "firmware=#{firmware}, " + | |
| 52 | + "transport=#{transport}," + | |
| 53 | + "streamMode=#{streamMode}, " + | |
| 54 | + "ip=#{ip}, " + | |
| 55 | + "port=#{port}, " + | |
| 56 | + "hostAddress=#{hostAddress}, " + | |
| 57 | + "online=#{online} " + | |
| 58 | + "WHERE deviceId=#{deviceId}") | |
| 19 | 59 | int update(Device device); |
| 20 | 60 | |
| 61 | + @Select("SELECT *, (SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de") | |
| 21 | 62 | List<Device> getDevices(); |
| 22 | 63 | |
| 64 | + @Delete("DELETE FROM device WHERE deviceId=#{deviceId}") | |
| 23 | 65 | int del(String deviceId); |
| 24 | 66 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
| ... | ... | @@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 7 | 7 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 8 | 8 | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| 9 | -import com.genersoft.iot.vmp.storager.dao.DeviceMapper; | |
| 10 | 9 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 11 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 11 | import org.springframework.stereotype.Component; |
| ... | ... | @@ -23,9 +22,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 23 | 22 | private RedisUtil redis; |
| 24 | 23 | |
| 25 | 24 | @Autowired |
| 26 | - private DeviceMapper deviceMapper; | |
| 27 | - | |
| 28 | - @Autowired | |
| 29 | 25 | private DeviceChannelMapper deviceChannelMapper; |
| 30 | 26 | |
| 31 | 27 | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| ... | ... | @@ -2,19 +2,17 @@ package com.genersoft.iot.vmp.storager.impl; |
| 2 | 2 | |
| 3 | 3 | import java.util.*; |
| 4 | 4 | |
| 5 | -import com.genersoft.iot.vmp.common.PageResult; | |
| 6 | -import com.genersoft.iot.vmp.common.StreamInfo; | |
| 7 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | |
| 8 | 5 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 9 | 6 | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| 10 | 7 | import com.genersoft.iot.vmp.storager.dao.DeviceMapper; |
| 8 | +import com.github.pagehelper.PageHelper; | |
| 9 | +import com.github.pagehelper.PageInfo; | |
| 10 | +import io.swagger.models.auth.In; | |
| 11 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 12 | import org.springframework.stereotype.Component; |
| 13 | 13 | |
| 14 | -import com.genersoft.iot.vmp.common.VideoManagerConstants; | |
| 15 | 14 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 16 | 15 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 17 | -import com.genersoft.iot.vmp.utils.redis.RedisUtil; | |
| 18 | 16 | import org.springframework.util.StringUtils; |
| 19 | 17 | |
| 20 | 18 | /** |
| ... | ... | @@ -50,7 +48,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 50 | 48 | * @return true:创建成功 false:创建失败 |
| 51 | 49 | */ |
| 52 | 50 | @Override |
| 53 | - public boolean create(Device device) { | |
| 51 | + public synchronized boolean create(Device device) { | |
| 54 | 52 | return deviceMapper.add(device) > 0; |
| 55 | 53 | } |
| 56 | 54 | |
| ... | ... | @@ -63,69 +61,26 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 63 | 61 | * @return true:更新成功 false:更新失败 |
| 64 | 62 | */ |
| 65 | 63 | @Override |
| 66 | - public boolean updateDevice(Device device) { | |
| 67 | -// if (deviceMap.get(device.getDeviceId()) == null) { | |
| 68 | -// deviceMap.put(device.getDeviceId(), new HashMap<String, HashSet<String>>()); | |
| 69 | -// } | |
| 70 | - // 更新device中的通道数量 | |
| 71 | -// device.setChannelCount(deviceMap.get(device.getDeviceId()).size()); | |
| 72 | - int result = deviceMapper.update(device); | |
| 73 | - // 存储device | |
| 74 | - return result > 0; | |
| 75 | - | |
| 64 | + public synchronized boolean updateDevice(Device device) { | |
| 65 | + Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId()); | |
| 66 | + if (deviceByDeviceId == null) { | |
| 67 | + return deviceMapper.add(device) > 0; | |
| 68 | + }else { | |
| 69 | + return deviceMapper.update(device) > 0; | |
| 70 | + } | |
| 76 | 71 | |
| 77 | 72 | } |
| 78 | 73 | |
| 79 | 74 | @Override |
| 80 | - public void updateChannel(String deviceId, DeviceChannel channel) { | |
| 75 | + public synchronized void updateChannel(String deviceId, DeviceChannel channel) { | |
| 81 | 76 | String channelId = channel.getChannelId(); |
| 82 | 77 | channel.setDeviceId(deviceId); |
| 83 | - deviceChannelMapper.update(channel); | |
| 84 | - | |
| 85 | -// HashMap<String, HashSet<String>> channelMap = deviceMap.get(deviceId); | |
| 86 | -// if (channelMap == null) return; | |
| 87 | -// // 作为父设备, 确定自己的子节点数 | |
| 88 | -// if (channelMap.get(channelId) == null) { | |
| 89 | -// channelMap.put(channelId, new HashSet<String>()); | |
| 90 | -// }else if (channelMap.get(channelId).size() > 0) { | |
| 91 | -// channel.setSubCount(channelMap.get(channelId).size()); | |
| 92 | -// } | |
| 93 | -// | |
| 94 | -// // 存储通道 | |
| 95 | -// redis.set(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + | |
| 96 | -// "_" + channel.getChannelId() + | |
| 97 | -// "_" + (channel.getStatus() == 1 ? "on":"off") + | |
| 98 | -// "_" + (channelMap.get(channelId).size() > 0)+ | |
| 99 | -// "_" + (StringUtils.isEmpty(channel.getParentId())?null:channel.getParentId()), | |
| 100 | -// channel); | |
| 101 | -// // 更新device中的通道数量 | |
| 102 | -// Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId); | |
| 103 | -// device.setChannelCount(deviceMap.get(deviceId).size()); | |
| 104 | -// redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device); | |
| 105 | -// | |
| 106 | -// | |
| 107 | -// // 如果有父设备,更新父设备内子节点数 | |
| 108 | -// String parentId = channel.getParentId(); | |
| 109 | -// if (!StringUtils.isEmpty(parentId) && !parentId.equals(deviceId)) { | |
| 110 | -// | |
| 111 | -// if (channelMap.get(parentId) == null) { | |
| 112 | -// channelMap.put(parentId, new HashSet<String>()); | |
| 113 | -// } | |
| 114 | -// channelMap.get(parentId).add(channelId); | |
| 115 | -// | |
| 116 | -// DeviceChannel deviceChannel = queryChannel(deviceId, parentId); | |
| 117 | -// if (deviceChannel != null) { | |
| 118 | -// deviceChannel.setSubCount(channelMap.get(parentId).size()); | |
| 119 | -// redis.set(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + | |
| 120 | -// "_" + deviceChannel.getChannelId() + | |
| 121 | -// "_" + (deviceChannel.getStatus() == 1 ? "on":"off") + | |
| 122 | -// "_" + (channelMap.get(deviceChannel.getChannelId()).size() > 0)+ | |
| 123 | -// "_" + (StringUtils.isEmpty(deviceChannel.getParentId())?null:deviceChannel.getParentId()), | |
| 124 | -// deviceChannel); | |
| 125 | -// | |
| 126 | -// } | |
| 127 | -// } | |
| 128 | - | |
| 78 | + DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId); | |
| 79 | + if (deviceChannel == null) { | |
| 80 | + deviceChannelMapper.add(channel); | |
| 81 | + }else { | |
| 82 | + deviceChannelMapper.update(channel); | |
| 83 | + } | |
| 129 | 84 | } |
| 130 | 85 | |
| 131 | 86 | /** |
| ... | ... | @@ -140,179 +95,45 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 140 | 95 | } |
| 141 | 96 | |
| 142 | 97 | @Override |
| 143 | - public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count) { | |
| 98 | + public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { | |
| 144 | 99 | // 获取到所有正在播放的流 |
| 145 | - List<DeviceChannel> result = new ArrayList<>(); | |
| 146 | - PageResult pageResult = new PageResult<DeviceChannel>(); | |
| 147 | - | |
| 148 | - deviceChannelMapper.queryChannelsByDeviceId(deviceId); | |
| 149 | -// String queryContent = "*"; | |
| 150 | -// if (!StringUtils.isEmpty(query)) queryContent = String.format("*%S*",query); | |
| 151 | -// String queryHasSubChannel = "*"; | |
| 152 | -// if (hasSubChannel != null) queryHasSubChannel = hasSubChannel?"true":"false"; | |
| 153 | -// String queryOnline = "*"; | |
| 154 | -// if (!StringUtils.isEmpty(online)) queryOnline = online; | |
| 155 | -// String queryStr = VideoManagerConstants.CACHEKEY_PREFIX + deviceId + | |
| 156 | -// "_" + queryContent + // 搜索编号和名称 | |
| 157 | -// "_" + queryOnline + // 搜索是否在线 | |
| 158 | -// "_" + queryHasSubChannel + // 搜索是否含有子节点 | |
| 159 | -// "_" + "*"; | |
| 160 | -// List<Object> deviceChannelList = redis.scan(queryStr); | |
| 161 | -// //对查询结果排序,避免出现通道排列顺序乱序的情况 | |
| 162 | -// Collections.sort(deviceChannelList,new Comparator<Object>(){ | |
| 163 | -// @Override | |
| 164 | -// public int compare(Object o1, Object o2) { | |
| 165 | -// return o1.toString().compareToIgnoreCase(o2.toString()); | |
| 166 | -// } | |
| 167 | -// }); | |
| 168 | -// pageResult.setPage(page); | |
| 169 | -// pageResult.setCount(count); | |
| 170 | -// pageResult.setTotal(deviceChannelList.size()); | |
| 171 | -// int maxCount = (page + 1 ) * count; | |
| 172 | -// if (deviceChannelList != null && deviceChannelList.size() > 0 ) { | |
| 173 | -// for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) { | |
| 174 | -// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i)); | |
| 175 | -// StreamInfo streamInfo = stringStreamInfoMap.get(deviceId + "_" + deviceChannel.getChannelId()); | |
| 176 | -// deviceChannel.setPlay(streamInfo != null); | |
| 177 | -// if (streamInfo != null) deviceChannel.setStreamId(streamInfo.getStreamId()); | |
| 178 | -// result.add(deviceChannel); | |
| 179 | -// } | |
| 180 | -// pageResult.setData(result); | |
| 181 | -// } | |
| 182 | - | |
| 183 | - return pageResult; | |
| 100 | + PageHelper.startPage(page, count); | |
| 101 | + List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, null, query, hasSubChannel, online); | |
| 102 | + return new PageInfo<>(all); | |
| 184 | 103 | } |
| 185 | 104 | |
| 186 | 105 | |
| 187 | 106 | |
| 188 | 107 | @Override |
| 189 | 108 | public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) { |
| 190 | -// List<DeviceChannel> result = new ArrayList<>(); | |
| 191 | -//// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*"); | |
| 192 | -// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*"); | |
| 193 | -// | |
| 194 | -// if (deviceChannelList != null && deviceChannelList.size() > 0 ) { | |
| 195 | -// for (int i = 0; i < deviceChannelList.size(); i++) { | |
| 196 | -// result.add((DeviceChannel)redis.get((String) deviceChannelList.get(i))); | |
| 197 | -// } | |
| 198 | -// } | |
| 199 | - return deviceChannelMapper.queryChannelsByDeviceId(deviceId); | |
| 109 | + return deviceChannelMapper.queryChannelsByDeviceId(deviceId, null,null, null, null); | |
| 200 | 110 | } |
| 201 | 111 | |
| 202 | 112 | @Override |
| 203 | - public PageResult querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) { | |
| 204 | - | |
| 205 | - deviceChannelMapper.queryChannelsByDeviceId(deviceId, parentChannelId); | |
| 206 | - | |
| 207 | -// List<DeviceChannel> allDeviceChannels = new ArrayList<>(); | |
| 208 | -// String queryContent = "*"; | |
| 209 | -// if (!StringUtils.isEmpty(query)) queryContent = String.format("*%S*",query); | |
| 210 | -// String queryHasSubChannel = "*"; | |
| 211 | -// if (hasSubChannel != null) queryHasSubChannel = hasSubChannel?"true":"false"; | |
| 212 | -// String queryOnline = "*"; | |
| 213 | -// if (!StringUtils.isEmpty(online)) queryOnline = online; | |
| 214 | -// String queryStr = VideoManagerConstants.CACHEKEY_PREFIX + deviceId + | |
| 215 | -// "_" + queryContent + // 搜索编号和名称 | |
| 216 | -// "_" + queryOnline + // 搜索是否在线 | |
| 217 | -// "_" + queryHasSubChannel + // 搜索是否含有子节点 | |
| 218 | -// "_" + parentChannelId; | |
| 219 | -// | |
| 220 | -//// List<Object> deviceChannelList = redis.keys(queryStr); | |
| 221 | -// List<Object> deviceChannelList = redis.scan(queryStr); | |
| 222 | -// | |
| 223 | -// if (deviceChannelList != null && deviceChannelList.size() > 0 ) { | |
| 224 | -// for (int i = 0; i < deviceChannelList.size(); i++) { | |
| 225 | -// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i)); | |
| 226 | -// if (deviceChannel.getParentId() != null && deviceChannel.getParentId().equals(parentChannelId)) { | |
| 227 | -// allDeviceChannels.add(deviceChannel); | |
| 228 | -// } | |
| 229 | -// } | |
| 230 | -// } | |
| 231 | -// int maxCount = (page + 1 ) * count; | |
| 232 | - PageResult pageResult = new PageResult<DeviceChannel>(); | |
| 233 | -// pageResult.setPage(page); | |
| 234 | -// pageResult.setCount(count); | |
| 235 | -// pageResult.setTotal(allDeviceChannels.size()); | |
| 236 | -// | |
| 237 | -// if (allDeviceChannels.size() > 0) { | |
| 238 | -// pageResult.setData(allDeviceChannels.subList( | |
| 239 | -// page * count, pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() | |
| 240 | -// )); | |
| 241 | -// } | |
| 242 | - return pageResult; | |
| 243 | - } | |
| 244 | - | |
| 245 | - public List<DeviceChannel> querySubChannels(String deviceId, String parentChannelId) { | |
| 246 | - List<DeviceChannel> allDeviceChannels = new ArrayList<>(); | |
| 247 | -// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*"); | |
| 248 | -// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*"); | |
| 249 | -// | |
| 250 | -// if (deviceChannelList != null && deviceChannelList.size() > 0 ) { | |
| 251 | -// for (int i = 0; i < deviceChannelList.size(); i++) { | |
| 252 | -// DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i)); | |
| 253 | -// if (deviceChannel.getParentId() != null && deviceChannel.getParentId().equals(parentChannelId)) { | |
| 254 | -// allDeviceChannels.add(deviceChannel); | |
| 255 | -// } | |
| 256 | -// } | |
| 257 | -// } | |
| 258 | - | |
| 259 | - return allDeviceChannels; | |
| 113 | + public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) { | |
| 114 | + PageHelper.startPage(page, count); | |
| 115 | + List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, parentChannelId, null, null, null); | |
| 116 | + return new PageInfo<>(all); | |
| 260 | 117 | } |
| 261 | 118 | |
| 262 | 119 | @Override |
| 263 | 120 | public DeviceChannel queryChannel(String deviceId, String channelId) { |
| 264 | - DeviceChannel deviceChannel = null; | |
| 265 | 121 | return deviceChannelMapper.queryChannel(deviceId, channelId); |
| 266 | -//// List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + | |
| 267 | -// List<Object> deviceChannelList = redis.scan(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + | |
| 268 | -// "_" + channelId + "*"); | |
| 269 | -// if (deviceChannelList != null && deviceChannelList.size() > 0 ) { | |
| 270 | -// deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(0)); | |
| 271 | -// } | |
| 272 | -// return deviceChannel; | |
| 273 | 122 | } |
| 274 | 123 | |
| 275 | 124 | |
| 276 | 125 | /** |
| 277 | 126 | * 获取多个设备 |
| 278 | 127 | * |
| 279 | - * @param deviceIds 设备ID数组 | |
| 280 | - * @return List<Device> 设备对象数组 | |
| 128 | + * @param page 当前页数 | |
| 129 | + * @param count 每页数量 | |
| 130 | + * @return PageInfo<Device> 分页设备对象数组 | |
| 281 | 131 | */ |
| 282 | 132 | @Override |
| 283 | - public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count) { | |
| 284 | - List<Device> devices = new ArrayList<>(); | |
| 285 | - PageResult pageResult = new PageResult<Device>(); | |
| 286 | -// pageResult.setPage(page); | |
| 287 | -// pageResult.setCount(count); | |
| 288 | -// Device device = null; | |
| 289 | -// | |
| 290 | -// if (deviceIds == null || deviceIds.length == 0) { | |
| 291 | -// | |
| 292 | -//// List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*"); | |
| 293 | -// List<Object> deviceIdList = redis.scan(VideoManagerConstants.DEVICE_PREFIX+"*"); | |
| 294 | -// pageResult.setTotal(deviceIdList.size()); | |
| 295 | -// int maxCount = (page + 1)* count; | |
| 296 | -// for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) { | |
| 297 | -// // devices.add((Device)redis.get((String)deviceIdList.get(i))); | |
| 298 | -// device =(Device)redis.get((String)deviceIdList.get(i)); | |
| 299 | -// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){ | |
| 300 | -// // outline(device.getDeviceId()); | |
| 301 | -// } | |
| 302 | -// devices.add(device); | |
| 303 | -// } | |
| 304 | -// } else { | |
| 305 | -// for (int i = 0; i < deviceIds.length; i++) { | |
| 306 | -// // devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i])); | |
| 307 | -// device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]); | |
| 308 | -// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){ | |
| 309 | -// // outline(device.getDeviceId()); | |
| 310 | -// } | |
| 311 | -// devices.add(device); | |
| 312 | -// } | |
| 313 | -// } | |
| 314 | -// pageResult.setData(devices); | |
| 315 | - return pageResult; | |
| 133 | + public PageInfo<Device> queryVideoDeviceList(int page, int count) { | |
| 134 | + PageHelper.startPage(page, count); | |
| 135 | + List<Device> all = deviceMapper.getDevices(); | |
| 136 | + return new PageInfo<>(all); | |
| 316 | 137 | } |
| 317 | 138 | |
| 318 | 139 | /** |
| ... | ... | @@ -323,26 +144,6 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 323 | 144 | @Override |
| 324 | 145 | public List<Device> queryVideoDeviceList() { |
| 325 | 146 | |
| 326 | -// if (deviceIds == null || deviceIds.length == 0) { | |
| 327 | -//// List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*"); | |
| 328 | -// List<Object> deviceIdList = redis.scan(VideoManagerConstants.DEVICE_PREFIX+"*"); | |
| 329 | -// for (int i = 0; i < deviceIdList.size(); i++) { | |
| 330 | -// device =(Device)redis.get((String)deviceIdList.get(i)); | |
| 331 | -// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){ | |
| 332 | -// outline(device.getDeviceId()); | |
| 333 | -// } | |
| 334 | -// devices.add(device); | |
| 335 | -// } | |
| 336 | -// } else { | |
| 337 | -// for (int i = 0; i < deviceIds.length; i++) { | |
| 338 | -// device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]); | |
| 339 | -// if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){ | |
| 340 | -// outline(device.getDeviceId()); | |
| 341 | -// } | |
| 342 | -// devices.add(device); | |
| 343 | -// } | |
| 344 | -// } | |
| 345 | - | |
| 346 | 147 | List<Device> deviceList = deviceMapper.getDevices(); |
| 347 | 148 | return deviceList; |
| 348 | 149 | } |
| ... | ... | @@ -367,9 +168,13 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 367 | 168 | * @return true:更新成功 false:更新失败 |
| 368 | 169 | */ |
| 369 | 170 | @Override |
| 370 | - public boolean online(String deviceId) { | |
| 171 | + public synchronized boolean online(String deviceId) { | |
| 371 | 172 | Device device = deviceMapper.getDeviceByDeviceId(deviceId); |
| 372 | 173 | device.setOnline(1); |
| 174 | + System.out.println("更新设备在线"); | |
| 175 | + if (device == null) { | |
| 176 | + return false; | |
| 177 | + } | |
| 373 | 178 | return deviceMapper.update(device) > 0; |
| 374 | 179 | } |
| 375 | 180 | |
| ... | ... | @@ -380,14 +185,10 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 380 | 185 | * @return true:更新成功 false:更新失败 |
| 381 | 186 | */ |
| 382 | 187 | @Override |
| 383 | - public boolean outline(String deviceId) { | |
| 384 | -// Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId); | |
| 385 | -// if (device == null) return false; | |
| 386 | -// device.setOnline(0); | |
| 387 | -// return redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device); | |
| 388 | - | |
| 188 | + public synchronized boolean outline(String deviceId) { | |
| 389 | 189 | Device device = deviceMapper.getDeviceByDeviceId(deviceId); |
| 390 | 190 | device.setOnline(0); |
| 191 | + System.out.println("更新设备离线"); | |
| 391 | 192 | return deviceMapper.update(device) > 0; |
| 392 | 193 | } |
| 393 | 194 | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.device; |
| 2 | 2 | |
| 3 | -import java.util.List; | |
| 4 | - | |
| 5 | -import com.genersoft.iot.vmp.common.PageResult; | |
| 6 | 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 7 | 4 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 5 | +import com.github.pagehelper.PageInfo; | |
| 8 | 6 | import org.slf4j.Logger; |
| 9 | 7 | import org.slf4j.LoggerFactory; |
| 10 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | 9 | import org.springframework.http.HttpStatus; |
| 12 | 10 | import org.springframework.http.ResponseEntity; |
| 11 | +import org.springframework.util.StringUtils; | |
| 13 | 12 | import org.springframework.web.bind.annotation.*; |
| 14 | 13 | import org.springframework.web.context.request.async.DeferredResult; |
| 15 | 14 | |
| ... | ... | @@ -53,13 +52,13 @@ public class DeviceController { |
| 53 | 52 | } |
| 54 | 53 | |
| 55 | 54 | @GetMapping("/devices") |
| 56 | - public PageResult<Device> devices(int page, int count){ | |
| 55 | + public PageInfo<Device> devices(int page, int count){ | |
| 57 | 56 | |
| 58 | 57 | if (logger.isDebugEnabled()) { |
| 59 | 58 | logger.debug("查询所有视频设备API调用"); |
| 60 | 59 | } |
| 61 | 60 | |
| 62 | - return storager.queryVideoDeviceList(null, page, count); | |
| 61 | + return storager.queryVideoDeviceList(page, count); | |
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | /** |
| ... | ... | @@ -69,18 +68,33 @@ public class DeviceController { |
| 69 | 68 | * @param count 每页条数 |
| 70 | 69 | * @return 通道列表 |
| 71 | 70 | */ |
| 71 | + /** | |
| 72 | + * 分页查询通道数 | |
| 73 | + * | |
| 74 | + * @param deviceId 设备id | |
| 75 | + * @param page 当前页 | |
| 76 | + * @param count 每页条数 | |
| 77 | + * @param query 查询内容 | |
| 78 | + * @param online 是否在线 在线 true / 离线 false | |
| 79 | + * @param channelType 设备 false/子目录 true | |
| 80 | + * @return 通道列表 | |
| 81 | + */ | |
| 72 | 82 | @GetMapping("/devices/{deviceId}/channels") |
| 73 | - public ResponseEntity<PageResult> channels(@PathVariable String deviceId, | |
| 83 | + public ResponseEntity<PageInfo> channels(@PathVariable String deviceId, | |
| 74 | 84 | int page, int count, |
| 75 | 85 | @RequestParam(required = false) String query, |
| 76 | - @RequestParam(required = false) String online, | |
| 86 | + @RequestParam(required = false) Boolean online, | |
| 77 | 87 | @RequestParam(required = false) Boolean channelType |
| 78 | 88 | ){ |
| 79 | 89 | |
| 80 | 90 | if (logger.isDebugEnabled()) { |
| 81 | 91 | logger.debug("查询所有视频设备API调用"); |
| 82 | 92 | } |
| 83 | - PageResult pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count); | |
| 93 | + if (StringUtils.isEmpty(query)) { | |
| 94 | + query = null; | |
| 95 | + } | |
| 96 | + | |
| 97 | + PageInfo pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count); | |
| 84 | 98 | return new ResponseEntity<>(pageResult,HttpStatus.OK); |
| 85 | 99 | } |
| 86 | 100 | |
| ... | ... | @@ -141,7 +155,7 @@ public class DeviceController { |
| 141 | 155 | * @return 子通道列表 |
| 142 | 156 | */ |
| 143 | 157 | @GetMapping("/subChannels/{deviceId}/{channelId}/channels") |
| 144 | - public ResponseEntity<PageResult> subChannels(@PathVariable String deviceId, | |
| 158 | + public ResponseEntity<PageInfo> subChannels(@PathVariable String deviceId, | |
| 145 | 159 | @PathVariable String channelId, |
| 146 | 160 | int page, |
| 147 | 161 | int count, |
| ... | ... | @@ -154,23 +168,23 @@ public class DeviceController { |
| 154 | 168 | } |
| 155 | 169 | DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId); |
| 156 | 170 | if (deviceChannel == null) { |
| 157 | - PageResult<DeviceChannel> deviceChannelPageResult = new PageResult<>(); | |
| 171 | + PageInfo<DeviceChannel> deviceChannelPageResult = new PageInfo<>(); | |
| 158 | 172 | return new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK); |
| 159 | 173 | } |
| 160 | 174 | |
| 161 | - PageResult pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count); | |
| 175 | + PageInfo pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count); | |
| 162 | 176 | return new ResponseEntity<>(pageResult,HttpStatus.OK); |
| 163 | 177 | } |
| 164 | 178 | |
| 165 | 179 | @PostMapping("/channel/update/{deviceId}") |
| 166 | - public ResponseEntity<PageResult> updateChannel(@PathVariable String deviceId,DeviceChannel channel){ | |
| 180 | + public ResponseEntity<PageInfo> updateChannel(@PathVariable String deviceId,DeviceChannel channel){ | |
| 167 | 181 | storager.updateChannel(deviceId, channel); |
| 168 | 182 | return new ResponseEntity<>(null,HttpStatus.OK); |
| 169 | 183 | } |
| 170 | 184 | |
| 171 | 185 | @GetMapping("/devices/{deviceId}/transport/{streamMode}") |
| 172 | 186 | @PostMapping("/devices/{deviceId}/transport/{streamMode}") |
| 173 | - public ResponseEntity<PageResult> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ | |
| 187 | + public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ | |
| 174 | 188 | Device device = storager.queryVideoDevice(deviceId); |
| 175 | 189 | device.setStreamMode(streamMode); |
| 176 | 190 | storager.updateDevice(device); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/Device.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.vmanager.device.entity; | |
| 2 | - | |
| 3 | -import java.util.List; | |
| 4 | - | |
| 5 | -import javax.persistence.Column; | |
| 6 | -import javax.persistence.Id; | |
| 7 | -import javax.persistence.Table; | |
| 8 | -import javax.persistence.Transient; | |
| 9 | -import javax.validation.constraints.Max; | |
| 10 | -import javax.validation.constraints.NotNull; | |
| 11 | -import javax.validation.constraints.Size; | |
| 12 | - | |
| 13 | -import io.swagger.annotations.ApiModel; | |
| 14 | -import io.swagger.annotations.ApiModelProperty; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * @Description:视频设备信息 | |
| 18 | - * @author: songww | |
| 19 | - * @date: 2020年5月8日 下午2:05:56 | |
| 20 | - */ | |
| 21 | -@ApiModel(value = "视频设备信息", description = "视频设备信息") | |
| 22 | -@Table(name="VMP_VIDEODEVICES") | |
| 23 | -public class Device { | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * 设备Id | |
| 27 | - */ | |
| 28 | - @ApiModelProperty("设备编号") | |
| 29 | - @Id | |
| 30 | - @Column(name="DEVICE_ID") | |
| 31 | - @NotNull(message = "deviceId 不能为 null") | |
| 32 | - @Size(min = 4, max = 32, message = "deviceId 必须大于 4 位并且小于 32 位") | |
| 33 | - private String deviceId; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * 设备名称 | |
| 37 | - */ | |
| 38 | - @ApiModelProperty("设备名称") | |
| 39 | - @Column(name="DEVICE_NAME") | |
| 40 | - @Size(max = 32, message = "deviceName 必须小于 32 位") | |
| 41 | - private String deviceName; | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * 生产厂商 | |
| 45 | - */ | |
| 46 | - @ApiModelProperty("生产厂商") | |
| 47 | - @Column(name="MANUFACTURER") | |
| 48 | - @Size(max = 64, message = "manufacturer 必须小于 64 位") | |
| 49 | - private String manufacturer; | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * 型号 | |
| 53 | - */ | |
| 54 | - @ApiModelProperty("型号") | |
| 55 | - @Column(name="MODEL") | |
| 56 | - @Size(max = 64, message = "manufacturer 必须小于 64 位") | |
| 57 | - private String model; | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * 固件版本 | |
| 61 | - */ | |
| 62 | - @ApiModelProperty("固件版本") | |
| 63 | - @Column(name="FIRMWARE") | |
| 64 | - @Size(max = 64, message = "firmware 必须小于 64 位") | |
| 65 | - private String firmware; | |
| 66 | - | |
| 67 | - /** | |
| 68 | - * 通信协议 | |
| 69 | - * GB28181 ONVIF | |
| 70 | - */ | |
| 71 | - @ApiModelProperty("通信协议") | |
| 72 | - @Column(name="PROTOCOL") | |
| 73 | - @NotNull(message = "protocol 不能为 null") | |
| 74 | - @Size(max = 16, message = "protocol 必须小于 16 位") | |
| 75 | - private String protocol; | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * SIP 传输协议 | |
| 79 | - * UDP/TCP | |
| 80 | - */ | |
| 81 | - @ApiModelProperty("SIP 传输协议") | |
| 82 | - @Column(name="TRANSPORT") | |
| 83 | - @Size(min = 3,max = 3 ,message = "transport 必须为 3 位") | |
| 84 | - private String transport; | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * 数据流传输模式 | |
| 88 | - * UDP:udp传输 | |
| 89 | - * TCP-ACTIVE:tcp主动模式 | |
| 90 | - * TCP-PASSIVE:tcp被动模式 | |
| 91 | - */ | |
| 92 | - @ApiModelProperty("数据流传输模式") | |
| 93 | - @Column(name="STREAM_MODE") | |
| 94 | - @Size(max = 64, message = "streamMode 必须小于 16 位") | |
| 95 | - private String streamMode; | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * IP地址 | |
| 99 | - */ | |
| 100 | - @ApiModelProperty("IP地址") | |
| 101 | - @Column(name="IP") | |
| 102 | - @Size(max = 15, message = "streamMode 必须小于 15 位") | |
| 103 | - private String ip; | |
| 104 | - | |
| 105 | - /** | |
| 106 | - * 端口号 | |
| 107 | - */ | |
| 108 | - @ApiModelProperty("端口号") | |
| 109 | - @Column(name="PORT") | |
| 110 | - @Max(value = 65535,message = "port 最大值为 65535") | |
| 111 | - private Integer port; | |
| 112 | - | |
| 113 | - /** | |
| 114 | - * 在线状态 1在线, 0离线 | |
| 115 | - */ | |
| 116 | - @ApiModelProperty("在线状态") | |
| 117 | - @Size(min = 1,max = 1 ,message = "online 必须为 1 位") | |
| 118 | - @Column(name="ONLINE") | |
| 119 | - private String online; | |
| 120 | - | |
| 121 | - /** | |
| 122 | - * 通道数量 | |
| 123 | - */ | |
| 124 | - @ApiModelProperty("通道数量") | |
| 125 | - @Column(name="CHANNEL_SUM") | |
| 126 | - @Max(value = 1000000000,message = "channelSum 最大值为 1000000000") | |
| 127 | - private Integer channelSum; | |
| 128 | - | |
| 129 | - @Override | |
| 130 | - public String toString() { | |
| 131 | - return "Device{" + | |
| 132 | - "deviceId='" + deviceId + '\'' + | |
| 133 | - ", deviceName='" + deviceName + '\'' + | |
| 134 | - ", manufacturer='" + manufacturer + '\'' + | |
| 135 | - ", model='" + model + '\'' + | |
| 136 | - ", firmware='" + firmware + '\'' + | |
| 137 | - ", protocol='" + protocol + '\'' + | |
| 138 | - ", transport='" + transport + '\'' + | |
| 139 | - ", streamMode='" + streamMode + '\'' + | |
| 140 | - ", ip='" + ip + '\'' + | |
| 141 | - ", port=" + port + | |
| 142 | - ", online='" + online + '\'' + | |
| 143 | - ", channelSum=" + channelSum + | |
| 144 | - ", createTime='" + createTime + '\'' + | |
| 145 | - ", registerTime='" + registerTime + '\'' + | |
| 146 | - ", heartbeatTime='" + heartbeatTime + '\'' + | |
| 147 | - ", updateTime='" + updateTime + '\'' + | |
| 148 | - ", updatePerson='" + updatePerson + '\'' + | |
| 149 | - ", syncTime='" + syncTime + '\'' + | |
| 150 | - ", syncPerson='" + syncPerson + '\'' + | |
| 151 | - ", username='" + username + '\'' + | |
| 152 | - ", password='" + password + '\'' + | |
| 153 | - ", channelList=" + channelList + | |
| 154 | - '}'; | |
| 155 | - } | |
| 156 | - | |
| 157 | - /** | |
| 158 | - * 创建时间 | |
| 159 | - */ | |
| 160 | - @ApiModelProperty("创建时间") | |
| 161 | - @Column(name="CREATE_TIME") | |
| 162 | - private String createTime; | |
| 163 | - | |
| 164 | - /** | |
| 165 | - * 注册时间 | |
| 166 | - */ | |
| 167 | - @ApiModelProperty("注册时间") | |
| 168 | - @Column(name="REGISTER_TIME") | |
| 169 | - private String registerTime; | |
| 170 | - | |
| 171 | - /** | |
| 172 | - * 心跳时间 | |
| 173 | - */ | |
| 174 | - @ApiModelProperty("心跳时间") | |
| 175 | - @Column(name="HEARTBEAT_TIME") | |
| 176 | - private String heartbeatTime; | |
| 177 | - | |
| 178 | - /** | |
| 179 | - * 修改时间 | |
| 180 | - */ | |
| 181 | - @ApiModelProperty("更新时间") | |
| 182 | - @Column(name="UPDATE_TIME") | |
| 183 | - private String updateTime; | |
| 184 | - | |
| 185 | - /** | |
| 186 | - * 修改人 | |
| 187 | - */ | |
| 188 | - @ApiModelProperty("修改人") | |
| 189 | - @Column(name="UPDATE_PERSON") | |
| 190 | - private String updatePerson; | |
| 191 | - | |
| 192 | - /** | |
| 193 | - * 同步时间 | |
| 194 | - */ | |
| 195 | - @ApiModelProperty("同步时间") | |
| 196 | - @Column(name="SYNC_TIME") | |
| 197 | - private String syncTime; | |
| 198 | - | |
| 199 | - /** | |
| 200 | - * 同步人 | |
| 201 | - */ | |
| 202 | - @ApiModelProperty("同步人") | |
| 203 | - @Column(name="SYNC_PERSON") | |
| 204 | - private String syncPerson; | |
| 205 | - | |
| 206 | - /** | |
| 207 | - * ONVIF协议-用户名 | |
| 208 | - */ | |
| 209 | - @ApiModelProperty("用户名") | |
| 210 | - @Column(name="USERNAME") | |
| 211 | - @Size(max = 32, message = "username 必须小于 32 位") | |
| 212 | - private String username; | |
| 213 | - | |
| 214 | - /** | |
| 215 | - * ONVIF协议-密码 | |
| 216 | - */ | |
| 217 | - @ApiModelProperty("密码") | |
| 218 | - @Size(max = 32, message = "password 必须小于 32 位") | |
| 219 | - @Column(name="PASSWORD") | |
| 220 | - private String password; | |
| 221 | - | |
| 222 | - @Transient | |
| 223 | - private List<DeviceChannel> channelList; | |
| 224 | - | |
| 225 | - | |
| 226 | - public String getDeviceId() { | |
| 227 | - return deviceId; | |
| 228 | - } | |
| 229 | - | |
| 230 | - public void setDeviceId(String deviceId) { | |
| 231 | - this.deviceId = deviceId; | |
| 232 | - } | |
| 233 | - | |
| 234 | - public String getDeviceName() { | |
| 235 | - return deviceName; | |
| 236 | - } | |
| 237 | - | |
| 238 | - public void setDeviceName(String deviceName) { | |
| 239 | - this.deviceName = deviceName; | |
| 240 | - } | |
| 241 | - | |
| 242 | - public String getManufacturer() { | |
| 243 | - return manufacturer; | |
| 244 | - } | |
| 245 | - | |
| 246 | - public void setManufacturer(String manufacturer) { | |
| 247 | - this.manufacturer = manufacturer; | |
| 248 | - } | |
| 249 | - | |
| 250 | - public String getModel() { | |
| 251 | - return model; | |
| 252 | - } | |
| 253 | - | |
| 254 | - public void setModel(String model) { | |
| 255 | - this.model = model; | |
| 256 | - } | |
| 257 | - | |
| 258 | - public String getFirmware() { | |
| 259 | - return firmware; | |
| 260 | - } | |
| 261 | - | |
| 262 | - public void setFirmware(String firmware) { | |
| 263 | - this.firmware = firmware; | |
| 264 | - } | |
| 265 | - | |
| 266 | - public String getProtocol() { | |
| 267 | - return protocol; | |
| 268 | - } | |
| 269 | - | |
| 270 | - public void setProtocol(String protocol) { | |
| 271 | - this.protocol = protocol; | |
| 272 | - } | |
| 273 | - | |
| 274 | - public String getTransport() { | |
| 275 | - return transport; | |
| 276 | - } | |
| 277 | - | |
| 278 | - public void setTransport(String transport) { | |
| 279 | - this.transport = transport; | |
| 280 | - } | |
| 281 | - | |
| 282 | - public String getStreamMode() { | |
| 283 | - return streamMode; | |
| 284 | - } | |
| 285 | - | |
| 286 | - public void setStreamMode(String streamMode) { | |
| 287 | - this.streamMode = streamMode; | |
| 288 | - } | |
| 289 | - | |
| 290 | - public String getIp() { | |
| 291 | - return ip; | |
| 292 | - } | |
| 293 | - | |
| 294 | - public void setIp(String ip) { | |
| 295 | - this.ip = ip; | |
| 296 | - } | |
| 297 | - | |
| 298 | - public Integer getPort() { | |
| 299 | - return port; | |
| 300 | - } | |
| 301 | - | |
| 302 | - public void setPort(Integer port) { | |
| 303 | - this.port = port; | |
| 304 | - } | |
| 305 | - | |
| 306 | - public String getOnline() { | |
| 307 | - return online; | |
| 308 | - } | |
| 309 | - | |
| 310 | - public void setOnline(String online) { | |
| 311 | - this.online = online; | |
| 312 | - } | |
| 313 | - | |
| 314 | - public Integer getChannelSum() { | |
| 315 | - return channelSum; | |
| 316 | - } | |
| 317 | - | |
| 318 | - public void setChannelSum(Integer channelSum) { | |
| 319 | - this.channelSum = channelSum; | |
| 320 | - } | |
| 321 | - | |
| 322 | - public String getCreateTime() { | |
| 323 | - return createTime; | |
| 324 | - } | |
| 325 | - | |
| 326 | - public void setCreateTime(String createTime) { | |
| 327 | - this.createTime = createTime; | |
| 328 | - } | |
| 329 | - | |
| 330 | - public String getRegisterTime() { | |
| 331 | - return registerTime; | |
| 332 | - } | |
| 333 | - | |
| 334 | - public void setRegisterTime(String registerTime) { | |
| 335 | - this.registerTime = registerTime; | |
| 336 | - } | |
| 337 | - | |
| 338 | - public String getHeartbeatTime() { | |
| 339 | - return heartbeatTime; | |
| 340 | - } | |
| 341 | - | |
| 342 | - public void setHeartbeatTime(String heartbeatTime) { | |
| 343 | - this.heartbeatTime = heartbeatTime; | |
| 344 | - } | |
| 345 | - | |
| 346 | - public String getUpdateTime() { | |
| 347 | - return updateTime; | |
| 348 | - } | |
| 349 | - | |
| 350 | - public void setUpdateTime(String updateTime) { | |
| 351 | - this.updateTime = updateTime; | |
| 352 | - } | |
| 353 | - | |
| 354 | - public String getUpdatePerson() { | |
| 355 | - return updatePerson; | |
| 356 | - } | |
| 357 | - | |
| 358 | - public void setUpdatePerson(String updatePerson) { | |
| 359 | - this.updatePerson = updatePerson; | |
| 360 | - } | |
| 361 | - | |
| 362 | - public String getSyncTime() { | |
| 363 | - return syncTime; | |
| 364 | - } | |
| 365 | - | |
| 366 | - public void setSyncTime(String syncTime) { | |
| 367 | - this.syncTime = syncTime; | |
| 368 | - } | |
| 369 | - | |
| 370 | - public String getSyncPerson() { | |
| 371 | - return syncPerson; | |
| 372 | - } | |
| 373 | - | |
| 374 | - public void setSyncPerson(String syncPerson) { | |
| 375 | - this.syncPerson = syncPerson; | |
| 376 | - } | |
| 377 | - | |
| 378 | - public String getUsername() { | |
| 379 | - return username; | |
| 380 | - } | |
| 381 | - | |
| 382 | - public void setUsername(String username) { | |
| 383 | - this.username = username; | |
| 384 | - } | |
| 385 | - | |
| 386 | - public String getPassword() { | |
| 387 | - return password; | |
| 388 | - } | |
| 389 | - | |
| 390 | - public void setPassword(String password) { | |
| 391 | - this.password = password; | |
| 392 | - } | |
| 393 | - | |
| 394 | - public List<DeviceChannel> getChannelList() { | |
| 395 | - return channelList; | |
| 396 | - } | |
| 397 | - | |
| 398 | - public void setChannelList(List<DeviceChannel> channelList) { | |
| 399 | - this.channelList = channelList; | |
| 400 | - } | |
| 401 | -} |
src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/DeviceChannel.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.vmanager.device.entity; | |
| 2 | - | |
| 3 | -import javax.persistence.Column; | |
| 4 | -import javax.persistence.Id; | |
| 5 | -import javax.persistence.Table; | |
| 6 | - | |
| 7 | -import io.swagger.annotations.ApiModel; | |
| 8 | -import io.swagger.annotations.ApiModelProperty; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * @Description:设备通道信息 | |
| 12 | - * @author: songww | |
| 13 | - * @date: 2020年5月20日 下午9:00:46 | |
| 14 | - */ | |
| 15 | -@ApiModel(value = "设备通道信息", description = "设备通道信息") | |
| 16 | -@Table(name="VMP_VIDEOCHANNELS") | |
| 17 | -public class DeviceChannel { | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * 通道编号 | |
| 21 | - */ | |
| 22 | - @ApiModelProperty("通道编号") | |
| 23 | - @Id | |
| 24 | - @Column(name="CHANNEL_ID") | |
| 25 | - private String channelId; | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * 设备编号 | |
| 29 | - */ | |
| 30 | - @ApiModelProperty("设备编号") | |
| 31 | - @Column(name="DEVICE_ID") | |
| 32 | - private String deviceId; | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * 通道名 | |
| 36 | - */ | |
| 37 | - @ApiModelProperty("通道名") | |
| 38 | - @Column(name="CHANNEL_NAME") | |
| 39 | - private String channelName; | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * 生产厂商 | |
| 43 | - */ | |
| 44 | - @ApiModelProperty("生产厂商") | |
| 45 | - @Column(name="MANUFACTURER") | |
| 46 | - private String manufacture; | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * 型号 | |
| 50 | - */ | |
| 51 | - @ApiModelProperty("型号") | |
| 52 | - @Column(name="MODEL") | |
| 53 | - private String model; | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * 设备归属 | |
| 57 | - */ | |
| 58 | - @ApiModelProperty("设备归属") | |
| 59 | - @Column(name="OWNER") | |
| 60 | - private String owner; | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * 行政区域 | |
| 64 | - */ | |
| 65 | - @ApiModelProperty("行政区域") | |
| 66 | - @Column(name="CIVIL_CODE") | |
| 67 | - private String civilCode; | |
| 68 | - | |
| 69 | - /** | |
| 70 | - * 警区 | |
| 71 | - */ | |
| 72 | - @ApiModelProperty("警区") | |
| 73 | - @Column(name="BLOCK") | |
| 74 | - private String block; | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * 安装地址 | |
| 78 | - */ | |
| 79 | - @ApiModelProperty("安装地址") | |
| 80 | - @Column(name="ADDRESS") | |
| 81 | - private String address; | |
| 82 | - | |
| 83 | - /** | |
| 84 | - * 是否有子设备 1有, 0没有 | |
| 85 | - */ | |
| 86 | - @ApiModelProperty("是否有子设备") | |
| 87 | - @Column(name="PARENTAL") | |
| 88 | - private String parental; | |
| 89 | - | |
| 90 | - /** | |
| 91 | - * 父级id | |
| 92 | - */ | |
| 93 | - @ApiModelProperty("父级编码") | |
| 94 | - @Column(name="PARENT_ID") | |
| 95 | - private String parentId; | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式 | |
| 99 | - */ | |
| 100 | - @ApiModelProperty("信令安全模式") | |
| 101 | - @Column(name="SAFETY_WAY") | |
| 102 | - private String safetyWay; | |
| 103 | - | |
| 104 | - /** | |
| 105 | - * 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式 | |
| 106 | - */ | |
| 107 | - @ApiModelProperty("注册方式") | |
| 108 | - @Column(name="REGISTER_WAY") | |
| 109 | - private String registerWay; | |
| 110 | - | |
| 111 | - /** | |
| 112 | - * 证书序列号 | |
| 113 | - */ | |
| 114 | - @ApiModelProperty("证书序列号") | |
| 115 | - @Column(name="CERT_NUM") | |
| 116 | - private String certNum; | |
| 117 | - | |
| 118 | - /** | |
| 119 | - * 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效 | |
| 120 | - */ | |
| 121 | - @ApiModelProperty("证书有效标识") | |
| 122 | - @Column(name="CERT_VALID") | |
| 123 | - private String certValid; | |
| 124 | - | |
| 125 | - /** | |
| 126 | - * 证书无效原因码 | |
| 127 | - */ | |
| 128 | - @ApiModelProperty("证书无效原因码") | |
| 129 | - @Column(name="CERT_ERRCODE") | |
| 130 | - private String certErrCode; | |
| 131 | - | |
| 132 | - /** | |
| 133 | - * 证书终止有效期 | |
| 134 | - */ | |
| 135 | - @ApiModelProperty("证书终止有效期") | |
| 136 | - @Column(name="CERT_ENDTIME") | |
| 137 | - private String certEndTime; | |
| 138 | - | |
| 139 | - /** | |
| 140 | - * 保密属性 缺省为0; 0:不涉密, 1:涉密 | |
| 141 | - */ | |
| 142 | - @ApiModelProperty("保密属性") | |
| 143 | - @Column(name="SECRECY") | |
| 144 | - private String secrecy; | |
| 145 | - | |
| 146 | - /** | |
| 147 | - * IP地址 | |
| 148 | - */ | |
| 149 | - @ApiModelProperty("IP地址") | |
| 150 | - @Column(name="IP") | |
| 151 | - private String ip; | |
| 152 | - | |
| 153 | - /** | |
| 154 | - * 端口号 | |
| 155 | - */ | |
| 156 | - @ApiModelProperty("端口号") | |
| 157 | - @Column(name="PORT") | |
| 158 | - private Integer port; | |
| 159 | - | |
| 160 | - /** | |
| 161 | - * 密码 | |
| 162 | - */ | |
| 163 | - @ApiModelProperty("密码") | |
| 164 | - @Column(name="PASSWORD") | |
| 165 | - private String password; | |
| 166 | - | |
| 167 | - /** | |
| 168 | - * 在线/离线 | |
| 169 | - * 1在线,0离线 | |
| 170 | - * 默认在线 | |
| 171 | - * 信令: | |
| 172 | - * <Status>ON</Status> | |
| 173 | - * <Status>OFF</Status> | |
| 174 | - * 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF | |
| 175 | - */ | |
| 176 | - @ApiModelProperty("状态") | |
| 177 | - @Column(name="ONLINE") | |
| 178 | - private String online; | |
| 179 | - | |
| 180 | - /** | |
| 181 | - * 经度 | |
| 182 | - */ | |
| 183 | - @ApiModelProperty("经度") | |
| 184 | - @Column(name="LONGITUDE") | |
| 185 | - private double longitude; | |
| 186 | - | |
| 187 | - /** | |
| 188 | - * 纬度 | |
| 189 | - */ | |
| 190 | - @ApiModelProperty("纬度") | |
| 191 | - @Column(name="LATITUDE") | |
| 192 | - private double latitude; | |
| 193 | - | |
| 194 | - public String getChannelId() { | |
| 195 | - return channelId; | |
| 196 | - } | |
| 197 | - | |
| 198 | - public void setChannelId(String channelId) { | |
| 199 | - this.channelId = channelId; | |
| 200 | - } | |
| 201 | - | |
| 202 | - public String getDeviceId() { | |
| 203 | - return deviceId; | |
| 204 | - } | |
| 205 | - | |
| 206 | - public void setDeviceId(String deviceId) { | |
| 207 | - this.deviceId = deviceId; | |
| 208 | - } | |
| 209 | - | |
| 210 | - public String getChannelName() { | |
| 211 | - return channelName; | |
| 212 | - } | |
| 213 | - | |
| 214 | - public void setChannelName(String channelName) { | |
| 215 | - this.channelName = channelName; | |
| 216 | - } | |
| 217 | - | |
| 218 | - public String getManufacture() { | |
| 219 | - return manufacture; | |
| 220 | - } | |
| 221 | - | |
| 222 | - public void setManufacture(String manufacture) { | |
| 223 | - this.manufacture = manufacture; | |
| 224 | - } | |
| 225 | - | |
| 226 | - public String getModel() { | |
| 227 | - return model; | |
| 228 | - } | |
| 229 | - | |
| 230 | - public void setModel(String model) { | |
| 231 | - this.model = model; | |
| 232 | - } | |
| 233 | - | |
| 234 | - public String getOwner() { | |
| 235 | - return owner; | |
| 236 | - } | |
| 237 | - | |
| 238 | - public void setOwner(String owner) { | |
| 239 | - this.owner = owner; | |
| 240 | - } | |
| 241 | - | |
| 242 | - public String getCivilCode() { | |
| 243 | - return civilCode; | |
| 244 | - } | |
| 245 | - | |
| 246 | - public void setCivilCode(String civilCode) { | |
| 247 | - this.civilCode = civilCode; | |
| 248 | - } | |
| 249 | - | |
| 250 | - public String getBlock() { | |
| 251 | - return block; | |
| 252 | - } | |
| 253 | - | |
| 254 | - public void setBlock(String block) { | |
| 255 | - this.block = block; | |
| 256 | - } | |
| 257 | - | |
| 258 | - public String getAddress() { | |
| 259 | - return address; | |
| 260 | - } | |
| 261 | - | |
| 262 | - public void setAddress(String address) { | |
| 263 | - this.address = address; | |
| 264 | - } | |
| 265 | - | |
| 266 | - public String getParental() { | |
| 267 | - return parental; | |
| 268 | - } | |
| 269 | - | |
| 270 | - public void setParental(String parental) { | |
| 271 | - this.parental = parental; | |
| 272 | - } | |
| 273 | - | |
| 274 | - public String getParentId() { | |
| 275 | - return parentId; | |
| 276 | - } | |
| 277 | - | |
| 278 | - public void setParentId(String parentId) { | |
| 279 | - this.parentId = parentId; | |
| 280 | - } | |
| 281 | - | |
| 282 | - public String getSafetyWay() { | |
| 283 | - return safetyWay; | |
| 284 | - } | |
| 285 | - | |
| 286 | - public void setSafetyWay(String safetyWay) { | |
| 287 | - this.safetyWay = safetyWay; | |
| 288 | - } | |
| 289 | - | |
| 290 | - public String getRegisterWay() { | |
| 291 | - return registerWay; | |
| 292 | - } | |
| 293 | - | |
| 294 | - public void setRegisterWay(String registerWay) { | |
| 295 | - this.registerWay = registerWay; | |
| 296 | - } | |
| 297 | - | |
| 298 | - public String getCertNum() { | |
| 299 | - return certNum; | |
| 300 | - } | |
| 301 | - | |
| 302 | - public void setCertNum(String certNum) { | |
| 303 | - this.certNum = certNum; | |
| 304 | - } | |
| 305 | - | |
| 306 | - public String getCertValid() { | |
| 307 | - return certValid; | |
| 308 | - } | |
| 309 | - | |
| 310 | - public void setCertValid(String certValid) { | |
| 311 | - this.certValid = certValid; | |
| 312 | - } | |
| 313 | - | |
| 314 | - public String getCertErrCode() { | |
| 315 | - return certErrCode; | |
| 316 | - } | |
| 317 | - | |
| 318 | - public void setCertErrCode(String certErrCode) { | |
| 319 | - this.certErrCode = certErrCode; | |
| 320 | - } | |
| 321 | - | |
| 322 | - public String getCertEndTime() { | |
| 323 | - return certEndTime; | |
| 324 | - } | |
| 325 | - | |
| 326 | - public void setCertEndTime(String certEndTime) { | |
| 327 | - this.certEndTime = certEndTime; | |
| 328 | - } | |
| 329 | - | |
| 330 | - public String getSecrecy() { | |
| 331 | - return secrecy; | |
| 332 | - } | |
| 333 | - | |
| 334 | - public void setSecrecy(String secrecy) { | |
| 335 | - this.secrecy = secrecy; | |
| 336 | - } | |
| 337 | - | |
| 338 | - public String getIp() { | |
| 339 | - return ip; | |
| 340 | - } | |
| 341 | - | |
| 342 | - public void setIp(String ip) { | |
| 343 | - this.ip = ip; | |
| 344 | - } | |
| 345 | - | |
| 346 | - public Integer getPort() { | |
| 347 | - return port; | |
| 348 | - } | |
| 349 | - | |
| 350 | - public void setPort(Integer port) { | |
| 351 | - this.port = port; | |
| 352 | - } | |
| 353 | - | |
| 354 | - public String getPassword() { | |
| 355 | - return password; | |
| 356 | - } | |
| 357 | - | |
| 358 | - public void setPassword(String password) { | |
| 359 | - this.password = password; | |
| 360 | - } | |
| 361 | - | |
| 362 | - public String getOnline() { | |
| 363 | - return online; | |
| 364 | - } | |
| 365 | - | |
| 366 | - public void setOnline(String online) { | |
| 367 | - this.online = online; | |
| 368 | - } | |
| 369 | - | |
| 370 | - public double getLongitude() { | |
| 371 | - return longitude; | |
| 372 | - } | |
| 373 | - | |
| 374 | - public void setLongitude(double longitude) { | |
| 375 | - this.longitude = longitude; | |
| 376 | - } | |
| 377 | - | |
| 378 | - public double getLatitude() { | |
| 379 | - return latitude; | |
| 380 | - } | |
| 381 | - | |
| 382 | - public void setLatitude(double latitude) { | |
| 383 | - this.latitude = latitude; | |
| 384 | - } | |
| 385 | -} |
src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java
| 1 | 1 | package com.genersoft.iot.vmp.web; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | 3 | import com.alibaba.fastjson.JSONArray; |
| 5 | 4 | import com.alibaba.fastjson.JSONObject; |
| 6 | -import com.genersoft.iot.vmp.common.PageResult; | |
| 7 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 8 | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 9 | 7 | import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; |
| 10 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 11 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 12 | 10 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 13 | -import com.genersoft.iot.vmp.vmanager.device.DeviceController; | |
| 11 | +import com.github.pagehelper.PageInfo; | |
| 14 | 12 | import org.slf4j.Logger; |
| 15 | 13 | import org.slf4j.LoggerFactory; |
| 16 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | -import org.springframework.http.HttpStatus; | |
| 18 | -import org.springframework.http.ResponseEntity; | |
| 19 | -import org.springframework.stereotype.Controller; | |
| 20 | 15 | import org.springframework.web.bind.annotation.*; |
| 21 | 16 | |
| 22 | 17 | import java.util.List; |
| ... | ... | @@ -68,9 +63,9 @@ public class ApiDeviceController { |
| 68 | 63 | devices = storager.queryVideoDeviceList(); |
| 69 | 64 | result.put("DeviceCount", devices.size()); |
| 70 | 65 | }else { |
| 71 | - PageResult<Device> deviceList = storager.queryVideoDeviceList(null, start/limit, limit); | |
| 66 | + PageInfo<Device> deviceList = storager.queryVideoDeviceList(start/limit, limit); | |
| 72 | 67 | result.put("DeviceCount", deviceList.getTotal()); |
| 73 | - devices = deviceList.getData(); | |
| 68 | + devices = deviceList.getList(); | |
| 74 | 69 | } |
| 75 | 70 | |
| 76 | 71 | JSONArray deviceJSONList = new JSONArray(); |
| ... | ... | @@ -86,8 +81,8 @@ public class ApiDeviceController { |
| 86 | 81 | deviceJsonObject.put("Online", device.getOnline() == 1); |
| 87 | 82 | deviceJsonObject.put("Password", ""); |
| 88 | 83 | deviceJsonObject.put("MediaTransport", device.getTransport()); |
| 89 | - deviceJsonObject.put("RemoteIP", device.getHost().getIp()); | |
| 90 | - deviceJsonObject.put("RemotePort", device.getHost().getPort()); | |
| 84 | + deviceJsonObject.put("RemoteIP", device.getIp()); | |
| 85 | + deviceJsonObject.put("RemotePort", device.getPort()); | |
| 91 | 86 | deviceJsonObject.put("LastRegisterAt", ""); |
| 92 | 87 | deviceJsonObject.put("LastKeepaliveAt", ""); |
| 93 | 88 | deviceJsonObject.put("UpdatedAt", ""); |
| ... | ... | @@ -123,9 +118,9 @@ public class ApiDeviceController { |
| 123 | 118 | deviceChannels = storager.queryChannelsByDeviceId(serial); |
| 124 | 119 | result.put("ChannelCount", deviceChannels.size()); |
| 125 | 120 | }else { |
| 126 | - PageResult<DeviceChannel> pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start/limit, limit); | |
| 121 | + PageInfo<DeviceChannel> pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start/limit, limit); | |
| 127 | 122 | result.put("ChannelCount", pageResult.getTotal()); |
| 128 | - deviceChannels = pageResult.getData(); | |
| 123 | + deviceChannels = pageResult.getList(); | |
| 129 | 124 | } |
| 130 | 125 | |
| 131 | 126 | JSONArray channleJSONList = new JSONArray(); | ... | ... |
src/main/resources/application-dev.yml
src/main/resources/application.yml
src/main/resources/wvp.sqlite
No preview for this file type
web_src/src/components/channelList.vue
| ... | ... | @@ -21,8 +21,8 @@ |
| 21 | 21 | </el-select> |
| 22 | 22 | 在线状态: <el-select size="mini" @change="search" v-model="online" placeholder="请选择" default-first-option> |
| 23 | 23 | <el-option label="全部" value=""></el-option> |
| 24 | - <el-option label="在线" value="on"></el-option> | |
| 25 | - <el-option label="离线" value="off"></el-option> | |
| 24 | + <el-option label="在线" value="true"></el-option> | |
| 25 | + <el-option label="离线" value="false"></el-option> | |
| 26 | 26 | </el-select> |
| 27 | 27 | |
| 28 | 28 | </div> |
| ... | ... | @@ -161,7 +161,7 @@ export default { |
| 161 | 161 | .then(function (res) { |
| 162 | 162 | console.log(res); |
| 163 | 163 | that.total = res.data.total; |
| 164 | - that.deviceChannelList = res.data.data; | |
| 164 | + that.deviceChannelList = res.data.list; | |
| 165 | 165 | // 防止出现表格错位 |
| 166 | 166 | that.$nextTick(() => { |
| 167 | 167 | that.$refs.channelListTable.doLayout(); | ... | ... |
web_src/src/components/videoList.vue
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | <el-table-column label="地址" width="180" align="center"> |
| 22 | 22 | <template slot-scope="scope"> |
| 23 | 23 | <div slot="reference" class="name-wrapper"> |
| 24 | - <el-tag size="medium">{{ scope.row.host.address }}</el-tag> | |
| 24 | + <el-tag size="medium">{{ scope.row.hostAddress }}</el-tag> | |
| 25 | 25 | </div> |
| 26 | 26 | </template> |
| 27 | 27 | </el-table-column> |
| ... | ... | @@ -140,8 +140,9 @@ |
| 140 | 140 | } ) |
| 141 | 141 | .then(function (res) { |
| 142 | 142 | console.log(res); |
| 143 | + console.log(res.data.list); | |
| 143 | 144 | that.total = res.data.total; |
| 144 | - that.deviceList = res.data.data; | |
| 145 | + that.deviceList = res.data.list; | |
| 145 | 146 | that.getDeviceListLoading = false; |
| 146 | 147 | }) |
| 147 | 148 | .catch(function (error) { | ... | ... |