influx查询数据方式调整

This commit is contained in:
2023-06-08 21:03:32 +08:00
parent 91df5cb181
commit 7e19126891
3 changed files with 34 additions and 15 deletions

View File

@@ -190,6 +190,10 @@ whitelist:
- /*/v2/api-docs - /*/v2/api-docs
- /favicon.ico - /favicon.ico
- /system-boot/theme/getTheme - /system-boot/theme/getTheme
- /cs-harmonic-boot/**
- /cs-device-boot/**
- /cs-system-boot/**
- /cs-warn-boot/**
#- /device-boot/** #- /device-boot/**
#- /system-boot/** #- /system-boot/**

View File

@@ -3,10 +3,7 @@ package com.njcn.influx.pojo.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.njcn.common.utils.serializer.InstantDateSerializer; import com.njcn.common.utils.serializer.InstantDateSerializer;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.influxdb.annotation.Column; import org.influxdb.annotation.Column;
import org.influxdb.annotation.Measurement;
import retrofit2.http.Field;
import java.time.Instant; import java.time.Instant;
@@ -21,13 +18,23 @@ import java.time.Instant;
@Data @Data
public class StatisticalDataDTO { public class StatisticalDataDTO {
@Column(name = "time") @Column(name = "time")
@JsonSerialize(using = InstantDateSerializer.class) @JsonSerialize(using = InstantDateSerializer.class)
private Instant time; private Instant time;
private String LineId;
private String Phase; @Column(name = "line_id")
@Column(name = "Stat_Method") private String lineId;
private String statMethod;
@Column(name = "phasic_type")
private String phaseType;
@Column(name = "value_type")
private String valueType;
private Double value;
private String statisticalName; private String statisticalName;
private Double statisticalData;
} }

View File

@@ -1,5 +1,12 @@
package com.njcn.influx.service.impl; package com.njcn.influx.service.impl;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.PubUtils;
import com.njcn.influx.ano.Select;
import com.njcn.influx.imapper.CommonMapper; import com.njcn.influx.imapper.CommonMapper;
import com.njcn.influx.pojo.dto.StatisticalDataDTO; import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.pojo.po.HarmonicRatioData; import com.njcn.influx.pojo.po.HarmonicRatioData;
@@ -31,7 +38,7 @@ public class CommonServiceImpl implements CommonService {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(aClass,StatisticalDataDTO.class); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(aClass,StatisticalDataDTO.class);
influxQueryWrapper.eq("LineId",lineId). influxQueryWrapper.eq("LineId",lineId).
last(columnName,"statisticalData"). last(columnName,"statisticalData").
groupBy(StatisticalDataDTO::getLineId, StatisticalDataDTO::getStatMethod, StatisticalDataDTO::getPhase); groupBy(StatisticalDataDTO::getLineId, StatisticalDataDTO::getValueType, StatisticalDataDTO::getPhaseType);
List<StatisticalDataDTO> statistical = commonMapper.getStatistical(influxQueryWrapper); List<StatisticalDataDTO> statistical = commonMapper.getStatistical(influxQueryWrapper);
@@ -41,13 +48,14 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public StatisticalDataDTO getLineRtData(String lineId, String tableName, String columnName, String phasic, String dataType) { public StatisticalDataDTO getLineRtData(String lineId, String tableName, String columnName, String phasic, String dataType) {
HashMap<String, Class<?>> entityClassesByAnnotation = ReflectUitl.getEntityClassesByAnnotation(); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(tableName,StatisticalDataDTO.class);
Class<?> aClass = entityClassesByAnnotation.get(tableName); influxQueryWrapper.select(StatisticalDataDTO::getLineId)
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(aClass,StatisticalDataDTO.class); .select(StatisticalDataDTO::getPhaseType)
influxQueryWrapper.eq("line_id",lineId) .select(StatisticalDataDTO::getValueType)
.last(columnName)
.eq("line_id",lineId)
.eq("phasic_type",phasic) .eq("phasic_type",phasic)
.eq("value_type",dataType) .eq("value_type",dataType);
.last(columnName,"statisticalData");
return commonMapper.getLineRtData(influxQueryWrapper); return commonMapper.getLineRtData(influxQueryWrapper);
} }
} }