|
@@ -0,0 +1,42 @@
|
|
|
+package com.persagy.ibms.data.sdk.util;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.persagy.ibms.core.data.SceneDataObject;
|
|
|
+import com.persagy.ibms.core.data.SceneDataSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+public class NearestCameraUtil {
|
|
|
+ public static JSONArray NearestCamera(String objectId) throws Exception {
|
|
|
+ RepositoryImpl Repository = RepositoryContainer.instance;
|
|
|
+ String groupCode = RepositoryContainer.RepositoryProject.groupCode;
|
|
|
+ String projectId = RepositoryContainer.RepositoryProject.projectId;
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("userId", "0");
|
|
|
+ param.put("appId", "0");
|
|
|
+ param.put("groupCode", groupCode);
|
|
|
+ param.put("projectId", projectId);
|
|
|
+ param.put("objectId", objectId);
|
|
|
+ String post_result = HttpClientUtil.post(Constant.zkt_monitor_url + "/camera/nearest/v2", param.toJSONString());
|
|
|
+ JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
+ List<JSONObject> content = (List<JSONObject>) resultJSON.get("Content");
|
|
|
+ SceneDataSet arr = Repository.ZKTObjectArrayDic.get("spjk").get("shexiangtou").value_array;
|
|
|
+ JSONArray cameraArray = new JSONArray();
|
|
|
+ for (JSONObject obj : content) {
|
|
|
+ String objId = obj.get("id").toString();
|
|
|
+ SceneDataObject obj2= arr.set.stream().filter(item->item.get("id").value_prim.value.equals(objId)).findFirst().get();
|
|
|
+ cameraArray.add(obj2.toJSON(1));
|
|
|
+// for (SceneDataObject data : arr.set) {
|
|
|
+// Object itemId = data.get("id").value_prim.value;
|
|
|
+// if (objId.equals(itemId)) {
|
|
|
+// cameraArray.add(data.toJSON(1));
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+ return cameraArray;
|
|
|
+ }
|
|
|
+}
|