数据20250904优化

This commit is contained in:
2025-09-12 04:40:47 +08:00
parent ab6771d33d
commit bfdbc4f42c
14 changed files with 162 additions and 68 deletions

View File

@ -57,6 +57,9 @@ public class BMSBatteryClusterVo {
/** 设备唯一标识符 */
private String deviceId;
/** 父类设备名称 */
private String parentDeviceName;
private List<BMSBatteryClusterDataList> batteryDataList;
public String getDeviceName() {
@ -194,4 +197,12 @@ public class BMSBatteryClusterVo {
public void setBatteryDataList(List<BMSBatteryClusterDataList> batteryDataList) {
this.batteryDataList = batteryDataList;
}
public String getParentDeviceName() {
return parentDeviceName;
}
public void setParentDeviceName(String parentDeviceName) {
this.parentDeviceName = parentDeviceName;
}
}

View File

@ -24,6 +24,10 @@ public class SiteMonitorDataVo {
private BigDecimal dailyEfficiency;
private BigDecimal totalChargedCap;
private BigDecimal totalDisChargedCap;
public String getAmmeterDate() {
return ammeterDate;
}
@ -55,4 +59,20 @@ public class SiteMonitorDataVo {
public void setDailyEfficiency(BigDecimal dailyEfficiency) {
this.dailyEfficiency = dailyEfficiency;
}
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;
}
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import com.xzzn.ems.domain.EmsDailyChargeData;
import com.xzzn.ems.domain.vo.ElectricIndexList;
import com.xzzn.ems.domain.vo.SiteMonitorDataVo;
import org.apache.ibatis.annotations.Param;
@ -76,4 +77,9 @@ public interface EmsDailyChargeDataMapper
// 按天获取站点每日总充总放
public List<SiteMonitorDataVo> getTotalChargeDataByDay(@Param("siteId")String siteId,@Param("startDate")Date startDate, @Param("endDate")Date endDate);
// 按月获取站点每日总充总放
public List<SiteMonitorDataVo> getTotalChargeDataByMonth(@Param("siteId")String siteId,@Param("startDate")Date startDate, @Param("endDate")Date endDate);
public List<ElectricIndexList> getAllSiteChargeDataByMonth();
}

View File

@ -77,11 +77,11 @@ public interface EmsDevicesSettingMapper
public List<Map<String, Object>> getDeviceInfosBySiteIdAndCategory(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory);
/**
* 获取该设备下的总
* 获取该设备下所有的电
* @param siteId
* @return
*/
public List<Map<String, Object>> getLoadNameList(String siteId);
public List<Map<String, Object>> getAmmeterNameList(String siteId);
public EmsDevicesSetting getDeviceBySiteAndDeviceId(@Param("deviceId")String deviceId, @Param("siteId")String siteId);

View File

@ -92,12 +92,6 @@ public interface EmsPcsDataMapper
*/
public List<PcsDetailInfoVo> getPcsDetailInfoBySiteId(String siteId);
/**
* 获取总充+总放
* @return
*/
public Map<String, BigDecimal> getPcsTotalChargeData(String siteId);
/**
* 根据时间按天获取充放电量
* @param siteId
@ -106,14 +100,7 @@ public interface EmsPcsDataMapper
* @return
*/
public List<SiteMonitorDataVo> getPcsDataByDay(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
/**
* 根据时间按月获取充放电量
* @param siteId
* @param startDate
* @param endDate
* @return
*/
public List<SiteMonitorDataVo> getPcsDataByMonth(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
/**
* 根据时间按小时获取充放电量
* @param siteId

View File

@ -1,6 +1,7 @@
package com.xzzn.ems.service.impl;
import com.xzzn.common.utils.DateUtils;
import com.xzzn.ems.domain.EmsAmmeterData;
import com.xzzn.ems.domain.vo.*;
import com.xzzn.ems.mapper.*;
import com.xzzn.ems.service.IEmsStatsReportService;
@ -70,37 +71,38 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
String siteId = requestVo.getSiteId();
String deviceId = requestVo.getDeviceId();
if ("021_DDS_01".equals(siteId)){
deviceId = "METE";
} else if ("021_FXX_01".equals(siteId)){
deviceId = "LOAD";
}
// 日期筛选
List<SiteMonitorDataVo> dataList = new ArrayList();
// 开始日期和结束日期同一天,展示 0-24 小时数据
if (DateUtils.isSameDay(startDate, endDate)){
electricDataInfoVo.setUnit("");
//endDate = DateUtils.addDays(endDate, 1);
//dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate);
dataList = emsAmmeterDataMapper.getChargeDataByHour(siteId,deviceId,startDate);
if ("021_DDS_01".equals(siteId)) {
deviceId = "METE";
dataList = emsAmmeterDataMapper.getChargeDataByHour(siteId,deviceId,startDate);
} else if ("021_FXX_01".equals(siteId)) {
endDate = DateUtils.addDays(endDate, 1);
dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate);
}
} else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1
&& DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){
electricDataInfoVo.setUnit("");
// 开始日期-结束日期大于 1 天小于30 天,按天展示数据
//dataList = emsPcsDataMapper.getPcsDataByDay(requestVo.getSiteId(), startDate, endDate);
dataList = emsDailyChargeDataMapper.getTotalChargeDataByDay(siteId,startDate,endDate);
} else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){
electricDataInfoVo.setUnit("");
// 开始日期-结束日期大于 1 个月,按月展示数据
dataList = emsAmmeterDataMapper.getChargeDataByMonth(requestVo.getSiteId(),deviceId, startDate, endDate);
dataList = emsDailyChargeDataMapper.getTotalChargeDataByMonth(siteId,startDate, endDate);
}
// 根据时间获取每天的充放电量
// 获取昨天昨晚一条数据,计算第一个小时的差值
//setFirstDataDiff(dataList,siteId,deviceId);
// 计算充放电效率
if (!CollectionUtils.isEmpty(dataList)){
for (SiteMonitorDataVo siteMonitorDataVo : dataList) {
// 计算单天的效率
BigDecimal dailyEfficiency = new BigDecimal(0);
if ( siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){
if ( siteMonitorDataVo.getChargedCap() != null &&
siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){
dailyEfficiency = siteMonitorDataVo.getDisChargedCap().divide(siteMonitorDataVo.getChargedCap(), 2, RoundingMode.HALF_UP);
dailyEfficiency = dailyEfficiency.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
}
@ -112,6 +114,29 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
return electricDataInfoVo;
}
private void setFirstDataDiff(List<SiteMonitorDataVo> dataList, String siteId, String deviceId) {
BigDecimal yestTotalDisChargeDate = new BigDecimal(0);
BigDecimal yestTotalChargeDate = new BigDecimal(0);
String yestDate = DateUtils.getYesterdayDate();
if (dataList != null && dataList.size()>0){
SiteMonitorDataVo firstData = dataList.get(0);
if ("021_DDS_01".equals(siteId)){
EmsAmmeterData yestData = emsAmmeterDataMapper.getYestLatestDate(siteId,deviceId,yestDate);
if (yestData != null) {
yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal();
yestTotalChargeDate = yestData.getCurrentForwardActiveTotal();
}
} else if ("021_FXX_01".equals(siteId)) {
}
firstData.setChargedCap(firstData.getTotalChargedCap() == null ? BigDecimal.ZERO
: firstData.getTotalChargedCap().subtract(yestTotalChargeDate));
firstData.setDisChargedCap(firstData.getTotalDisChargedCap() == null ? BigDecimal.ZERO
: firstData.getTotalDisChargedCap().subtract(yestTotalDisChargeDate));
}
}
// pcs曲线数据
@Override
public List<PcsStatisListVo> getPCSDataResult(DateSearchRequest requestVo) {
@ -188,7 +213,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
@Override
public List<Map<String, Object>> getLoadNameList(String siteId) {
return emsDevicesSettingMapper.getLoadNameList(siteId);
return emsDevicesSettingMapper.getAmmeterNameList(siteId);
}
// 电表报表

View File

@ -113,7 +113,7 @@ public class HomePageServiceImpl implements IHomePageService
HomePageDataViewVo homePageDataViewVo = new HomePageDataViewVo();
// 电量指标
//List<ElectricIndexList> electricDataList = emsPcsDataMapper.getElectDataList();
List<ElectricIndexList> electricDataList = getElectricDataList();
List<ElectricIndexList> electricDataList = getElectricDataList2();
homePageDataViewVo.setElecDataList(electricDataList);
// 系统效率
List<SystemEfficiencyList> systemEfficiencyLists = new ArrayList<>();
@ -159,6 +159,12 @@ public class HomePageServiceImpl implements IHomePageService
return homePageDataViewVo;
}
private List<ElectricIndexList> getElectricDataList2() {
List<ElectricIndexList> electricDataList = new ArrayList<>();
electricDataList = emsDailyChargeDataMapper.getAllSiteChargeDataByMonth();
return electricDataList;
}
private List<ElectricIndexList> getElectricDataList() {
List<ElectricIndexList> electricDataList = new ArrayList<>();
// 获取每个月最早和最晚的时间

View File

@ -321,9 +321,11 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
for (Map<String, Object> clusterDevice : clusterIds) {
BMSBatteryClusterVo bmsBatteryClusterVo = new BMSBatteryClusterVo();
bmsBatteryClusterVo.setDeviceName(clusterDevice.get("deviceName").toString());
bmsBatteryClusterVo.setParentDeviceName(clusterDevice.get("parentDeviceName").toString());
// 从redis取单个簇详细数据
String clusterId = clusterDevice.get("id").toString();
EmsBatteryCluster clusterData = redisCache.getCacheObject(RedisKeyConstants.CLUSTER +siteId+"_"+clusterId);
String parentDeviceId = "";
if (clusterData != null) {
BeanUtils.copyProperties(clusterData, bmsBatteryClusterVo);
// 处理单体电池数据-平均/最大/最小
@ -331,7 +333,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
dealWithBatteryClusterData(clusterData,clusterDataList);
bmsBatteryClusterVo.setBatteryDataList(clusterDataList);
}
bmsBatteryClusterVoList.add(bmsBatteryClusterVo);
}
}