influxDB测试
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.njcn.common.utils;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Max;
|
||||
@@ -16,7 +16,6 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/5 15:11
|
||||
*/
|
||||
@Validated
|
||||
public class HarmonicTimesUtil {
|
||||
|
||||
/***
|
||||
@@ -27,7 +26,7 @@ public class HarmonicTimesUtil {
|
||||
* @param interval 间隔
|
||||
* @return List<Object>
|
||||
*/
|
||||
public static List<Object> harmonicTimesList(@Min(value = 1) @Max(value = 100) Integer start, @Min(value = 1) @Max(value = 100) Integer end, Integer interval) {
|
||||
public static List<Object> harmonicTimesList(@Min(value = 1) @Max(value = 100) Integer start, @Min(value = 1) @Max(value = 100) Integer end, @Min(value = 1) Integer interval) {
|
||||
List<Object> timesList = new ArrayList<>();
|
||||
for (int i = start; i <= end;i = i+interval) {
|
||||
timesList.add(i);
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user