From 03d6ad289baddf8feed64ffca5f1b13828bea710 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 01 九月 2022 14:50:28 +0800
Subject: [PATCH] Merge branch 'wvp-28181-2.0'

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java |   54 +++++++++++++++++++++++++-----------------------------
 1 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
index a48dd20..a5cddae 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
@@ -6,8 +6,10 @@
 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract;
+import com.genersoft.iot.vmp.service.IPlatformService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +46,9 @@
 	@Autowired
 	private SubscribeHolder subscribeHolder;
 
+	@Autowired
+	private IPlatformService platformService;
+
 	@Override
 	public void afterPropertiesSet() throws Exception {
 		// 娣诲姞娑堟伅澶勭悊鐨勮闃�
@@ -60,48 +65,39 @@
 		Response response = evt.getResponse();
 		CallIdHeader callIdHeader = (CallIdHeader) response.getHeader(CallIdHeader.NAME);
 		String callId = callIdHeader.getCallId();
-
-		String platformGBId = redisCatchStorage.queryPlatformRegisterInfo(callId);
-		if (platformGBId == null) {
-			logger.info(String.format("鏈壘鍒癱allId锛� %s 鐨勬敞鍐�/娉ㄩ攢骞冲彴id", callId ));
+		PlatformRegisterInfo platformRegisterInfo = redisCatchStorage.queryPlatformRegisterInfo(callId);
+		if (platformRegisterInfo == null) {
+			logger.info(String.format("[鍥芥爣绾ц仈]鏈壘鍒癱allId锛� %s 鐨勬敞鍐�/娉ㄩ攢骞冲彴id", callId ));
 			return;
 		}
 
-		ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformGBId);
+		ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformRegisterInfo.getPlatformId());
 		if (parentPlatformCatch == null) {
-			logger.warn(String.format("[鏀跺埌娉ㄥ唽/娉ㄩ攢%S璇锋眰]骞冲彴锛�%s锛屼絾鏄钩鍙扮紦瀛樹俊鎭湭鏌ヨ鍒�!!!", response.getStatusCode(),platformGBId));
+			logger.warn(String.format("[鍥芥爣绾ц仈]鏀跺埌娉ㄥ唽/娉ㄩ攢%S璇锋眰锛屽钩鍙帮細%s锛屼絾鏄钩鍙扮紦瀛樹俊鎭湭鏌ヨ鍒�!!!", response.getStatusCode(),platformRegisterInfo.getPlatformId()));
 			return;
 		}
-		String action = parentPlatformCatch.getParentPlatform().getExpires().equals("0") ? "娉ㄩ攢" : "娉ㄥ唽";
-		logger.info(String.format("[%s %S鍝嶅簲]%s ", action, response.getStatusCode(), platformGBId ));
+
+		String action = platformRegisterInfo.isRegister() ? "娉ㄥ唽" : "娉ㄩ攢";
+		logger.info(String.format("[鍥芥爣绾ц仈]%s %S鍝嶅簲,%s ", action, response.getStatusCode(), platformRegisterInfo.getPlatformId() ));
 		ParentPlatform parentPlatform = parentPlatformCatch.getParentPlatform();
 		if (parentPlatform == null) {
-			logger.warn(String.format("鏀跺埌 %s %s鐨�%S璇锋眰, 浣嗘槸骞冲彴淇℃伅鏈煡璇㈠埌!!!", platformGBId, action, response.getStatusCode()));
+			logger.warn(String.format("[鍥芥爣绾ц仈]鏀跺埌 %s %s鐨�%S璇锋眰, 浣嗘槸骞冲彴淇℃伅鏈煡璇㈠埌!!!", platformRegisterInfo.getPlatformId(), action, response.getStatusCode()));
 			return;
 		}
 
-		if (response.getStatusCode() == 401) {
+		if (response.getStatusCode() == Response.UNAUTHORIZED) {
 			WWWAuthenticateHeader www = (WWWAuthenticateHeader)response.getHeader(WWWAuthenticateHeader.NAME);
-			sipCommanderForPlatform.register(parentPlatform, callId, www, null, null, true);
-		}else if (response.getStatusCode() == 200){
-			// 娉ㄥ唽/娉ㄩ攢鎴愬姛
-			logger.info(String.format("%s %s鎴愬姛", platformGBId, action));
+			sipCommanderForPlatform.register(parentPlatform, callId, www, null, null, true, platformRegisterInfo.isRegister());
+		}else if (response.getStatusCode() == Response.OK){
+
+			if (platformRegisterInfo.isRegister()) {
+				platformService.online(parentPlatform);
+			}else {
+				platformService.offline(parentPlatform);
+			}
+
+			// 娉ㄥ唽/娉ㄩ攢鎴愬姛绉婚櫎缂撳瓨鐨勪俊鎭�
 			redisCatchStorage.delPlatformRegisterInfo(callId);
-			redisCatchStorage.delPlatformCatchInfo(platformGBId);
-			// 鍙栧洖Expires璁剧疆锛岄伩鍏嶆敞閿�杩囩▼涓缃负0
-			ParentPlatform parentPlatformTmp = storager.queryParentPlatByServerGBId(platformGBId);
-			if (parentPlatformTmp != null) {
-				parentPlatformTmp.setStatus("娉ㄥ唽".equals(action));
-				redisCatchStorage.updatePlatformRegister(parentPlatformTmp);
-				redisCatchStorage.updatePlatformKeepalive(parentPlatformTmp);
-				parentPlatformCatch.setParentPlatform(parentPlatformTmp);
-			}
-			redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
-			storager.updateParentPlatformStatus(platformGBId, "娉ㄥ唽".equals(action));
-			if ("娉ㄩ攢".equals(action)) {
-				subscribeHolder.removeCatalogSubscribe(platformGBId);
-				subscribeHolder.removeMobilePositionSubscribe(platformGBId);
-			}
 		}
 	}
 

--
Gitblit v1.8.0