概率统计-电量指标
This commit is contained in:
@ -0,0 +1,50 @@
|
|||||||
|
package com.xzzn.web.controller.ems;
|
||||||
|
|
||||||
|
import com.xzzn.common.core.controller.BaseController;
|
||||||
|
import com.xzzn.common.core.domain.AjaxResult;
|
||||||
|
import com.xzzn.common.utils.StringUtils;
|
||||||
|
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||||
|
import com.xzzn.ems.service.IEmsStatsReportService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单站监控-统计报表
|
||||||
|
*
|
||||||
|
* @author xzzn
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ems/statsReport")
|
||||||
|
public class EmsStatisticalReportController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IEmsStatsReportService ieEmsStatsReportService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 概率统计-收益指标查询
|
||||||
|
*/
|
||||||
|
@GetMapping("/getRevenueData")
|
||||||
|
public AjaxResult getRevenueData(DateSearchRequest requestVo)
|
||||||
|
{
|
||||||
|
return success(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 概率统计-电量指标查询
|
||||||
|
*/
|
||||||
|
@GetMapping("/getElectricData")
|
||||||
|
public AjaxResult getElectricData(DateSearchRequest requestVo)
|
||||||
|
{
|
||||||
|
if (!StringUtils.isEmpty(requestVo.getSiteId())) {
|
||||||
|
return success(ieEmsStatsReportService.getElectricDataResult(requestVo));
|
||||||
|
} else {
|
||||||
|
return error("站点id必传");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.xzzn.ems.domain.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入参-时间
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DateSearchRequest {
|
||||||
|
|
||||||
|
/** 开始时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date startDate;
|
||||||
|
|
||||||
|
/** 结束时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date endDate;
|
||||||
|
|
||||||
|
private String siteId;
|
||||||
|
|
||||||
|
public Date getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(Date startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(Date endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSiteId() {
|
||||||
|
return siteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSiteId(String siteId) {
|
||||||
|
this.siteId = siteId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.xzzn.ems.domain.vo;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 概率统计-电量指标返回
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ElectricDataInfoVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总充电量
|
||||||
|
*/
|
||||||
|
private BigDecimal totalChargedCap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总放电量
|
||||||
|
*/
|
||||||
|
private BigDecimal totalDisChargedCap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合效率 = 放电量/充电量
|
||||||
|
*/
|
||||||
|
private BigDecimal efficiency;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按天放电统计
|
||||||
|
*/
|
||||||
|
private List<SiteMonitorDataVo> sevenDayDisChargeStats;
|
||||||
|
|
||||||
|
public BigDecimal getTotalChargedCap() {
|
||||||
|
return totalChargedCap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalChargedCap(BigDecimal totalChargedCap) {
|
||||||
|
this.totalChargedCap = totalChargedCap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalDisChargedCap() {
|
||||||
|
return totalDisChargedCap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalDisChargedCap(BigDecimal totalDisChargedCap) {
|
||||||
|
this.totalDisChargedCap = totalDisChargedCap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getEfficiency() {
|
||||||
|
return efficiency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEfficiency(BigDecimal efficiency) {
|
||||||
|
this.efficiency = efficiency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SiteMonitorDataVo> getSevenDayDisChargeStats() {
|
||||||
|
return sevenDayDisChargeStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSevenDayDisChargeStats(List<SiteMonitorDataVo> sevenDayDisChargeStats) {
|
||||||
|
this.sevenDayDisChargeStats = sevenDayDisChargeStats;
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,8 @@ public class SiteMonitorDataVo {
|
|||||||
*/
|
*/
|
||||||
private BigDecimal chargedCap;
|
private BigDecimal chargedCap;
|
||||||
|
|
||||||
|
private BigDecimal dailyEfficiency;
|
||||||
|
|
||||||
public String getAmmeterDate() {
|
public String getAmmeterDate() {
|
||||||
return ammeterDate;
|
return ammeterDate;
|
||||||
}
|
}
|
||||||
@ -45,4 +47,12 @@ public class SiteMonitorDataVo {
|
|||||||
public void setChargedCap(BigDecimal chargedCap) {
|
public void setChargedCap(BigDecimal chargedCap) {
|
||||||
this.chargedCap = chargedCap;
|
this.chargedCap = chargedCap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getDailyEfficiency() {
|
||||||
|
return dailyEfficiency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDailyEfficiency(BigDecimal dailyEfficiency) {
|
||||||
|
this.dailyEfficiency = dailyEfficiency;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.xzzn.ems.domain.EmsPcsData;
|
import com.xzzn.ems.domain.EmsPcsData;
|
||||||
import com.xzzn.ems.domain.vo.ElectricIndexList;
|
import com.xzzn.ems.domain.vo.*;
|
||||||
import com.xzzn.ems.domain.vo.PcsDetailInfoVo;
|
|
||||||
import com.xzzn.ems.domain.vo.SiteMonitorDataVo;
|
|
||||||
import com.xzzn.ems.domain.vo.SiteMonitorRunningHeadInfoVo;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,9 +100,8 @@ public interface EmsPcsDataMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据时间按天获取充放电量
|
* 根据时间按天获取充放电量
|
||||||
* @param startDate
|
* @param requestVo
|
||||||
* @param endDate
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<SiteMonitorDataVo> getPcsDataByDate(Date startDate, Date endDate);
|
public List<SiteMonitorDataVo> getPcsDataByDate(DateSearchRequest requestVo);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.xzzn.ems.service;
|
||||||
|
|
||||||
|
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||||
|
import com.xzzn.ems.domain.vo.ElectricDataInfoVo;;import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计报表数据Service接口
|
||||||
|
*
|
||||||
|
* @author xzzn
|
||||||
|
* @date 2025-06-29
|
||||||
|
*/
|
||||||
|
public interface IEmsStatsReportService
|
||||||
|
{
|
||||||
|
|
||||||
|
public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo);
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.xzzn.ems.service.impl;
|
||||||
|
|
||||||
|
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||||
|
import com.xzzn.ems.domain.vo.ElectricDataInfoVo;
|
||||||
|
import com.xzzn.ems.domain.vo.SiteMonitorDataVo;
|
||||||
|
import com.xzzn.ems.mapper.EmsPcsDataMapper;
|
||||||
|
import com.xzzn.ems.service.IEmsStatsReportService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计报表数据Service业务层处理
|
||||||
|
*
|
||||||
|
* @author xzzn
|
||||||
|
* @date 2025-06-29
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||||
|
{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmsPcsDataMapper emsPcsDataMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) {
|
||||||
|
ElectricDataInfoVo electricDataInfoVo = new ElectricDataInfoVo();
|
||||||
|
|
||||||
|
// 根据时间获取每天的充放电量
|
||||||
|
List<SiteMonitorDataVo> dataList = emsPcsDataMapper.getPcsDataByDate(requestVo);
|
||||||
|
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.getDisChargedCap().compareTo(BigDecimal.ZERO)>0){
|
||||||
|
dailyEfficiency = siteMonitorDataVo.getDisChargedCap().divide(siteMonitorDataVo.getChargedCap(), 2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
siteMonitorDataVo.setDailyEfficiency(dailyEfficiency);
|
||||||
|
}
|
||||||
|
if ( totalCharge.compareTo(BigDecimal.ZERO)>0){
|
||||||
|
efficiency = totalDischarge.divide(totalCharge, 2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
electricDataInfoVo.setSevenDayDisChargeStats(dataList);
|
||||||
|
electricDataInfoVo.setTotalDisChargedCap(totalDischarge);
|
||||||
|
electricDataInfoVo.setTotalChargedCap(totalCharge);
|
||||||
|
electricDataInfoVo.setEfficiency(efficiency);
|
||||||
|
}
|
||||||
|
return electricDataInfoVo;
|
||||||
|
}
|
||||||
|
}
|
@ -151,7 +151,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getAllClusterInfoByStackId" parameterType="String" resultType="java.util.Map">
|
<select id="getAllClusterInfoByStackId" parameterType="String" resultType="java.util.Map">
|
||||||
select distinct t.device_id,t.device_name from ems_devices_setting t where t.parent_id = #{stackDeviceId}
|
select distinct t.device_id as id,t.device_name as deviceName from ems_devices_setting t where t.parent_id = #{stackDeviceId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getAllBatteryDeviceBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.EmsDevicesSetting">
|
<select id="getAllBatteryDeviceBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.EmsDevicesSetting">
|
||||||
|
@ -379,6 +379,10 @@
|
|||||||
from ( SELECT p.site_id, p.device_id,p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time
|
from ( SELECT p.site_id, p.device_id,p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time
|
||||||
FROM ems_pcs_data p
|
FROM ems_pcs_data p
|
||||||
where p.site_id = #{siteId}
|
where p.site_id = #{siteId}
|
||||||
|
<if test="startDate != null and endDate != null">
|
||||||
|
and p.data_update_time >= #{startDate}
|
||||||
|
and p.data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
|
||||||
|
</if>
|
||||||
GROUP BY p.site_id,p.device_id,p.date_month,p.date_day
|
GROUP BY p.site_id,p.device_id,p.date_month,p.date_day
|
||||||
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
|
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
|
||||||
AND latest.device_id = t.device_id
|
AND latest.device_id = t.device_id
|
||||||
@ -386,6 +390,6 @@
|
|||||||
and latest.date_month = t.date_month
|
and latest.date_month = t.date_month
|
||||||
and latest.date_day = t.date_day
|
and latest.date_day = t.date_day
|
||||||
group by ammeterDate
|
group by ammeterDate
|
||||||
order by ammeterDate desc
|
order by ammeterDate desc;
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Reference in New Issue
Block a user