谐波频谱查询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

@@ -15,6 +15,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import lombok.Data;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.math.BigDecimal;
@@ -32,6 +33,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
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 {