统计报表-电表报表
This commit is contained in:
@ -6,6 +6,7 @@ import com.xzzn.common.core.page.TableDataInfo;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.vo.ClusterStatisListVo;
|
||||
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||
import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest;
|
||||
import com.xzzn.ems.domain.vo.StatisClusterDateRequest;
|
||||
import com.xzzn.ems.service.IEmsStatsReportService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -98,4 +99,30 @@ public class EmsStatisticalReportController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 概率统计-获取总表
|
||||
*/
|
||||
@GetMapping("/getLoadNameList")
|
||||
public AjaxResult getLoadNameList(String siteId)
|
||||
{
|
||||
if (!StringUtils.isEmpty(siteId)) {
|
||||
return success(ieEmsStatsReportService.getLoadNameList(siteId));
|
||||
} else {
|
||||
return error("缺少必传项");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 概率统计-电表报表
|
||||
*/
|
||||
@GetMapping("/getAmmeterData")
|
||||
public AjaxResult getAmmeterData(StatisAmmeterDateRequest requestVo)
|
||||
{
|
||||
if (!StringUtils.isEmpty(requestVo.getDeviceId())) {
|
||||
return success(ieEmsStatsReportService.getAmmeterDataResult(requestVo));
|
||||
} else {
|
||||
return error("缺少必传项");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,142 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 电表数据
|
||||
*/
|
||||
public class AmmeterStatisListVo {
|
||||
|
||||
|
||||
/** 类别 */
|
||||
private String dataTime;
|
||||
|
||||
/** 组合有功-总 (kWh) */
|
||||
private BigDecimal activeTotalKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合有功-尖 (kWh) */
|
||||
private BigDecimal activePeakKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合有功-峰 (kWh) */
|
||||
private BigDecimal activeHighKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合有功-平 (kWh) */
|
||||
private BigDecimal activeFlatKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合有功-谷 (kWh) */
|
||||
private BigDecimal activeValleyKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合无功-总 (kWh) */
|
||||
private BigDecimal reActiveTotalKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合无功-尖 (kWh) */
|
||||
private BigDecimal reActivePeakKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合无功-峰 (kWh) */
|
||||
private BigDecimal reActiveHighKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合无功-平 (kWh) */
|
||||
private BigDecimal reActiveFlatKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 组合无功-谷 (kWh) */
|
||||
private BigDecimal reActiveValleyKwh = BigDecimal.ZERO;
|
||||
|
||||
/** 效率-有功总/无功总 */
|
||||
private BigDecimal effect = BigDecimal.ZERO;
|
||||
|
||||
public String getDataTime() {
|
||||
return dataTime;
|
||||
}
|
||||
|
||||
public void setDataTime(String dataTime) {
|
||||
this.dataTime = dataTime;
|
||||
}
|
||||
|
||||
public BigDecimal getActiveTotalKwh() {
|
||||
return activeTotalKwh;
|
||||
}
|
||||
|
||||
public void setActiveTotalKwh(BigDecimal activeTotalKwh) {
|
||||
this.activeTotalKwh = activeTotalKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getActivePeakKwh() {
|
||||
return activePeakKwh;
|
||||
}
|
||||
|
||||
public void setActivePeakKwh(BigDecimal activePeakKwh) {
|
||||
this.activePeakKwh = activePeakKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getActiveHighKwh() {
|
||||
return activeHighKwh;
|
||||
}
|
||||
|
||||
public void setActiveHighKwh(BigDecimal activeHighKwh) {
|
||||
this.activeHighKwh = activeHighKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getActiveFlatKwh() {
|
||||
return activeFlatKwh;
|
||||
}
|
||||
|
||||
public void setActiveFlatKwh(BigDecimal activeFlatKwh) {
|
||||
this.activeFlatKwh = activeFlatKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getActiveValleyKwh() {
|
||||
return activeValleyKwh;
|
||||
}
|
||||
|
||||
public void setActiveValleyKwh(BigDecimal activeValleyKwh) {
|
||||
this.activeValleyKwh = activeValleyKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getReActiveTotalKwh() {
|
||||
return reActiveTotalKwh;
|
||||
}
|
||||
|
||||
public void setReActiveTotalKwh(BigDecimal reActiveTotalKwh) {
|
||||
this.reActiveTotalKwh = reActiveTotalKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getReActivePeakKwh() {
|
||||
return reActivePeakKwh;
|
||||
}
|
||||
|
||||
public void setReActivePeakKwh(BigDecimal reActivePeakKwh) {
|
||||
this.reActivePeakKwh = reActivePeakKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getReActiveHighKwh() {
|
||||
return reActiveHighKwh;
|
||||
}
|
||||
|
||||
public void setReActiveHighKwh(BigDecimal reActiveHighKwh) {
|
||||
this.reActiveHighKwh = reActiveHighKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getReActiveFlatKwh() {
|
||||
return reActiveFlatKwh;
|
||||
}
|
||||
|
||||
public void setReActiveFlatKwh(BigDecimal reActiveFlatKwh) {
|
||||
this.reActiveFlatKwh = reActiveFlatKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getReActiveValleyKwh() {
|
||||
return reActiveValleyKwh;
|
||||
}
|
||||
|
||||
public void setReActiveValleyKwh(BigDecimal reActiveValleyKwh) {
|
||||
this.reActiveValleyKwh = reActiveValleyKwh;
|
||||
}
|
||||
|
||||
public BigDecimal getEffect() {
|
||||
return effect;
|
||||
}
|
||||
|
||||
public void setEffect(BigDecimal effect) {
|
||||
this.effect = effect;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 报表统计-电表报表入参
|
||||
*
|
||||
*/
|
||||
public class StatisAmmeterDateRequest {
|
||||
|
||||
/**
|
||||
* 筛选时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date dateTime;
|
||||
|
||||
private String siteId;
|
||||
|
||||
private String deviceId;
|
||||
|
||||
public Date getDateTime() {
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public void setDateTime(Date dateTime) {
|
||||
this.dateTime = dateTime;
|
||||
}
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,8 @@ package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsAmmeterData;
|
||||
import com.xzzn.ems.domain.vo.AmmeterStatisListVo;
|
||||
import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest;
|
||||
|
||||
/**
|
||||
* 总数据Mapper接口
|
||||
@ -58,4 +60,11 @@ public interface EmsAmmeterDataMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsAmmeterDataByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 按小时获取当天电表曲线数据
|
||||
* @param requestVo
|
||||
* @return
|
||||
*/
|
||||
public List<AmmeterStatisListVo> getLoadDataByHour(StatisAmmeterDateRequest requestVo);
|
||||
}
|
||||
|
||||
@ -67,12 +67,6 @@ public interface EmsDevicesSettingMapper
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getDeviceInfoByParentId(String parentId);
|
||||
/**
|
||||
* 获取该设备下的所有电表
|
||||
* @param siteId
|
||||
* @return
|
||||
*/
|
||||
public List<EmsDevicesSetting> getAllBatteryDeviceBySiteId(String siteId);
|
||||
|
||||
/**
|
||||
* 根据site_id和device_category获取指定设备信息
|
||||
@ -88,4 +82,11 @@ public interface EmsDevicesSettingMapper
|
||||
* @return
|
||||
*/
|
||||
public EmsDevicesSetting getDeviceDetailInfo(String deviceId);
|
||||
|
||||
/**
|
||||
* 获取该设备下的总表
|
||||
* @param siteId
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getLoadNameList(String siteId);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xzzn.ems.service;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 统计报表数据Service接口
|
||||
@ -20,4 +21,8 @@ public interface IEmsStatsReportService
|
||||
public List<StackStatisListVo> getStackDataResult(DateSearchRequest requestVo);
|
||||
|
||||
public List<ClusterStatisListVo> getClusterDataResult(StatisClusterDateRequest requestVo);
|
||||
|
||||
public List<Map<String,Object>> getLoadNameList(String siteId);
|
||||
|
||||
public List<AmmeterStatisListVo> getAmmeterDataResult(StatisAmmeterDateRequest requestVo);
|
||||
}
|
||||
|
||||
@ -2,13 +2,8 @@ package com.xzzn.ems.service.impl;
|
||||
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
import com.xzzn.ems.mapper.EmsBatteryClusterMapper;
|
||||
import com.xzzn.ems.mapper.EmsBatteryDataMapper;
|
||||
import com.xzzn.ems.mapper.EmsBatteryStackMapper;
|
||||
import com.xzzn.ems.mapper.EmsPcsDataMapper;
|
||||
import com.xzzn.ems.mapper.*;
|
||||
import com.xzzn.ems.service.IEmsStatsReportService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -19,6 +14,7 @@ import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 统计报表数据Service业务层处理
|
||||
@ -29,17 +25,16 @@ import java.util.List;
|
||||
@Service
|
||||
public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
{
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EmsStatsReportServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EmsPcsDataMapper emsPcsDataMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDataMapper emsBatteryDataMapper;
|
||||
@Autowired
|
||||
private EmsBatteryStackMapper emsBatteryStackMapper;
|
||||
@Autowired
|
||||
private EmsBatteryClusterMapper emsBatteryClusterMapper;
|
||||
@Autowired
|
||||
private EmsAmmeterDataMapper emsAmmeterDataMapper;
|
||||
@Autowired
|
||||
private EmsDevicesSettingMapper emsDevicesSettingMapper;
|
||||
|
||||
@Override
|
||||
public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) {
|
||||
@ -161,7 +156,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
List<ClusterStatisListVo> dataList = new ArrayList();
|
||||
// 时间不传默认当天
|
||||
if (requestVo.getDateTime() == null) {
|
||||
requestVo.setDateTime(new Date());
|
||||
String now = DateUtils.getDate();
|
||||
requestVo.setDateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD, now));
|
||||
}
|
||||
|
||||
// 根据时间获取每小时最新数据
|
||||
@ -169,6 +165,69 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
return dataList;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getLoadNameList(String siteId) {
|
||||
return emsDevicesSettingMapper.getLoadNameList(siteId);
|
||||
}
|
||||
|
||||
public List<AmmeterStatisListVo> getAmmeterDataResult(StatisAmmeterDateRequest requestVo){
|
||||
List<AmmeterStatisListVo> dataList = new ArrayList();
|
||||
// 时间不传默认当天
|
||||
if (requestVo.getDateTime() == null) {
|
||||
String now = DateUtils.getDate();
|
||||
requestVo.setDateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD, now));
|
||||
}
|
||||
dataList = emsAmmeterDataMapper.getLoadDataByHour(requestVo);
|
||||
if (dataList.size()>0){
|
||||
AmmeterStatisListVo totalVo = new AmmeterStatisListVo();
|
||||
totalVo.setDataTime("汇总");
|
||||
for (AmmeterStatisListVo ammeterStatisListVo : dataList) {
|
||||
BigDecimal effect = new BigDecimal(0);
|
||||
BigDecimal activePower = ammeterStatisListVo.getActiveTotalKwh();
|
||||
BigDecimal reactivePower = ammeterStatisListVo.getReActiveTotalKwh();
|
||||
if ( activePower != null && reactivePower !=null
|
||||
&& activePower.compareTo(BigDecimal.ZERO) >= 0
|
||||
&& reactivePower.compareTo(BigDecimal.ZERO) >= 0){
|
||||
effect = reactivePower.divide(activePower, 2, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
// 每小时的效率
|
||||
ammeterStatisListVo.setEffect(effect);
|
||||
|
||||
// 处理汇总数据
|
||||
dealWithAmmeterTotalDate(ammeterStatisListVo,totalVo);
|
||||
}
|
||||
|
||||
// 处理汇总的效率
|
||||
BigDecimal totalActive = totalVo.getActiveTotalKwh();
|
||||
BigDecimal totalReactive = totalVo.getReActiveTotalKwh();
|
||||
if ( totalActive != null && totalReactive !=null
|
||||
&& totalActive.compareTo(BigDecimal.ZERO) >= 0
|
||||
&& totalReactive.compareTo(BigDecimal.ZERO) >= 0){
|
||||
BigDecimal totalEffect = new BigDecimal(0);
|
||||
totalEffect = totalReactive.divide(totalActive, 2, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
|
||||
totalVo.setEffect(totalEffect);
|
||||
}
|
||||
dataList.add(totalVo);
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
private void dealWithAmmeterTotalDate(AmmeterStatisListVo ammeterStatisListVo, AmmeterStatisListVo totalVo) {
|
||||
// 有功
|
||||
totalVo.setActiveTotalKwh(totalVo.getActiveTotalKwh().add(ammeterStatisListVo.getActiveTotalKwh()));
|
||||
totalVo.setActivePeakKwh(totalVo.getActivePeakKwh().add(ammeterStatisListVo.getActivePeakKwh()));
|
||||
totalVo.setActiveHighKwh(totalVo.getActiveHighKwh().add(ammeterStatisListVo.getActiveHighKwh()));
|
||||
totalVo.setActiveFlatKwh(totalVo.getActiveFlatKwh().add(ammeterStatisListVo.getActiveFlatKwh()));
|
||||
totalVo.setActiveValleyKwh(totalVo.getActiveValleyKwh().add(ammeterStatisListVo.getActiveValleyKwh()));
|
||||
// 无功
|
||||
totalVo.setReActiveTotalKwh(totalVo.getReActiveTotalKwh().add(ammeterStatisListVo.getReActiveTotalKwh()));
|
||||
totalVo.setReActivePeakKwh(totalVo.getReActivePeakKwh().add(ammeterStatisListVo.getReActivePeakKwh()));
|
||||
totalVo.setReActiveHighKwh(totalVo.getReActiveHighKwh().add(ammeterStatisListVo.getReActiveHighKwh()));
|
||||
totalVo.setReActiveFlatKwh(totalVo.getReActiveFlatKwh().add(ammeterStatisListVo.getReActiveFlatKwh()));
|
||||
totalVo.setReActiveValleyKwh(totalVo.getReActiveValleyKwh().add(ammeterStatisListVo.getReActiveValleyKwh()));
|
||||
}
|
||||
|
||||
// 统计入参时间处理
|
||||
public void dealRequestTime(DateSearchRequest requestVo){
|
||||
|
||||
|
||||
@ -549,4 +549,28 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getLoadDataByHour" resultType="com.xzzn.ems.domain.vo.AmmeterStatisListVo">
|
||||
select latest.dataHour as dataTime,
|
||||
t.current_comb_active_total as activeTotalKwh,
|
||||
t.current_comb_active_peak as activePeakKwh,
|
||||
t.current_comb_active_high as activeHighKwh,
|
||||
t.current_comb_active_flat as activeFlatKwh,
|
||||
t.current_comb_active_valley as activeValleyKwh,
|
||||
t.current_comb_reactive_total as reActiveTotalKwh,
|
||||
t.current_comb_reactive_peak as reActivePeakKwh,
|
||||
t.current_comb_reactive_high as reActiveHighKwh,
|
||||
t.current_comb_reactive_flat as reActiveFlatKwh,
|
||||
t.current_comb_reactive_valley as reActiveValleyKwh
|
||||
from ems_ammeter_data t
|
||||
INNER JOIN ( select site_id,device_id,HOUR(data_update_time) as dataHour, MAX(data_update_time) as max_update_time
|
||||
from ems_ammeter_data
|
||||
where site_id = #{siteId}
|
||||
and device_id = #{deviceId}
|
||||
and data_update_time > #{dateTime}
|
||||
group by site_id,device_id,dataHour
|
||||
) latest on t.site_id = latest.site_id
|
||||
and t.device_id = latest.device_id
|
||||
and t.data_update_time = latest.max_update_time
|
||||
order by dataTime
|
||||
</select>
|
||||
</mapper>
|
||||
@ -185,4 +185,8 @@
|
||||
where device_id = #{deviceId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getLoadNameList" parameterType="String" resultType="java.util.Map">
|
||||
select distinct device_id,device_name from ems_devices_setting where site_id = #{siteId} and device_id like '%LOAD%'
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user