Просмотр исходного кода

需求响应接口调整:添加字段

fuyuchuan 1 неделя назад
Родитель
Сommit
59258ba2b8
19 измененных файлов с 199 добавлено и 18 удалено
  1. 8 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppBiddingConfig.java
  2. 34 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrEvent.java
  3. 1 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrInvitation.java
  4. 2 1
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrParticipation.java
  5. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrEventIngestServiceImpl.java
  6. 1 1
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrInvitationServiceImpl.java
  7. 66 6
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrServiceImpl.java
  8. 3 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/BiddingConfigRequest.java
  9. 4 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/BiddingConfigVO.java
  10. 22 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrEventDetailVO.java
  11. 20 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrEventRequest.java
  12. 1 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrInvitationRequest.java
  13. 1 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrInvitationVO.java
  14. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrParticipateRequest.java
  15. 1 1
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrParticipationVO.java
  16. 13 1
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/util/VppDrParticipationHelper.java
  17. 1 1
      service-vpp/service-vpp-biz/src/main/resources/sql/vpp_dr_invitation_migration.sql
  18. 2 2
      service-vpp/service-vpp-biz/src/main/resources/sql/vpp_dr_participation_completion_rate_migration.sql
  19. 15 5
      service-vpp/service-vpp-biz/src/main/resources/sql/vpp_schema.sql

+ 8 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppBiddingConfig.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -47,16 +48,23 @@ public class VppBiddingConfig implements Serializable {
     private String siteIds;
     @TableField("tenant_id")
     private Integer tenantId;
+
     @TableField("create_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime createTime;
+
     @TableField("update_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime updateTime;
+
     @TableField("created_by")
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
     @TableField("delete_flag")
     private Integer deleteFlag;
+
     @TableField("deleted_at")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime deletedAt;
 }

+ 34 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrEvent.java

@@ -34,10 +34,44 @@ public class VppDrEvent implements Serializable {
     private LocalDateTime startTime;
     @TableField("end_time")
     private LocalDateTime endTime;
+    /** 申报截止时间 */
+    @TableField("declare_deadline")
+    private LocalDateTime declareDeadline;
+    /** 邀约范围 */
+    @TableField("invite_scope")
+    private String inviteScope;
+    /** 邀约规模 kW */
     @TableField("target_capacity_kw")
     private BigDecimal targetCapacityKw;
+    /** 出清规模 kW */
     @TableField("cleared_capacity_kw")
     private BigDecimal clearedCapacityKw;
+    /** 申报出清容量 kW */
+    @TableField("declared_cleared_capacity_kw")
+    private BigDecimal declaredClearedCapacityKw;
+    /** 实际出清 kW(电网审核通过) */
+    @TableField("actual_cleared_capacity_kw")
+    private BigDecimal actualClearedCapacityKw;
+    /** 预估响应容量 kW(响应完成后本平台评估) */
+    @TableField("estimated_response_capacity_kw")
+    private BigDecimal estimatedResponseCapacityKw;
+    /** 实际响应容量 kW(电网评估最终结果) */
+    @TableField("actual_response_capacity_kw")
+    private BigDecimal actualResponseCapacityKw;
+    /**
+     * 响应完成率 = 实际响应容量 / 邀约规模;展示时 ×100%
+     */
+    @TableField("response_completion_rate")
+    private BigDecimal responseCompletionRate;
+    /** 是否中标 0否 1是(单选,集中标记) */
+    @TableField("is_winning_bid")
+    private Integer isWinningBid;
+    /** 备注附件 URL */
+    @TableField("remark_attachment_url")
+    private String remarkAttachmentUrl;
+    /** 备注附件名称 */
+    @TableField("remark_attachment_name")
+    private String remarkAttachmentName;
     @TableField("subsidy_price")
     private BigDecimal subsidyPrice;
     @TableField("event_status")

+ 1 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrInvitation.java

@@ -44,6 +44,7 @@ public class VppDrInvitation implements Serializable {
     private Integer responseType;
     @TableField("demand_capacity_kw")
     private BigDecimal demandCapacityKw;
+    /** 申报出清容量 kW */
     @TableField("declared_capacity_kw")
     private BigDecimal declaredCapacityKw;
     @TableField("reply_status")

+ 2 - 1
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrParticipation.java

@@ -30,11 +30,12 @@ public class VppDrParticipation implements Serializable {
     private Long resourceId;
     @TableField("participate_status")
     private Integer participateStatus;
+    /** 申报出清容量 */
     @TableField("declared_capacity_kw")
     private BigDecimal declaredCapacityKw;
     @TableField("cleared_capacity_kw")
     private BigDecimal clearedCapacityKw;
-    /** 完成率 = 出清容量 / 申报容量 */
+    /** 完成率 = 出清容量 / 申报出清容量 */
     @TableField("completion_rate")
     private BigDecimal completionRate;
     @TableField("declared_at")

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrEventIngestServiceImpl.java

@@ -82,6 +82,7 @@ public class VppDrEventIngestServiceImpl implements VppDrEventIngestService {
             BigDecimal total = sumListLoad(list);
             if (total.compareTo(BigDecimal.ZERO) > 0) {
                 event.setClearedCapacityKw(total);
+                event.setActualClearedCapacityKw(total);
             }
         }
         if (event.getEventStatus() == null || event.getEventStatus() == EVENT_STATUS_PENDING) {
@@ -202,6 +203,7 @@ public class VppDrEventIngestServiceImpl implements VppDrEventIngestService {
                 BigDecimal cleared = VppUnEventParser.sumResourceLoadKw(resources, true);
                 if (cleared.compareTo(BigDecimal.ZERO) > 0) {
                     event.setClearedCapacityKw(cleared);
+                    event.setActualClearedCapacityKw(cleared);
                 }
                 unDrSyncService.syncTargetResources(event, resources, true);
                 event.setEventStatus(EVENT_STATUS_DECLARED);

+ 1 - 1
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrInvitationServiceImpl.java

@@ -258,7 +258,7 @@ public class VppDrInvitationServiceImpl implements VppDrInvitationService {
                     ? request.getDeclaredCapacityKw()
                     : invitation.getDeclaredCapacityKw();
             if (declared == null || declared.compareTo(BigDecimal.ZERO) <= 0) {
-                throw new BusinessException("申报容量必须大于0");
+                throw new BusinessException("申报出清容量必须大于0");
             }
 
             VppDrParticipation participation = findOrCreateParticipation(invitation, declared);

+ 66 - 6
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrServiceImpl.java

@@ -147,8 +147,19 @@ public class VppDrServiceImpl implements VppDrService {
         event.setEventType(request.getEventType());
         event.setStartTime(request.getStartTime());
         event.setEndTime(request.getEndTime());
+        event.setDeclareDeadline(request.getDeclareDeadline());
+        event.setInviteScope(request.getInviteScope());
         event.setTargetCapacityKw(request.getTargetCapacityKw());
         event.setClearedCapacityKw(request.getClearedCapacityKw());
+        event.setDeclaredClearedCapacityKw(request.getDeclaredClearedCapacityKw());
+        event.setActualClearedCapacityKw(request.getActualClearedCapacityKw());
+        event.setEstimatedResponseCapacityKw(request.getEstimatedResponseCapacityKw());
+        event.setActualResponseCapacityKw(request.getActualResponseCapacityKw());
+        event.setResponseCompletionRate(VppDrParticipationHelper.calcResponseCompletionRate(
+                request.getActualResponseCapacityKw(), request.getTargetCapacityKw()));
+        event.setIsWinningBid(request.getIsWinningBid());
+        event.setRemarkAttachmentUrl(request.getRemarkAttachmentUrl());
+        event.setRemarkAttachmentName(request.getRemarkAttachmentName());
         event.setSubsidyPrice(request.getSubsidyPrice());
         event.setEventStatus(EVENT_STATUS_PENDING);
         VppAuditHelper.fillCreate(event);
@@ -174,8 +185,19 @@ public class VppDrServiceImpl implements VppDrService {
         event.setEventType(request.getEventType());
         event.setStartTime(request.getStartTime());
         event.setEndTime(request.getEndTime());
+        event.setDeclareDeadline(request.getDeclareDeadline());
+        event.setInviteScope(request.getInviteScope());
         event.setTargetCapacityKw(request.getTargetCapacityKw());
         event.setClearedCapacityKw(request.getClearedCapacityKw());
+        event.setDeclaredClearedCapacityKw(request.getDeclaredClearedCapacityKw());
+        event.setActualClearedCapacityKw(request.getActualClearedCapacityKw());
+        event.setEstimatedResponseCapacityKw(request.getEstimatedResponseCapacityKw());
+        event.setActualResponseCapacityKw(request.getActualResponseCapacityKw());
+        event.setResponseCompletionRate(VppDrParticipationHelper.calcResponseCompletionRate(
+                request.getActualResponseCapacityKw(), request.getTargetCapacityKw()));
+        event.setIsWinningBid(request.getIsWinningBid());
+        event.setRemarkAttachmentUrl(request.getRemarkAttachmentUrl());
+        event.setRemarkAttachmentName(request.getRemarkAttachmentName());
         event.setSubsidyPrice(request.getSubsidyPrice());
         VppAuditHelper.fillUpdate(event);
         eventMapper.updateById(event);
@@ -269,7 +291,7 @@ public class VppDrServiceImpl implements VppDrService {
 
         if (Boolean.TRUE.equals(request.getParticipate())) {
             if (request.getDeclaredCapacityKw() == null || request.getDeclaredCapacityKw().compareTo(BigDecimal.ZERO) <= 0) {
-                throw new BusinessException("申报容量必须大于0");
+                throw new BusinessException("申报出清容量必须大于0");
             }
 
             if (request.getResources() == null || request.getResources().isEmpty()) {
@@ -288,7 +310,7 @@ public class VppDrServiceImpl implements VppDrService {
                     throw new BusinessException("资源ID不能为空");
                 }
                 if (resource.getDeclaredCapacityKw() == null || resource.getDeclaredCapacityKw().compareTo(BigDecimal.ZERO) <= 0) {
-                    throw new BusinessException("资源申报容量必须大于0");
+                    throw new BusinessException("资源申报出清容量必须大于0");
                 }
                 VppResourcePoint rp = resourcePointMapper.selectById(resource.getResourceId());
                 if (rp == null || VppAuditHelper.isDeleted(rp.getDeleteFlag())) {
@@ -305,7 +327,7 @@ public class VppDrServiceImpl implements VppDrService {
             }
 
             if (resourceDeclaredTotal.compareTo(request.getDeclaredCapacityKw()) != 0) {
-                throw new BusinessException("各资源申报容量之和与总申报容量不一致");
+                throw new BusinessException("各资源申报出清容量之和与总申报出清容量不一致");
             }
 
             for (DrParticipateRequest.DrResourceDeclare resource : request.getResources()) {
@@ -322,6 +344,7 @@ public class VppDrServiceImpl implements VppDrService {
                 participationMapper.insert(participation);
             }
 
+            event.setDeclaredClearedCapacityKw(request.getDeclaredCapacityKw());
             event.setEventStatus(EVENT_STATUS_DECLARED);
             VppAuditHelper.fillUpdate(event);
             eventMapper.updateById(event);
@@ -396,7 +419,7 @@ public class VppDrServiceImpl implements VppDrService {
             }
             if (participation.getDeclaredCapacityKw() != null
                     && resource.getClearedCapacityKw().compareTo(participation.getDeclaredCapacityKw()) > 0) {
-                throw new BusinessException("出清容量不能超过申报容量");
+                throw new BusinessException("出清容量不能超过申报出清容量");
             }
             participation.setClearedCapacityKw(resource.getClearedCapacityKw());
             VppDrParticipationHelper.refreshCompletionRate(participation);
@@ -575,6 +598,9 @@ public class VppDrServiceImpl implements VppDrService {
             executionMapper.updateById(execution);
         }
 
+        event.setEstimatedResponseCapacityKw(totalActual);
+        event.setResponseCompletionRate(VppDrParticipationHelper.calcResponseCompletionRate(
+                totalActual, event.getTargetCapacityKw()));
         event.setEventStatus(EVENT_STATUS_ENDED);
         VppAuditHelper.fillUpdate(event);
         eventMapper.updateById(event);
@@ -814,10 +840,34 @@ public class VppDrServiceImpl implements VppDrService {
             throw new BusinessException("响应结束时间不能早于开始时间");
         }
         if (request.getTargetCapacityKw() == null || request.getTargetCapacityKw().compareTo(BigDecimal.ZERO) <= 0) {
-            throw new BusinessException("目标容量必须大于0");
+            throw new BusinessException("邀约规模必须大于0");
         }
         if (request.getClearedCapacityKw() != null && request.getClearedCapacityKw().compareTo(BigDecimal.ZERO) < 0) {
-            throw new BusinessException("出清容量不能为负数");
+            throw new BusinessException("出清规模不能为负数");
+        }
+        if (request.getDeclaredClearedCapacityKw() != null
+                && request.getDeclaredClearedCapacityKw().compareTo(BigDecimal.ZERO) < 0) {
+            throw new BusinessException("申报出清容量不能为负数");
+        }
+        if (request.getActualClearedCapacityKw() != null
+                && request.getActualClearedCapacityKw().compareTo(BigDecimal.ZERO) < 0) {
+            throw new BusinessException("实际出清不能为负数");
+        }
+        if (request.getEstimatedResponseCapacityKw() != null
+                && request.getEstimatedResponseCapacityKw().compareTo(BigDecimal.ZERO) < 0) {
+            throw new BusinessException("预估响应容量不能为负数");
+        }
+        if (request.getActualResponseCapacityKw() != null
+                && request.getActualResponseCapacityKw().compareTo(BigDecimal.ZERO) < 0) {
+            throw new BusinessException("实际响应容量不能为负数");
+        }
+        if (request.getIsWinningBid() != null
+                && request.getIsWinningBid() != 0 && request.getIsWinningBid() != 1) {
+            throw new BusinessException("是否中标无效,取值 0否 1是");
+        }
+        if (request.getDeclareDeadline() != null && request.getStartTime() != null
+                && request.getDeclareDeadline().isAfter(request.getStartTime())) {
+            throw new BusinessException("申报截止时间不能晚于响应开始时间");
         }
         if (request.getSubsidyPrice() != null && request.getSubsidyPrice().compareTo(BigDecimal.ZERO) < 0) {
             throw new BusinessException("补贴标准不能为负数");
@@ -866,8 +916,18 @@ public class VppDrServiceImpl implements VppDrService {
         vo.setEventType(event.getEventType());
         vo.setStartTime(event.getStartTime());
         vo.setEndTime(event.getEndTime());
+        vo.setDeclareDeadline(event.getDeclareDeadline());
+        vo.setInviteScope(event.getInviteScope());
         vo.setTargetCapacityKw(event.getTargetCapacityKw());
         vo.setClearedCapacityKw(event.getClearedCapacityKw());
+        vo.setDeclaredClearedCapacityKw(event.getDeclaredClearedCapacityKw());
+        vo.setActualClearedCapacityKw(event.getActualClearedCapacityKw());
+        vo.setEstimatedResponseCapacityKw(event.getEstimatedResponseCapacityKw());
+        vo.setActualResponseCapacityKw(event.getActualResponseCapacityKw());
+        vo.setResponseCompletionRate(event.getResponseCompletionRate());
+        vo.setIsWinningBid(event.getIsWinningBid());
+        vo.setRemarkAttachmentUrl(event.getRemarkAttachmentUrl());
+        vo.setRemarkAttachmentName(event.getRemarkAttachmentName());
         vo.setSubsidyPrice(event.getSubsidyPrice());
         vo.setEventStatus(event.getEventStatus());
         vo.setParticipations(loadParticipationVos(event.getId()));

+ 3 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/BiddingConfigRequest.java

@@ -1,5 +1,6 @@
 package com.usky.vpp.service.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -13,7 +14,9 @@ import java.util.List;
 public class BiddingConfigRequest {
 
     private String configName;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime effectiveStart;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime effectiveEnd;
     private String attachmentUrl;
     private String attachmentName;

+ 4 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/BiddingConfigVO.java

@@ -1,5 +1,6 @@
 package com.usky.vpp.service.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -14,7 +15,9 @@ public class BiddingConfigVO {
 
     private Long id;
     private String configName;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime effectiveStart;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime effectiveEnd;
     /** 适用时间段展示,如 2025-01-01 00:00:00 - 2025-06-30 23:59:59 */
     private String effectivePeriod;
@@ -30,5 +33,6 @@ public class BiddingConfigVO {
     private BigDecimal minPrice;
     private List<Long> siteIds;
     private List<BiddingConfigSiteVO> sites;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime updateTime;
 }

+ 22 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrEventDetailVO.java

@@ -19,8 +19,30 @@ public class DrEventDetailVO {
     private Integer eventType;
     private LocalDateTime startTime;
     private LocalDateTime endTime;
+    /** 申报截止时间 */
+    private LocalDateTime declareDeadline;
+    /** 邀约范围 */
+    private String inviteScope;
+    /** 邀约规模 kW */
     private BigDecimal targetCapacityKw;
+    /** 出清规模 kW */
     private BigDecimal clearedCapacityKw;
+    /** 申报出清容量 kW */
+    private BigDecimal declaredClearedCapacityKw;
+    /** 实际出清 kW(电网审核通过) */
+    private BigDecimal actualClearedCapacityKw;
+    /** 预估响应容量 kW(响应完成后本平台评估) */
+    private BigDecimal estimatedResponseCapacityKw;
+    /** 实际响应容量 kW(电网评估最终结果) */
+    private BigDecimal actualResponseCapacityKw;
+    /** 响应完成率 = 实际响应容量 / 邀约规模 */
+    private BigDecimal responseCompletionRate;
+    /** 是否中标 0否 1是 */
+    private Integer isWinningBid;
+    /** 备注附件 URL */
+    private String remarkAttachmentUrl;
+    /** 备注附件名称 */
+    private String remarkAttachmentName;
     private BigDecimal subsidyPrice;
     private Integer eventStatus;
     private List<DrParticipationVO> participations;

+ 20 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrEventRequest.java

@@ -20,7 +20,27 @@ public class DrEventRequest {
     private Integer eventType;
     private LocalDateTime startTime;
     private LocalDateTime endTime;
+    /** 申报截止时间 */
+    private LocalDateTime declareDeadline;
+    /** 邀约范围 */
+    private String inviteScope;
+    /** 邀约规模 kW */
     private BigDecimal targetCapacityKw;
+    /** 出清规模 kW */
     private BigDecimal clearedCapacityKw;
+    /** 申报出清容量 kW */
+    private BigDecimal declaredClearedCapacityKw;
+    /** 实际出清 kW(电网审核通过) */
+    private BigDecimal actualClearedCapacityKw;
+    /** 预估响应容量 kW(响应完成后本平台评估) */
+    private BigDecimal estimatedResponseCapacityKw;
+    /** 实际响应容量 kW(电网评估最终结果) */
+    private BigDecimal actualResponseCapacityKw;
+    /** 是否中标 0否 1是 */
+    private Integer isWinningBid;
+    /** 备注附件 URL */
+    private String remarkAttachmentUrl;
+    /** 备注附件名称 */
+    private String remarkAttachmentName;
     private BigDecimal subsidyPrice;
 }

+ 1 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrInvitationRequest.java

@@ -18,6 +18,7 @@ public class DrInvitationRequest {
     private LocalDate executeEndDate;
     private LocalDateTime replyDeadline;
     private BigDecimal demandCapacityKw;
+    /** 申报出清容量 kW */
     private BigDecimal declaredCapacityKw;
     /** 1削峰 2填谷 */
     private Integer transactionType;

+ 1 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrInvitationVO.java

@@ -25,6 +25,7 @@ public class DrInvitationVO {
     private Integer transactionType;
     private Integer responseType;
     private BigDecimal demandCapacityKw;
+    /** 申报出清容量 kW */
     private BigDecimal declaredCapacityKw;
     private Integer replyStatus;
     private Integer responseStatus;

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrParticipateRequest.java

@@ -13,6 +13,7 @@ public class DrParticipateRequest {
 
     private Boolean participate;
     private Long strategyId;
+    /** 申报出清容量 kW */
     private BigDecimal declaredCapacityKw;
     private String reason;
     private List<DrResourceDeclare> resources;
@@ -20,6 +21,7 @@ public class DrParticipateRequest {
     @Data
     public static class DrResourceDeclare {
         private Long resourceId;
+        /** 申报出清容量 kW */
         private BigDecimal declaredCapacityKw;
     }
 }

+ 1 - 1
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/vo/DrParticipationVO.java

@@ -19,7 +19,7 @@ public class DrParticipationVO {
     private Integer participateStatus;
     private BigDecimal declaredCapacityKw;
     private BigDecimal clearedCapacityKw;
-    /** 完成率 = 出清容量 / 申报容量 */
+    /** 完成率 = 出清容量 / 申报出清容量 */
     private BigDecimal completionRate;
     private LocalDateTime declaredAt;
 }

+ 13 - 1
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/util/VppDrParticipationHelper.java

@@ -16,7 +16,7 @@ public final class VppDrParticipationHelper {
     }
 
     /**
-     * 完成率 = 出清容量 / 申报容量;申报容量为空或 ≤0、出清容量为空时返回 null。
+     * 完成率 = 出清容量 / 申报出清容量;申报出清容量为空或 ≤0、出清容量为空时返回 null。
      */
     public static BigDecimal calcCompletionRate(BigDecimal clearedCapacityKw, BigDecimal declaredCapacityKw) {
         if (clearedCapacityKw == null || declaredCapacityKw == null
@@ -26,6 +26,18 @@ public final class VppDrParticipationHelper {
         return clearedCapacityKw.divide(declaredCapacityKw, RATE_SCALE, RoundingMode.HALF_UP);
     }
 
+    /**
+     * 响应完成率 = 实际响应容量 / 邀约规模;邀约规模为空或 ≤0、实际响应容量为空时返回 null。
+     */
+    public static BigDecimal calcResponseCompletionRate(BigDecimal actualResponseCapacityKw,
+                                                        BigDecimal inviteScaleKw) {
+        if (actualResponseCapacityKw == null || inviteScaleKw == null
+                || inviteScaleKw.compareTo(BigDecimal.ZERO) <= 0) {
+            return null;
+        }
+        return actualResponseCapacityKw.divide(inviteScaleKw, RATE_SCALE, RoundingMode.HALF_UP);
+    }
+
     public static void refreshCompletionRate(VppDrParticipation participation) {
         if (participation == null) {
             return;

+ 1 - 1
service-vpp/service-vpp-biz/src/main/resources/sql/vpp_dr_invitation_migration.sql

@@ -15,7 +15,7 @@ SET @sql = IF(
         `transaction_type` TINYINT NULL COMMENT ''交易类型 1削峰 2填谷'',
         `response_type` TINYINT NOT NULL COMMENT ''1日前 2日内 3秒级'',
         `demand_capacity_kw` DECIMAL(12,4) NOT NULL COMMENT ''需求容量 kW'',
-        `declared_capacity_kw` DECIMAL(12,4) NULL COMMENT ''申报容量 kW'',
+        `declared_capacity_kw` DECIMAL(12,4) NULL COMMENT ''申报出清容量 kW'',
         `reply_status` TINYINT NOT NULL COMMENT ''0待回复 1参与 2拒绝 3超时'',
         `response_status` TINYINT NOT NULL COMMENT ''0待响应 1已申报 2执行中 3已结束 4已取消'',
         `sms_notify_status` TINYINT NOT NULL DEFAULT 0 COMMENT ''0未发送 1已发送 2发送失败'',

+ 2 - 2
service-vpp/service-vpp-biz/src/main/resources/sql/vpp_dr_participation_completion_rate_migration.sql

@@ -1,12 +1,12 @@
 -- 事件参与记录增加完成率(已有库执行,可重复执行)
--- completion_rate = cleared_capacity_kw / declared_capacity_kw
+-- completion_rate = cleared_capacity_kw / declared_capacity_kw(申报出清容量)
 
 SET @sql = IF(
     (SELECT COUNT(*) FROM information_schema.columns
      WHERE table_schema = DATABASE()
        AND table_name = 'vpp_dr_participation'
        AND column_name = 'completion_rate') = 0,
-    'ALTER TABLE `vpp_dr_participation` ADD COLUMN `completion_rate` DECIMAL(12,4) NULL COMMENT ''完成率=出清容量/申报容量'' AFTER `cleared_capacity_kw`',
+    'ALTER TABLE `vpp_dr_participation` ADD COLUMN `completion_rate` DECIMAL(12,4) NULL COMMENT ''完成率=出清容量/申报出清容量'' AFTER `cleared_capacity_kw`',
     'SELECT 1'
 );
 PREPARE stmt FROM @sql;

+ 15 - 5
service-vpp/service-vpp-biz/src/main/resources/sql/vpp_schema.sql

@@ -426,8 +426,18 @@ CREATE TABLE `vpp_dr_event` (
     `event_type` TINYINT NULL COMMENT '1削峰 2填谷',
     `start_time` DATETIME(3) NOT NULL COMMENT '响应开始',
     `end_time` DATETIME(3) NOT NULL COMMENT '响应结束',
-    `target_capacity_kw` DECIMAL(12,4) NOT NULL COMMENT '目标容量 kW',
-    `cleared_capacity_kw` DECIMAL(12,4) NULL COMMENT '出清容量 kW',
+    `declare_deadline` DATETIME(3) NULL COMMENT '申报截止时间',
+    `invite_scope` VARCHAR(500) NULL COMMENT '邀约范围',
+    `target_capacity_kw` DECIMAL(12,4) NOT NULL COMMENT '邀约规模 kW',
+    `cleared_capacity_kw` DECIMAL(12,4) NULL COMMENT '出清规模 kW',
+    `declared_cleared_capacity_kw` DECIMAL(12,4) NULL COMMENT '申报出清容量 kW',
+    `actual_cleared_capacity_kw` DECIMAL(12,4) NULL COMMENT '实际出清 kW(电网审核通过)',
+    `estimated_response_capacity_kw` DECIMAL(12,4) NULL COMMENT '预估响应容量 kW(响应完成后本平台评估)',
+    `actual_response_capacity_kw` DECIMAL(12,4) NULL COMMENT '实际响应容量 kW(电网评估最终结果)',
+    `response_completion_rate` DECIMAL(12,4) NULL COMMENT '响应完成率=实际响应容量/邀约规模',
+    `is_winning_bid` TINYINT NULL COMMENT '是否中标 0否 1是',
+    `remark_attachment_url` VARCHAR(500) NULL COMMENT '备注附件URL',
+    `remark_attachment_name` VARCHAR(200) NULL COMMENT '备注附件名称',
     `subsidy_price` DECIMAL(10,4) NULL COMMENT '补贴标准 元/kWh',
     `event_status` TINYINT NOT NULL COMMENT '0待参与 1已申报 2执行中 3已结束 4已取消',
     `raw_payload` JSON NULL COMMENT '原始邀约报文',
@@ -449,9 +459,9 @@ CREATE TABLE `vpp_dr_participation` (
     `customer_id` BIGINT NOT NULL COMMENT '客户ID',
     `resource_id` BIGINT NULL COMMENT '资源点ID',
     `participate_status` TINYINT NOT NULL COMMENT '0待确认 1参与 2拒绝',
-    `declared_capacity_kw` DECIMAL(12,4) NULL COMMENT '申报容量',
+    `declared_capacity_kw` DECIMAL(12,4) NULL COMMENT '申报出清容量',
     `cleared_capacity_kw` DECIMAL(12,4) NULL COMMENT '出清容量',
-    `completion_rate` DECIMAL(12,4) NULL COMMENT '完成率=出清容量/申报容量',
+    `completion_rate` DECIMAL(12,4) NULL COMMENT '完成率=出清容量/申报出清容量',
     `declared_at` DATETIME(3) NULL COMMENT '申报时间',
     `tenant_id` INT NULL COMMENT '租户ID',
     `create_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
@@ -477,7 +487,7 @@ CREATE TABLE `vpp_dr_invitation` (
     `transaction_type` TINYINT NULL COMMENT '交易类型 1削峰 2填谷',
     `response_type` TINYINT NOT NULL COMMENT '1日前 2日内 3秒级',
     `demand_capacity_kw` DECIMAL(12,4) NOT NULL COMMENT '需求容量 kW',
-    `declared_capacity_kw` DECIMAL(12,4) NULL COMMENT '申报容量 kW',
+    `declared_capacity_kw` DECIMAL(12,4) NULL COMMENT '申报出清容量 kW',
     `reply_status` TINYINT NOT NULL COMMENT '0待回复 1参与 2拒绝 3超时',
     `response_status` TINYINT NOT NULL COMMENT '0待响应 1已申报 2执行中 3已结束 4已取消',
     `sms_notify_status` TINYINT NOT NULL DEFAULT 0 COMMENT '0未发送 1已发送 2发送失败',