提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab; |
H |
2 |
|
4a47e4
|
3 |
import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
H |
4 |
import com.iailab.module.data.influxdb.pojo.InfluxPointValueSimPOJO; |
|
5 |
import com.iailab.module.data.influxdb.service.InfluxDBService; |
|
6 |
import org.junit.jupiter.api.Test; |
|
7 |
|
a6de49
|
8 |
import javax.annotation.Resource; |
H |
9 |
|
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Calendar; |
|
12 |
import java.util.Date; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author PanZhibao |
|
17 |
* @Description |
|
18 |
* @createTime 2023年12月10日 12:19:00 |
|
19 |
*/ |
|
20 |
public class InfluxDBTest { |
|
21 |
|
|
22 |
@Resource |
|
23 |
private InfluxDBService influxDBService; |
|
24 |
|
|
25 |
|
|
26 |
@Test |
|
27 |
public void testWrite() { |
|
28 |
try { |
|
29 |
List<InfluxPointValuePOJO> pointValues = new ArrayList<>(); |
|
30 |
InfluxPointValuePOJO pojo = new InfluxPointValueSimPOJO(); |
|
31 |
pojo.setPoint("88880102030001"); |
|
32 |
pojo.setType("float"); |
|
33 |
pojo.setTimestamp(new Date().toInstant()); |
|
34 |
((InfluxPointValueSimPOJO) pojo).setValue(123d); |
|
35 |
pointValues.add(pojo); |
|
36 |
|
|
37 |
InfluxPointValuePOJO pojo1 = new InfluxPointValueSimPOJO(); |
|
38 |
pojo1.setPoint("88880102030001"); |
|
39 |
pojo1.setType("float"); |
|
40 |
pojo1.setTimestamp(new Date().toInstant()); |
|
41 |
((InfluxPointValueSimPOJO) pojo1).setValue(456d); |
|
42 |
pointValues.add(pojo1); |
|
43 |
|
|
44 |
influxDBService.asyncWritePointValues(pointValues); |
|
45 |
} catch (Exception ex) { |
|
46 |
ex.printStackTrace(); |
|
47 |
} |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
@Test |
|
52 |
public void testQueryPointMaxValue() { |
|
53 |
InfluxPointValuePOJO point = new InfluxPointValuePOJO(); |
|
54 |
point.setType("float"); |
|
55 |
point.setPoint("88880102030001"); |
|
56 |
Calendar calendar = Calendar.getInstance(); |
|
57 |
calendar.add(Calendar.HOUR_OF_DAY, -1); |
|
58 |
|
|
59 |
Object value = influxDBService.queryPointMaxValue(point, calendar.getTime()); |
|
60 |
|
|
61 |
System.out.println("value=" + value); |
|
62 |
|
|
63 |
} |
|
64 |
} |