ソースを参照

报警去掉comment,增加检查功能

menglu 3 年 前
コミット
b13a0230bf

+ 12 - 5
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/RestApi.java

@@ -21,6 +21,7 @@ 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.core.util.CheckUtil;
 import com.persagy.ibms.data.sdk.util.ExportUtil;
 import com.persagy.ibms.data.sdk.util.RWDAlarmUtil;
 import com.persagy.ibms.data.sdk.util.RepositoryContainer;
@@ -78,10 +79,11 @@ public class RestApi {
 		return "alarm_websocket_close";
 	}
 
-	@GetMapping(path = { "/check" }, produces = "application/json;charset=UTF-8")
-	String check() {
-		String result = RestUtil.check();
-		return result;
+	@PostMapping(path = { "/check" }, produces = "application/json;charset=UTF-8")
+	public String check(@RequestBody String param) {
+		JSONObject sceneJSON_ori = JSON.parseObject(param);
+		JSONObject result = CheckUtil.check(sceneJSON_ori);
+		return JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue);
 	}
 
 	@PostMapping(path = { "/desc" }, produces = "application/json;charset=UTF-8")
@@ -120,9 +122,14 @@ public class RestApi {
 		return result;
 	}
 
+	@GetMapping(path = "/get_SDKVersion")
+	public String get_SDKVersion() {
+		return "ibms-sdk";
+	}
+
 	@GetMapping(path = "/get_sceneJSON")
 	public String get_sceneJSON() {
-		String result = JSONObject.toJSONString(RepositoryContainer.instance.sceneJSON, SerializerFeature.WriteMapNullValue);		
+		String result = JSONObject.toJSONString(RepositoryContainer.instance.sceneJSON, SerializerFeature.WriteMapNullValue);
 		return result;
 	}
 

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

@@ -23,7 +23,6 @@ import com.persagy.ibms.core.data.SceneDataObject;
 import com.persagy.ibms.core.data.SceneDataPrimitive;
 import com.persagy.ibms.core.data.SceneDataSet;
 import com.persagy.ibms.core.data.SceneDataValue;
-import com.persagy.ibms.core.data.SceneProperty;
 import com.persagy.ibms.core.util.ComputeUtil;
 import com.persagy.ibms.core.util.ExamineUtil;
 import com.persagy.ibms.core.util.ExceptionItem;
@@ -139,118 +138,6 @@ public class RestUtil {
 		return JSONObject.toJSONString(JSON, SerializerFeature.WriteMapNullValue);
 	}
 
-	public static String check() {
-		RepositoryImpl Repository = RepositoryContainer.instance;
-		for (String key : Repository.objectData.keySet()) {
-			SceneDataValue sdv = Repository.objectData.get(key);
-			SceneProperty rel_sp = null;
-			for (SceneProperty sp : Repository.objectData.rel_object.getPropertyList()) {
-				if (sp.propertyName.equals(key)) {
-					rel_sp = sp;
-					break;
-				}
-			}
-			checkProperty(key, Repository.objectData, key, rel_sp, sdv);
-		}
-		return null;
-	}
-
-	private static void checkProperty(String path, SceneDataObject parentObjectData, String myPropertyName, SceneProperty rel_sp,
-			SceneDataValue sdv) {
-		// log.info("begin checkProperty:" + path);
-		if (parentObjectData != null && myPropertyName != null && sdv.parentObjectData != null && sdv.myPropertyName != null
-				&& parentObjectData.equals(sdv.parentObjectData) && myPropertyName.equals(sdv.myPropertyName)) {
-
-		} else if (parentObjectData == null && myPropertyName == null && sdv.parentObjectData == null && sdv.myPropertyName == null) {
-
-		} else {
-			log.info("checkProperty:a " + path);
-		}
-
-		if (rel_sp != null && sdv.rel_property != null && rel_sp.equals(sdv.rel_property)) {
-
-		} else if (rel_sp == null && sdv.rel_property == null) {
-
-		} else {
-			log.info("checkProperty:b " + path);
-		}
-
-		if (sdv.rel_property != null) {
-			if (sdv.rel_property.propertyValueSchema.equals("JSONObject") && sdv.value_object != null) {
-
-			} else if (sdv.rel_property.propertyValueSchema.equals("JSONArray") && sdv.value_array != null) {
-
-			} else if (!sdv.rel_property.propertyValueSchema.equals("JSONObject") && !sdv.rel_property.propertyValueSchema.equals("JSONArray")
-					&& sdv.value_object == null && sdv.value_array == null) {
-
-			} else {
-				log.info("checkProperty:c " + path);
-			}
-		}
-
-		if (sdv.rel_property != null && !sdv.rel_property.propertyValueType.equals("custom") && !sdv.finish) {
-			log.info("checkProperty:d " + path);
-		}
-
-		if (sdv.rel_property != null) {
-			if (sdv.value_object != null) {
-				checkObject(path, parentObjectData, myPropertyName, null, sdv.value_object);
-			} else if (sdv.value_array != null) {
-				for (int i = 0; i < sdv.value_array.set.size(); i++) {
-					SceneDataObject sdb = sdv.value_array.set.get(i);
-					if (sdb instanceof SceneDataObject) {
-						SceneDataObject sod = (SceneDataObject) sdb;
-						checkObject(path + "[" + i + "]", null, null, sdv, sod);
-					}
-				}
-			}
-		}
-	}
-
-	private static void checkObject(String path, SceneDataObject parentObjectData, String myPropertyName, SceneDataValue parentArrayData,
-			SceneDataObject sdo) {
-		// log.info("begin checkObject:" + path);
-		if (parentObjectData != null && sdo.parentObjectData != null && myPropertyName != null && sdo.myPropertyName != null
-				&& parentArrayData == null && sdo.parentArrayData == null && parentObjectData.equals(sdo.parentObjectData)
-				&& myPropertyName.equals(sdo.myPropertyName)) {
-
-		} else if (parentObjectData == null && sdo.parentObjectData == null && myPropertyName == null && sdo.myPropertyName == null
-				&& parentArrayData != null && sdo.parentArrayData != null && parentArrayData.equals(sdo.parentArrayData)) {
-
-		} else if (parentObjectData == null && sdo.parentObjectData == null && myPropertyName == null && sdo.myPropertyName == null
-				&& parentArrayData == null && sdo.parentArrayData == null) {
-
-		} else {
-			log.info("checkObject:" + path);
-		}
-
-		for (String key : sdo.keySet()) {
-			SceneProperty rel_sp = null;
-			if (sdo.rel_object != null) {
-				for (SceneProperty sp : sdo.rel_object.getPropertyList()) {
-					if (sp.propertyName.equals(key)) {
-						rel_sp = sp;
-						break;
-					}
-				}
-			}
-			if (rel_sp == null) {
-				if (sdo.query_attached != null) {
-					for (SceneProperty sp : sdo.query_attached) {
-						if (sp.propertyName.equals(key)) {
-							rel_sp = sp;
-							break;
-						}
-					}
-				}
-			}
-			if (rel_sp != null) {
-				SceneDataValue sdv = sdo.get(key);
-				checkProperty(path + "." + key, sdo, key, rel_sp, sdv);
-			}
-		}
-	}
-
 	public static String desc(String param) {
 		JSONArray path = JSON.parseArray(param);
 		String[] valuePath = new String[path.size()];

+ 3 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDAlarmUtil.java

@@ -322,6 +322,9 @@ public class RWDAlarmUtil {
 				alarm.put("comments", comments);
 			}
 		}
+		if (alarm.containsKey("comment")) {
+			alarm.remove("comment");
+		}
 
 		if (alarm.containsKey("triggerTime")) {
 			Object object = alarm.get("triggerTime");