Browse Source

modify:

1. guard提取;
tags/24082201
WendyYang 4 months ago
parent
commit
f97daecb5b
3 changed files with 36 additions and 35 deletions
  1. +4
    -8
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java
  2. +0
    -27
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectDeclareGuardFactory.java
  3. +32
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java

+ 4
- 8
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java View File

@@ -1,12 +1,10 @@
package com.hz.pm.api.common.statemachine.builder.impl;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.EnumUtil;
import com.hz.pm.api.common.statemachine.action.TenderStateChangeAction;
import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder;
import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent;
import com.hz.pm.api.common.statemachine.factory.TenderGuardFactory;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectdeclared.model.enumerization.BidTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.status.ITenderStatus;
import com.hz.pm.api.projectlib.model.enumeration.status.TenderAdaptStatus;
import com.hz.pm.api.projectlib.model.enumeration.status.TenderMainStatus;
@@ -25,7 +23,8 @@ import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.HashSet;
import java.util.List;

/**
* <p>
@@ -87,10 +86,7 @@ public class TenderStateMachineBuilderImpl implements BaseStateMachineBuilder<Pu
.source(TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO)
.target(TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO)
.event(TenderStateChangeEvent.SUBMIT_PURCHASE_CONSTRUCTION_INFO)
.guard(ctx -> {
Purchase purchase = TenderStateChangeAction.getPurchaseInfo(ctx.getMessage());
return !BidTypeEnum.BUILD_APP.eq(purchase.getBidType());
})
.guard(new TenderGuardFactory.PurchaseContractRecordGuard())
.and()
// 填写实施计划
.withExternal()


+ 0
- 27
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectDeclareGuardFactory.java View File

@@ -1,27 +0,0 @@
package com.hz.pm.api.common.statemachine.factory;

import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.guard.Guard;

/**
* 项目申报状态机guard集合类
*
* @author CMM
* @since 2023/02/07 16:18
*/
public class ProjectDeclareGuardFactory {

private ProjectDeclareGuardFactory() {
}

public static class PendingPreQualificationChoiceGuard implements Guard<ProjectStatus, ProjectStateChangeEvent> {
@Override
public boolean evaluate(StateContext<ProjectStatus, ProjectStateChangeEvent> context) {
// 判断申报项目是否是市级项目,且申报金额是否大于等于1000万元
return true;
}
}

}

+ 32
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java View File

@@ -0,0 +1,32 @@
package com.hz.pm.api.common.statemachine.factory;

import com.hz.pm.api.common.statemachine.action.TenderStateChangeAction;
import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectdeclared.model.enumerization.BidTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.status.ITenderStatus;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.guard.Guard;

/**
* <p>
* TenderGuardFactory
* </p>
*
* @author WendyYang
* @since 17:51 2024/8/20
*/
public class TenderGuardFactory {

private TenderGuardFactory() {
}

public static class PurchaseContractRecordGuard implements Guard<ITenderStatus, TenderStateChangeEvent> {
@Override
public boolean evaluate(StateContext<ITenderStatus, TenderStateChangeEvent> context) {
Purchase purchase = TenderStateChangeAction.getPurchaseInfo(context.getMessage());
return !BidTypeEnum.BUILD_APP.eq(purchase.getBidType());
}
}

}

Loading…
Cancel
Save