数据20250904优化
This commit is contained in:
@ -100,7 +100,7 @@ public class EmsStatisticalReportController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 概率统计-获取总表
|
||||
* 概率统计-获取站点下所有电表
|
||||
*/
|
||||
@GetMapping("/getLoadNameList")
|
||||
public AjaxResult getLoadNameList(String siteId)
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
// 电表报表
|
||||
|
||||
@ -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<>();
|
||||
// 获取每个月最早和最晚的时间
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -918,24 +918,25 @@
|
||||
</select>
|
||||
|
||||
<select id="getChargeDataByHour" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
SELECT hour AS ammeterDate,
|
||||
data_update_time AS dataUpdateTime,
|
||||
current_forward_active_total AS chargedCap,
|
||||
current_reverse_active_total AS disChargedCap
|
||||
FROM (
|
||||
SELECT data_update_time,
|
||||
current_forward_active_total,
|
||||
current_reverse_active_total,
|
||||
DATE_FORMAT(data_update_time, '%H:00') AS hour,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY DATE_FORMAT(data_update_time, '%H:00')
|
||||
ORDER BY data_update_time DESC
|
||||
SELECT ammeterDate,
|
||||
dataUpdateTime,
|
||||
totalChargedCap,
|
||||
totalDisChargedCap,
|
||||
totalChargedCap - LAG(totalChargedCap) OVER (ORDER BY ammeterDate) AS chargedCap,
|
||||
totalDisChargedCap - LAG(totalDisChargedCap) OVER (ORDER BY ammeterDate) AS disChargedCap
|
||||
FROM ( SELECT data_update_time AS dataUpdateTime,
|
||||
current_forward_active_total AS totalChargedCap,
|
||||
current_reverse_active_total AS totalDisChargedCap,
|
||||
DATE_FORMAT(data_update_time, '%H:00') AS ammeterDate,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY DATE_FORMAT(data_update_time, '%H:00')
|
||||
ORDER BY data_update_time DESC
|
||||
) AS rn
|
||||
FROM ems_ammeter_data
|
||||
WHERE site_id = #{siteId}
|
||||
AND device_id = #{deviceId}
|
||||
AND DATE(data_update_time) = #{startDate}
|
||||
) AS hourly_data
|
||||
FROM ems_ammeter_data
|
||||
WHERE site_id = #{siteId}
|
||||
AND device_id = #{deviceId}
|
||||
AND DATE(data_update_time) = #{startDate}
|
||||
) AS hourly_data
|
||||
WHERE rn = 1
|
||||
ORDER BY ammeterDate
|
||||
</select>
|
||||
|
||||
@ -428,8 +428,8 @@
|
||||
</select>
|
||||
|
||||
<select id="getSiteSumStackInfo" parameterType="String" resultType="com.xzzn.ems.domain.EmsBatteryStack">
|
||||
select SUM(t.stack_soc) as stackSoc,
|
||||
sum(t.stack_soh) as stackSoh
|
||||
select AVG(t.stack_soc) as stackSoc,
|
||||
AVG(t.stack_soh) as stackSoh
|
||||
from ems_battery_stack t
|
||||
INNER JOIN (
|
||||
select p.site_id,p.device_id,MAX(p.create_time) as max_time
|
||||
|
||||
@ -143,16 +143,25 @@
|
||||
</insert>
|
||||
|
||||
<select id="getAllSiteChargeData" resultType="map">
|
||||
SELECT SUM(t.total_charge_data) AS totalChargedCap,
|
||||
SUM(t.total_discharge_data) AS totalDischargedCap
|
||||
SELECT
|
||||
SUM(t.total_charge_data) AS totalChargedCap,
|
||||
SUM(t.total_discharge_data) AS totalDischargedCap
|
||||
FROM ems_daily_charge_data t
|
||||
LEFT JOIN ems_site_setting ss ON t.site_id = ss.site_id
|
||||
WHERE t.date_time = #{nowData}
|
||||
LEFT JOIN ems_site_setting ss ON t.site_id = ss.site_id
|
||||
INNER JOIN (
|
||||
SELECT site_id,MAX(date_time) AS latest_date FROM ems_daily_charge_data
|
||||
WHERE date_time <= #{nowData}
|
||||
<if test="siteId != null">
|
||||
and t.site_id = #{siteId}
|
||||
and site_id = #{siteId}
|
||||
</if>
|
||||
AND t.total_charge_data IS NOT NULL
|
||||
AND t.total_discharge_data IS NOT NULL
|
||||
AND total_charge_data IS NOT NULL
|
||||
AND total_discharge_data IS NOT NULL
|
||||
GROUP BY site_id
|
||||
) AS latest ON t.date_time = latest.latest_date
|
||||
and t.site_id = latest.site_id
|
||||
<if test="siteId != null">
|
||||
where t.site_id = #{siteId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getSingleSiteChargeData" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
@ -168,11 +177,34 @@
|
||||
|
||||
<select id="getTotalChargeDataByDay" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
SELECT t.date_time AS ammeterDate,
|
||||
t.total_charge_Data as chargedCap,
|
||||
t.total_discharge_Data as disChargedCap
|
||||
SUM(t.charge_data) as chargedCap,
|
||||
SUM(t.discharge_data) as disChargedCap
|
||||
FROM ems_daily_charge_data t
|
||||
WHERE t.site_id = #{siteId}
|
||||
AND t.date_time BETWEEN #{startDate} AND #{endDate}
|
||||
group BY ammeterDate
|
||||
order by ammeterDate
|
||||
</select>
|
||||
|
||||
<select id="getTotalChargeDataByMonth" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
SELECT
|
||||
DATE_FORMAT(t.date_time, '%Y-%m') AS ammeterMonth,
|
||||
SUM(t.charge_data) AS chargedCap,
|
||||
SUM(t.discharge_data) AS disChargedCap
|
||||
FROM ems_daily_charge_data t
|
||||
WHERE t.site_id = #{siteId}
|
||||
AND t.date_time BETWEEN #{startDate} AND #{endDate}
|
||||
GROUP BY ammeterMonth
|
||||
ORDER BY ammeterMonth
|
||||
</select>
|
||||
|
||||
<select id="getAllSiteChargeDataByMonth" resultType="com.xzzn.ems.domain.vo.ElectricIndexList">
|
||||
SELECT
|
||||
DATE_FORMAT(t.date_time, '%Y-%m') AS dateMonth,
|
||||
SUM(t.charge_data) AS chargeEnergy,
|
||||
SUM(t.discharge_data) AS disChargeEnergy
|
||||
FROM ems_daily_charge_data t
|
||||
GROUP BY dateMonth
|
||||
ORDER BY dateMonth
|
||||
</select>
|
||||
</mapper>
|
||||
@ -182,10 +182,15 @@
|
||||
</select>
|
||||
|
||||
<select id="getDeviceInfosBySiteIdAndCategory" resultType="java.util.Map">
|
||||
select DISTINCT device_id as id,
|
||||
device_name as deviceName,
|
||||
communication_status as communicationStatus
|
||||
from ems_devices_setting where site_id = #{siteId} and device_category = #{deviceCategory}
|
||||
select DISTINCT t1.device_id as id,
|
||||
t1.device_name as deviceName,
|
||||
t1.communication_status as communicationStatus,
|
||||
t1.parent_id as parentDeviceId,
|
||||
t2.device_name as parentDeviceName
|
||||
from ems_devices_setting t1
|
||||
LEFT JOIN ems_devices_setting t2
|
||||
ON t1.parent_id = t2.device_id and t1.site_id = t2.site_id
|
||||
where t1.site_id = #{siteId} and t1.device_category = #{deviceCategory}
|
||||
</select>
|
||||
|
||||
<select id="getDeviceBySiteAndDeviceId" parameterType="String" resultMap="EmsDevicesSettingResult">
|
||||
@ -195,8 +200,8 @@
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getLoadNameList" parameterType="String" resultType="java.util.Map">
|
||||
select distinct device_id as id,device_name as deviceName from ems_devices_setting where site_id = #{siteId} and device_id like '%LOAD%'
|
||||
<select id="getAmmeterNameList" parameterType="String" resultType="java.util.Map">
|
||||
select distinct device_id as id,device_name as deviceName from ems_devices_setting where site_id = #{siteId} and device_category = 'AMMETER'
|
||||
</select>
|
||||
|
||||
<select id="getClusterIdsByFuzzyQuery" resultType="java.util.Map">
|
||||
|
||||
@ -454,8 +454,8 @@
|
||||
|
||||
<select id="getPcsDataByHour" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
select latest.dateHour as ammeterDate,
|
||||
sum(t.total_ac_charge_energy) as chargedCap,
|
||||
sum(t.total_ac_discharge_energy) as disChargedCap
|
||||
sum(t.daily_ac_charge_energy) as chargedCap,
|
||||
sum(t.daily_ac_discharge_energy) as disChargedCap
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_pcs_data p
|
||||
<include refid="commonFilter"/>
|
||||
|
||||
Reference in New Issue
Block a user