From 9fcfc2da51b6cb89415566384a76143900f61b05 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 30 八月 2023 08:52:36 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/utils/NyHttpUtils.java |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/NyHttpUtils.java b/src/main/java/com/zy/common/utils/NyHttpUtils.java
index 12d8c2c..a049062 100644
--- a/src/main/java/com/zy/common/utils/NyHttpUtils.java
+++ b/src/main/java/com/zy/common/utils/NyHttpUtils.java
@@ -5,6 +5,7 @@
 import com.zy.common.model.NavigateNode;
 import com.zy.core.model.command.NyShuttleHttpCommand;
 import com.zy.core.model.protocol.NyShuttleProtocol;
+import springfox.documentation.spring.web.json.Json;
 
 import java.io.*;
 import java.net.Socket;
@@ -303,14 +304,27 @@
                 }
             } while (response != null);
 //            System.out.println("Received response from server: " + sb);
-             return JSON.parseObject(sb.toString());
+
+            JSONObject result = JSON.parseObject(sb.toString());//寰楀埌鍝嶅簲缁撴灉闆�
+            if (!result.get("msgType").equals("responseMsg")) {//涓嶆槸鍝嶅簲鍐呭
+                return null;
+            }
+
+            JSONObject resultResponse = JSON.parseObject(result.get("response").toString());
+            JSONObject resultHeader = JSON.parseObject(resultResponse.get("header").toString());
+            int responseId = Integer.parseInt(resultHeader.get("responseId").toString());
+            if (responseId != httpCommand.getRequest().getHeader().getRequestId()) {
+                return null;//鍝嶅簲ID涓庤姹侷D涓嶄竴鑷�
+            }
+
+            return filterBodyData(result);//杩斿洖Body缁撴灉闆�
         } catch (Exception e) {
             e.printStackTrace();
         }
         return null;
     }
 
-    public static JSONObject filterData(JSONObject data) {
+    public static JSONObject filterBodyData(JSONObject data) {
         Object response = data.get("response");
         if (response == null) {
             return null;

--
Gitblit v1.9.1