光伏今日放电统计逻辑修改

This commit is contained in:
2026-02-03 17:57:41 +08:00
parent 2e6cee7f49
commit a859c4b649
2 changed files with 31 additions and 3 deletions

View File

@ -146,6 +146,7 @@ public class OpenStationServiceImpl implements OpenStationService {
BigDecimal pvActivePower = new BigDecimal(CommonConstant.ZERO);
BigDecimal totalRelease = new BigDecimal(CommonConstant.ZERO);
BigDecimal dailyReleaseElec = new BigDecimal(CommonConstant.ZERO);
String nowDay = DateUtil.format(new Date(), CommonConstant.DATE_YMD);
if (!pcsList.isEmpty()) {
for (DeviceRespVO deviceRespVO : pcsList) {
//在缓存里拿映射字段
@ -155,11 +156,37 @@ public class OpenStationServiceImpl implements OpenStationService {
if (mpptMap != null) {
MpptVo vo = JSON.parseObject(JSON.toJSONString(mpptMap), MpptVo.class);
if (vo != null) {
BigDecimal pvActivePowerMppt = vo.getPvActivePower() == null ? BigDecimal.ZERO : vo.getPvActivePower().getValue();
// 今日功率
BigDecimal pvActivePowerMppt = BigDecimal.ZERO;
if(vo.getPvActivePower() != null){
if(nowDay.equals(DateUtil.format(vo.getPvActivePower().getUpdateTime(), CommonConstant.DATE_YMD))){
pvActivePowerMppt = vo.getPvActivePower().getValue();
}
}
// 累计发电量
BigDecimal totalReleaseMppt = vo.getTotalRelease() == null ? BigDecimal.ZERO : vo.getTotalRelease().getValue();
BigDecimal pvDailyReleaseStart = vo.getPvDailyReleaseStart() == null ? BigDecimal.ZERO : vo.getPvDailyReleaseStart().getValue();
BigDecimal dailyReleaseElecMppt = totalReleaseMppt.subtract(pvDailyReleaseStart);
// 今日发电起始值
BigDecimal pvDailyReleaseStart = BigDecimal.ZERO;
if(vo.getPvDailyReleaseStart() != null){
if(nowDay.equals(DateUtil.format(vo.getPvDailyReleaseStart().getUpdateTime(), CommonConstant.DATE_YMD))){
pvDailyReleaseStart = vo.getPvDailyReleaseStart().getValue();
}
}
// 今日更新的累计发电量
BigDecimal totalReleaseMppt1 = BigDecimal.ZERO;
if(vo.getTotalRelease() != null){
if(nowDay.equals(DateUtil.format(vo.getTotalRelease().getUpdateTime(), CommonConstant.DATE_YMD))){
totalReleaseMppt1 = vo.getTotalRelease().getValue();
}
}
// 计算今日发电量 = 今日更新的累计发电量 - 今日发电起始值
BigDecimal dailyReleaseElecMppt = BigDecimal.ZERO;
if(totalReleaseMppt1.compareTo(BigDecimal.ZERO)>0&&pvDailyReleaseStart.compareTo(BigDecimal.ZERO)>0){
dailyReleaseElecMppt = totalReleaseMppt1.subtract(pvDailyReleaseStart);
}
// 如果计算到的今日发电量小于0 则设置为0
dailyReleaseElecMppt = dailyReleaseElecMppt.compareTo(BigDecimal.ZERO)<0?BigDecimal.ZERO:dailyReleaseElecMppt;
// 最后组装值
pvActivePower = pvActivePower.add(pvActivePowerMppt);
totalRelease = totalRelease.add(totalReleaseMppt);
dailyReleaseElec = dailyReleaseElec.add(dailyReleaseElecMppt);

View File

@ -1475,6 +1475,7 @@ public class Device001ApiController {
}
if (stationHomeRespVos != null && stationHomeRespVos.size() > 0) {
BigDecimal startEle = stationHomeRespVos.get(0).getDigital();
query.setBegin(DateUtil.beginOfDay(new Date()));
cacheObj(query, DeviceTypeConstant.PV_DAILY_CHARGE_START, startEle);
}
}