|
@@ -36,6 +36,11 @@ public class RestUtil {
|
|
|
Object Content;
|
|
|
try {
|
|
|
JSONObject sql_json = JSON.parseObject(param);
|
|
|
+ List<ExceptionItem> errorList = new ArrayList<ExceptionItem>();
|
|
|
+ ExamineUtil.check_sql(Repository, null, "query", null, false, false, false, sql_json, errorList);
|
|
|
+ if (errorList.size() > 0) {
|
|
|
+ throw new ExceptionWrapper(errorList);
|
|
|
+ }
|
|
|
Integer read_level = (Integer) sql_json.get("read_level");
|
|
|
read_level = read_level == null ? 4 : read_level;
|
|
|
Object queryResult = QueryUtil.query(Repository, null, sql_json, new QueryAssist());
|
|
@@ -697,44 +702,43 @@ 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_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
|
|
@@ -742,27 +746,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);
|
|
@@ -771,17 +775,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;
|
|
|
}
|