Commit eca1e05aeed3c51cce36bbce80c71bc3cbcea87d

Authored by 648540858
1 parent 58545493

维护目录订阅消息与接口

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
@@ -71,7 +71,7 @@ public class SIPProcessorObserver implements SipListener { @@ -71,7 +71,7 @@ public class SIPProcessorObserver implements SipListener {
71 logger.warn("不支持方法{}的request", method); 71 logger.warn("不支持方法{}的request", method);
72 return; 72 return;
73 } 73 }
74 - requestProcessorMap.get(requestEvent.getRequest().getMethod()).process(requestEvent); 74 + requestProcessorMap.get(method).process(requestEvent);
75 } 75 }
76 76
77 /** 77 /**
@@ -143,17 +143,18 @@ public class SIPProcessorObserver implements SipListener { @@ -143,17 +143,18 @@ public class SIPProcessorObserver implements SipListener {
143 143
144 @Override 144 @Override
145 public void processIOException(IOExceptionEvent exceptionEvent) { 145 public void processIOException(IOExceptionEvent exceptionEvent) {
146 - 146 +// System.out.println("processIOException");
147 } 147 }
148 148
149 @Override 149 @Override
150 public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent) { 150 public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent) {
151 - 151 +// System.out.println("processTransactionTerminated");
152 } 152 }
153 153
154 @Override 154 @Override
155 public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) { 155 public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) {
156 - 156 + CallIdHeader callId = dialogTerminatedEvent.getDialog().getCallId();
  157 + System.out.println("processDialogTerminated:::::" + callId);
157 } 158 }
158 159
159 160
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
@@ -125,7 +125,8 @@ public abstract class SIPRequestProcessorParent { @@ -125,7 +125,8 @@ public abstract class SIPRequestProcessorParent {
125 Response response = getMessageFactory().createResponse(statusCode, evt.getRequest()); 125 Response response = getMessageFactory().createResponse(statusCode, evt.getRequest());
126 ServerTransaction serverTransaction = getServerTransaction(evt); 126 ServerTransaction serverTransaction = getServerTransaction(evt);
127 serverTransaction.sendResponse(response); 127 serverTransaction.sendResponse(response);
128 - if (statusCode >= 200) { 128 + if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) {
  129 +
129 if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); 130 if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete();
130 } 131 }
131 } 132 }
@@ -135,7 +136,7 @@ public abstract class SIPRequestProcessorParent { @@ -135,7 +136,7 @@ public abstract class SIPRequestProcessorParent {
135 response.setReasonPhrase(msg); 136 response.setReasonPhrase(msg);
136 ServerTransaction serverTransaction = getServerTransaction(evt); 137 ServerTransaction serverTransaction = getServerTransaction(evt);
137 serverTransaction.sendResponse(response); 138 serverTransaction.sendResponse(response);
138 - if (statusCode >= 200) { 139 + if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) {
139 if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); 140 if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete();
140 } 141 }
141 } 142 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
@@ -253,87 +253,52 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements @@ -253,87 +253,52 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
253 if (channelDeviceElement == null) { 253 if (channelDeviceElement == null) {
254 continue; 254 continue;
255 } 255 }
256 - String channelDeviceId = channelDeviceElement.getTextTrim();  
257 - Element channdelNameElement = itemDevice.element("Name");  
258 - String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : "";  
259 - Element statusElement = itemDevice.element("Status");  
260 - String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON";  
261 - DeviceChannel deviceChannel = new DeviceChannel();  
262 - deviceChannel.setName(channelName);  
263 - deviceChannel.setChannelId(channelDeviceId);  
264 - // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理  
265 - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) {  
266 - deviceChannel.setStatus(1);  
267 - }  
268 - if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {  
269 - deviceChannel.setStatus(0);  
270 - } 256 + Element eventElement = itemDevice.element("Event");
  257 + switch (eventElement.getText().toUpperCase()) {
  258 + case "ON" : // 上线
  259 + logger.info("收到来自设备【{}】的通道上线【{}】通知", device.getDeviceId(), channelId);
  260 + storager.deviceChannelOnline(deviceId, channelId);
  261 + // 回复200 OK
  262 + responseAck(evt, Response.OK);
  263 + break;
  264 + case "OFF" : // 离线
  265 + logger.info("收到来自设备【{}】的通道离线【{}】通知", device.getDeviceId(), channelId);
  266 + storager.deviceChannelOffline(deviceId, channelId);
  267 + // 回复200 OK
  268 + responseAck(evt, Response.OK);
  269 + break;
  270 + case "VLOST" : // 视频丢失
  271 + logger.info("收到来自设备【{}】的通道视频丢失【{}】通知", device.getDeviceId(), channelId);
  272 + storager.deviceChannelOffline(deviceId, channelId);
  273 + // 回复200 OK
  274 + responseAck(evt, Response.OK);
  275 + break;
  276 + case "DEFECT" : // 故障
  277 + // 回复200 OK
  278 + responseAck(evt, Response.OK);
  279 + break;
  280 + case "ADD" : // 增加
  281 + logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channelId);
  282 + DeviceChannel deviceChannel = channelContentHander(itemDevice, channelId);
  283 + storager.updateChannel(deviceId, deviceChannel);
  284 + responseAck(evt, Response.OK);
  285 + break;
  286 + case "DEL" : // 删除
  287 + logger.info("收到来自设备【{}】的删除通道【{}】通知", device.getDeviceId(), channelId);
  288 + storager.delChannel(deviceId, channelId);
  289 + responseAck(evt, Response.OK);
  290 + break;
  291 + case "UPDATE" : // 更新
  292 + logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channelId);
  293 + DeviceChannel channel = channelContentHander(itemDevice, channelId);
  294 + storager.updateChannel(deviceId, channel);
  295 + responseAck(evt, Response.OK);
  296 + break;
  297 + default:
  298 + responseAck(evt, Response.BAD_REQUEST, "event not found");
271 299
272 - deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer"));  
273 - deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model"));  
274 - deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner"));  
275 - deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode"));  
276 - deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));  
277 - deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));  
278 - if (XmlUtil.getText(itemDevice, "Parental") == null  
279 - || XmlUtil.getText(itemDevice, "Parental") == "") {  
280 - deviceChannel.setParental(0);  
281 - } else {  
282 - deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental")));  
283 - }  
284 - deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID"));  
285 - if (XmlUtil.getText(itemDevice, "SafetyWay") == null  
286 - || XmlUtil.getText(itemDevice, "SafetyWay") == "") {  
287 - deviceChannel.setSafetyWay(0);  
288 - } else {  
289 - deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay")));  
290 - }  
291 - if (XmlUtil.getText(itemDevice, "RegisterWay") == null  
292 - || XmlUtil.getText(itemDevice, "RegisterWay") == "") {  
293 - deviceChannel.setRegisterWay(1);  
294 - } else {  
295 - deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay")));  
296 - }  
297 - deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));  
298 - if (XmlUtil.getText(itemDevice, "Certifiable") == null  
299 - || XmlUtil.getText(itemDevice, "Certifiable") == "") {  
300 - deviceChannel.setCertifiable(0);  
301 - } else {  
302 - deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable")));  
303 - }  
304 - if (XmlUtil.getText(itemDevice, "ErrCode") == null  
305 - || XmlUtil.getText(itemDevice, "ErrCode") == "") {  
306 - deviceChannel.setErrCode(0);  
307 - } else {  
308 - deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode")));  
309 - }  
310 - deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime"));  
311 - deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy"));  
312 - deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress"));  
313 - if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") == "") {  
314 - deviceChannel.setPort(0);  
315 - } else {  
316 - deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port")));  
317 } 300 }
318 - deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));  
319 - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {  
320 - deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude")));  
321 - } else {  
322 - deviceChannel.setLongitude(0.00);  
323 - }  
324 - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) {  
325 - deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude")));  
326 - } else {  
327 - deviceChannel.setLatitude(0.00);  
328 - }  
329 - if (XmlUtil.getText(itemDevice, "PTZType") == null  
330 - || XmlUtil.getText(itemDevice, "PTZType") == "") {  
331 - deviceChannel.setPTZType(0);  
332 - } else {  
333 - deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType")));  
334 - }  
335 - deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC  
336 - storager.updateChannel(device.getDeviceId(), deviceChannel); 301 +
337 } 302 }
338 303
339 // RequestMessage msg = new RequestMessage(); 304 // RequestMessage msg = new RequestMessage();
@@ -341,8 +306,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements @@ -341,8 +306,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
341 // msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG); 306 // msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG);
342 // msg.setData(device); 307 // msg.setData(device);
343 // deferredResultHolder.invokeResult(msg); 308 // deferredResultHolder.invokeResult(msg);
344 - // 回复200 OK  
345 - responseAck(evt, Response.OK); 309 +
346 if (offLineDetector.isOnline(deviceId)) { 310 if (offLineDetector.isOnline(deviceId)) {
347 publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); 311 publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE);
348 } 312 }
@@ -352,6 +316,88 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements @@ -352,6 +316,88 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
352 } 316 }
353 } 317 }
354 318
  319 + public DeviceChannel channelContentHander(Element itemDevice, String channelId){
  320 + Element channdelNameElement = itemDevice.element("Name");
  321 + String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : "";
  322 + Element statusElement = itemDevice.element("Status");
  323 + String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON";
  324 + DeviceChannel deviceChannel = new DeviceChannel();
  325 + deviceChannel.setName(channelName);
  326 + deviceChannel.setChannelId(channelId);
  327 + // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
  328 + if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) {
  329 + deviceChannel.setStatus(1);
  330 + }
  331 + if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {
  332 + deviceChannel.setStatus(0);
  333 + }
  334 +
  335 + deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer"));
  336 + deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model"));
  337 + deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner"));
  338 + deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode"));
  339 + deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
  340 + deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
  341 + if (XmlUtil.getText(itemDevice, "Parental") == null
  342 + || XmlUtil.getText(itemDevice, "Parental") == "") {
  343 + deviceChannel.setParental(0);
  344 + } else {
  345 + deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental")));
  346 + }
  347 + deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID"));
  348 + if (XmlUtil.getText(itemDevice, "SafetyWay") == null
  349 + || XmlUtil.getText(itemDevice, "SafetyWay") == "") {
  350 + deviceChannel.setSafetyWay(0);
  351 + } else {
  352 + deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay")));
  353 + }
  354 + if (XmlUtil.getText(itemDevice, "RegisterWay") == null
  355 + || XmlUtil.getText(itemDevice, "RegisterWay") == "") {
  356 + deviceChannel.setRegisterWay(1);
  357 + } else {
  358 + deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay")));
  359 + }
  360 + deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));
  361 + if (XmlUtil.getText(itemDevice, "Certifiable") == null
  362 + || XmlUtil.getText(itemDevice, "Certifiable") == "") {
  363 + deviceChannel.setCertifiable(0);
  364 + } else {
  365 + deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable")));
  366 + }
  367 + if (XmlUtil.getText(itemDevice, "ErrCode") == null
  368 + || XmlUtil.getText(itemDevice, "ErrCode") == "") {
  369 + deviceChannel.setErrCode(0);
  370 + } else {
  371 + deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode")));
  372 + }
  373 + deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime"));
  374 + deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy"));
  375 + deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress"));
  376 + if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") == "") {
  377 + deviceChannel.setPort(0);
  378 + } else {
  379 + deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port")));
  380 + }
  381 + deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
  382 + if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {
  383 + deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude")));
  384 + } else {
  385 + deviceChannel.setLongitude(0.00);
  386 + }
  387 + if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) {
  388 + deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude")));
  389 + } else {
  390 + deviceChannel.setLatitude(0.00);
  391 + }
  392 + if (XmlUtil.getText(itemDevice, "PTZType") == null
  393 + || XmlUtil.getText(itemDevice, "PTZType") == "") {
  394 + deviceChannel.setPTZType(0);
  395 + } else {
  396 + deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType")));
  397 + }
  398 + deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC
  399 + return deviceChannel;
  400 + }
355 401
356 402
357 403
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
@@ -98,6 +98,13 @@ public interface IVideoManagerStorager { @@ -98,6 +98,13 @@ public interface IVideoManagerStorager {
98 public DeviceChannel queryChannel(String deviceId, String channelId); 98 public DeviceChannel queryChannel(String deviceId, String channelId);
99 99
100 /** 100 /**
  101 + * 删除通道
  102 + * @param deviceId 设备ID
  103 + * @param channelId 通道ID
  104 + */
  105 + public int delChannel(String deviceId, String channelId);
  106 +
  107 + /**
101 * 获取多个设备 108 * 获取多个设备
102 * @param page 当前页数 109 * @param page 当前页数
103 * @param count 每页数量 110 * @param count 每页数量
@@ -387,4 +394,16 @@ public interface IVideoManagerStorager { @@ -387,4 +394,16 @@ public interface IVideoManagerStorager {
387 * @return 394 * @return
388 */ 395 */
389 Device queryVideoDeviceByChannelId(String channelId); 396 Device queryVideoDeviceByChannelId(String channelId);
  397 +
  398 + /**
  399 + * 通道上线
  400 + * @param channelId 通道ID
  401 + */
  402 + void deviceChannelOnline(String deviceId, String channelId);
  403 +
  404 + /**
  405 + * 通道离线
  406 + * @param channelId 通道ID
  407 + */
  408 + void deviceChannelOffline(String deviceId, String channelId);
390 } 409 }
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
@@ -74,6 +74,9 @@ public interface DeviceChannelMapper { @@ -74,6 +74,9 @@ public interface DeviceChannelMapper {
74 @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}") 74 @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}")
75 int cleanChannelsByDeviceId(String deviceId); 75 int cleanChannelsByDeviceId(String deviceId);
76 76
  77 + @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
  78 + int del(String deviceId, String channelId);
  79 +
77 @Update(value = {"UPDATE device_channel SET streamId=null WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) 80 @Update(value = {"UPDATE device_channel SET streamId=null WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
78 void stopPlay(String deviceId, String channelId); 81 void stopPlay(String deviceId, String channelId);
79 82
@@ -104,5 +107,11 @@ public interface DeviceChannelMapper { @@ -104,5 +107,11 @@ public interface DeviceChannelMapper {
104 List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, Boolean inPlatform); 107 List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, Boolean inPlatform);
105 108
106 @Select("SELECT * FROM device_channel WHERE channelId=#{channelId}") 109 @Select("SELECT * FROM device_channel WHERE channelId=#{channelId}")
107 - List<DeviceChannel> queryChannelByChannelId(String channelId); 110 + List<DeviceChannel> queryChannelByChannelId( String channelId);
  111 +
  112 + @Update(value = {"UPDATE device_channel SET status=0 WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
  113 + void offline(String deviceId, String channelId);
  114 +
  115 + @Update(value = {"UPDATE device_channel SET status=1 WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
  116 + void online(String deviceId, String channelId);
108 } 117 }
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
1 package com.genersoft.iot.vmp.storager.impl; 1 package com.genersoft.iot.vmp.storager.impl;
2 2
3 -import java.text.SimpleDateFormat;  
4 -import java.util.*;  
5 -  
6 import com.genersoft.iot.vmp.gb28181.bean.*; 3 import com.genersoft.iot.vmp.gb28181.bean.*;
7 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; 4 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
8 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 5 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
9 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; 6 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
10 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; 7 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
11 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 8 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  9 +import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
12 import com.genersoft.iot.vmp.storager.dao.*; 10 import com.genersoft.iot.vmp.storager.dao.*;
13 import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; 11 import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
14 import com.github.pagehelper.PageHelper; 12 import com.github.pagehelper.PageHelper;
@@ -18,12 +16,16 @@ import org.slf4j.LoggerFactory; @@ -18,12 +16,16 @@ import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.jdbc.datasource.DataSourceTransactionManager; 17 import org.springframework.jdbc.datasource.DataSourceTransactionManager;
20 import org.springframework.stereotype.Component; 18 import org.springframework.stereotype.Component;
21 -  
22 -import com.genersoft.iot.vmp.storager.IVideoManagerStorager;  
23 import org.springframework.transaction.TransactionDefinition; 19 import org.springframework.transaction.TransactionDefinition;
24 import org.springframework.transaction.TransactionStatus; 20 import org.springframework.transaction.TransactionStatus;
25 import org.springframework.transaction.annotation.Transactional; 21 import org.springframework.transaction.annotation.Transactional;
26 22
  23 +import java.text.SimpleDateFormat;
  24 +import java.util.ArrayList;
  25 +import java.util.HashMap;
  26 +import java.util.List;
  27 +import java.util.Map;
  28 +
27 /** 29 /**
28 * @description:视频设备数据存储-jdbc实现 30 * @description:视频设备数据存储-jdbc实现
29 * @author: swwheihei 31 * @author: swwheihei
@@ -138,6 +140,16 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { @@ -138,6 +140,16 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
138 } 140 }
139 141
140 @Override 142 @Override
  143 + public void deviceChannelOnline(String deviceId, String channelId) {
  144 + deviceChannelMapper.online(deviceId, channelId);
  145 + }
  146 +
  147 + @Override
  148 + public void deviceChannelOffline(String deviceId, String channelId) {
  149 + deviceChannelMapper.offline(deviceId, channelId);
  150 + }
  151 +
  152 + @Override
141 public void startPlay(String deviceId, String channelId, String streamId) { 153 public void startPlay(String deviceId, String channelId, String streamId) {
142 deviceChannelMapper.startPlay(deviceId, channelId, streamId); 154 deviceChannelMapper.startPlay(deviceId, channelId, streamId);
143 } 155 }
@@ -184,6 +196,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { @@ -184,6 +196,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
184 } 196 }
185 197
186 198
  199 + @Override
  200 + public int delChannel(String deviceId, String channelId) {
  201 + return deviceChannelMapper.del(deviceId, channelId);
  202 + }
  203 +
187 /** 204 /**
188 * 获取多个设备 205 * 获取多个设备
189 * 206 *
@@ -624,8 +641,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { @@ -624,8 +641,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
624 return streamProxyMapper.selectForEnableInMediaServer(id, enable); 641 return streamProxyMapper.selectForEnableInMediaServer(id, enable);
625 } 642 }
626 643
  644 +
627 @Override 645 @Override
628 - public Device queryVideoDeviceByChannelId(String channelId) { 646 + public Device queryVideoDeviceByChannelId( String channelId) {
629 Device result = null; 647 Device result = null;
630 List<DeviceChannel> channelList = deviceChannelMapper.queryChannelByChannelId(channelId); 648 List<DeviceChannel> channelList = deviceChannelMapper.queryChannelByChannelId(channelId);
631 if (channelList.size() == 1) { 649 if (channelList.size() == 1) {