|
|
@@ -225,29 +225,15 @@ public class VppDrMonitorServiceImpl implements VppDrMonitorService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DrMonitorCurveVO getCurve(Long eventId, List<Long> siteIds, Integer baselineDays) {
|
|
|
- if (eventId == null) {
|
|
|
- throw new BusinessException("事件ID不能为空");
|
|
|
- }
|
|
|
+ public DrMonitorCurveVO getCurve(List<Long> siteIds, Integer baselineDays) {
|
|
|
requireSiteIds(siteIds);
|
|
|
if (baselineDays != null && baselineDays != 3 && baselineDays != 5) {
|
|
|
- throw new BusinessException("baselineDays 仅支持 3 或 5");
|
|
|
+ throw new BusinessException("基线负荷仅支持3天或5天维度查询!");
|
|
|
}
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
- VppDrEvent event = eventMapper.selectById(eventId);
|
|
|
- if (event == null || VppAuditHelper.isDeleted(event.getDeleteFlag())) {
|
|
|
- throw new BusinessException("事件不存在");
|
|
|
- }
|
|
|
- if (tenantId != null && event.getTenantId() != null && !tenantId.equals(event.getTenantId())) {
|
|
|
- throw new BusinessException("事件不存在");
|
|
|
- }
|
|
|
- if (event.getStartTime() == null) {
|
|
|
- throw new BusinessException("事件缺少开始时间");
|
|
|
- }
|
|
|
-
|
|
|
List<VppResourcePoint> peakResources = listPeakResources(siteIds, tenantId);
|
|
|
if (peakResources.isEmpty()) {
|
|
|
- throw new BusinessException("所选站点下无可参与调峰的资源点");
|
|
|
+ throw new BusinessException("所选站点下无可参与调峰的资源点!");
|
|
|
}
|
|
|
int resourceCount = peakResources.size();
|
|
|
Map<Long, Long> siteResourceCount = new HashMap<>();
|
|
|
@@ -256,28 +242,18 @@ public class VppDrMonitorServiceImpl implements VppDrMonitorService {
|
|
|
}
|
|
|
Set<Long> peakSiteIds = siteResourceCount.keySet();
|
|
|
|
|
|
- List<VppDrInvitation> invitations = listInvitations(
|
|
|
- Collections.singleton(event.getId()), peakSiteIds, tenantId);
|
|
|
- Map<Long, BigDecimal> invitationActualBySite = new HashMap<>();
|
|
|
- for (VppDrInvitation invitation : invitations) {
|
|
|
- if (invitation.getSiteId() == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- invitationActualBySite.merge(invitation.getSiteId(),
|
|
|
- nz(invitation.getActualResponseCapacityKw()), BigDecimal::add);
|
|
|
- }
|
|
|
-
|
|
|
- LocalDateTime windowStart = event.getStartTime().minusHours(2);
|
|
|
- LocalDateTime windowEnd = (event.getEndTime() != null ? event.getEndTime() : event.getStartTime()).plusHours(1);
|
|
|
- String responseStartTime = event.getStartTime().format(DATE_TIME_FMT);
|
|
|
- String eventEndTime = (event.getEndTime() != null ? event.getEndTime() : event.getStartTime()).format(DATE_TIME_FMT);
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDateTime windowStart = today.atStartOfDay();
|
|
|
+ LocalDateTime windowEnd = today.atTime(LocalTime.MAX);
|
|
|
+ String responseStartTime = windowStart.format(DATE_TIME_FMT);
|
|
|
+ String responseEndTime = windowEnd.format(DATE_TIME_FMT);
|
|
|
String actualEndTime = windowEnd.format(DATE_TIME_FMT);
|
|
|
int requiredDays = (baselineDays != null && baselineDays == 3) ? 3 : 5;
|
|
|
|
|
|
BigDecimal actualSum = BigDecimal.ZERO;
|
|
|
for (Long siteId : peakSiteIds) {
|
|
|
actualSum = actualSum.add(resolveSiteActualResponseKw(
|
|
|
- siteId, responseStartTime, eventEndTime, invitationActualBySite.get(siteId)));
|
|
|
+ siteId, responseStartTime, responseEndTime, BigDecimal.ZERO));
|
|
|
}
|
|
|
BigDecimal actualAvg = avg(actualSum, resourceCount);
|
|
|
|
|
|
@@ -307,9 +283,7 @@ public class VppDrMonitorServiceImpl implements VppDrMonitorService {
|
|
|
|
|
|
BigDecimal divisor = BigDecimal.valueOf(resourceCount);
|
|
|
DrMonitorCurveVO curve = new DrMonitorCurveVO();
|
|
|
- curve.setId(event.getId());
|
|
|
- curve.setEventId(event.getEventId());
|
|
|
- curve.setResponseDate(event.getStartTime().toLocalDate().format(DATE_FMT));
|
|
|
+ curve.setResponseDate(today.format(DATE_FMT));
|
|
|
curve.setSiteIds(usedSiteIds);
|
|
|
curve.setActualResponseCapacityKw(actualAvg);
|
|
|
if (dataSources.isEmpty()) {
|