Commit f559e6a39565f17688e44c9d881c7a8217be116b

Authored by 648540858
1 parent 2f108a46

完善目录订阅

src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java
... ... @@ -8,7 +8,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
8 8 import java.util.concurrent.ThreadPoolExecutor;
9 9  
10 10 @Configuration
11   -@EnableAsync
  11 +@EnableAsync(proxyTargetClass = true)
12 12 public class ThreadPoolTaskConfig {
13 13  
14 14 /**
... ... @@ -36,7 +36,7 @@ public class ThreadPoolTaskConfig {
36 36 /**
37 37 * 线程池名前缀
38 38 */
39   - private static final String threadNamePrefix = "hdl-uhi-service-";
  39 + private static final String threadNamePrefix = "wvp-sip-handle-";
40 40  
41 41 @Bean("taskExecutor") // bean的名称,默认为首字母小写的方法名
42 42 public ThreadPoolTaskExecutor taskExecutor() {
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
... ... @@ -230,8 +230,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
230 230 String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
231 231  
232 232 Element rootElement = getRootElement(evt);
233   - Element deviceIdElement = rootElement.element("DeviceID");
234   - String channelId = deviceIdElement.getText();
235 233 Device device = storager.queryVideoDevice(deviceId);
236 234 if (device == null) {
237 235 return;
... ... @@ -254,22 +252,23 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
254 252 continue;
255 253 }
256 254 Element eventElement = itemDevice.element("Event");
  255 + DeviceChannel channel = channelContentHander(itemDevice);
257 256 switch (eventElement.getText().toUpperCase()) {
258 257 case "ON" : // 上线
259   - logger.info("收到来自设备【{}】的通道上线【{}】通知", device.getDeviceId(), channelId);
260   - storager.deviceChannelOnline(deviceId, channelId);
  258 + logger.info("收到来自设备【{}】的通道【{}】上线通知", device.getDeviceId(), channel.getChannelId());
  259 + storager.deviceChannelOnline(deviceId, channel.getChannelId());
261 260 // 回复200 OK
262 261 responseAck(evt, Response.OK);
263 262 break;
264 263 case "OFF" : // 离线
265   - logger.info("收到来自设备【{}】的通道离线【{}】通知", device.getDeviceId(), channelId);
266   - storager.deviceChannelOffline(deviceId, channelId);
  264 + logger.info("收到来自设备【{}】的通道【{}】离线通知", device.getDeviceId(), channel.getChannelId());
  265 + storager.deviceChannelOffline(deviceId, channel.getChannelId());
267 266 // 回复200 OK
268 267 responseAck(evt, Response.OK);
269 268 break;
270 269 case "VLOST" : // 视频丢失
271   - logger.info("收到来自设备【{}】的通道视频丢失【{}】通知", device.getDeviceId(), channelId);
272   - storager.deviceChannelOffline(deviceId, channelId);
  270 + logger.info("收到来自设备【{}】的通道【{}】视频丢失通知", device.getDeviceId(), channel.getChannelId());
  271 + storager.deviceChannelOffline(deviceId, channel.getChannelId());
273 272 // 回复200 OK
274 273 responseAck(evt, Response.OK);
275 274 break;
... ... @@ -278,19 +277,17 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
278 277 responseAck(evt, Response.OK);
279 278 break;
280 279 case "ADD" : // 增加
281   - logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channelId);
282   - DeviceChannel deviceChannel = channelContentHander(itemDevice, channelId);
283   - storager.updateChannel(deviceId, deviceChannel);
  280 + logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channel.getChannelId());
  281 + storager.updateChannel(deviceId, channel);
284 282 responseAck(evt, Response.OK);
285 283 break;
286 284 case "DEL" : // 删除
287   - logger.info("收到来自设备【{}】的删除通道【{}】通知", device.getDeviceId(), channelId);
288   - storager.delChannel(deviceId, channelId);
  285 + logger.info("收到来自设备【{}】的删除通道【{}】通知", device.getDeviceId(), channel.getChannelId());
  286 + storager.delChannel(deviceId, channel.getChannelId());
289 287 responseAck(evt, Response.OK);
290 288 break;
291 289 case "UPDATE" : // 更新
292   - logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channelId);
293   - DeviceChannel channel = channelContentHander(itemDevice, channelId);
  290 + logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channel.getChannelId());
294 291 storager.updateChannel(deviceId, channel);
295 292 responseAck(evt, Response.OK);
296 293 break;
... ... @@ -316,13 +313,15 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
316 313 }
317 314 }
318 315  
319   - public DeviceChannel channelContentHander(Element itemDevice, String channelId){
  316 + public DeviceChannel channelContentHander(Element itemDevice){
320 317 Element channdelNameElement = itemDevice.element("Name");
321 318 String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : "";
322 319 Element statusElement = itemDevice.element("Status");
323 320 String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON";
324 321 DeviceChannel deviceChannel = new DeviceChannel();
325 322 deviceChannel.setName(channelName);
  323 + Element channdelIdElement = itemDevice.element("DeviceID");
  324 + String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : "";
326 325 deviceChannel.setChannelId(channelId);
327 326 // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
328 327 if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) {
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
... ... @@ -47,7 +47,7 @@ public class DeviceServiceImpl implements IDeviceService {
47 47 if (device == null || device.getSubscribeCycleForCatalog() < 0) {
48 48 return false;
49 49 }
50   - logger.info("移除目录订阅【{}】", device.getDeviceId());
  50 + logger.info("移除目录订阅: {}", device.getDeviceId());
51 51 dynamicTask.stopCron(device.getDeviceId());
52 52 device.setSubscribeCycleForCatalog(0);
53 53 sipCommander.catalogSubscribe(device, null, null);
... ...