|
|
@ -431,6 +431,8 @@ public class DcDeviceController extends BaseController { |
|
|
|
Map<String, Double> deviceHourlyAggregates = new TreeMap<>(); |
|
|
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.##"); |
|
|
|
decimalFormat.setRoundingMode(RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
// 处理每个数据点
|
|
|
|
for (Object o : dataArray) { |
|
|
@ -452,9 +454,10 @@ public class DcDeviceController extends BaseController { |
|
|
|
String key = String.format("%d-%02d-%02d %02d:00:00", |
|
|
|
calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, |
|
|
|
calendar.get(Calendar.DAY_OF_MONTH), hour); |
|
|
|
|
|
|
|
//转换为 double 类型,去除单位
|
|
|
|
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); |
|
|
|
double formatValue = Double.parseDouble(valueWithoutUnit); |
|
|
|
double formatValue = Double.parseDouble(decimalFormat.format(valueWithoutUnit)); |
|
|
|
|
|
|
|
// 汇总每个小时的数据
|
|
|
|
deviceHourlyAggregates.merge(key, formatValue, Double::sum); |
|
|
@ -489,7 +492,8 @@ public class DcDeviceController extends BaseController { |
|
|
|
); |
|
|
|
List<DcDevice> dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameters); |
|
|
|
Map<String, Double> attributeMap = new HashMap<>(); |
|
|
|
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.##"); |
|
|
|
decimalFormat.setRoundingMode(RoundingMode.HALF_UP); |
|
|
|
for (DcDevice dcDevice : dcDevices) { |
|
|
|
String deviceId = dcDevice.getIotDeviceId(); |
|
|
|
for (String propertyId : propertyIds) { |
|
|
@ -501,13 +505,12 @@ public class DcDeviceController extends BaseController { |
|
|
|
String property = data.get("property").getAsString(); |
|
|
|
String formatValueStr = data.get("formatValue").getAsString(); |
|
|
|
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); |
|
|
|
double value = Double.parseDouble(valueWithoutUnit); |
|
|
|
double value = Double.parseDouble(decimalFormat.format(valueWithoutUnit)); |
|
|
|
attributeMap.merge(property, value, (oldVal, newVal) -> oldVal + newVal); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.##"); |
|
|
|
decimalFormat.setRoundingMode(RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
|
|
|
|
// 计算碳减排 碳减排(kg)=光伏发电量(kWh)*0.7119
|
|
|
|
double carbonEmissionReduction = attributeMap.getOrDefault("theAccumulatedChargeOfTheYear", 0.0) * 0.7119; |
|
|
|