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