Commit b15e559eae82db811b31f1e3c47e3be027f20e27

Authored by 648540858
2 parents a2cac5ca a74fb6ec

Merge branch '2.6.9' into wvp-28181-2.0

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,6 +13,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
13 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; 13 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
14 import com.genersoft.iot.vmp.service.IDeviceChannelService; 14 import com.genersoft.iot.vmp.service.IDeviceChannelService;
15 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 15 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  16 +import com.genersoft.iot.vmp.utils.DateUtil;
16 import org.dom4j.DocumentException; 17 import org.dom4j.DocumentException;
17 import org.dom4j.Element; 18 import org.dom4j.Element;
18 import org.slf4j.Logger; 19 import org.slf4j.Logger;
@@ -185,6 +186,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent @@ -185,6 +186,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
185 // 判断此通道是否存在 186 // 判断此通道是否存在
186 DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channel.getChannelId()); 187 DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channel.getChannelId());
187 if (deviceChannel != null) { 188 if (deviceChannel != null) {
  189 + logger.info("[增加通道] 已存在,不发送通知只更新,设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
188 channel.setId(deviceChannel.getId()); 190 channel.setId(deviceChannel.getId());
189 updateChannelMap.put(channel.getChannelId(), channel); 191 updateChannelMap.put(channel.getChannelId(), channel);
190 if (updateChannelMap.keySet().size() > 300) { 192 if (updateChannelMap.keySet().size() > 300) {
@@ -222,6 +224,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent @@ -222,6 +224,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
222 DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId()); 224 DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId());
223 if (deviceChannelForUpdate != null) { 225 if (deviceChannelForUpdate != null) {
224 channel.setId(deviceChannelForUpdate.getId()); 226 channel.setId(deviceChannelForUpdate.getId());
  227 + channel.setUpdateTime(DateUtil.getNow());
225 updateChannelMap.put(channel.getChannelId(), channel); 228 updateChannelMap.put(channel.getChannelId(), channel);
226 if (updateChannelMap.keySet().size() > 300) { 229 if (updateChannelMap.keySet().size() > 300) {
227 executeSaveForUpdate(); 230 executeSaveForUpdate();
@@ -244,11 +247,11 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent @@ -244,11 +247,11 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
244 // 转发变化信息 247 // 转发变化信息
245 eventPublisher.catalogEventPublish(null, channel, event); 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 if (!dynamicTask.contains(talkKey)) { 256 if (!dynamicTask.contains(talkKey)) {
254 dynamicTask.startDelay(talkKey, this::executeSave, 1000); 257 dynamicTask.startDelay(talkKey, this::executeSave, 1000);
@@ -262,16 +265,36 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent @@ -262,16 +265,36 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
262 } 265 }
263 266
264 private void executeSave(){ 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 dynamicTask.stop(talkKey); 293 dynamicTask.stop(talkKey);
271 } 294 }
272 295
273 private void executeSaveForUpdate(){ 296 private void executeSaveForUpdate(){
274 - if (updateChannelMap.values().size() > 0) { 297 + if (!updateChannelMap.values().isEmpty()) {
275 ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(updateChannelMap.values()); 298 ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(updateChannelMap.values());
276 updateChannelMap.clear(); 299 updateChannelMap.clear();
277 deviceChannelService.batchUpdateChannel(deviceChannels); 300 deviceChannelService.batchUpdateChannel(deviceChannels);
@@ -280,7 +303,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent @@ -280,7 +303,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
280 } 303 }
281 304
282 private void executeSaveForAdd(){ 305 private void executeSaveForAdd(){
283 - if (addChannelMap.values().size() > 0) { 306 + if (!addChannelMap.values().isEmpty()) {
284 ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(addChannelMap.values()); 307 ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(addChannelMap.values());
285 addChannelMap.clear(); 308 addChannelMap.clear();
286 deviceChannelService.batchAddChannel(deviceChannels); 309 deviceChannelService.batchAddChannel(deviceChannels);
@@ -288,21 +311,21 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent @@ -288,21 +311,21 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
288 } 311 }
289 312
290 private void executeSaveForDelete(){ 313 private void executeSaveForDelete(){
291 - if (deleteChannelList.size() > 0) { 314 + if (!deleteChannelList.isEmpty()) {
292 deviceChannelService.deleteChannels(deleteChannelList); 315 deviceChannelService.deleteChannels(deleteChannelList);
293 deleteChannelList.clear(); 316 deleteChannelList.clear();
294 } 317 }
295 } 318 }
296 319
297 private void executeSaveForOnline(){ 320 private void executeSaveForOnline(){
298 - if (updateChannelOnlineList.size() > 0) { 321 + if (!updateChannelOnlineList.isEmpty()) {
299 deviceChannelService.channelsOnline(updateChannelOnlineList); 322 deviceChannelService.channelsOnline(updateChannelOnlineList);
300 updateChannelOnlineList.clear(); 323 updateChannelOnlineList.clear();
301 } 324 }
302 } 325 }
303 326
304 private void executeSaveForOffline(){ 327 private void executeSaveForOffline(){
305 - if (updateChannelOfflineList.size() > 0) { 328 + if (!updateChannelOfflineList.isEmpty()) {
306 deviceChannelService.channelsOffline(updateChannelOfflineList); 329 deviceChannelService.channelsOffline(updateChannelOfflineList);
307 updateChannelOfflineList.clear(); 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,11 +50,12 @@ public class RedisGpsMsgListener implements MessageListener {
50 Message msg = taskQueue.poll(); 50 Message msg = taskQueue.poll();
51 try { 51 try {
52 GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class); 52 GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class);
  53 + logger.info("[REDIS的位置变化通知], {}", JSON.toJSONString(gpsMsgInfo));
53 // 只是放入redis缓存起来 54 // 只是放入redis缓存起来
54 redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); 55 redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo);
55 }catch (Exception e) { 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 });