From 8874c90db2c238fa4c55df491675fe7fec9d93b2 Mon Sep 17 00:00:00 2001
From: fine <54142345+criver31@users.noreply.github.com>
Date: 星期二, 09 一月 2024 11:45:30 +0800
Subject: [PATCH] Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java |   53 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
index a78404e..4ea7667 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
+++ b/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.XmlUtil;
 import com.genersoft.iot.vmp.service.IDeviceChannelService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
+import com.genersoft.iot.vmp.utils.DateUtil;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
 import org.slf4j.Logger;
@@ -185,6 +186,7 @@
 							// 鍒ゆ柇姝ら�氶亾鏄惁瀛樺湪
 							DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channel.getChannelId());
 							if (deviceChannel != null) {
+								logger.info("[澧炲姞閫氶亾] 宸插瓨鍦紝涓嶅彂閫侀�氱煡鍙洿鏂帮紝璁惧: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId());
 								channel.setId(deviceChannel.getId());
 								updateChannelMap.put(channel.getChannelId(), channel);
 								if (updateChannelMap.keySet().size() > 300) {
@@ -222,6 +224,7 @@
 							DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId());
 							if (deviceChannelForUpdate != null) {
 								channel.setId(deviceChannelForUpdate.getId());
+								channel.setUpdateTime(DateUtil.getNow());
 								updateChannelMap.put(channel.getChannelId(), channel);
 								if (updateChannelMap.keySet().size() > 300) {
 									executeSaveForUpdate();
@@ -244,11 +247,11 @@
 					// 杞彂鍙樺寲淇℃伅
 					eventPublisher.catalogEventPublish(null, channel, event);
 
-					if (updateChannelMap.keySet().size() > 0
-							|| addChannelMap.keySet().size() > 0
-							|| updateChannelOnlineList.size() > 0
-							|| updateChannelOfflineList.size() > 0
-							|| deleteChannelList.size() > 0) {
+					if (!updateChannelMap.keySet().isEmpty()
+							|| !addChannelMap.keySet().isEmpty()
+							|| !updateChannelOnlineList.isEmpty()
+							|| !updateChannelOfflineList.isEmpty()
+							|| !deleteChannelList.isEmpty()) {
 
 						if (!dynamicTask.contains(talkKey)) {
 							dynamicTask.startDelay(talkKey, this::executeSave, 1000);
@@ -262,16 +265,36 @@
 	}
 
 	private void executeSave(){
-		executeSaveForAdd();
-		executeSaveForUpdate();
-		executeSaveForDelete();
-		executeSaveForOnline();
-		executeSaveForOffline();
+		try {
+			executeSaveForAdd();
+		} catch (Exception e) {
+			logger.error("[瀛樺偍鏀跺埌鐨勫鍔犻�氶亾] 寮傚父锛� ", e );
+		}
+		try {
+			executeSaveForUpdate();
+		} catch (Exception e) {
+			logger.error("[瀛樺偍鏀跺埌鐨勬洿鏂伴�氶亾] 寮傚父锛� ", e );
+		}
+		try {
+			executeSaveForDelete();
+		} catch (Exception e) {
+			logger.error("[瀛樺偍鏀跺埌鐨勫垹闄ら�氶亾] 寮傚父锛� ", e );
+		}
+		try {
+			executeSaveForOnline();
+		} catch (Exception e) {
+			logger.error("[瀛樺偍鏀跺埌鐨勯�氶亾涓婄嚎] 寮傚父锛� ", e );
+		}
+		try {
+			executeSaveForOffline();
+		} catch (Exception e) {
+			logger.error("[瀛樺偍鏀跺埌鐨勯�氶亾绂荤嚎] 寮傚父锛� ", e );
+		}
 		dynamicTask.stop(talkKey);
 	}
 
 	private void executeSaveForUpdate(){
-		if (updateChannelMap.values().size() > 0) {
+		if (!updateChannelMap.values().isEmpty()) {
 			ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(updateChannelMap.values());
 			updateChannelMap.clear();
 			deviceChannelService.batchUpdateChannel(deviceChannels);
@@ -280,7 +303,7 @@
 	}
 
 	private void executeSaveForAdd(){
-		if (addChannelMap.values().size() > 0) {
+		if (!addChannelMap.values().isEmpty()) {
 			ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(addChannelMap.values());
 			addChannelMap.clear();
 			deviceChannelService.batchAddChannel(deviceChannels);
@@ -288,21 +311,21 @@
 	}
 
 	private void executeSaveForDelete(){
-		if (deleteChannelList.size() > 0) {
+		if (!deleteChannelList.isEmpty()) {
 			deviceChannelService.deleteChannels(deleteChannelList);
 			deleteChannelList.clear();
 		}
 	}
 
 	private void executeSaveForOnline(){
-		if (updateChannelOnlineList.size() > 0) {
+		if (!updateChannelOnlineList.isEmpty()) {
 			deviceChannelService.channelsOnline(updateChannelOnlineList);
 			updateChannelOnlineList.clear();
 		}
 	}
 
 	private void executeSaveForOffline(){
-		if (updateChannelOfflineList.size() > 0) {
+		if (!updateChannelOfflineList.isEmpty()) {
 			deviceChannelService.channelsOffline(updateChannelOfflineList);
 			updateChannelOfflineList.clear();
 		}

--
Gitblit v1.8.0