谐波频谱查询Influxdb分钟数据修改成查询mysql统计数据
This commit is contained in:
@@ -15,6 +15,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -32,6 +33,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static java.lang.Integer.parseInt;
|
import static java.lang.Integer.parseInt;
|
||||||
|
|
||||||
@@ -281,6 +283,30 @@ public class PubUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于获取对象中,前缀一样,后缀为2~50的属性值
|
||||||
|
*
|
||||||
|
* @param methodPrefix 方法前缀
|
||||||
|
* @param number 方法后缀
|
||||||
|
* @return 对象属性值
|
||||||
|
*/
|
||||||
|
public static Double getValueByMethodDouble(List data ,Class clazz, String methodPrefix, Integer number) {
|
||||||
|
try {
|
||||||
|
Method method = clazz.getMethod(methodPrefix + number);
|
||||||
|
OptionalDouble average = data.stream().mapToDouble(temp -> {
|
||||||
|
try {
|
||||||
|
return (Double) method.invoke(temp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BusinessException(CommonResponseEnum.REFLECT_METHOD_EXCEPTION);
|
||||||
|
}
|
||||||
|
}).average();
|
||||||
|
return average.orElse(0.0);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BusinessException(CommonResponseEnum.REFLECT_METHOD_EXCEPTION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<String> getStartTimeEndTime(String beginDate, String endDate) throws Exception {
|
public static List<String> getStartTimeEndTime(String beginDate, String endDate) throws Exception {
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
package com.njcn.harmonic.service.impl;
|
package com.njcn.harmonic.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||||
|
import com.njcn.harmonic.common.mapper.RStatDataHarmRateVDMapper;
|
||||||
|
import com.njcn.harmonic.common.mapper.RStatDataIDMapper;
|
||||||
import com.njcn.harmonic.constant.Param;
|
import com.njcn.harmonic.constant.Param;
|
||||||
|
import com.njcn.harmonic.mapper.RStatDataHarmRateIDMapper;
|
||||||
import com.njcn.harmonic.pojo.param.HarmInHarmParam;
|
import com.njcn.harmonic.pojo.param.HarmInHarmParam;
|
||||||
|
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateIDPO;
|
||||||
|
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateVDPO;
|
||||||
|
import com.njcn.harmonic.pojo.po.day.RStatDataIDPO;
|
||||||
import com.njcn.harmonic.pojo.vo.HarmInHarmVO;
|
import com.njcn.harmonic.pojo.vo.HarmInHarmVO;
|
||||||
import com.njcn.harmonic.service.HarmInHarmService;
|
import com.njcn.harmonic.service.HarmInHarmService;
|
||||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||||
@@ -21,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -41,7 +50,8 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
|
|||||||
|
|
||||||
private final IDataIService dataIService;
|
private final IDataIService dataIService;
|
||||||
|
|
||||||
|
private final RStatDataHarmRateVDMapper dataHarmRateVDMapper;
|
||||||
|
private final RStatDataIDMapper dataIDMapper;
|
||||||
@Override
|
@Override
|
||||||
public HarmInHarmVO getHarmInHarmData(HarmInHarmParam harmInHarmParam) {
|
public HarmInHarmVO getHarmInHarmData(HarmInHarmParam harmInHarmParam) {
|
||||||
HarmInHarmVO harmInHarmVO = new HarmInHarmVO();
|
HarmInHarmVO harmInHarmVO = new HarmInHarmVO();
|
||||||
@@ -77,33 +87,70 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
|
|||||||
List<Float> floatList = new ArrayList<>();
|
List<Float> floatList = new ArrayList<>();
|
||||||
if (StrUtil.isNotBlank(lineId)) {
|
if (StrUtil.isNotBlank(lineId)) {
|
||||||
if (harmState == 0) {
|
if (harmState == 0) {
|
||||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
|
// InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
|
||||||
influxQueryWrapper.meanSamePrefixAndSuffix("v_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
// influxQueryWrapper.meanSamePrefixAndSuffix("v_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||||
.between(DataHarmRateV::getTime, startTime, endTime)
|
// .between(DataHarmRateV::getTime, startTime, endTime)
|
||||||
.eq(DataHarmRateV::getLineId, lineId)
|
// .eq(DataHarmRateV::getLineId, lineId)
|
||||||
.eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
// .eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||||
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
// .ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||||
DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
|
// DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
|
||||||
if (Objects.nonNull(dataHarmRateV)) {
|
// if (Objects.nonNull(dataHarmRateV)) {
|
||||||
|
// for (int i = 2; i < 51; i++) {
|
||||||
|
// floatList.add(PubUtils.getValueByMethodDouble(dataHarmRateV, "getV", i).floatValue());
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// for (int i = 2; i < 51; i++) {
|
||||||
|
// floatList.add(null);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//转换成查mysql统计数据,分钟数据没有值
|
||||||
|
List<RStatDataHarmrateVDPO> harmV = dataHarmRateVDMapper.selectList(new LambdaQueryWrapper<RStatDataHarmrateVDPO>()
|
||||||
|
.eq(RStatDataHarmrateVDPO::getLineId, lineId)
|
||||||
|
.eq(RStatDataHarmrateVDPO::getValueType,"CP95")
|
||||||
|
.in(RStatDataHarmrateVDPO::getPhaseType, Arrays.asList("A","B","C"))
|
||||||
|
.ge(RStatDataHarmrateVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||||
|
.le(RStatDataHarmrateVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Objects.nonNull(harmV)) {
|
||||||
for (int i = 2; i < 51; i++) {
|
for (int i = 2; i < 51; i++) {
|
||||||
floatList.add(PubUtils.getValueByMethodDouble(dataHarmRateV, "getV", i).floatValue());
|
floatList.add(PubUtils.getValueByMethodDouble(harmV,RStatDataHarmrateVDPO.class, "getV", i).floatValue());
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
for (int i = 2; i < 51; i++) {
|
for (int i = 2; i < 51; i++) {
|
||||||
floatList.add(null);
|
floatList.add(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
// InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||||
influxQueryWrapper.meanSamePrefixAndSuffix("i_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
// influxQueryWrapper.meanSamePrefixAndSuffix("i_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||||
.between(DataHarmRateV::getTime, startTime, endTime)
|
// .between(DataHarmRateV::getTime, startTime, endTime)
|
||||||
.eq(DataHarmRateV::getLineId, lineId)
|
// .eq(DataHarmRateV::getLineId, lineId)
|
||||||
.eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
// .eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||||
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
// .ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||||
DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
|
// DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
|
||||||
if (Objects.nonNull(dataI)) {
|
// if (Objects.nonNull(dataI)) {
|
||||||
|
// for (int i = 2; i < 51; i++) {
|
||||||
|
// floatList.add(PubUtils.getValueByMethodDouble(dataI, "getI", i).floatValue());
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// for (int i = 2; i < 51; i++) {
|
||||||
|
// floatList.add(null);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//转换成查mysql统计数据,分钟数据没有值
|
||||||
|
List<RStatDataIDPO> harmI = dataIDMapper.selectList(new LambdaQueryWrapper<RStatDataIDPO>()
|
||||||
|
.eq(RStatDataIDPO::getLineId, lineId)
|
||||||
|
.eq(RStatDataIDPO::getValueType,"CP95")
|
||||||
|
.in(RStatDataIDPO::getPhaseType, Arrays.asList("A","B","C"))
|
||||||
|
.ge(RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||||
|
.le(RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||||
|
);
|
||||||
|
if (Objects.nonNull(harmI)) {
|
||||||
for (int i = 2; i < 51; i++) {
|
for (int i = 2; i < 51; i++) {
|
||||||
floatList.add(PubUtils.getValueByMethodDouble(dataI, "getI", i).floatValue());
|
floatList.add(PubUtils.getValueByMethodDouble(harmI,RStatDataIDPO.class, "getI", i).floatValue());
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
for (int i = 2; i < 51; i++) {
|
for (int i = 2; i < 51; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user