influxDB测试

This commit is contained in:
2023-05-10 20:02:15 +08:00
parent ba8c4541f1
commit 2e71088c8d
7 changed files with 94 additions and 11 deletions

View File

@@ -0,0 +1,21 @@
package com.njcn.influx.mapper;
import com.njcn.influx.base.InfluxDbBaseMapper;
import com.njcn.influx.pojo.po.DataV;
import com.njcn.influx.query.InfluxQueryWrapper;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/5/5 14:39
*/
public interface DataVMapper extends InfluxDbBaseMapper<DataV> {
List<DataV> getStatisticsByWraper(InfluxQueryWrapper influxQueryWrapper);
}

View File

@@ -213,12 +213,12 @@ public class DataV{
private String lineId;
@Column(name = "phasic_type")
private String phaseType;
private String phasicType;
@Column(name = "value_type")
private String valueType;
//自定义字段-总计算次数
@Column(name = "all_time")
private Integer allTime;
//@Column(name = "all_time")
//private Integer allTime;
}

View File

@@ -0,0 +1,10 @@
package com.njcn.influx.service;
import com.njcn.influx.pojo.po.DataV;
import java.util.List;
public interface IDataVService {
List<DataV> getDataV(String lineIndex, String startTime, String endTime);
}

View File

@@ -10,6 +10,7 @@ import com.njcn.influx.service.DataFlickerService;
import com.njcn.influx.utils.InfluxDbUtil;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

View File

@@ -0,0 +1,51 @@
package com.njcn.influx.service.impl;
import com.njcn.common.utils.HarmonicTimesUtil;
import com.njcn.influx.mapper.DataVMapper;
import com.njcn.influx.pojo.po.DataV;
import com.njcn.influx.query.InfluxQueryWrapper;
import com.njcn.influx.service.IDataVService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/5/5 14:38
*/
@Service
public class DataVServiceImpl implements IDataVService {
@Resource
private DataVMapper dataVMapper;
@Override
public List<DataV> getDataV(String lineIndex, String startTime, String endTime) {
//最小值
List<DataV> result1 ;
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class);
influxQueryWrapper.minSamePrefixAndSuffix("v_","", HarmonicTimesUtil.harmonicTimesList(1,50,1));
influxQueryWrapper.eq(DataV::getLineId, lineIndex)
.eq(DataV::getValueType, "MIN")
.min(DataV::getFreq)
.min(DataV::getFreqDev)
.min(DataV::getRms)
.min(DataV::getRmsLvr)
.min(DataV::getVNeg)
.min(DataV::getVPos)
.min(DataV::getVThd)
.min(DataV::getVUnbalance)
.min(DataV::getVZero)
.min(DataV::getVlDev)
.min(DataV::getVuDev)
.groupBy(DataV::getLineId,DataV::getPhasicType,DataV::getQualityFlag,DataV::getValueType)
.between(DataV::getTime, startTime, endTime);
result1 = dataVMapper.getStatisticsByWraper(influxQueryWrapper);
System.out.println("result1==:" + result1);
return result1;
}
}

View File

@@ -4,9 +4,11 @@ import com.njcn.influx.mapper.CldStatisticsFlowMapper;
import com.njcn.influx.pojo.po.CldStatisFlow;
import com.njcn.influx.query.InfluxQueryWrapper;
import com.njcn.influx.service.DataFlickerService;
import com.njcn.influx.service.IDataVService;
import lombok.SneakyThrows;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import java.util.List;
@@ -17,21 +19,20 @@ import java.util.List;
*/
public class DemoTest extends BaseJunitTest {
@Autowired
private CldStatisticsFlowMapper cldStatisticsFlowMapper;
@Autowired
private DataFlickerService dataFlickerService;
@Autowired
private IDataVService dataVService;
@SneakyThrows
@Test
public void test() {
dataFlickerService.getDataFlicker("ff2d9674c1f1ecce7f33a5bf17fc4f2d","2023-05-02 00:00:00","2023-05-02 23:59:59");
// dataFlickerService.getDataFlicker("ff2d9674c1f1ecce7f33a5bf17fc4f2d","2023-05-02 00:00:00","2023-05-02 23:59:59");
dataVService.getDataV("ff2d9674c1f1ecce7f33a5bf17fc4f2d","2023-05-02 00:00:00","2023-05-02 23:59:59");
}