Quellcode durchsuchen

效果评-估响应监控调整

fuyuchuan vor 5 Tagen
Ursprung
Commit
d5ce170ce4

+ 4 - 7
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/controller/web/DrMonitorController.java

@@ -9,7 +9,6 @@ import com.usky.vpp.service.vo.DrMonitorSummaryVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -56,16 +55,14 @@ public class DrMonitorController {
     }
 
     /**
-     * 折线图:基线负荷 + 实际响应容量;时间窗为响应前2小时 + 响应时长 + 响应后1小时
+     * 折线图:基线负荷 + 实际响应容量;查询范围为当天
      * <p>基线负荷复用 getSiteBaseline,实际响应容量复用 getSiteDeclaredCapacity。</p>
-     * <p>id 为响应记录/事件主键;siteIds 为站点范围,二者不是同一资源。</p>
      * <p>baselineDays 传 3 或 5 时按对应周期计算基线负荷;为空则按 5 日基线。</p>
      */
-    @GetMapping("/records/{id}/curve")
-    public ApiResult<DrMonitorCurveVO> curve(@PathVariable("id") Long id,
-                                             @RequestParam("siteIds") List<Long> siteIds,
+    @GetMapping("/records/curve")
+    public ApiResult<DrMonitorCurveVO> curve(@RequestParam("siteIds") List<Long> siteIds,
                                              @RequestParam(value = "baselineDays", required = false) Integer baselineDays) {
-        return ApiResult.success(drMonitorService.getCurve(id, siteIds, baselineDays));
+        return ApiResult.success(drMonitorService.getCurve(siteIds, baselineDays));
     }
 
     // private List<Long> parseSiteIds(List<String> raw) {

+ 4 - 4
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/VppDrMonitorService.java

@@ -29,11 +29,11 @@ public interface VppDrMonitorService {
                                               List<Long> siteIds, Map<String, Object> params);
 
     /**
-     * 折线图:基线负荷复用 getSiteBaseline,实际响应容量复用 getSiteDeclaredCapacity,再按可调峰资源点平均
+     * 折线图:以当天为查询范围,基线负荷复用 getSiteBaseline,实际响应容量复用
+     * getSiteDeclaredCapacity,再按可调峰资源点平均
      *
-     * @param eventId      响应记录/事件主键
-     * @param siteIds      站点范围(与 eventId 互补,不是同一资源)
+     * @param siteIds      站点范围
      * @param baselineDays 基线参考天数,仅支持 3 或 5;为空时按 5 日基线
      */
-    DrMonitorCurveVO getCurve(Long eventId, List<Long> siteIds, Integer baselineDays);
+    DrMonitorCurveVO getCurve(List<Long> siteIds, Integer baselineDays);
 }

+ 10 - 36
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrMonitorServiceImpl.java

@@ -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()) {

+ 7 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrMonitorRecordVO.java

@@ -21,10 +21,17 @@ public class DrMonitorRecordVO {
     private LocalDateTime startTime;
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime endTime;
+    /** 响应截止时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime declareDeadline;
+
+    /** 邀约范围 */
     private String inviteScope;
+
+    /** 邀约容量 */
     private BigDecimal targetCapacityKw;
+
+    /** 出清容量 */
     private BigDecimal clearedCapacityKw;
     private String remark;
     private String attachmentUrl;