Browse Source

太阳能数据保留两位小数

develop
王兴琳 3 weeks ago
parent
commit
2ab4b238da
  1. 9
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

9
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -476,11 +476,10 @@ private VideoController videoController;
// 保留两位小数 // 保留两位小数
double formatValue = Double.parseDouble(decimalFormat.format(parsedValue)); double formatValue = Double.parseDouble(decimalFormat.format(parsedValue));
// 汇总每个小时的数据 // 汇总每个小时的数据
deviceHourlyAggregates.merge(key, formatValue, Double::sum); deviceHourlyAggregates.merge(key, formatValue, (oldVal, newVal) -> Double.parseDouble(decimalFormat.format(oldVal + newVal))); }
}
// 将设备的数据合并到所有设备的汇总数据中 // 将设备的数据合并到所有设备的汇总数据中
for (String key : deviceHourlyAggregates.keySet()) { for (String key : deviceHourlyAggregates.keySet()) {
allDevicesHourlyAggregates.merge(key, deviceHourlyAggregates.get(key), Double::sum); allDevicesHourlyAggregates.merge(key, deviceHourlyAggregates.get(key), (oldVal, newVal) -> Double.parseDouble(decimalFormat.format(oldVal + newVal)));
} }
} }
@ -524,8 +523,8 @@ private VideoController videoController;
double value2 = Double.parseDouble(valueWithoutUnit); double value2 = Double.parseDouble(valueWithoutUnit);
double value = Double.parseDouble(decimalFormat.format(value2)); double value = Double.parseDouble(decimalFormat.format(value2));
// 在合并时重新应用格式化
attributeMap.merge(property, value, (oldVal, newVal) -> oldVal + newVal); attributeMap.merge(property, value, (oldVal, newVal) -> Double.parseDouble(decimalFormat.format(oldVal + newVal)));
} }
} }
} }

Loading…
Cancel
Save