代码调整
This commit is contained in:
@@ -26,15 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@AllArgsConstructor
|
||||
public class InfluxDbTest {
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void insert() {
|
||||
InfluxDbUtils influxDbUtils = new InfluxDbUtils("admin", "123456", "http://192.168.1.16:8086", "pqsbase_zl", "");
|
||||
List<String> records = new ArrayList<>();
|
||||
List<String> phasic = Arrays.asList("A","B","C");
|
||||
@@ -44,13 +36,13 @@ public class InfluxDbTest {
|
||||
for (String item2 : dataType) {
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
tags.put("line_id","4");
|
||||
tags.put("line_id","7f6753c721dbf1ce37117073eddf2215");
|
||||
tags.put("phasic_type",item1);
|
||||
tags.put("value_type",item2);
|
||||
fields.put("W",new Random().nextDouble());
|
||||
fields.put("PhV",new Random().nextDouble());
|
||||
Point point = influxDbUtils.pointBuilder("pqd_data", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName ()).tag(InfluxDBPublicParam.LINE_ID, "4").tag(InfluxDBPublicParam.PHASIC_TYPE,item1).tag(InfluxDBPublicParam.VALUE_TYPE,item2).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName ()).tag(InfluxDBPublicParam.LINE_ID, "7f6753c721dbf1ce37117073eddf2215").tag(InfluxDBPublicParam.PHASIC_TYPE,item1).tag(InfluxDBPublicParam.VALUE_TYPE,item2).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
records.add(batchPoints.lineProtocol());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user