指标通用查询

This commit is contained in:
huangzj
2023-06-05 15:19:38 +08:00
parent 0bfcdfd1b5
commit ffca9a7cec
5 changed files with 187 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package com.njcn.influx.service;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import java.util.List;
/**
* Description:
* Date: 2023/6/2 16:00【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CommonService {
List<StatisticalDataDTO> commonquery(String lineId, String tableName, String columnName);
}

View File

@@ -0,0 +1,41 @@
package com.njcn.influx.service.impl;
import com.njcn.influx.imapper.CommonMapper;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.pojo.po.HarmonicRatioData;
import com.njcn.influx.query.InfluxQueryWrapper;
import com.njcn.influx.service.CommonService;
import com.njcn.influx.utils.ReflectUitl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
/**
* Description:
* Date: 2023/6/2 16:04【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class CommonServiceImpl implements CommonService {
private final CommonMapper commonMapper;
@Override
public List<StatisticalDataDTO> commonquery(String lineId ,String tableName, String columnName) {
HashMap<String, Class<?>> entityClassesByAnnotation = ReflectUitl.getEntityClassesByAnnotation();
Class<?> aClass = entityClassesByAnnotation.get(tableName);
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(aClass,StatisticalDataDTO.class);
influxQueryWrapper.eq("LineId",lineId).
last(columnName,"statisticalData").
groupBy(StatisticalDataDTO::getLineId, StatisticalDataDTO::getStatMethod, StatisticalDataDTO::getPhase);
List<StatisticalDataDTO> statistical = commonMapper.getStatistical(influxQueryWrapper);
return statistical;
}
}