|
@@ -581,33 +581,35 @@ public class RestUtil {
|
|
|
if (time_to.getTime() - time_from.getTime() < 1000L * 60 * 60 * 6) {
|
|
|
time_from = new Date(time_from.getTime() - (1000L * 60 * 60 * 12));
|
|
|
}
|
|
|
+ JSONObject parseObject = JSON.parseObject(param);
|
|
|
+ String objId = parseObject.getString("objId");
|
|
|
+ String code = parseObject.getString("code");
|
|
|
+ String pointString = RepositoryBase.info2point.get(objId).get(code);
|
|
|
+ int index_ = pointString.lastIndexOf('-');
|
|
|
+ String meter = pointString.substring(0, index_);
|
|
|
+ int funcid = Integer.parseInt(pointString.substring(index_ + 1));
|
|
|
+ String result = fjd_query_history(meter, funcid, sdf.format(time_from), sdf.format(time_to));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
+ public static String fjd_query_history(String param) {
|
|
|
+ JSONObject parseObject = JSON.parseObject(param);
|
|
|
+ String objId = parseObject.getString("objId");
|
|
|
+ String code = parseObject.getString("code");
|
|
|
+ String pointString = RepositoryBase.info2point.get(objId).get(code);
|
|
|
+ int index_ = pointString.lastIndexOf('-');
|
|
|
+ String meter = pointString.substring(0, index_);
|
|
|
+ int funcid = Integer.parseInt(pointString.substring(index_ + 1));
|
|
|
+ String time_from = parseObject.getString("time_from");
|
|
|
+ String time_to = parseObject.getString("time_to");
|
|
|
+ String result = fjd_query_history(meter, funcid, time_from, time_to);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String fjd_query_history(String meter, int funcid, String time_from, String time_to) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
try {
|
|
|
- JSONObject parseObject = JSON.parseObject(param);
|
|
|
- String objId = parseObject.getString("objId");
|
|
|
- String code = parseObject.getString("code");
|
|
|
- String pointString = RepositoryBase.info2point.get(objId + "-" + code);
|
|
|
- int index_ = pointString.lastIndexOf('-');
|
|
|
- String meter = pointString.substring(0, index_);
|
|
|
- int funcid = Integer.parseInt(pointString.substring(index_ + 1));
|
|
|
- JSONObject pointObject = new JSONObject();
|
|
|
- pointObject.put("meter", meter);
|
|
|
- pointObject.put("funcid", funcid);
|
|
|
- pointObject.put("time_period", "15min");
|
|
|
- pointObject.put("time_from", sdf.format(time_from));
|
|
|
- pointObject.put("time_to", sdf.format(time_to));
|
|
|
- JSONArray points = new JSONArray();
|
|
|
- points.add(pointObject);
|
|
|
- JSONObject postJSON = new JSONObject();
|
|
|
- postJSON.put("building", RepositoryBase.projectId.substring(2));
|
|
|
- postJSON.put("points", points);
|
|
|
- String post_url = Constant.iot_collect_url + "fjd_query_batch_post";
|
|
|
- String post_result = HttpClientUtil.post(post_url, postJSON.toJSONString());
|
|
|
- JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
- JSONArray result_points = (JSONArray) resultJSON.get("points");
|
|
|
- JSONObject result_point = (JSONObject) result_points.get(0);
|
|
|
- JSONArray datas = (JSONArray) result_point.get("datas");
|
|
|
+ JSONArray datas = fjd_query_inner(meter, funcid, time_from, time_to);
|
|
|
result.put("Content", datas);
|
|
|
result.put("Result", "success");
|
|
|
} catch (Exception e) {
|
|
@@ -620,4 +622,48 @@ public class RestUtil {
|
|
|
}
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
+
|
|
|
+ public static String path_array_history_fjd_query(String param) {
|
|
|
+ JSONArray result = new JSONArray();
|
|
|
+ JSONObject parseObject = JSON.parseObject(param);
|
|
|
+ String time_from = parseObject.getString("time_from");
|
|
|
+ String time_to = parseObject.getString("time_to");
|
|
|
+ JSONArray Items = parseObject.getJSONArray("Items");
|
|
|
+ for (int i = 0; i < Items.size(); i++) {
|
|
|
+ JSONObject item = (JSONObject) Items.get(i);
|
|
|
+ JSONObject resultItem = new JSONObject();
|
|
|
+ resultItem.put("name", item.get("name"));
|
|
|
+ resultItem.put("path", item.get("path"));
|
|
|
+ resultItem.put("Content", path_query_inner(time_from, time_to, item));
|
|
|
+ result.add(resultItem);
|
|
|
+ }
|
|
|
+ return result.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static JSONArray path_query_inner(String time_from, String time_to, JSONObject parseObject) {
|
|
|
+ JSONArray result = new JSONArray();
|
|
|
+ // TODO
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static JSONArray fjd_query_inner(String meter, int funcid, String time_from, String time_to) throws Exception {
|
|
|
+ JSONObject pointObject = new JSONObject();
|
|
|
+ pointObject.put("meter", meter);
|
|
|
+ pointObject.put("funcid", funcid);
|
|
|
+ pointObject.put("time_period", "15min");
|
|
|
+ pointObject.put("time_from", time_from);
|
|
|
+ pointObject.put("time_to", time_to);
|
|
|
+ JSONArray points = new JSONArray();
|
|
|
+ points.add(pointObject);
|
|
|
+ JSONObject postJSON = new JSONObject();
|
|
|
+ postJSON.put("building", RepositoryBase.projectId.substring(2));
|
|
|
+ postJSON.put("points", points);
|
|
|
+ String post_url = Constant.iot_collect_url + "fjd_query_batch_post";
|
|
|
+ String post_result = HttpClientUtil.post(post_url, postJSON.toJSONString());
|
|
|
+ JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
+ JSONArray result_points = (JSONArray) resultJSON.get("points");
|
|
|
+ JSONObject result_point = (JSONObject) result_points.get(0);
|
|
|
+ JSONArray datas = (JSONArray) result_point.get("datas");
|
|
|
+ return datas;
|
|
|
+ }
|
|
|
}
|