|
@@ -13,7 +13,16 @@ import com.saga.entity.Record;
|
|
|
import com.sagacloud.json.JSONArray;
|
|
|
import com.sagacloud.json.JSONObject;
|
|
|
|
|
|
+
|
|
|
+ * HBase工具
|
|
|
+ *
|
|
|
+ * @author 李井强
|
|
|
+ */
|
|
|
public class HBaseUtil {
|
|
|
+
|
|
|
+
|
|
|
+ * 加载状态-物理结构
|
|
|
+ */
|
|
|
public static Map<String, String> ps_physical_status(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -50,6 +59,9 @@ public class HBaseUtil {
|
|
|
return dbPhysicalStatus;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载状态-点位
|
|
|
+ */
|
|
|
public static Map<String, String> ps_virtual_point_status(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -87,6 +99,9 @@ public class HBaseUtil {
|
|
|
return dbPointStatus;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载状态-meter
|
|
|
+ */
|
|
|
public static Map<String, String> ps_virtual_meter_status(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -123,6 +138,9 @@ public class HBaseUtil {
|
|
|
return dbMeterStatus;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载状态-project
|
|
|
+ */
|
|
|
public static Map<String, String> ps_virtual_project_status(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -154,6 +172,9 @@ public class HBaseUtil {
|
|
|
return dbProjectStatus;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载配置点表
|
|
|
+ */
|
|
|
public static void LoadDB2Cache_dy_pointlist(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -247,6 +268,9 @@ public class HBaseUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 记录状态
|
|
|
+ */
|
|
|
private static void checkStatus(String project, String meter, long funcid, String address_1, String address_2,
|
|
|
String address_3, String address_4) {
|
|
|
|
|
@@ -277,6 +301,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载状态-物理结构
|
|
|
+ */
|
|
|
public static void LoadDB2Cache_ps_physical_status(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -314,6 +341,9 @@ public class HBaseUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载状态-point
|
|
|
+ */
|
|
|
public static void LoadDB2Cache_ps_virtual_point_status(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -353,6 +383,9 @@ public class HBaseUtil {
|
|
|
LogUtil.info(Constant.agent.getFull_name() + " Reload :" + " ps_virtual_point_status End...");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载状态-meter
|
|
|
+ */
|
|
|
public static void LoadDB2Cache_ps_virtual_meter_status(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -389,6 +422,9 @@ public class HBaseUtil {
|
|
|
LogUtil.info(Constant.agent.getFull_name() + " Reload :" + " ps_virtual_meter_status End...");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载状态-project
|
|
|
+ */
|
|
|
public static void LoadDB2Cache_ps_virtual_project_status(String db, String tb) throws Exception {
|
|
|
|
|
|
|
|
@@ -493,6 +529,9 @@ public class HBaseUtil {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ * 加载状态-配置点表
|
|
|
+ */
|
|
|
public static Map<String, List<Integer>> GetDBPointList(String db, String tb, String building) throws Exception {
|
|
|
|
|
|
Map<String, List<Integer>> dbPointList = new HashMap<String, List<Integer>>();
|
|
@@ -524,6 +563,9 @@ public class HBaseUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载指令列表
|
|
|
+ */
|
|
|
public static void Getset(String db, String tb, String building, String meter, long funcid, String query_from,
|
|
|
String query_to) throws Exception {
|
|
|
|
|
@@ -561,6 +603,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 加载当前指令
|
|
|
+ */
|
|
|
public static void Getset_present(String db, String tb, String building, String meter, long funcid)
|
|
|
throws Exception {
|
|
|
|
|
@@ -659,6 +704,9 @@ public class HBaseUtil {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ * 生成json
|
|
|
+ */
|
|
|
public static JSONObject CreateJSON(String Name, String Type) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("Name", Name);
|
|
@@ -666,11 +714,17 @@ public class HBaseUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建库
|
|
|
+ */
|
|
|
public static void CreateDB(String DB) throws Exception {
|
|
|
LogUtil.info(Constant.agent.getFull_name() + " CreateDB:" + DB);
|
|
|
Constant.agent.NDL_AddDatabase(DB);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 判断表是否存在
|
|
|
+ */
|
|
|
public static boolean tableExist(String DBName, String tableName) throws Exception {
|
|
|
JSONObject wrapperObject = new JSONObject();
|
|
|
wrapperObject.put("QueryType", "table_list");
|
|
@@ -687,6 +741,9 @@ public class HBaseUtil {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-monthdata
|
|
|
+ */
|
|
|
public static void CreateTable(String DB, String tableName) throws Exception {
|
|
|
if (!tableExist(DB, tableName)) {
|
|
|
JSONArray Columns = new JSONArray();
|
|
@@ -711,6 +768,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-detail
|
|
|
+ */
|
|
|
public static void CreateTable_detail(String DB, String tableName) throws Exception {
|
|
|
if (!tableExist(DB, tableName)) {
|
|
|
JSONArray Columns = new JSONArray();
|
|
@@ -735,6 +795,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-upload
|
|
|
+ */
|
|
|
public static void CreateTable_upload(String DB, List<String> uploadList) throws Exception {
|
|
|
for (String tableName : uploadList) {
|
|
|
if (!tableExist(DB, tableName)) {
|
|
@@ -759,6 +822,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-present
|
|
|
+ */
|
|
|
public static void CreateTable_present(String DB, String tableName) throws Exception {
|
|
|
if (!tableExist(DB, tableName)) {
|
|
|
|
|
@@ -781,6 +847,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-指令记录
|
|
|
+ */
|
|
|
public static void CreateTable_set(String DB, String tableName) throws Exception {
|
|
|
if (!tableExist(DB, tableName)) {
|
|
|
|
|
@@ -805,6 +874,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-当前指令
|
|
|
+ */
|
|
|
public static void CreateTable_setpresent(String DB, String tableName) throws Exception {
|
|
|
if (!tableExist(DB, tableName)) {
|
|
|
|
|
@@ -876,6 +948,9 @@ public class HBaseUtil {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ * 建表-fjd_0_buildingcomputetime
|
|
|
+ */
|
|
|
public static void CreateTable_fjd_0_buildingcomputetime(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -899,6 +974,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-dy_pointlist
|
|
|
+ */
|
|
|
public static void CreateTable_dy_pointlist(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -959,6 +1037,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-physical_status
|
|
|
+ */
|
|
|
public static void CreateTable_ps_physical_status(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -998,6 +1079,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-physical_log
|
|
|
+ */
|
|
|
public static void CreateTable_ps_physical_log(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -1037,6 +1121,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-ps_virtual_point_status
|
|
|
+ */
|
|
|
public static void CreateTable_ps_virtual_point_status(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -1073,6 +1160,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-ps_virtual_point_log
|
|
|
+ */
|
|
|
public static void CreateTable_ps_virtual_point_log(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -1120,6 +1210,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-ps_virtual_meter_status
|
|
|
+ */
|
|
|
public static void CreateTable_ps_virtual_meter_status(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -1153,6 +1246,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-ps_virtual_meter_log
|
|
|
+ */
|
|
|
public static void CreateTable_ps_virtual_meter_log(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -1186,6 +1282,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-ps_virtual_project_status
|
|
|
+ */
|
|
|
public static void CreateTable_ps_virtual_project_status(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -1213,6 +1312,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 建表-ps_virtual_project_log
|
|
|
+ */
|
|
|
public static void CreateTable_ps_virtual_project_log(String DB, String tableName) throws Exception {
|
|
|
|
|
|
|
|
@@ -1550,6 +1652,9 @@ public class HBaseUtil {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ * 写fjd_0_buildingcomputetime
|
|
|
+ */
|
|
|
public static void Insert_fjd_0_buildingcomputetime(String DB, String building, String compute_time,
|
|
|
String first_compute_time) throws Exception {
|
|
|
|
|
@@ -1587,6 +1692,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写dy_pointlist
|
|
|
+ */
|
|
|
public static void Insert_dy_pointlist(String DB, String building, String meter, long funcid, String system,
|
|
|
String source, String address_1, String ip_port, String address_2, String address_3, String address_4,
|
|
|
String collect_cycle, String data_type, String unit) throws Exception {
|
|
@@ -1651,6 +1759,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 判断地址是否为空
|
|
|
+ */
|
|
|
private static boolean addressNull(String address_1, String address_2, String address_3, String address_4) {
|
|
|
|
|
|
if ("null".equalsIgnoreCase(address_1) || "null".equalsIgnoreCase(address_2)
|
|
@@ -1660,6 +1771,9 @@ public class HBaseUtil {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写ps_physical_status
|
|
|
+ */
|
|
|
public static void Insert_ps_physical_status(String DB, String project, String address_1, String address_2,
|
|
|
String address_3, String address_4, String status, String receivetime, String detail) throws Exception {
|
|
|
|
|
@@ -1711,6 +1825,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写ps_physical_log
|
|
|
+ */
|
|
|
public static void Insert_ps_physical_log(String DB, String project, String address_1, String address_2,
|
|
|
String address_3, String address_4, String receivetime, String function) throws Exception {
|
|
|
|
|
@@ -1759,6 +1876,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写ps_virtual_point_status
|
|
|
+ */
|
|
|
public static void Insert_ps_virtual_point_status(String DB, String project, String meter, long funcid,
|
|
|
String updown, String status, String receivetime, String detail) throws Exception {
|
|
|
|
|
@@ -1806,6 +1926,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写ps_virtual_point_log
|
|
|
+ */
|
|
|
public static void Insert_ps_virtual_point_log(String DB, String project, String meter, long funcid, String updown,
|
|
|
String receivetime, long seq, String function, String feedback) throws Exception {
|
|
|
|
|
@@ -1860,6 +1983,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写ps_virtual_meter_status
|
|
|
+ */
|
|
|
public static void Insert_ps_virtual_meter_status(String DB, String project, String meter, String updown,
|
|
|
String status, String receivetime, String detail) throws Exception {
|
|
|
|
|
@@ -1905,6 +2031,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写ps_virtual_meter_log
|
|
|
+ */
|
|
|
public static void Insert_ps_virtual_meter_log(String DB, String project, String meter, String updown,
|
|
|
String receivetime, String function) throws Exception {
|
|
|
|
|
@@ -1946,6 +2075,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写ps_virtual_project_status
|
|
|
+ */
|
|
|
public static void Insert_ps_virtual_project_status(String DB, String project, String status, String receivetime,
|
|
|
String detail) throws Exception {
|
|
|
|
|
@@ -1987,6 +2119,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写ps_virtual_project_log
|
|
|
+ */
|
|
|
public static void Insert_ps_virtual_project_log(String DB, String project, String receivetime, String function)
|
|
|
throws Exception {
|
|
|
|
|
@@ -2073,6 +2208,9 @@ public class HBaseUtil {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ * 写数据
|
|
|
+ */
|
|
|
public static void BatchInsert(String DB, List<Record> dataList) throws Exception {
|
|
|
JSONArray InsertObjects = new JSONArray();
|
|
|
JSONArray InsertLogObjects = new JSONArray();
|
|
@@ -2150,6 +2288,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写指令记录-sent
|
|
|
+ */
|
|
|
public static void BatchInsert_Set1(String DB, PointSet ps) throws Exception {
|
|
|
JSONArray InsertObjects = new JSONArray();
|
|
|
try {
|
|
@@ -2197,6 +2338,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写指令记录-其他状态
|
|
|
+ */
|
|
|
public static void BatchInsert_Set2(String DB, PointSet ps) throws Exception {
|
|
|
JSONArray InsertObjects = new JSONArray();
|
|
|
try {
|
|
@@ -2245,6 +2389,9 @@ public class HBaseUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 写指令记录-timeout
|
|
|
+ */
|
|
|
public static void BatchInsert_Set3(String DB, PointSet ps) throws Exception {
|
|
|
JSONArray InsertObjects = new JSONArray();
|
|
|
try {
|