将influxDB的数据库名配置调整为配置文件

This commit is contained in:
2022-10-08 12:50:20 +08:00
parent ab8e86f257
commit 5ba00aca0a
18 changed files with 135 additions and 79 deletions

View File

@@ -1,4 +1,5 @@
import com.njcn.executor.pojo.vo.DataFlicker;
import com.njcn.influxdb.config.InfluxDbConfig;
import com.njcn.influxdb.utils.InfluxDbUtils;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
@@ -11,6 +12,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
@@ -24,14 +26,15 @@ import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
* @version 1.0.0
* @createTime 2022/7/4 19:04
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Test1.class)
public class Test1 {
public class Test1 extends BaseJunitTest{
@Resource
private InfluxDbConfig influxDbConfig;
@Test
public void testMethod(){
InfluxDbUtils influxDBUtil = new InfluxDbUtils("admin", "njcnpqs", "http://192.168.1.18:8086", "PQSBASE", "");
SelectQueryImpl selectQuery = select().from("PQSBASE","data_flicker").where(eq("fluc",0)).limit(1).tz("Asia/Shanghai");
InfluxDbUtils influxDBUtil = new InfluxDbUtils(influxDbConfig.getUserName(), influxDbConfig.getPassword(), influxDbConfig.getInfluxDBUrl(), influxDbConfig.getDatabase(), "");
SelectQueryImpl selectQuery = select().from(influxDbConfig.getDatabase(),"data_flicker").where(eq("fluc",0)).limit(1).tz("Asia/Shanghai");
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
QueryResult queryResult = influxDBUtil.query(selectQuery.getCommand());
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();