|
|
@@ -51,10 +51,11 @@ public class VideoController {
|
|
|
|
|
|
String url = baseUrl + "/videoAdmin/login";
|
|
|
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 "";
|
|
|
@@ -95,33 +96,35 @@ public class VideoController {
|
|
|
// 调用方法
|
|
|
JSONObject videoList = videoService.getVideoList(url, jsonParams.toString(), headers);
|
|
|
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);
|
|
|
- } 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();
|
|
|
}
|
|
|
}
|
|
|
- // 满足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();
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|