Prechádzať zdrojové kódy

增加用于调试的接口

menglu 3 rokov pred
rodič
commit
a7dfff060f

+ 14 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/RestApi.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.persagy.ibms.data.sdk.util.ExportUtil;
@@ -119,6 +120,12 @@ public class RestApi {
 		return result;
 	}
 
+	@GetMapping(path = "/get_sceneJSON")
+	public String get_sceneJSON() {
+		String result = JSONObject.toJSONString(RepositoryContainer.instance.sceneJSON, SerializerFeature.WriteMapNullValue);		
+		return result;
+	}
+
 	@PostMapping(path = { "/post", "/zkt-sdk/post" }, produces = "application/json;charset=UTF-8")
 	public String post(@RequestBody String param, HttpServletRequest request) {
 		String ip = RestUtil.getIp(request);
@@ -138,6 +145,13 @@ public class RestApi {
 		}
 	}
 
+	@PostMapping(path = { "/post_batch", "/zkt-sdk/post_batch" }, produces = "application/json;charset=UTF-8")
+	public String post_batch(@RequestBody String param, HttpServletRequest request) {
+		JSONArray resultObject = RestUtil.post_batch(JSON.parseArray(param));
+		String result = JSONArray.toJSONString(resultObject, SerializerFeature.WriteMapNullValue);
+		return result;
+	}
+
 	@PostMapping(path = { "/wrapper_post", "/zkt-sdk/wrapper_post" }, produces = "application/json;charset=UTF-8")
 	public String wrapper_post(@RequestBody String param, HttpServletRequest request) {
 		JSONObject paramObject = JSON.parseObject(param);

+ 19 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/RestUtil.java

@@ -345,6 +345,25 @@ public class RestUtil {
 		}
 	}
 
+	public static JSONArray post_batch(JSONArray pathArray) {
+		JSONArray batchResult = new JSONArray();
+		for (int i = 0; i < pathArray.size(); i++) {
+			JSONArray path = pathArray.getJSONArray(i);
+			Object one = post(path);
+			batchResult.add(one);
+		}
+		return batchResult;
+	}
+
+	public static Object post(JSONArray path) {
+		String[] valuePath = new String[path.size()];
+		for (int i = 0; i < path.size(); i++) {
+			valuePath[i] = path.getString(i);
+		}
+		Object result = RestUtil.post(valuePath);
+		return result;
+	}
+
 	public static Object post(String param) {
 		JSONArray path = JSON.parseArray(param);
 		String[] valuePath = new String[path.size()];

+ 18 - 2
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/test/CheckTest.java

@@ -3,6 +3,7 @@ package com.persagy.ibms.data.sdk.test;
 import java.io.File;
 import java.util.List;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.persagy.ibms.core.data.SceneObject;
 import com.persagy.ibms.core.data.SceneProperty;
@@ -30,8 +31,23 @@ public class CheckTest {
 
 			log.warn("LoadConfig");
 			SceneObject sceneObject = new SceneObject();
-			JSONObject sceneJSON = FastJsonReaderUtil.Instance().ReadJSONObject(new File(Constant.getLatestPath(Constant.config, false)));
-			FastJsonUtil.Set_JavaObject(sceneJSON, sceneObject);
+			{
+				JSONObject sceneJSON_ori = FastJsonReaderUtil.Instance().ReadJSONObject(new File(Constant.getLatestPath(Constant.config, false)));
+				JSONArray PropertyList_ori = sceneJSON_ori.getJSONArray("PropertyList");
+				JSONObject sceneJSON = new JSONObject();
+				JSONArray PropertyList = new JSONArray();
+				for (int i = 0; i < PropertyList_ori.size(); i++) {
+					JSONObject Property = PropertyList_ori.getJSONObject(i);
+					String PropertyName = Property.getString("PropertyName");
+					if (PropertyName.equals("general_query")) {
+					} else {
+						PropertyList.add(Property);
+					}
+				}
+				sceneJSON.put("PropertyList", PropertyList);
+				FastJsonUtil.Set_JavaObject(sceneJSON, sceneObject);
+				Repository.sceneJSON = sceneJSON;
+			}
 			Repository.sceneObject = sceneObject;
 			ComputeUtil.RefreshRepository(Repository);
 			List<List<SceneProperty>> spListList = ComputeUtil.computePrepare(Repository);

+ 2 - 2
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDRepositoryUtil.java

@@ -89,14 +89,14 @@ public class RWDRepositoryUtil {
 			}
 			sceneJSON.put("PropertyList", PropertyList);
 			FastJsonUtil.Set_JavaObject(sceneJSON, sceneObject);
+			Repository.sceneJSON = sceneJSON;
 		}
 		Repository.sceneObject = sceneObject;
 
 		Repository.property2SDV_enable = true;
 		Repository.property2SDV.clear();
 		ComputeUtil.RefreshRepository(Repository);
-		List<List<SceneProperty>> spListList = ComputeUtil.
-				computePrepare(Repository);
+		List<List<SceneProperty>> spListList = ComputeUtil.computePrepare(Repository);
 		log.warn("computeAll");
 		ComputeUtil.computeAll(Repository, spListList);
 		try {