This commit is contained in:
2023-07-31 16:39:57 +08:00
parent 3e0157e889
commit f5de42b2aa
2 changed files with 21 additions and 2 deletions

View File

@@ -218,6 +218,25 @@ public class PubUtils {
}
}
/**
* 用于获取对象中前缀一样后缀为2~50的属性值
*
* @param object 待操作对象
* @param methodPrefix 方法前缀
* @param number 方法后缀
* @return 对象属性值
*/
public static Double getValueByMethodDouble(Object object, String methodPrefix, Integer number) {
try {
Method method = object.getClass().getMethod(methodPrefix + number);
return (Double) method.invoke(object);
} catch (Exception e) {
throw new BusinessException(CommonResponseEnum.REFLECT_METHOD_EXCEPTION);
}
}
public static List<String> getStartTimeEndTime(String beginDate, String endDate) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

View File

@@ -86,7 +86,7 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
if(Objects.nonNull(dataHarmRateV)){
for (int i = 2; i < 51; i++) {
floatList.add(PubUtils.getValueByMethod(dataHarmRateV, "getV", i));
floatList.add(PubUtils.getValueByMethodDouble(dataHarmRateV, "getV", i).floatValue());
}
}
} else {
@@ -99,7 +99,7 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
if(Objects.nonNull(dataI)){
for (int i = 2; i < 51; i++) {
floatList.add(PubUtils.getValueByMethod(dataI, "getI", i));
floatList.add(PubUtils.getValueByMethodDouble(dataI, "getI", i).floatValue());
}
}
}