diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java index c17a9ca..e16659a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java @@ -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; /** *

@@ -87,10 +86,7 @@ public class TenderStateMachineBuilderImpl implements BaseStateMachineBuilder { - Purchase purchase = TenderStateChangeAction.getPurchaseInfo(ctx.getMessage()); - return !BidTypeEnum.BUILD_APP.eq(purchase.getBidType()); - }) + .guard(new TenderGuardFactory.PurchaseContractRecordGuard()) .and() // 填写实施计划 .withExternal() diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectDeclareGuardFactory.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectDeclareGuardFactory.java deleted file mode 100644 index e3a5b97..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectDeclareGuardFactory.java +++ /dev/null @@ -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 { - @Override - public boolean evaluate(StateContext context) { - // 判断申报项目是否是市级项目,且申报金额是否大于等于1000万元 - return true; - } - } - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java new file mode 100644 index 0000000..bb00188 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java @@ -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; + +/** + *

+ * TenderGuardFactory + *

+ * + * @author WendyYang + * @since 17:51 2024/8/20 + */ +public class TenderGuardFactory { + + private TenderGuardFactory() { + } + + public static class PurchaseContractRecordGuard implements Guard { + @Override + public boolean evaluate(StateContext context) { + Purchase purchase = TenderStateChangeAction.getPurchaseInfo(context.getMessage()); + return !BidTypeEnum.BUILD_APP.eq(purchase.getBidType()); + } + } + +}