Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
mengff 3 weeks ago
parent
commit
6cf308a163
  1. 13
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  2. 490
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  3. 9
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

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

@ -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;

490
zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java

File diff suppressed because it is too large

9
zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

@ -457,8 +457,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION ALL
SELECT 'Weather Warning' AS WarningTypeSource, id, warning_description, warning_type, warning_time, create_time, other_config
FROM dc_no_stake_warning_table
WHERE warning_type = 2
AND warning_time >= DATE_SUB(CURDATE(), INTERVAL 3 DAY)
WHERE warning_type = 2 AND warning_time >= DATE_SUB(CURDATE(), INTERVAL 3 DAY)
UNION ALL
SELECT 'TrafficFlow' AS WarningTypeSource, id, warning_description, warning_type, warning_time, create_time, other_config
FROM dc_no_stake_warning_table
WHERE warning_type = 3
AND warning_time >= DATE_SUB(CURDATE(), INTERVAL 2 DAY)
ORDER BY warning_time DESC
</select>

Loading…
Cancel
Save