From 807efbe01d2781a688d2879c71dd1ce9296df520 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期二, 07 一月 2025 16:44:56 +0800 Subject: [PATCH] void insert(List<MmItemResultJsonEntity> resultJsonList); --- iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java | 67 +++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java b/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java new file mode 100644 index 0000000..528b006 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java @@ -0,0 +1,67 @@ +package com.iailab; + +import com.iailab.module.model.common.enums.DataTypeEnum; +import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO; +import com.iailab.module.model.influxdb.pojo.InfluxModelResultSimPOJO; +import com.iailab.module.model.influxdb.service.InfluxDBService; +import com.iailab.module.model.influxdb.vo.InfluxModelResultVO; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月10日 12:19:00 + */ +@SpringBootTest +public class InfluxDBTest { + + @Resource + private InfluxDBService influxDBService; + + + @Test + public void testWrite() { + try { + List<InfluxModelResultPOJO> pointValues = new ArrayList<>(); + InfluxModelResultSimPOJO pojo = new InfluxModelResultSimPOJO(); + pojo.setOutPutId("0001"); + pojo.setType(DataTypeEnum.FLOAT.getCode()); + pojo.setTimestamp(new Date().toInstant()); + pojo.setValue(Double.valueOf(0.001)); + pointValues.add(pojo); + + InfluxModelResultSimPOJO pojo1 = new InfluxModelResultSimPOJO(); + pojo1.setOutPutId("0002"); + pojo1.setType(DataTypeEnum.FLOAT.getCode()); + pojo1.setTimestamp(new Date().toInstant()); + pojo1.setValue(Double.valueOf(0.002)); + pointValues.add(pojo1); + + influxDBService.asyncWriteModelResults(pointValues); + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + + @Test + public void testQuery() { + InfluxModelResultPOJO pojo = new InfluxModelResultPOJO(); + pojo.setType("float"); + pojo.setOutPutId("0001"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -1); + + List<InfluxModelResultVO> influxModelResultVOS = influxDBService.queryModelResults(pojo, calendar.getTime(), Calendar.getInstance().getTime()); + + System.out.println("value=" + influxModelResultVOS); + + } +} -- Gitblit v1.9.3