Browse Source

视频接口返回异常会异常

soft5566 2 years ago
parent
commit
67c8c34fcd

+ 30 - 27
src/main/java/com/ch/jiaoxuelou_houtai/controller/VideoController.java

@@ -51,10 +51,11 @@ public class VideoController {
 
 
         String url = baseUrl + "/videoAdmin/login";
         String url = baseUrl + "/videoAdmin/login";
         JSONObject login = videoService.login(url, jsonObject.toString(), headers);
         JSONObject login = videoService.login(url, jsonObject.toString(), headers);
-        Boolean success = login.getBoolean("success");
-        if (success) {
-            // 获取登录成功后的token
-            return login.getJSONObject("data").getString("token");
+        if (login != null) {
+            if (login.getBoolean("success")) {
+                // 获取登录成功后的token
+                return login.getJSONObject("data").getString("token");
+            }
         }
         }
 
 
         return "";
         return "";
@@ -95,33 +96,35 @@ public class VideoController {
         // 调用方法
         // 调用方法
         JSONObject videoList = videoService.getVideoList(url, jsonParams.toString(), headers);
         JSONObject videoList = videoService.getVideoList(url, jsonParams.toString(), headers);
         JSONArray map = new JSONArray();
         JSONArray map = new JSONArray();
-        if (videoList.getBoolean("success")) {
-            JSONArray jsonArray = new JSONArray();
-            String tempRoom = null;
-            // 从JSONObject中提取"data"数组
-            JSONArray dataArray = videoList.getJSONArray("data");
-            // 遍历"data"数组并提取每个对象的数据
-            for (int i = 0; i < dataArray.size(); i++) {
-                JSONObject dataObject = dataArray.getJSONObject(i);
-                // 提取具体的数据字段:教室摄像头名称,比如A101前要获取A101
-                String room = dataObject.getString("installationSite").substring(0, 4);
-                // 为了达到同一个教室放一组,有的摄像头会离线,会存在教室单个摄像头在线,如果单个摄像头在线就过滤掉
-                if (jsonArray.size() == 0) {
-                    jsonArray.add(dataObject);
-                    tempRoom = room;
-                } else if (jsonArray.size() == 1) {
-                    if (tempRoom != null && tempRoom.equals(room)) {
+        if (videoList != null) {
+            if (videoList.getBoolean("success")) {
+                JSONArray jsonArray = new JSONArray();
+                String tempRoom = null;
+                // 从JSONObject中提取"data"数组
+                JSONArray dataArray = videoList.getJSONArray("data");
+                // 遍历"data"数组并提取每个对象的数据
+                for (int i = 0; i < dataArray.size(); i++) {
+                    JSONObject dataObject = dataArray.getJSONObject(i);
+                    // 提取具体的数据字段:教室摄像头名称,比如A101前要获取A101
+                    String room = dataObject.getString("installationSite").substring(0, 4);
+                    // 为了达到同一个教室放一组,有的摄像头会离线,会存在教室单个摄像头在线,如果单个摄像头在线就过滤掉
+                    if (jsonArray.size() == 0) {
                         jsonArray.add(dataObject);
                         jsonArray.add(dataObject);
-                    } else {
+                        tempRoom = room;
+                    } else if (jsonArray.size() == 1) {
+                        if (tempRoom != null && tempRoom.equals(room)) {
+                            jsonArray.add(dataObject);
+                        } else {
+                            jsonArray.clear();
+                        }
+                    }
+                    // 满足2个就不过滤
+                    if (jsonArray.size() == 2) {
+                        String item = "{\"room\":\"" + room + "\",\"arr\":" + JSON.parseObject(jsonArray.toString(), JSONArray.class) + "}";
+                        map.add(JSON.parseObject(item, JSONObject.class));
                         jsonArray.clear();
                         jsonArray.clear();
                     }
                     }
                 }
                 }
-                // 满足2个就不过滤
-                if (jsonArray.size() == 2) {
-                    String item = "{\"room\":\"" + room + "\",\"arr\":" + JSON.parseObject(jsonArray.toString(), JSONArray.class) + "}";
-                    map.add(JSON.parseObject(item, JSONObject.class));
-                    jsonArray.clear();
-                }
             }
             }
         }
         }
 
 

+ 4 - 0
src/main/resources/application.yml

@@ -4,6 +4,10 @@ server:
     session:
     session:
       timeout: 1440m
       timeout: 1440m
   port: 8088
   port: 8088
+  tomcat:
+    uri-encoding: UTF-8
+    max-threads: 1000
+    max-http-header-size: 102400
 
 
 spring:
 spring:
   datasource:
   datasource: