谐波频谱查询Influxdb分钟数据修改成查询mysql统计数据

This commit is contained in:
hzj
2026-04-10 13:32:36 +08:00
parent 6d69027e16
commit 46f521c7a7
2 changed files with 92 additions and 19 deletions

View File

@@ -1,12 +1,20 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.date.DateUtil;
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.PubUtils;
import com.njcn.device.pq.api.LineFeignClient;
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.mapper.RStatDataHarmRateIDMapper;
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.service.HarmInHarmService;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
@@ -21,6 +29,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -41,7 +50,8 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
private final IDataIService dataIService;
private final RStatDataHarmRateVDMapper dataHarmRateVDMapper;
private final RStatDataIDMapper dataIDMapper;
@Override
public HarmInHarmVO getHarmInHarmData(HarmInHarmParam harmInHarmParam) {
HarmInHarmVO harmInHarmVO = new HarmInHarmVO();
@@ -77,33 +87,70 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
List<Float> floatList = new ArrayList<>();
if (StrUtil.isNotBlank(lineId)) {
if (harmState == 0) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
influxQueryWrapper.meanSamePrefixAndSuffix("v_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
.between(DataHarmRateV::getTime, startTime, endTime)
.eq(DataHarmRateV::getLineId, lineId)
.eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
if (Objects.nonNull(dataHarmRateV)) {
// InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
// influxQueryWrapper.meanSamePrefixAndSuffix("v_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
// .between(DataHarmRateV::getTime, startTime, endTime)
// .eq(DataHarmRateV::getLineId, lineId)
// .eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
// .ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
// DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
// 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++) {
floatList.add(PubUtils.getValueByMethodDouble(dataHarmRateV, "getV", i).floatValue());
floatList.add(PubUtils.getValueByMethodDouble(harmV,RStatDataHarmrateVDPO.class, "getV", i).floatValue());
}
}else {
for (int i = 2; i < 51; i++) {
floatList.add(null);
}
}
} else {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
influxQueryWrapper.meanSamePrefixAndSuffix("i_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
.between(DataHarmRateV::getTime, startTime, endTime)
.eq(DataHarmRateV::getLineId, lineId)
.eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
if (Objects.nonNull(dataI)) {
// InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
// influxQueryWrapper.meanSamePrefixAndSuffix("i_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
// .between(DataHarmRateV::getTime, startTime, endTime)
// .eq(DataHarmRateV::getLineId, lineId)
// .eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
// .ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
// DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
// 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++) {
floatList.add(PubUtils.getValueByMethodDouble(dataI, "getI", i).floatValue());
floatList.add(PubUtils.getValueByMethodDouble(harmI,RStatDataIDPO.class, "getI", i).floatValue());
}
}else {
for (int i = 2; i < 51; i++) {