Forráskód Böngészése

service-vpp模块数据表增加delete_flag字段

hanzhengyi 1 napja
szülő
commit
c7eca7db1a
31 módosított fájl, 311 hozzáadás és 44 törlés
  1. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppContract.java
  2. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppContractTemplate.java
  3. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppCustomer.java
  4. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppCustomerAccess.java
  5. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppCustomerContact.java
  6. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDevice.java
  7. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrEvaluation.java
  8. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrEvent.java
  9. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrExecution.java
  10. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrParticipation.java
  11. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrStrategy.java
  12. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppEnergyReadingMonthly.java
  13. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppEnergySummaryDaily.java
  14. 4 2
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppFileArchive.java
  15. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppRegistration.java
  16. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppReportData.java
  17. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppReportRecord.java
  18. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppReportTask.java
  19. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppResourcePoint.java
  20. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppResourcePointConfig.java
  21. 2 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppSettlementBill.java
  22. 7 8
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppCustomerServiceImpl.java
  23. 1 1
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrEventIngestServiceImpl.java
  24. 2 2
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrExecutionBootstrapServiceImpl.java
  25. 20 21
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrServiceImpl.java
  26. 3 3
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppUnDrSyncServiceImpl.java
  27. 4 4
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppUnIntegrationServiceImpl.java
  28. 4 3
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppUnReportServiceImpl.java
  29. 14 0
      service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/util/VppAuditHelper.java
  30. 191 0
      service-vpp/service-vpp-biz/src/main/resources/sql/vpp_delete_flag_migration.sql
  31. 21 0
      service-vpp/service-vpp-biz/src/main/resources/sql/vpp_schema.sql

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppContract.java

@@ -60,6 +60,8 @@ public class VppContract implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppContractTemplate.java

@@ -44,6 +44,8 @@ public class VppContractTemplate implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppCustomer.java

@@ -59,6 +59,8 @@ public class VppCustomer implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppCustomerAccess.java

@@ -58,6 +58,8 @@ public class VppCustomerAccess implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppCustomerContact.java

@@ -42,6 +42,8 @@ public class VppCustomerContact implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDevice.java

@@ -55,6 +55,8 @@ public class VppDevice implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrEvaluation.java

@@ -46,6 +46,8 @@ public class VppDrEvaluation implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

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

@@ -54,6 +54,8 @@ public class VppDrEvent implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrExecution.java

@@ -46,6 +46,8 @@ public class VppDrExecution implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

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

@@ -46,6 +46,8 @@ public class VppDrParticipation implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppDrStrategy.java

@@ -48,6 +48,8 @@ public class VppDrStrategy implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppEnergyReadingMonthly.java

@@ -56,6 +56,8 @@ public class VppEnergyReadingMonthly implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppEnergySummaryDaily.java

@@ -49,6 +49,8 @@ public class VppEnergySummaryDaily implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 4 - 2
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppFileArchive.java

@@ -102,13 +102,15 @@ public class VppFileArchive implements Serializable {
     /**
      * 软删除标识 0未删除 1已删除
      */
-    private Integer isDelete;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
 
     /**
      * 软删除时间
      */
+    @TableField("deleted_at")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private LocalDateTime deleteTime;
+    private LocalDateTime deletedAt;
 
     /**
      * 版本号 默认V1.0

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppRegistration.java

@@ -41,6 +41,8 @@ public class VppRegistration implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppReportData.java

@@ -39,6 +39,8 @@ public class VppReportData implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppReportRecord.java

@@ -51,6 +51,8 @@ public class VppReportRecord implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppReportTask.java

@@ -48,6 +48,8 @@ public class VppReportTask implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppResourcePoint.java

@@ -63,6 +63,8 @@ public class VppResourcePoint implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppResourcePointConfig.java

@@ -48,6 +48,8 @@ public class VppResourcePointConfig implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 2 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/domain/VppSettlementBill.java

@@ -55,6 +55,8 @@ public class VppSettlementBill implements Serializable {
     private String createdBy;
     @TableField("updated_by")
     private String updatedBy;
+    @TableField("delete_flag")
+    private Integer deleteFlag;
     @TableField("deleted_at")
     private LocalDateTime deletedAt;
 }

+ 7 - 8
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppCustomerServiceImpl.java

@@ -67,7 +67,7 @@ public class VppCustomerServiceImpl implements VppCustomerService {
     public CommonPage<VppCustomerAccess> pageAccess(Map<String, Object> params) {
         Page<VppCustomerAccess> page = VppPageHelper.of(params);
         LambdaQueryWrapper<VppCustomerAccess> wrapper = new LambdaQueryWrapper<VppCustomerAccess>()
-                .isNull(VppCustomerAccess::getDeletedAt)
+                .eq(VppCustomerAccess::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .orderByDesc(VppCustomerAccess::getApplyAt);
         if (params != null && params.get("accessStatus") != null) {
             wrapper.eq(VppCustomerAccess::getAccessStatus, Integer.parseInt(params.get("accessStatus").toString()));
@@ -80,7 +80,7 @@ public class VppCustomerServiceImpl implements VppCustomerService {
     @Transactional(rollbackFor = Exception.class)
     public void auditAccess(Long id, CustomerAccessAuditRequest request) {
         VppCustomerAccess access = accessMapper.selectById(id);
-        if (access == null || access.getDeletedAt() != null) {
+        if (access == null || VppAuditHelper.isDeleted(access.getDeleteFlag())) {
             throw new BusinessException("准入申请不存在");
         }
         if (access.getAccessStatus() != ACCESS_PENDING) {
@@ -108,7 +108,7 @@ public class VppCustomerServiceImpl implements VppCustomerService {
     public CommonPage<VppCustomer> pageCustomer(Map<String, Object> params) {
         Page<VppCustomer> page = VppPageHelper.of(params);
         LambdaQueryWrapper<VppCustomer> wrapper = new LambdaQueryWrapper<VppCustomer>()
-                .isNull(VppCustomer::getDeletedAt)
+                .eq(VppCustomer::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .orderByDesc(VppCustomer::getCreateTime);
         if (params != null) {
             if (params.get("customerName") != null) {
@@ -130,7 +130,7 @@ public class VppCustomerServiceImpl implements VppCustomerService {
     @Override
     public VppCustomer getCustomer(Long id) {
         VppCustomer customer = customerMapper.selectById(id);
-        if (customer == null || customer.getDeletedAt() != null) {
+        if (customer == null || VppAuditHelper.isDeleted(customer.getDeleteFlag())) {
             throw new BusinessException("客户不存在");
         }
         return customer;
@@ -154,7 +154,7 @@ public class VppCustomerServiceImpl implements VppCustomerService {
         Page<VppCustomerContact> page = VppPageHelper.of(params);
         LambdaQueryWrapper<VppCustomerContact> wrapper = new LambdaQueryWrapper<VppCustomerContact>()
                 .eq(VppCustomerContact::getCustomerId, customerId)
-                .isNull(VppCustomerContact::getDeletedAt)
+                .eq(VppCustomerContact::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .orderByDesc(VppCustomerContact::getIsPrimary);
         return toCommonPage(contactMapper.selectPage(page, wrapper));
     }
@@ -196,8 +196,7 @@ public class VppCustomerServiceImpl implements VppCustomerService {
     @Transactional(rollbackFor = Exception.class)
     public void deleteContact(Long customerId, Long contactId) {
         VppCustomerContact contact = getContact(customerId, contactId);
-        contact.setDeletedAt(LocalDateTime.now());
-        VppAuditHelper.fillUpdate(contact);
+        VppAuditHelper.fillSoftDelete(contact);
         contactMapper.updateById(contact);
     }
 
@@ -207,7 +206,7 @@ public class VppCustomerServiceImpl implements VppCustomerService {
 
     private VppCustomerContact getContact(Long customerId, Long contactId) {
         VppCustomerContact contact = contactMapper.selectById(contactId);
-        if (contact == null || contact.getDeletedAt() != null || !customerId.equals(contact.getCustomerId())) {
+        if (contact == null || VppAuditHelper.isDeleted(contact.getDeleteFlag()) || !customerId.equals(contact.getCustomerId())) {
             throw new BusinessException("联系人不存在");
         }
         return contact;

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

@@ -286,7 +286,7 @@ public class VppDrEventIngestServiceImpl implements VppDrEventIngestService {
     private VppDrEvent findByPlatformEventId(String platformEventId) {
         return eventMapper.selectOne(new LambdaQueryWrapper<VppDrEvent>()
                 .eq(VppDrEvent::getEventId, platformEventId)
-                .isNull(VppDrEvent::getDeletedAt)
+                .eq(VppDrEvent::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .last("LIMIT 1"));
     }
 

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

@@ -39,7 +39,7 @@ public class VppDrExecutionBootstrapServiceImpl implements VppDrExecutionBootstr
         }
         long existing = executionMapper.selectCount(new LambdaQueryWrapper<VppDrExecution>()
                 .eq(VppDrExecution::getEventId, event.getId())
-                .isNull(VppDrExecution::getDeletedAt));
+                .eq(VppDrExecution::getDeleteFlag, VppAuditHelper.NOT_DELETED));
         if (existing > 0) {
             return;
         }
@@ -48,7 +48,7 @@ public class VppDrExecutionBootstrapServiceImpl implements VppDrExecutionBootstr
                 new LambdaQueryWrapper<VppDrParticipation>()
                         .eq(VppDrParticipation::getEventId, event.getId())
                         .eq(VppDrParticipation::getParticipateStatus, PARTICIPATE_STATUS_ACCEPT)
-                        .isNull(VppDrParticipation::getDeletedAt));
+                        .eq(VppDrParticipation::getDeleteFlag, VppAuditHelper.NOT_DELETED));
         LocalDateTime now = LocalDateTime.now();
         int created = 0;
         for (VppDrParticipation participation : participations) {

+ 20 - 21
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppDrServiceImpl.java

@@ -77,7 +77,7 @@ public class VppDrServiceImpl implements VppDrService {
     public CommonPage<VppDrEvent> pageEvent(Map<String, Object> params) {
         Page<VppDrEvent> page = VppPageHelper.of(params);
         LambdaQueryWrapper<VppDrEvent> wrapper = new LambdaQueryWrapper<VppDrEvent>()
-                .isNull(VppDrEvent::getDeletedAt)
+                .eq(VppDrEvent::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .orderByDesc(VppDrEvent::getStartTime);
 
         if (params != null) {
@@ -105,7 +105,7 @@ public class VppDrServiceImpl implements VppDrService {
     @Override
     public VppDrEvent getEvent(Long id) {
         VppDrEvent event = eventMapper.selectById(id);
-        if (event == null || event.getDeletedAt() != null) {
+        if (event == null || VppAuditHelper.isDeleted(event.getDeleteFlag())) {
             throw new BusinessException("需求响应事件不存在");
         }
         return event;
@@ -116,7 +116,7 @@ public class VppDrServiceImpl implements VppDrService {
         VppDrEvent event = getEvent(eventId);
 
         LambdaQueryWrapper<VppResourcePoint> resourceWrapper = new LambdaQueryWrapper<VppResourcePoint>()
-                .isNull(VppResourcePoint::getDeletedAt)
+                .eq(VppResourcePoint::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .eq(VppResourcePoint::getRunStatus, 1);
 
         List<VppResourcePoint> resources = resourcePointMapper.selectList(resourceWrapper);
@@ -172,7 +172,7 @@ public class VppDrServiceImpl implements VppDrService {
                 new LambdaQueryWrapper<VppDrParticipation>()
                         .eq(VppDrParticipation::getEventId, eventId)
                         .eq(VppDrParticipation::getParticipateStatus, PARTICIPATE_STATUS_ACCEPT)
-                        .isNull(VppDrParticipation::getDeletedAt)
+                        .eq(VppDrParticipation::getDeleteFlag, VppAuditHelper.NOT_DELETED)
         );
 
         if (!existingParticipations.isEmpty()) {
@@ -197,7 +197,7 @@ public class VppDrServiceImpl implements VppDrService {
                     throw new BusinessException("资源申报容量必须大于0");
                 }
                 VppResourcePoint rp = resourcePointMapper.selectById(resource.getResourceId());
-                if (rp == null || rp.getDeletedAt() != null) {
+                if (rp == null || VppAuditHelper.isDeleted(rp.getDeleteFlag())) {
                     throw new BusinessException("资源点不存在");
                 }
                 if (rp.getRunStatus() != 1) {
@@ -267,7 +267,7 @@ public class VppDrServiceImpl implements VppDrService {
         long existingExecCount = executionMapper.selectCount(
                 new LambdaQueryWrapper<VppDrExecution>()
                         .eq(VppDrExecution::getEventId, eventId)
-                        .isNull(VppDrExecution::getDeletedAt)
+                        .eq(VppDrExecution::getDeleteFlag, VppAuditHelper.NOT_DELETED)
         );
         if (existingExecCount > 0) {
             throw new BusinessException("已出清,请勿重复操作");
@@ -293,7 +293,7 @@ public class VppDrServiceImpl implements VppDrService {
                     .eq(VppDrParticipation::getEventId, eventId)
                     .eq(VppDrParticipation::getResourceId, resource.getResourceId())
                     .eq(VppDrParticipation::getParticipateStatus, PARTICIPATE_STATUS_ACCEPT)
-                    .isNull(VppDrParticipation::getDeletedAt);
+                    .eq(VppDrParticipation::getDeleteFlag, VppAuditHelper.NOT_DELETED);
 
             VppDrParticipation participation = participationMapper.selectOne(wrapper);
             if (participation == null) {
@@ -343,7 +343,7 @@ public class VppDrServiceImpl implements VppDrService {
         List<VppDrExecution> executions = executionMapper.selectList(
                 new LambdaQueryWrapper<VppDrExecution>()
                         .eq(VppDrExecution::getEventId, eventId)
-                        .isNull(VppDrExecution::getDeletedAt)
+                        .eq(VppDrExecution::getDeleteFlag, VppAuditHelper.NOT_DELETED)
         );
 
         BigDecimal totalTarget = BigDecimal.ZERO;
@@ -398,7 +398,7 @@ public class VppDrServiceImpl implements VppDrService {
         List<VppDrExecution> executions = executionMapper.selectList(
                 new LambdaQueryWrapper<VppDrExecution>()
                         .eq(VppDrExecution::getEventId, eventId)
-                        .isNull(VppDrExecution::getDeletedAt)
+                        .eq(VppDrExecution::getDeleteFlag, VppAuditHelper.NOT_DELETED)
         );
         if (executions.isEmpty()) {
             throw new BusinessException("暂无执行明细,无法干预");
@@ -409,7 +409,7 @@ public class VppDrServiceImpl implements VppDrService {
                 throw new BusinessException("切换策略时必须指定策略ID");
             }
             VppDrStrategy strategy = strategyMapper.selectById(request.getStrategyId());
-            if (strategy == null || strategy.getDeletedAt() != null) {
+            if (strategy == null || VppAuditHelper.isDeleted(strategy.getDeleteFlag())) {
                 throw new BusinessException("策略不存在");
             }
             if (strategy.getIsEnabled() != null && strategy.getIsEnabled() == 0) {
@@ -451,7 +451,7 @@ public class VppDrServiceImpl implements VppDrService {
         List<VppDrExecution> executions = executionMapper.selectList(
                 new LambdaQueryWrapper<VppDrExecution>()
                         .eq(VppDrExecution::getEventId, eventId)
-                        .isNull(VppDrExecution::getDeletedAt)
+                        .eq(VppDrExecution::getDeleteFlag, VppAuditHelper.NOT_DELETED)
         );
         if (executions.isEmpty()) {
             throw new BusinessException("暂无执行明细,无法结束事件");
@@ -479,7 +479,7 @@ public class VppDrServiceImpl implements VppDrService {
         VppDrEvaluation evaluation = evaluationMapper.selectOne(
                 new LambdaQueryWrapper<VppDrEvaluation>()
                         .eq(VppDrEvaluation::getEventId, eventId)
-                        .isNull(VppDrEvaluation::getDeletedAt)
+                        .eq(VppDrEvaluation::getDeleteFlag, VppAuditHelper.NOT_DELETED)
         );
         if (evaluation == null) {
             evaluation = new VppDrEvaluation();
@@ -523,7 +523,7 @@ public class VppDrServiceImpl implements VppDrService {
 
         LambdaQueryWrapper<VppDrEvaluation> wrapper = new LambdaQueryWrapper<VppDrEvaluation>()
                 .eq(VppDrEvaluation::getEventId, eventId)
-                .isNull(VppDrEvaluation::getDeletedAt);
+                .eq(VppDrEvaluation::getDeleteFlag, VppAuditHelper.NOT_DELETED);
 
         VppDrEvaluation evaluation = evaluationMapper.selectOne(wrapper);
         if (evaluation == null) {
@@ -536,7 +536,7 @@ public class VppDrServiceImpl implements VppDrService {
     public CommonPage<VppDrStrategy> pageStrategy(Map<String, Object> params) {
         Page<VppDrStrategy> page = VppPageHelper.of(params);
         LambdaQueryWrapper<VppDrStrategy> wrapper = new LambdaQueryWrapper<VppDrStrategy>()
-                .isNull(VppDrStrategy::getDeletedAt)
+                .eq(VppDrStrategy::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .orderByDesc(VppDrStrategy::getCreateTime);
 
         if (params != null) {
@@ -576,7 +576,7 @@ public class VppDrServiceImpl implements VppDrService {
             LambdaQueryWrapper<VppDrStrategy> wrapper = new LambdaQueryWrapper<VppDrStrategy>()
                     .ne(VppDrStrategy::getId, strategy.getId())
                     .eq(VppDrStrategy::getIsDefault, 1)
-                    .isNull(VppDrStrategy::getDeletedAt);
+                    .eq(VppDrStrategy::getDeleteFlag, VppAuditHelper.NOT_DELETED);
 
             List<VppDrStrategy> defaults = strategyMapper.selectList(wrapper);
             for (VppDrStrategy def : defaults) {
@@ -604,7 +604,7 @@ public class VppDrServiceImpl implements VppDrService {
     @Transactional(rollbackFor = Exception.class)
     public void updateStrategy(Long id, DrStrategyRequest request) {
         VppDrStrategy strategy = strategyMapper.selectById(id);
-        if (strategy == null || strategy.getDeletedAt() != null) {
+        if (strategy == null || VppAuditHelper.isDeleted(strategy.getDeleteFlag())) {
             throw new BusinessException("策略不存在");
         }
 
@@ -629,7 +629,7 @@ public class VppDrServiceImpl implements VppDrService {
             LambdaQueryWrapper<VppDrStrategy> wrapper = new LambdaQueryWrapper<VppDrStrategy>()
                     .ne(VppDrStrategy::getId, id)
                     .eq(VppDrStrategy::getIsDefault, 1)
-                    .isNull(VppDrStrategy::getDeletedAt);
+                    .eq(VppDrStrategy::getDeleteFlag, VppAuditHelper.NOT_DELETED);
 
             List<VppDrStrategy> defaults = strategyMapper.selectList(wrapper);
             for (VppDrStrategy def : defaults) {
@@ -661,12 +661,11 @@ public class VppDrServiceImpl implements VppDrService {
     @Transactional(rollbackFor = Exception.class)
     public void deleteStrategy(Long id) {
         VppDrStrategy strategy = strategyMapper.selectById(id);
-        if (strategy == null || strategy.getDeletedAt() != null) {
+        if (strategy == null || VppAuditHelper.isDeleted(strategy.getDeleteFlag())) {
             throw new BusinessException("策略不存在");
         }
 
-        strategy.setDeletedAt(LocalDateTime.now());
-        VppAuditHelper.fillUpdate(strategy);
+        VppAuditHelper.fillSoftDelete(strategy);
         strategyMapper.updateById(strategy);
 
         strategyResourceMapper.delete(new LambdaQueryWrapper<VppDrStrategyResource>()
@@ -692,7 +691,7 @@ public class VppDrServiceImpl implements VppDrService {
                     throw new BusinessException("策略资源ID不能为空");
                 }
                 VppResourcePoint rp = resourcePointMapper.selectById(resource.getResourceId());
-                if (rp == null || rp.getDeletedAt() != null) {
+                if (rp == null || VppAuditHelper.isDeleted(rp.getDeleteFlag())) {
                     throw new BusinessException("策略关联的资源点不存在");
                 }
             }

+ 3 - 3
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppUnDrSyncServiceImpl.java

@@ -65,7 +65,7 @@ public class VppUnDrSyncServiceImpl implements VppUnDrSyncService {
 
         VppCustomer customer = customerMapper.selectOne(new LambdaQueryWrapper<VppCustomer>()
                 .eq(VppCustomer::getAccountNo, account)
-                .isNull(VppCustomer::getDeletedAt)
+                .eq(VppCustomer::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .last("LIMIT 1"));
         if (customer == null) {
             return;
@@ -73,14 +73,14 @@ public class VppUnDrSyncServiceImpl implements VppUnDrSyncService {
 
         VppResourcePoint resourcePoint = resourcePointMapper.selectOne(new LambdaQueryWrapper<VppResourcePoint>()
                 .eq(VppResourcePoint::getCustomerId, customer.getId())
-                .isNull(VppResourcePoint::getDeletedAt)
+                .eq(VppResourcePoint::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .last("LIMIT 1"));
 
         Long resourceId = resourcePoint != null ? resourcePoint.getId() : null;
         LambdaQueryWrapper<VppDrParticipation> wrapper = new LambdaQueryWrapper<VppDrParticipation>()
                 .eq(VppDrParticipation::getEventId, event.getId())
                 .eq(VppDrParticipation::getCustomerId, customer.getId())
-                .isNull(VppDrParticipation::getDeletedAt);
+                .eq(VppDrParticipation::getDeleteFlag, VppAuditHelper.NOT_DELETED);
         if (resourceId != null) {
             wrapper.eq(VppDrParticipation::getResourceId, resourceId);
         }

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

@@ -67,7 +67,7 @@ public class VppUnIntegrationServiceImpl implements VppUnIntegrationService {
         }
         VppRegistration registration = registrationMapper.selectOne(new LambdaQueryWrapper<VppRegistration>()
                 .eq(VppRegistration::getDnId, properties.getDnId())
-                .isNull(VppRegistration::getDeletedAt)
+                .eq(VppRegistration::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .orderByDesc(VppRegistration::getRegisteredAt)
                 .last("LIMIT 1"));
         if (registration != null && StringUtils.hasText(registration.getRegistrationId())) {
@@ -199,7 +199,7 @@ public class VppUnIntegrationServiceImpl implements VppUnIntegrationService {
                 new LambdaQueryWrapper<VppDrParticipation>()
                         .eq(VppDrParticipation::getEventId, eventId)
                         .eq(VppDrParticipation::getParticipateStatus, PARTICIPATE_STATUS_ACCEPT)
-                        .isNull(VppDrParticipation::getDeletedAt));
+                        .eq(VppDrParticipation::getDeleteFlag, VppAuditHelper.NOT_DELETED));
         List<Map<String, Object>> list = new ArrayList<>();
         for (VppDrParticipation participation : participations) {
             VppCustomer customer = customerMapper.selectById(participation.getCustomerId());
@@ -225,7 +225,7 @@ public class VppUnIntegrationServiceImpl implements VppUnIntegrationService {
 
         VppRegistration existing = registrationMapper.selectOne(new LambdaQueryWrapper<VppRegistration>()
                 .eq(VppRegistration::getDnId, properties.getDnId())
-                .isNull(VppRegistration::getDeletedAt)
+                .eq(VppRegistration::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                 .last("LIMIT 1"));
         if (existing == null) {
             existing = new VppRegistration();
@@ -245,7 +245,7 @@ public class VppUnIntegrationServiceImpl implements VppUnIntegrationService {
 
     private VppDrEvent requireEvent(Long eventId) {
         VppDrEvent event = eventMapper.selectById(eventId);
-        if (event == null || event.getDeletedAt() != null) {
+        if (event == null || VppAuditHelper.isDeleted(event.getDeleteFlag())) {
             throw new BusinessException("需求响应事件不存在");
         }
         if (!StringUtils.hasText(event.getEventId())) {

+ 4 - 3
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/service/impl/VppUnReportServiceImpl.java

@@ -1,5 +1,6 @@
 package com.usky.vpp.service.impl;
 
+import com.usky.vpp.util.VppAuditHelper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.usky.vpp.client.VppUnClient;
 import com.usky.vpp.config.VppUnProperties;
@@ -62,7 +63,7 @@ public class VppUnReportServiceImpl implements VppUnReportService {
     private void submitRegisterReport() {
         List<VppResourcePoint> resources = resourcePointMapper.selectList(
                 new LambdaQueryWrapper<VppResourcePoint>()
-                        .isNull(VppResourcePoint::getDeletedAt)
+                        .eq(VppResourcePoint::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                         .orderByAsc(VppResourcePoint::getId));
         Map<String, Object> request = VppUnMessageBuilder.buildRegisterReportRequest(resources, properties);
         unClient.post("RegisterReportRequest", request, true);
@@ -72,7 +73,7 @@ public class VppUnReportServiceImpl implements VppUnReportService {
     private void submitIntervalDataReport(Map<String, Object> createReportRequest) {
         List<VppResourcePoint> resources = resourcePointMapper.selectList(
                 new LambdaQueryWrapper<VppResourcePoint>()
-                        .isNull(VppResourcePoint::getDeletedAt)
+                        .eq(VppResourcePoint::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                         .eq(VppResourcePoint::getRunStatus, 1)
                         .orderByAsc(VppResourcePoint::getId));
         Map<String, Object> request = VppUnMessageBuilder.buildIntervalDataReportRequest(
@@ -84,7 +85,7 @@ public class VppUnReportServiceImpl implements VppUnReportService {
     private void submitMomentDataReport(Map<String, Object> createReportRequest) {
         List<VppResourcePoint> resources = resourcePointMapper.selectList(
                 new LambdaQueryWrapper<VppResourcePoint>()
-                        .isNull(VppResourcePoint::getDeletedAt)
+                        .eq(VppResourcePoint::getDeleteFlag, VppAuditHelper.NOT_DELETED)
                         .eq(VppResourcePoint::getRunStatus, 1)
                         .orderByAsc(VppResourcePoint::getId));
         Map<String, Object> request = VppUnMessageBuilder.buildMomentDataReportRequest(

+ 14 - 0
service-vpp/service-vpp-biz/src/main/java/com/usky/vpp/util/VppAuditHelper.java

@@ -12,6 +12,9 @@ import java.util.UUID;
  */
 public final class VppAuditHelper {
 
+    public static final int NOT_DELETED = 0;
+    public static final int DELETED = 1;
+
     private VppAuditHelper() {
     }
 
@@ -19,6 +22,7 @@ public final class VppAuditHelper {
         LocalDateTime now = LocalDateTime.now();
         invokeSetter(entity, "setCreateTime", now);
         invokeSetter(entity, "setUpdateTime", now);
+        invokeSetter(entity, "setDeleteFlag", NOT_DELETED);
         String auditUser = currentUsername();
         if (StringUtils.hasText(auditUser)) {
             invokeSetter(entity, "setCreatedBy", auditUser);
@@ -38,6 +42,16 @@ public final class VppAuditHelper {
         }
     }
 
+    public static void fillSoftDelete(Object entity) {
+        invokeSetter(entity, "setDeleteFlag", DELETED);
+        invokeSetter(entity, "setDeletedAt", LocalDateTime.now());
+        fillUpdate(entity);
+    }
+
+    public static boolean isDeleted(Integer deleteFlag) {
+        return deleteFlag != null && deleteFlag == DELETED;
+    }
+
     public static String nextApplyNo() {
         return "ACC" + System.currentTimeMillis() + UUID.randomUUID().toString().substring(0, 4).toUpperCase();
     }

+ 191 - 0
service-vpp/service-vpp-biz/src/main/resources/sql/vpp_delete_flag_migration.sql

@@ -0,0 +1,191 @@
+-- VPP 软删除标识字段(已有库执行,可重复执行)
+-- 含 deleted_at 的表新增 delete_flag INT(1) NOT NULL DEFAULT 0
+
+-- vpp_customer
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_customer` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_customer.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_customer` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_customer_access
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer_access' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_customer_access` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_customer_access.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_customer_access` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_customer_contact
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer_contact' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_customer_contact` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_customer_contact.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_customer_contact` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_contract
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_contract' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_contract` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_contract.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_contract` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_contract_template
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_contract_template' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_contract_template` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_contract_template.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_contract_template` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_resource_point
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_resource_point' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_resource_point` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_resource_point.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_resource_point` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_resource_point_config
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_resource_point_config' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_resource_point_config` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_resource_point_config.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_resource_point_config` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_device
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_device' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_device` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_device.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_device` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_energy_reading_monthly
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_energy_reading_monthly' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_energy_reading_monthly` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_energy_reading_monthly.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_energy_reading_monthly` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_energy_summary_daily
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_energy_summary_daily' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_energy_summary_daily` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_energy_summary_daily.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_energy_summary_daily` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_settlement_bill
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_settlement_bill' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_settlement_bill` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_settlement_bill.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_settlement_bill` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_report_task
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_task' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_report_task` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_report_task.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_report_task` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_report_record
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_record' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_report_record` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_report_record.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_report_record` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_report_data
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_data' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_report_data` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_report_data.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_report_data` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_dr_event
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_event' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_dr_event` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_dr_event.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_dr_event` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_dr_participation
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_participation' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_dr_participation` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_dr_participation.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_dr_participation` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_dr_strategy
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_strategy' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_dr_strategy` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_dr_strategy.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_dr_strategy` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_dr_execution
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_execution' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_dr_execution` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_dr_execution.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_dr_execution` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_dr_evaluation
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_evaluation' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_dr_evaluation` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_dr_evaluation.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_dr_evaluation` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_registration
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_registration' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_registration` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_registration.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_registration` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;
+
+-- vpp_file_archive
+SET @sql = IF(
+    (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_file_archive' AND column_name = 'delete_flag') = 0,
+    'ALTER TABLE `vpp_file_archive` ADD COLUMN `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT ''删除标识 0未删除 1已删除'' AFTER `updated_by`',
+    'SELECT ''skip: vpp_file_archive.delete_flag exists'''
+);
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+UPDATE `vpp_file_archive` SET `delete_flag` = 1 WHERE `deleted_at` IS NOT NULL AND `delete_flag` = 0;

+ 21 - 0
service-vpp/service-vpp-biz/src/main/resources/sql/vpp_schema.sql

@@ -24,6 +24,7 @@ CREATE TABLE `vpp_customer` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_customer_account_no` (account_no),
@@ -51,6 +52,7 @@ CREATE TABLE `vpp_customer_access` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_access_apply_no` (apply_no),
@@ -70,6 +72,7 @@ CREATE TABLE `vpp_customer_contact` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     KEY `idx_contact_customer` (customer_id)
@@ -96,6 +99,7 @@ CREATE TABLE `vpp_contract` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_contract_no` (contract_no),
@@ -117,6 +121,7 @@ CREATE TABLE `vpp_contract_template` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_template_code` (template_code)
@@ -160,6 +165,7 @@ CREATE TABLE `vpp_resource_point` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_resource_code` (resource_code),
@@ -182,6 +188,7 @@ CREATE TABLE `vpp_resource_point_config` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_config_resource` (resource_id)
@@ -207,6 +214,7 @@ CREATE TABLE `vpp_device` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_device_code` (device_code),
@@ -247,6 +255,7 @@ CREATE TABLE `vpp_energy_reading_monthly` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_energy_monthly` (customer_id, resource_id, settle_year, settle_month),
@@ -268,6 +277,7 @@ CREATE TABLE `vpp_energy_summary_daily` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_summary_daily` (summary_date, resource_id),
@@ -292,6 +302,7 @@ CREATE TABLE `vpp_settlement_bill` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_bill_no` (bill_no),
@@ -342,6 +353,7 @@ CREATE TABLE `vpp_report_task` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_report_task_no` (task_no),
@@ -365,6 +377,7 @@ CREATE TABLE `vpp_report_record` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_report_record_no` (record_no),
@@ -383,6 +396,7 @@ CREATE TABLE `vpp_report_data` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_report_data_record` (record_id)
@@ -420,6 +434,7 @@ CREATE TABLE `vpp_dr_event` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_dr_event_id` (event_id),
@@ -440,6 +455,7 @@ CREATE TABLE `vpp_dr_participation` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     KEY `idx_dr_part_event` (event_id),
@@ -461,6 +477,7 @@ CREATE TABLE `vpp_dr_strategy` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_dr_strategy_code` (strategy_code)
@@ -492,6 +509,7 @@ CREATE TABLE `vpp_dr_execution` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     KEY `idx_dr_exec_event` (event_id),
@@ -512,6 +530,7 @@ CREATE TABLE `vpp_dr_evaluation` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_dr_eval_event` (event_id)
@@ -529,6 +548,7 @@ CREATE TABLE `vpp_registration` (
     `update_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     `created_by` VARCHAR(30) NULL COMMENT '创建人',
     `updated_by` VARCHAR(30) NULL COMMENT '更新人',
+    `delete_flag` INT(1) NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     `deleted_at` DATETIME(3) NULL COMMENT '软删除时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uk_vpp_dn_id` (dn_id)
@@ -562,6 +582,7 @@ CREATE TABLE vpp_file_archive (
     update_time DATETIME(3)    NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
     created_by  VARCHAR(30)    NULL COMMENT '上传人',
     updated_by  VARCHAR(30)    NULL COMMENT '更新人',
+    delete_flag INT(1)         NOT NULL DEFAULT 0 COMMENT '删除标识 0未删除 1已删除',
     deleted_at  DATETIME(3)    NULL COMMENT '软删除时间',
     PRIMARY KEY (id),
     KEY idx_file_archive_biz (biz_type, biz_id)