|
@@ -696,4 +696,94 @@ public class RestUtil {
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 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");
|
|
|
|
+ return result.toJSONString();
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ //1.解析参数转为JSONObject对像
|
|
|
|
+ JSONObject paramObject = JSON.parseObject(param);
|
|
|
|
+ //2.组装ADM请求对像
|
|
|
|
+ JSONObject postJSON = new JSONObject();
|
|
|
|
+ //"label contain 'Sy440307000395af770eea9646b0b68e80748d596f19'"
|
|
|
|
+ postJSON.put("filters", "label contain "+paramObject.get("filters"));
|
|
|
|
+ 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.解析返回结果
|
|
|
|
+ JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
|
+ JSONArray content = (JSONArray)resultJSON.get("content");
|
|
|
|
+ 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
|
|
|
|
+ // ?graphId=cd08520e0e6d4fb4b06ed0b400feb9f0
|
|
|
|
+ // &id=69f4fc84cf8d4027b02325d2fc6da703
|
|
|
|
+ // &projectId=Pj4403050019
|
|
|
|
+ // &serviceUrl=http://192.168.0.53:8811
|
|
|
|
+ // &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");
|
|
|
|
+
|
|
|
|
+ //map.put("isPub","0");
|
|
|
|
+ //map.put("groupCode","");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //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返回对像
|
|
|
|
+ JSONObject rd = new JSONObject();
|
|
|
|
+ rd.put("url",toUrl(path,map));
|
|
|
|
+ rd.put("projectId","");
|
|
|
|
+ rd.put("graphId","");
|
|
|
|
+ result.put("Content",rd);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("获取图形数据失败",e);
|
|
|
|
+ result.put("Result", "failure");
|
|
|
|
+ String message = LogUtil.GetExceptionStackTrace(e);
|
|
|
|
+ result.put("ResultMsg", message);
|
|
|
|
+ result.put("ResultCode", 250);
|
|
|
|
+ }
|
|
|
|
+ return result.toJSONString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //组装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 +="&";
|
|
|
|
+ }
|
|
|
|
+ path += entry.getKey()+"="+entry.getValue();
|
|
|
|
+ }
|
|
|
|
+ return path;
|
|
|
|
+ }
|
|
}
|
|
}
|