代码修改
This commit is contained in:
@@ -61,21 +61,9 @@ public class DataTest {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
InfluxDbUtils influxDBUtil = new InfluxDbUtils("admin", "njcnpqs", "http://192.168.1.18:8086", "PQSBASE", "");
|
||||
String sql = "select * from pqs_eventdetail limit 10";
|
||||
//获取暂降事件
|
||||
QueryResult result = influxDBUtil.query(sql);
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(result, EventDetail.class);
|
||||
String bodyStr = PubUtils.obj2json(eventDetailList.get(0));
|
||||
//对结果进行转换
|
||||
EventDetail o = PubUtils.json2obj(bodyStr, EventDetail.class);
|
||||
Instant timeId = o.getTimeId();
|
||||
System.out.println(timeId);
|
||||
InfluxDbUtils influxDBUtil = new InfluxDbUtils("admin", "123456", "http://192.168.1.18:8086", "pqsbase_sjzx", "");
|
||||
|
||||
|
||||
System.out.println(1);
|
||||
//select(influxDBUtil);
|
||||
insert(influxDBUtil);
|
||||
}
|
||||
|
||||
public static void deleteDB(InfluxDbUtils influxDBUtil) {
|
||||
@@ -85,13 +73,14 @@ public class DataTest {
|
||||
//单条数据插入
|
||||
public static void insert(InfluxDbUtils influxDBUtil) {
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
long time = Long.parseLong("1654239603000");
|
||||
tags.put("dev_id", "6d53a38cc630675dbe7a179c44d9dc3c");
|
||||
long time = Long.parseLong("1675958400000");
|
||||
tags.put("dev_id", "57d121d45a26f3cc1d7b6ba541f895c0");
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
// fields.put("due",1440);
|
||||
// fields.put("real",1200);
|
||||
fields.put("onlinemin", 1123);
|
||||
fields.put("offlinemin", 377);
|
||||
fields.put("online_min", 0);
|
||||
fields.put("offline_min", 1440);
|
||||
fields.put("online_rate", 0.0000);
|
||||
influxDBUtil.insert("pqs_onlinerate", tags, fields, time, TimeUnit.MILLISECONDS);
|
||||
// long time = Long.parseLong("1655135328135");
|
||||
// Map<String, String> tags = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user