Browse Source

Merge branch 'master' of http://git.sagacloud.cn/IBMS/ibms-sdk

menglu 3 years ago
parent
commit
0a64a87144

+ 47 - 45
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/RestUtil.java

@@ -732,43 +732,45 @@ public class RestUtil {
 		return result;
 	}
 
-	public static String getAdmUrl(String param) {
+
+	public static String getAdmUrl(String param){
 		JSONObject result = new JSONObject();
-		result.put("status", "success");
-		result.put("statusCode", "0");
-		if (Objects.isNull(param)) {
-			result.put("status", "fail");
-			result.put("msg", "参数不能为空");
-			result.put("statusCode", "250");
+		result.put("status","success");
+		result.put("statusCode","0");
+		if(Objects.isNull(param)){
+			result.put("status","fail");
+			result.put("msg","参数不能为空");
+			result.put("statusCode","250");
 			return result.toJSONString();
 		}
 		try {
-			// 1.解析参数转为JSONObject对像
+			//1.解析参数转为JSONObject对像
 			JSONObject paramObject = JSON.parseObject(param);
-			// 2.组装ADM请求对像
+			//2.组装ADM请求对像
 			JSONObject postJSON = new JSONObject();
-			// "label contain 'Sy440307000395af770eea9646b0b68e80748d596f19'"
+			//"label contain 'Sy440307000395af770eea9646b0b68e80748d596f19'"
 			postJSON.put("filters", paramObject.get("filters"));
-			Map<String, String> head = new HashMap<>();
+			Map<String,String> head = new HashMap<>();
 			head.put("projectId", RepositoryContainer.RepositoryBase.projectId);
-			// 3.发送请求
-			// http://39.102.40.239:28888/labsl/graph/pub/query
-			String post_url = "http://39.102.40.239:28888" + "/labsl/graph/pub/query";
-			String post_result = HttpClientUtil.post(post_url, postJSON.toJSONString(), head);
-			// 4.解析返回结果
+			//3.发送请求
+			//http://39.102.40.239:28888/labsl/graph/pub/query
+			//String post_url ="http://39.102.40.239:28888"+ "/labsl/graph/pub/query";
+			String post_url = Constant.adm_project_url+"/labsl/graph/pub/query";
+			String post_result = HttpClientUtil.post(post_url, postJSON.toJSONString(),head);
+			//4.解析返回结果
 			JSONObject resultJSON = JSON.parseObject(post_result);
-			Map<String, String> map = new HashMap<>();
-			JSONArray content = (JSONArray) resultJSON.get("content");
+			Map<String,String> map = new HashMap<>();
+			JSONArray content = (JSONArray)resultJSON.get("content");
 			JSONObject rd = new JSONObject();
-			if (content == null || content.isEmpty()) {
-				// TODO 如果失败返回失败信息
+			if(content == null || content.isEmpty()){
+				//TODO 如果失败返回失败信息
 				result.put("Result", "failure");
 				result.put("ResultMsg", "暂无数据");
 				result.put("ResultCode", 250);
 				return result.toJSONString();
-			} else {
-				// 有数据返回
-				// http://192.168.0.34:8081/#/Home
+			}else{
+				//有数据返回
+				//http://192.168.0.34:8081/#/Home
 				// ?graphId=cd08520e0e6d4fb4b06ed0b400feb9f0
 				// &id=69f4fc84cf8d4027b02325d2fc6da703
 				// &projectId=Pj4403050019
@@ -776,27 +778,27 @@ public class RestUtil {
 				// &img_baseurl=http://39.102.40.239
 				// &topo_baseurl=http://39.102.40.239:28888
 				JSONObject obj = (JSONObject) content.get(0);
-				map.put("graphId", obj.get("graphId").toString());
-				map.put("id", obj.get("id").toString());
-				map.put("projectId", obj.get("projectId").toString());
-				map.put("serviceUrl", "http://192.168.0.53:8811");
-				map.put("img_baseurl", "http://39.102.40.239");
-				map.put("topo_baseurl", "http://39.102.40.239:28888");
-				rd.put("projectId", obj.get("projectId").toString());
-				rd.put("graphId", obj.get("graphId").toString());
+				map.put("graphId",obj.get("graphId").toString());
+				map.put("id",obj.get("id").toString());
+				map.put("projectId",obj.get("projectId").toString());
+				map.put("serviceUrl","http://192.168.0.53:8811");
+				map.put("img_baseurl","http://39.102.40.239");
+				map.put("topo_baseurl","http://39.102.40.239:28888");
+				rd.put("projectId",obj.get("projectId").toString());
+				rd.put("graphId",obj.get("graphId").toString());
 			}
 
-			// http://192.168.0.34:8081/#/?graphId=740364c0a1c849da948fd07d7ab3c0a8&id=72835645a33c4f70b9a2d6a851e7070c
+			//http://192.168.0.34:8081/#/?graphId=740364c0a1c849da948fd07d7ab3c0a8&id=72835645a33c4f70b9a2d6a851e7070c
 			// &categoryName=%25E4%25B8%25AD%25E5%25A4%25AE%25E4%25BE%259B%25E5%2586%25B7%25E7%25B3%25BB%25E7%25BB%259F%25EF%25BC%2588%25E5%2586%25B7%25E6%25BA%2590%25EF%25BC%2589
 			// &isPub=0&groupCode=&projectId=Pj5001120003
 			String path = "http://192.168.0.34:8081/#/";
-			// 5.组装URL返回对像
+			//5.组装URL返回对像
 
-			rd.put("url", toUrl(path, map));
+			rd.put("url",toUrl(path,map));
 
-			result.put("Content", rd);
-		} catch (Exception e) {
-			log.error("获取图形数据失败", e);
+			result.put("Content",rd);
+		}catch (Exception e){
+			log.error("获取图形数据失败",e);
 			result.put("Result", "failure");
 			String message = LogUtil.GetExceptionStackTrace(e);
 			result.put("ResultMsg", message);
@@ -805,17 +807,17 @@ public class RestUtil {
 		return result.toJSONString();
 	}
 
-	// 组装URL
-	private static String toUrl(String path, Map<String, String> param) {
+	//组装URL
+	private static String toUrl(String path,Map<String,String> param){
 
 		for (Map.Entry<String, String> entry : param.entrySet()) {
-			if (!path.contains("?")) {
-				// 说明地址中已有参数
-				path += "?";
-			} else {
-				path += "&";
+			if(!path.contains("?")){
+				path +="?";
+			}else{
+                //说明地址中已有参数?
+				path +="&";
 			}
-			path += entry.getKey() + "=" + entry.getValue();
+			path += entry.getKey()+"="+entry.getValue();
 		}
 		return path;
 	}

+ 8 - 1
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/Constant.java

@@ -43,6 +43,8 @@ public class Constant {
 	public static String alarm_rest_url;
 	public static boolean alarm_rest_get;
 
+	public static String adm_project_url;
+
 	public static Map<String, Boolean> objType_hasRelation = new HashMap<String, Boolean>();
 	public static List<ConfigRelation> ConfigRelationList = new ArrayList<ConfigRelation>();
 	public static Map<String, Boolean> keyWordMap = new HashMap<String, Boolean>();
@@ -140,7 +142,12 @@ public class Constant {
 					iot_project_url = element.attribute("url").getValue();
 					iot_project_url = StrUtil.removeSuffix(iot_project_url, "/");
 				}
-
+				iter = document.selectNodes("/root/adm_project").iterator();
+				if (iter.hasNext()) {
+					element = (Element) iter.next();
+					adm_project_url = element.attribute("url").getValue();
+					adm_project_url = StrUtil.removeSuffix(adm_project_url, "/");
+				}
 				iter = document.selectNodes("/root/alarm").iterator();
 				if (iter.hasNext()) {
 					element = (Element) iter.next();

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

@@ -95,7 +95,8 @@ public class RWDRepositoryUtil {
 		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 {

+ 2 - 0
ibms-data-sdk/src/main/resources/config.xml

@@ -21,6 +21,8 @@
 	<!-- iot-project的服务地址 -->
 	<!-- <iot_project url="http://192.168.0.30:8862/" /> -->
 	<iot_project url="http://192.168.100.33:9909/iot-project/" />
+	<!-- adm-project的服务地址 -->
+	<adm_project url="http://39.102.40.239:28888/" />
 	<!-- 报警的websocket地址和服务地址 -->
 	<!--
 	<alarm enable="true" websocket="ws://192.168.100.33:9909/webSocketServer" rest="http://192.168.100.33:9909/zkt-alarm/" rest_get="false" />