|
@@ -1,8 +1,12 @@
|
|
|
package com.saga.util;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Map.Entry;
|
|
|
|
|
|
import org.zillion.util.log.LogUtil;
|
|
|
|
|
@@ -76,6 +80,36 @@ public class HBaseUtil {
|
|
|
LogUtil.info("Reload Project:" + project + " PointStatus End...");
|
|
|
}
|
|
|
|
|
|
+ public static Map<String, List<Integer>> GetDBPointList(ZillionAgent agent, String db, String tb, String building)
|
|
|
+ throws Exception {
|
|
|
+
|
|
|
+ Map<String, List<Integer>> dbPointList = new HashMap<String, List<Integer>>();
|
|
|
+ JSONObject Criteria = new JSONObject();
|
|
|
+ Criteria.put("building", building);
|
|
|
+
|
|
|
+ JSONObject wrapperObject = new JSONObject();
|
|
|
+ wrapperObject.put("QueryType", "select");
|
|
|
+ wrapperObject.put("Database", db);
|
|
|
+ wrapperObject.put("Datatable", tb);
|
|
|
+ wrapperObject.put("Criteria", Criteria);
|
|
|
+ JSONObject queryResult = agent.Query(wrapperObject);
|
|
|
+ JSONArray resultContent = (JSONArray) queryResult.get("Content");
|
|
|
+
|
|
|
+ for (int i = 0; i < resultContent.size(); i++) {
|
|
|
+ JSONObject dataItem = (JSONObject) resultContent.get(i);
|
|
|
+
|
|
|
+ String meter = (String) dataItem.get("meter");
|
|
|
+ Integer funcid = (Integer) dataItem.get("funcid");
|
|
|
+ if (!dbPointList.containsKey(meter)) {
|
|
|
+ dbPointList.put(meter, new ArrayList<Integer>());
|
|
|
+ }
|
|
|
+ dbPointList.get(meter).add(funcid);
|
|
|
+
|
|
|
+ }
|
|
|
+ return dbPointList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public static void Getset(ZillionAgent agent, String db, String tb, String building, String meter, long funcid,
|
|
|
String query_from, String query_to) throws Exception {
|
|
|
|
|
@@ -567,6 +601,32 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static void InsertDBPointList(ZillionAgent agent, String DB, String building, String meter,
|
|
|
+ Map<Integer, String> funcidList) throws Exception {
|
|
|
+ JSONArray InsertObjects = new JSONArray();
|
|
|
+ for (Entry<Integer, String> f : funcidList.entrySet()) {
|
|
|
+ JSONObject InsertObject = new JSONObject();
|
|
|
+ InsertObject.put("building", building);
|
|
|
+ InsertObject.put("meter", meter);
|
|
|
+ InsertObject.put("funcid", (long) f.getKey());
|
|
|
+ InsertObject.put("data_type", f.getValue());
|
|
|
+ InsertObject.put("collect_cycle", "15min");
|
|
|
+ InsertObjects.add(InsertObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (InsertObjects.size() > 0) {
|
|
|
+
|
|
|
+ JSONObject wrapperObject = new JSONObject();
|
|
|
+ wrapperObject = new JSONObject();
|
|
|
+ wrapperObject.put("QueryType", "batch_insert");
|
|
|
+ wrapperObject.put("Database", DB);
|
|
|
+ wrapperObject.put("Datatable", "dy_pointlist");
|
|
|
+ wrapperObject.put("InsertObjects", InsertObjects);
|
|
|
+ LogUtil.info("InsertDBPointList" + wrapperObject);
|
|
|
+ agent.Query(wrapperObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void InsertPointInfo(ZillionAgent agent, String DB, String project, String node, String point,
|
|
|
String BusNo, String site) throws Exception {
|
|
|
|