From b4cbf0b34e2119fb4b11874995c1989ba94f710f Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 22 Jul 2025 13:54:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E9=87=8F=E6=8C=87=E6=A0=87-=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/vo/StatisClusterDateRequest.java | 10 +++++++ .../impl/EmsStatsReportServiceImpl.java | 29 ++++++++++--------- .../mapper/ems/EmsBatteryClusterMapper.xml | 3 +- .../resources/mapper/ems/EmsPcsDataMapper.xml | 3 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java index f4c67c8..214949e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java @@ -21,6 +21,8 @@ public class StatisClusterDateRequest { private String clusterId; + private String siteId; + public Date getDateTime() { return dateTime; } @@ -44,4 +46,12 @@ public class StatisClusterDateRequest { public void setClusterId(String clusterId) { this.clusterId = clusterId; } + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 78aa227..2cdb178 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -50,6 +50,20 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService Date startDate = requestVo.getStartDate(); Date endDate = requestVo.getEndDate(); + // 总充总放 + Map totalMap = emsPcsDataMapper.getPcsTotalChargeData(requestVo.getSiteId()); + BigDecimal totalDischarge = totalMap.get("totalDischargedCap") != null ? totalMap.get("totalDischargedCap") : BigDecimal.ZERO; + BigDecimal totalCharge = totalMap.get("totalChargedCap") != null ? totalMap.get("totalChargedCap") : BigDecimal.ZERO; + BigDecimal efficiency = new BigDecimal(0); + if ( totalCharge.compareTo(BigDecimal.ZERO)>0){ + efficiency = totalDischarge.divide(totalCharge, 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); + } + electricDataInfoVo.setTotalDisChargedCap(totalDischarge); + electricDataInfoVo.setTotalChargedCap(totalCharge); + electricDataInfoVo.setEfficiency(efficiency); + + // 日期筛选 List dataList = new ArrayList(); // 开始日期和结束日期同一天,展示 0-24 小时数据 if (DateUtils.isSameDay(startDate, endDate)){ @@ -70,15 +84,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService } // 根据时间获取每天的充放电量 if (!CollectionUtils.isEmpty(dataList)){ - // 总充、总放、效率 - BigDecimal totalDischarge = new BigDecimal(0); - BigDecimal totalCharge = new BigDecimal(0); - BigDecimal efficiency = new BigDecimal(0); for (SiteMonitorDataVo siteMonitorDataVo : dataList) { - totalDischarge = totalDischarge.add(siteMonitorDataVo.getDisChargedCap() == null ? BigDecimal.ZERO : siteMonitorDataVo.getDisChargedCap()); - totalCharge = totalCharge.add(siteMonitorDataVo.getChargedCap() == null ? BigDecimal.ZERO : siteMonitorDataVo.getChargedCap()); - // 计算单天的效率 BigDecimal dailyEfficiency = new BigDecimal(0); if ( siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){ @@ -87,14 +94,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService } siteMonitorDataVo.setDailyEfficiency(dailyEfficiency); } - if ( totalCharge.compareTo(BigDecimal.ZERO)>0){ - efficiency = totalDischarge.divide(totalCharge, 2, RoundingMode.HALF_UP); - efficiency = efficiency.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); - } + electricDataInfoVo.setSevenDayDisChargeStats(dataList); - electricDataInfoVo.setTotalDisChargedCap(totalDischarge); - electricDataInfoVo.setTotalChargedCap(totalCharge); - electricDataInfoVo.setEfficiency(efficiency); } return electricDataInfoVo; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 951fca9..55be7aa 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -362,7 +362,8 @@ t.min_cell_voltage_id as minVoltageId FROM ( SELECT p.site_id, p.device_id, DATE_FORMAT( p.update_time, '%H' ) AS statisDate, MAX(p.update_time) AS max_update_time FROM ems_battery_cluster p - WHERE p.stack_device_id = #{stackId} + WHERE p.site_id = #{siteId} + AND p.stack_device_id = #{stackId} AND p.device_id = #{clusterId} AND p.update_time >= #{dateTime} AND p.update_time < DATE_ADD(#{dateTime}, INTERVAL 1 DAY) diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index add5bff..0bf766c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -339,8 +339,7 @@ SUM(t.total_active_power) as totalActivePower, SUM(t.total_reactive_power) as totalReactivePower, sum(t.daily_ac_charge_energy) as dayChargedCap, - sum(t.daily_ac_discharge_energy) as dayDisChargedCap, - #{siteId} as siteId + sum(t.daily_ac_discharge_energy) as dayDisChargedCap FROM ( SELECT p.device_id, MAX(p.data_update_time) AS max_update_time FROM ems_pcs_data p