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

@@ -1,5 +1,12 @@
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.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.pojo.po.HarmonicRatioData;
@@ -31,7 +38,7 @@ public class CommonServiceImpl implements CommonService {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(aClass,StatisticalDataDTO.class);
influxQueryWrapper.eq("LineId",lineId).
last(columnName,"statisticalData").
groupBy(StatisticalDataDTO::getLineId, StatisticalDataDTO::getStatMethod, StatisticalDataDTO::getPhase);
groupBy(StatisticalDataDTO::getLineId, StatisticalDataDTO::getValueType, StatisticalDataDTO::getPhaseType);
List<StatisticalDataDTO> statistical = commonMapper.getStatistical(influxQueryWrapper);
@@ -41,13 +48,14 @@ public class CommonServiceImpl implements CommonService {
@Override
public StatisticalDataDTO getLineRtData(String lineId, String tableName, String columnName, String phasic, String dataType) {
HashMap<String, Class<?>> entityClassesByAnnotation = ReflectUitl.getEntityClassesByAnnotation();
Class<?> aClass = entityClassesByAnnotation.get(tableName);
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(aClass,StatisticalDataDTO.class);
influxQueryWrapper.eq("line_id",lineId)
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(tableName,StatisticalDataDTO.class);
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
.select(StatisticalDataDTO::getPhaseType)
.select(StatisticalDataDTO::getValueType)
.last(columnName)
.eq("line_id",lineId)
.eq("phasic_type",phasic)
.eq("value_type",dataType)
.last(columnName,"statisticalData");
.eq("value_type",dataType);
return commonMapper.getLineRtData(influxQueryWrapper);
}
}