Commit b15e559eae82db811b31f1e3c47e3be027f20e27
Merge branch '2.6.9' into wvp-28181-2.0
Showing
2 changed files
with
41 additions
and
17 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
| ... | ... | @@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 13 | 13 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| 14 | 14 | import com.genersoft.iot.vmp.service.IDeviceChannelService; |
| 15 | 15 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 16 | +import com.genersoft.iot.vmp.utils.DateUtil; | |
| 16 | 17 | import org.dom4j.DocumentException; |
| 17 | 18 | import org.dom4j.Element; |
| 18 | 19 | import org.slf4j.Logger; |
| ... | ... | @@ -185,6 +186,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent |
| 185 | 186 | // 判断此通道是否存在 |
| 186 | 187 | DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channel.getChannelId()); |
| 187 | 188 | if (deviceChannel != null) { |
| 189 | + logger.info("[增加通道] 已存在,不发送通知只更新,设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); | |
| 188 | 190 | channel.setId(deviceChannel.getId()); |
| 189 | 191 | updateChannelMap.put(channel.getChannelId(), channel); |
| 190 | 192 | if (updateChannelMap.keySet().size() > 300) { |
| ... | ... | @@ -222,6 +224,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent |
| 222 | 224 | DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId()); |
| 223 | 225 | if (deviceChannelForUpdate != null) { |
| 224 | 226 | channel.setId(deviceChannelForUpdate.getId()); |
| 227 | + channel.setUpdateTime(DateUtil.getNow()); | |
| 225 | 228 | updateChannelMap.put(channel.getChannelId(), channel); |
| 226 | 229 | if (updateChannelMap.keySet().size() > 300) { |
| 227 | 230 | executeSaveForUpdate(); |
| ... | ... | @@ -244,11 +247,11 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent |
| 244 | 247 | // 转发变化信息 |
| 245 | 248 | eventPublisher.catalogEventPublish(null, channel, event); |
| 246 | 249 | |
| 247 | - if (updateChannelMap.keySet().size() > 0 | |
| 248 | - || addChannelMap.keySet().size() > 0 | |
| 249 | - || updateChannelOnlineList.size() > 0 | |
| 250 | - || updateChannelOfflineList.size() > 0 | |
| 251 | - || deleteChannelList.size() > 0) { | |
| 250 | + if (!updateChannelMap.keySet().isEmpty() | |
| 251 | + || !addChannelMap.keySet().isEmpty() | |
| 252 | + || !updateChannelOnlineList.isEmpty() | |
| 253 | + || !updateChannelOfflineList.isEmpty() | |
| 254 | + || !deleteChannelList.isEmpty()) { | |
| 252 | 255 | |
| 253 | 256 | if (!dynamicTask.contains(talkKey)) { |
| 254 | 257 | dynamicTask.startDelay(talkKey, this::executeSave, 1000); |
| ... | ... | @@ -262,16 +265,36 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent |
| 262 | 265 | } |
| 263 | 266 | |
| 264 | 267 | private void executeSave(){ |
| 265 | - executeSaveForAdd(); | |
| 266 | - executeSaveForUpdate(); | |
| 267 | - executeSaveForDelete(); | |
| 268 | - executeSaveForOnline(); | |
| 269 | - executeSaveForOffline(); | |
| 268 | + try { | |
| 269 | + executeSaveForAdd(); | |
| 270 | + } catch (Exception e) { | |
| 271 | + logger.error("[存储收到的增加通道] 异常: ", e ); | |
| 272 | + } | |
| 273 | + try { | |
| 274 | + executeSaveForUpdate(); | |
| 275 | + } catch (Exception e) { | |
| 276 | + logger.error("[存储收到的更新通道] 异常: ", e ); | |
| 277 | + } | |
| 278 | + try { | |
| 279 | + executeSaveForDelete(); | |
| 280 | + } catch (Exception e) { | |
| 281 | + logger.error("[存储收到的删除通道] 异常: ", e ); | |
| 282 | + } | |
| 283 | + try { | |
| 284 | + executeSaveForOnline(); | |
| 285 | + } catch (Exception e) { | |
| 286 | + logger.error("[存储收到的通道上线] 异常: ", e ); | |
| 287 | + } | |
| 288 | + try { | |
| 289 | + executeSaveForOffline(); | |
| 290 | + } catch (Exception e) { | |
| 291 | + logger.error("[存储收到的通道离线] 异常: ", e ); | |
| 292 | + } | |
| 270 | 293 | dynamicTask.stop(talkKey); |
| 271 | 294 | } |
| 272 | 295 | |
| 273 | 296 | private void executeSaveForUpdate(){ |
| 274 | - if (updateChannelMap.values().size() > 0) { | |
| 297 | + if (!updateChannelMap.values().isEmpty()) { | |
| 275 | 298 | ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(updateChannelMap.values()); |
| 276 | 299 | updateChannelMap.clear(); |
| 277 | 300 | deviceChannelService.batchUpdateChannel(deviceChannels); |
| ... | ... | @@ -280,7 +303,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent |
| 280 | 303 | } |
| 281 | 304 | |
| 282 | 305 | private void executeSaveForAdd(){ |
| 283 | - if (addChannelMap.values().size() > 0) { | |
| 306 | + if (!addChannelMap.values().isEmpty()) { | |
| 284 | 307 | ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(addChannelMap.values()); |
| 285 | 308 | addChannelMap.clear(); |
| 286 | 309 | deviceChannelService.batchAddChannel(deviceChannels); |
| ... | ... | @@ -288,21 +311,21 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent |
| 288 | 311 | } |
| 289 | 312 | |
| 290 | 313 | private void executeSaveForDelete(){ |
| 291 | - if (deleteChannelList.size() > 0) { | |
| 314 | + if (!deleteChannelList.isEmpty()) { | |
| 292 | 315 | deviceChannelService.deleteChannels(deleteChannelList); |
| 293 | 316 | deleteChannelList.clear(); |
| 294 | 317 | } |
| 295 | 318 | } |
| 296 | 319 | |
| 297 | 320 | private void executeSaveForOnline(){ |
| 298 | - if (updateChannelOnlineList.size() > 0) { | |
| 321 | + if (!updateChannelOnlineList.isEmpty()) { | |
| 299 | 322 | deviceChannelService.channelsOnline(updateChannelOnlineList); |
| 300 | 323 | updateChannelOnlineList.clear(); |
| 301 | 324 | } |
| 302 | 325 | } |
| 303 | 326 | |
| 304 | 327 | private void executeSaveForOffline(){ |
| 305 | - if (updateChannelOfflineList.size() > 0) { | |
| 328 | + if (!updateChannelOfflineList.isEmpty()) { | |
| 306 | 329 | deviceChannelService.channelsOffline(updateChannelOfflineList); |
| 307 | 330 | updateChannelOfflineList.clear(); |
| 308 | 331 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java
| ... | ... | @@ -50,11 +50,12 @@ public class RedisGpsMsgListener implements MessageListener { |
| 50 | 50 | Message msg = taskQueue.poll(); |
| 51 | 51 | try { |
| 52 | 52 | GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class); |
| 53 | + logger.info("[REDIS的位置变化通知], {}", JSON.toJSONString(gpsMsgInfo)); | |
| 53 | 54 | // 只是放入redis缓存起来 |
| 54 | 55 | redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); |
| 55 | 56 | }catch (Exception e) { |
| 56 | - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); | |
| 57 | - logger.error("[REDIS的ALARM通知] 异常内容: ", e); | |
| 57 | + logger.warn("[REDIS的位置变化通知] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); | |
| 58 | + logger.error("[REDIS的位置变化通知] 异常内容: ", e); | |
| 58 | 59 | } |
| 59 | 60 | } |
| 60 | 61 | }); | ... | ... |