|
|
@ -199,9 +199,9 @@ public class MonitorService { |
|
|
|
IPage<Object> page = source.getMockData(queDto); |
|
|
|
return (IPage<T>) page; |
|
|
|
} |
|
|
|
log.debug("请求接口:{}", dataSyncUrl + path); |
|
|
|
String json = dataCenterRestTemplateUtils.doPostRequest(dataSyncUrl + path, queDto); |
|
|
|
resultWrapper.setResultJson(json); |
|
|
|
// log.debug("请求接口:{},参数:[{}],结果[{}]", dataSyncUrl + path, queDto, json);
|
|
|
|
return (IPage<T>) source.getRecords().apply(resultWrapper); |
|
|
|
} |
|
|
|
|
|
|
@ -245,26 +245,25 @@ public class MonitorService { |
|
|
|
switch (operatorEnum) { |
|
|
|
case MAX: |
|
|
|
Optional<Double> v = getData(monitorTypeEnum, data).max(Comparator.comparingDouble(Double::doubleValue)); |
|
|
|
v.ifPresent(aDouble -> item.setValue(aDouble.toString())); |
|
|
|
v.ifPresent(aDouble -> item.setValue(String.format("%.2f", aDouble))); |
|
|
|
break; |
|
|
|
case MIN: |
|
|
|
Optional<Double> v1 = getData(monitorTypeEnum, data).min(Comparator.comparingDouble(Double::doubleValue)); |
|
|
|
v1.ifPresent(aDouble -> item.setValue(aDouble.toString())); |
|
|
|
v1.ifPresent(aDouble -> item.setValue(String.format("%.2f", aDouble))); |
|
|
|
break; |
|
|
|
case TOTAL: |
|
|
|
Optional<Double> v2 = getData(monitorTypeEnum, data).reduce(Double::sum); |
|
|
|
v2.ifPresent(aDouble -> item.setValue(aDouble.toString())); |
|
|
|
v2.ifPresent(aDouble -> item.setValue(String.format("%.2f", aDouble))); |
|
|
|
break; |
|
|
|
case TOP: |
|
|
|
Optional<Double> v3 = getData(monitorTypeEnum, data).limit(1).findFirst(); |
|
|
|
v3.ifPresent(aDouble -> item.setValue(aDouble.toString())); |
|
|
|
v3.ifPresent(aDouble -> item.setValue(String.format("%.2f", aDouble))); |
|
|
|
break; |
|
|
|
default: |
|
|
|
Optional<Double> v4 = getData(monitorTypeEnum, data).reduce(Double::sum); |
|
|
|
v4.ifPresent(aDouble -> item.setValue((aDouble / data.size()) + "")); |
|
|
|
v4.ifPresent(aDouble -> item.setValue(String.format("%.2f", aDouble / data.size()))); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (IllegalArgumentException e) { |
|
|
|
log.error("未找到对应的枚举值MonitorTypeEnum, key:{}", keys[2]); |
|
|
|
} |
|
|
@ -272,7 +271,7 @@ public class MonitorService { |
|
|
|
|
|
|
|
private Stream<Double> getData(MonitorTypeEnum monitorTypeEnum, List<Map<String, Object>> data) { |
|
|
|
return data.stream() |
|
|
|
.map(map -> map.getOrDefault(monitorTypeEnum.getValueField(), "0.0").toString()) |
|
|
|
.map(map -> map.getOrDefault(monitorTypeEnum.getValueField(), "0.00").toString()) |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
.map(Double::parseDouble); |
|
|
|
} |
|
|
|