diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index acc2eb02..88b58a97 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/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)); // 汇总每个小时的数据 - deviceHourlyAggregates.merge(key, formatValue, Double::sum); - } + deviceHourlyAggregates.merge(key, formatValue, (oldVal, newVal) -> Double.parseDouble(decimalFormat.format(oldVal + newVal))); } // 将设备的数据合并到所有设备的汇总数据中 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 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))); } } }