diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/AdaptAction.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/AdaptStateChangeAction.java similarity index 95% rename from hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/AdaptAction.java rename to hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/AdaptStateChangeAction.java index 5a9796f..0687b19 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/AdaptAction.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/AdaptStateChangeAction.java @@ -2,7 +2,6 @@ package com.hz.pm.api.common.statemachine.action; import cn.hutool.core.lang.Assert; import com.hz.pm.api.common.statemachine.builder.impl.AdaptStateMachineBuilderImpl; -import com.hz.pm.api.common.statemachine.builder.impl.TestValidStateMachineBuilderImpl; import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent; import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; import com.hz.pm.api.projectdeclared.model.entity.Purchase; @@ -22,7 +21,7 @@ import org.springframework.statemachine.annotation.WithStateMachine; */ @Slf4j @WithStateMachine(id = AdaptStateMachineBuilderImpl.MACHINE_ID) -public class AdaptAction { +public class AdaptStateChangeAction { private Purchase getPurchaseInfo(Message message) { Purchase purchase = (Purchase) message.getHeaders().get(TenderStateMachineUtil.PURCHASE); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareActionChoice.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareActionChoice.java index 5a830ba..cd8f468 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareActionChoice.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareActionChoice.java @@ -5,7 +5,7 @@ import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.toolkit.Assert; import com.hz.pm.api.common.model.constant.StateMachineConst; import com.hz.pm.api.common.enumeration.CommonEnum; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectApplication; @@ -24,12 +24,12 @@ import static com.hz.pm.api.common.model.constant.StateMachineConst.APPLICATION_ * @since 2023/02/07 22:31 */ @Slf4j -public class ProjectDeclareActionChoice implements Action { +public class ProjectDeclareActionChoice implements Action { private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE; @Override - public void execute(StateContext stateContext) { + public void execute(StateContext stateContext) { log.info(String.valueOf(stateContext.getTarget().getId())); ProjectStatusEnum projectStatusEnum = stateContext.getTarget().getId(); switch (projectStatusEnum) { @@ -47,7 +47,7 @@ public class ProjectDeclareActionChoice implements Action stateContext) { + private void approvedAfterChoice(StateContext stateContext) { Project project = getProject(stateContext); List projectApplications = getProjectApplication(stateContext); log.info("立项批复之后,项目的状态为:{}", project.getStatus()); @@ -72,26 +72,26 @@ public class ProjectDeclareActionChoice implements Action stateContext) { + private void preDeclareChoice(StateContext stateContext) { Project project = getProject(stateContext); log.info("预审申报事件之前,项目的状态为:{}", project.getStatus()); project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode()); } - private void preWithDrawChoice(StateContext stateContext) { + private void preWithDrawChoice(StateContext stateContext) { Project project = getProject(stateContext); log.info("预审中撤回事件之前,项目的状态为:{}", project.getStatus()); project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()); } - private Project getProject(StateContext stateContext) { + private Project getProject(StateContext stateContext) { Project project = stateContext.getMessage().getHeaders().get(PROJECT_DECLARE, Project.class); Assert.notNull(project, "项目信息获取失败%s", JSONUtil.toJsonStr(stateContext.getMessage())); return project; } @SuppressWarnings("unchecked") - private List getProjectApplication(StateContext stateContext) { + private List getProjectApplication(StateContext stateContext) { return stateContext.getMessage().getHeaders().get(APPLICATION_DECLARE, List.class); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareAction.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectStateChangeAction.java similarity index 82% rename from hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareAction.java rename to hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectStateChangeAction.java index 00be560..0d3e723 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareAction.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectStateChangeAction.java @@ -2,8 +2,8 @@ package com.hz.pm.api.common.statemachine.action; import cn.hutool.core.lang.Assert; import com.hz.pm.api.common.model.constant.StateMachineConst; -import com.hz.pm.api.common.statemachine.builder.impl.ProjectDeclareStateMachineBuilderImpl; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.builder.impl.ProjectStateMachineBuilderImpl; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import lombok.extern.slf4j.Slf4j; @@ -18,180 +18,180 @@ import org.springframework.statemachine.annotation.WithStateMachine; * @since 2023/02/08 13:48 */ @Slf4j -@WithStateMachine(id = ProjectDeclareStateMachineBuilderImpl.MACHINE_ID) -public class ProjectDeclareAction { +@WithStateMachine(id = ProjectStateMachineBuilderImpl.MACHINE_ID) +public class ProjectStateChangeAction { private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE; - private Project getProject(Message message) { + private Project getProject(Message message) { Project project = (Project) message.getHeaders().get(PROJECT_DECLARE); Assert.notNull(project, "未获取到需要状态变更的项目信息"); return project; } @OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION") - public void UNDER_INTERNAL_PASS(Message message) { + public void UNDER_INTERNAL_PASS(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()); } @OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS") - public void UNDER_INTERNAL_REJECT(Message message) { + public void UNDER_INTERNAL_REJECT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode()); } @OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED") - public void UNDER_INTERNAL_WITHDRAW(Message message) { + public void UNDER_INTERNAL_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode()); } @OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT") - public void UNDER_INTERNAL_REJECT_RESUBMIT(Message message) { + public void UNDER_INTERNAL_REJECT_RESUBMIT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode()); } @OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE") - public void PRELIMINARY_REVIEW_DECLARE(Message message) { + public void PRELIMINARY_REVIEW_DECLARE(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode()); } @OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT") - public void PENDING_PREQUALIFICATION_WITHDRAW(Message message) { + public void PENDING_PREQUALIFICATION_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode()); } @OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS") - public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message message) { + public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode()); } @OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING") - public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message message) { + public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode()); } @OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED") - public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message message) { + public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode()); } @OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION") - public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message message) { + public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()); } @OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW") - public void PRELIMINARY_REVIEW_PASS(Message message) { + public void PRELIMINARY_REVIEW_PASS(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode()); } @OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED") - public void PRELIMINARY_REVIEW_REJECT(Message message) { + public void PRELIMINARY_REVIEW_REJECT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode()); } @OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE") - public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message message) { + public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode()); } @OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE") - public void PRE_APPLYING_WITHDRAW(Message message) { + public void PRE_APPLYING_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode()); } @OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN") - public void DEPARTMENT_UNITED_REVIEW_PASS(Message message) { + public void DEPARTMENT_UNITED_REVIEW_PASS(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode()); } @OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED") - public void DEPARTMENT_UNITED_REVIEW_REJECT(Message message) { + public void DEPARTMENT_UNITED_REVIEW_REJECT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode()); } @OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING") - public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message message) { + public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode()); } @OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED") - public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message message) { + public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode()); } @OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED") - public void ANNUAL_PLAN_SUSPEND(Message message) { + public void ANNUAL_PLAN_SUSPEND(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode()); } @OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW") - public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message message) { + public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode()); } @OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW") - public void DECLARE_PLAN(Message message) { + public void DECLARE_PLAN(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode()); } @OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN") - public void PLAN_TO_DECLARE_WITHDRAW(Message message) { + public void PLAN_TO_DECLARE_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode()); } @OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW") - public void DECLARE_PLAN_RESUBMIT(Message message) { + public void DECLARE_PLAN_RESUBMIT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode()); } @OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED") - public void PLAN_REVIEW_PASS(Message message) { + public void PLAN_REVIEW_PASS(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode()); } @OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED") - public void PLAN_REVIEW_REJECT(Message message) { + public void PLAN_REVIEW_REJECT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode()); } @OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW") - public void PLAN_REVIEW_REJECT_RESUBMIT(Message message) { + public void PLAN_REVIEW_REJECT_RESUBMIT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode()); } @OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED") - public void SCHEME_UNDER_REVIEW_WITHDRAW(Message message) { + public void SCHEME_UNDER_REVIEW_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode()); } @@ -199,20 +199,20 @@ public class ProjectDeclareAction { //================================================================================================================== @OnTransition(source = "DECLARED_APPROVED_TO_BE_RECORD", target = "DECLARED_APPROVED_RECORD_AUDITING") - public void DECLARED_RECORD_SUBMIT(Message message) { + public void DECLARED_RECORD_SUBMIT(Message message) { Project project = getProject(message); // 待立项批复批复后,项目一级状态变更为已立项 project.setStatus(ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING.getCode()); } @OnTransition(source = "DECLARED_APPROVED_RECORD_FAILED", target = "DECLARED_APPROVED_RECORD_AUDITING") - public void DECLARED_RECORD_RESUBMIT(Message message) { + public void DECLARED_RECORD_RESUBMIT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING.getCode()); } @OnTransition(source = "DECLARED_APPROVED_RECORD_AUDITING", target = "TO_BE_PURCHASED") - public void DECLARED_RECORD_PASS(Message message) { + public void DECLARED_RECORD_PASS(Message message) { Project project = getProject(message); // 待立项批复批复后,项目一级状态变更为已立项 project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode()); @@ -220,7 +220,7 @@ public class ProjectDeclareAction { } @OnTransition(source = "DECLARED_APPROVED_RECORD_AUDITING", target = "DECLARED_APPROVED_RECORD_FAILED") - public void DECLARED_RECORD_FAILED(Message message) { + public void DECLARED_RECORD_FAILED(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.DECLARED_APPROVED_RECORD_FAILED.getCode()); } @@ -228,7 +228,7 @@ public class ProjectDeclareAction { //================================================================================================================== @OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED") - public void PROJECT_APPROVAL(Message message) { + public void PROJECT_APPROVAL(Message message) { Project project = getProject(message); // 待立项批复批复后,项目一级状态变更为已立项 project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode()); @@ -236,25 +236,25 @@ public class ProjectDeclareAction { } @OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW") - public void TO_BE_APPROVED_WITHDRAW(Message message) { + public void TO_BE_APPROVED_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode()); } @OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION") - public void PURCHASE_PUT_ON_RECORD(Message message) { + public void PURCHASE_PUT_ON_RECORD(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.OPERATION.getCode()); } @OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION") - public void START_TO_WORK(Message message) { + public void START_TO_WORK(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); } @OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED") - public void TO_BE_PURCHASED_WITHDRAW(Message message) { + public void TO_BE_PURCHASED_WITHDRAW(Message message) { Project project = getProject(message); // 待采购状态撤回后,项目一级状态回退到未立项 project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); @@ -263,56 +263,56 @@ public class ProjectDeclareAction { @OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED") - public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message message) { + public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); } @OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED") - public void UNDER_CONSTRUCTION_WITHDRAW(Message message) { + public void UNDER_CONSTRUCTION_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode()); } @OnTransition(source = "TO_BE_PURCHASED", target = "ON_PURCHASING") - public void SUBMIT_PURCHASE_NOTICE(Message message) { + public void SUBMIT_PURCHASE_NOTICE(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.ON_PURCHASING.getCode()); } @OnTransition(source = "ON_PURCHASING", target = "TO_BE_FIRST_INSPECTED") - public void SUBMIT_OPERATION_PLAN(Message message) { + public void SUBMIT_OPERATION_PLAN(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.TO_BE_FIRST_INSPECTED.getCode()); } @OnTransition(source = "TO_BE_FIRST_INSPECTED", target = "ON_FIRST_INSPECTED") - public void SUBMIT_FIRST_INSPECTED_FILES(Message message) { + public void SUBMIT_FIRST_INSPECTED_FILES(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.ON_FIRST_INSPECTED.getCode()); } @OnTransition(source = "ON_FIRST_INSPECTED", target = "TO_BE_FINALLY_INSPECTED") - public void FIRST_INSPECTED_PASSED(Message message) { + public void FIRST_INSPECTED_PASSED(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); } @OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW") - public void FINAL_ACCEPTANCE_APPLICATION(Message message) { + public void FINAL_ACCEPTANCE_APPLICATION(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode()); } @OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION") - public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message message) { + public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); } @OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED") - public void FINAL_ACCEPTANCE_PASS(Message message) { + public void FINAL_ACCEPTANCE_PASS(Message message) { Project project = getProject(message); // 终验审核通过后,项目一级状态变更为已归档 project.setStage(ProjectStatusEnum.ARCHIVED.getCode()); @@ -320,19 +320,19 @@ public class ProjectDeclareAction { } @OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED") - public void FINAL_ACCEPTANCE_REJECT(Message message) { + public void FINAL_ACCEPTANCE_REJECT(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode()); } @OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "TO_BE_FINALLY_INSPECTED") - public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message message) { + public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); } @OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW") - public void FINAL_RE_ACCEPTANCE_APPLICATION(Message message) { + public void FINAL_RE_ACCEPTANCE_APPLICATION(Message message) { Project project = getProject(message); project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode()); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/SelfTestAction.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/SelfTestStateChangeAction.java similarity index 92% rename from hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/SelfTestAction.java rename to hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/SelfTestStateChangeAction.java index 66bdd80..0abbf0d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/SelfTestAction.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/SelfTestStateChangeAction.java @@ -2,7 +2,6 @@ package com.hz.pm.api.common.statemachine.action; import cn.hutool.core.lang.Assert; import com.hz.pm.api.common.statemachine.builder.impl.SelfTestStateMachineBuilderImpl; -import com.hz.pm.api.common.statemachine.builder.impl.TestValidStateMachineBuilderImpl; import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent; import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; import com.hz.pm.api.projectdeclared.model.entity.Purchase; @@ -22,7 +21,7 @@ import org.springframework.statemachine.annotation.WithStateMachine; */ @Slf4j @WithStateMachine(id = SelfTestStateMachineBuilderImpl.MACHINE_ID) -public class SelfTestAction { +public class SelfTestStateChangeAction { private Purchase getPurchaseInfo(Message message) { Purchase purchase = (Purchase) message.getHeaders().get(TenderStateMachineUtil.PURCHASE); @@ -48,7 +47,7 @@ public class SelfTestAction { purchase.setSelfTestStatus(TenderSelfTestStatusEnum.SELF_TEST_INFO_FAILED.getCode()); } - @OnTransition(source = "SELF_TEST_INFO_FAILED", target = "TEST_VALID_INFO_AUDIT") + @OnTransition(source = "SELF_TEST_INFO_FAILED", target = "SELF_TEST_INFO_AUDIT") public void RESUBMIT_SELF_TEST_INFO(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setSelfTestStatus(TenderSelfTestStatusEnum.SELF_TEST_INFO_AUDIT.getCode()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TenderAction.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TenderStateChangeAction.java similarity index 81% rename from hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TenderAction.java rename to hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TenderStateChangeAction.java index fe18296..cae1101 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TenderAction.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TenderStateChangeAction.java @@ -2,7 +2,7 @@ package com.hz.pm.api.common.statemachine.action; import cn.hutool.core.lang.Assert; import com.hz.pm.api.common.statemachine.builder.impl.TenderStateMachineBuilderImpl; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectlib.model.enumeration.TenderStatusEnum; @@ -21,9 +21,9 @@ import org.springframework.statemachine.annotation.WithStateMachine; */ @Slf4j @WithStateMachine(id = TenderStateMachineBuilderImpl.MACHINE_ID) -public class TenderAction { +public class TenderStateChangeAction { - private Purchase getPurchaseInfo(Message message) { + private Purchase getPurchaseInfo(Message message) { Purchase purchase = (Purchase) message.getHeaders().get(TenderStateMachineUtil.PURCHASE); Assert.notNull(purchase, "未获取到需要状态变更的标段信息"); return purchase; @@ -35,7 +35,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "TO_BE_SUBMIT_PURCHASE_INFO", target = "TO_BE_SUBMIT_CONSTRUCTION_INFO") - public void SUBMIT_PURCHASE_INFO(Message message) { + public void SUBMIT_PURCHASE_INFO(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.TO_BE_SUBMIT_CONSTRUCTION_INFO.getTenderStatus()); } @@ -46,7 +46,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "TO_BE_SUBMIT_CONSTRUCTION_INFO", target = "TO_BE_SUBMIT_OPERATION_PLAN") - public void SUBMIT_CONSTRUCTION_INFO(Message message) { + public void SUBMIT_CONSTRUCTION_INFO(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.TO_BE_SUBMIT_OPERATION_PLAN.getTenderStatus()); } @@ -57,7 +57,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "TO_BE_SUBMIT_OPERATION_PLAN", target = "TO_BE_SUBMIT_FIRST_INSPECTED_INFO") - public void SUBMIT_OPERATION_PLAN(Message message) { + public void SUBMIT_OPERATION_PLAN(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.getTenderStatus()); } @@ -68,7 +68,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "TO_BE_SUBMIT_FIRST_INSPECTED_INFO", target = "TO_BE_SUBMIT_XCFHX_APPLY") - public void SUBMIT_FIRST_INSPECTED_FILES(Message message) { + public void SUBMIT_FIRST_INSPECTED_FILES(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.TO_BE_SUBMIT_XCFHX_APPLY.getTenderStatus()); } @@ -79,7 +79,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "TO_BE_SUBMIT_XCFHX_APPLY", target = "ON_XCFHX_APPLY") - public void SUBMIT_XCFHX_APPLY(Message message) { + public void SUBMIT_XCFHX_APPLY(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.ON_XCFHX_APPLY.getTenderStatus()); } @@ -90,7 +90,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "ON_XCFHX_APPLY", target = "TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY") - public void XCFHX_APPLY_PASSED(Message message) { + public void XCFHX_APPLY_PASSED(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY.getTenderStatus()); } @@ -101,7 +101,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "ON_XCFHX_APPLY", target = "XCFHX_APPLY_FAILED") - public void XCFHX_APPLY_FAILED(Message message) { + public void XCFHX_APPLY_FAILED(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.XCFHX_APPLY_FAILED.getTenderStatus()); } @@ -112,7 +112,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "XCFHX_APPLY_FAILED", target = "ON_XCFHX_APPLY") - public void RESUBMIT_XCFHX_APPLY(Message message) { + public void RESUBMIT_XCFHX_APPLY(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.ON_XCFHX_APPLY.getTenderStatus()); } @@ -123,7 +123,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY", target = "ON_FINALLY_INSPECTED_APPLY") - public void SUBMIT_FINALLY_INSPECTED(Message message) { + public void SUBMIT_FINALLY_INSPECTED(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY.getTenderStatus()); } @@ -134,7 +134,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "FINALLY_INSPECTED_FAILED", target = "ON_FINALLY_INSPECTED_APPLY") - public void RESUBMIT_FINALLY_INSPECTED(Message message) { + public void RESUBMIT_FINALLY_INSPECTED(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY.getTenderStatus()); } @@ -145,7 +145,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "ON_FINALLY_INSPECTED_APPLY", target = "FINALLY_INSPECTED_PASSED") - public void FINALLY_INSPECTED_PASSED(Message message) { + public void FINALLY_INSPECTED_PASSED(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.FINALLY_INSPECTED_PASSED.getTenderStatus()); } @@ -156,7 +156,7 @@ public class TenderAction { * @param message \ */ @OnTransition(source = "ON_FINALLY_INSPECTED_APPLY", target = "FINALLY_INSPECTED_FAILED") - public void FINALLY_INSPECTED_FAILED(Message message) { + public void FINALLY_INSPECTED_FAILED(Message message) { Purchase purchase = getPurchaseInfo(message); purchase.setStatus(TenderStatusEnum.FINALLY_INSPECTED_FAILED.getTenderStatus()); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TestValidAction.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TestValidStateChangeAction.java similarity index 98% rename from hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TestValidAction.java rename to hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TestValidStateChangeAction.java index f1e21bc..7281c15 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TestValidAction.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TestValidStateChangeAction.java @@ -21,7 +21,7 @@ import org.springframework.statemachine.annotation.WithStateMachine; */ @Slf4j @WithStateMachine(id = TestValidStateMachineBuilderImpl.MACHINE_ID) -public class TestValidAction { +public class TestValidStateChangeAction { private Purchase getPurchaseInfo(Message message) { Purchase purchase = (Purchase) message.getHeaders().get(TenderStateMachineUtil.PURCHASE); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/AdaptStateMachineBuilder.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/AdaptStateMachineBuilder.java deleted file mode 100644 index 0feb877..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/AdaptStateMachineBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hz.pm.api.common.statemachine.builder; - -import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent; -import com.hz.pm.api.projectdeclared.model.entity.Purchase; -import com.hz.pm.api.projectlib.model.enumeration.TenderAdaptStatusEnum; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.statemachine.StateMachine; -import org.springframework.statemachine.StateMachineException; -import org.springframework.statemachine.persist.StateMachinePersister; - -/** - * 项目申报状态机 - * - * @author CMM - * @since 2023/02/07 15:56 - */ -public interface AdaptStateMachineBuilder { - - - StateMachine build() throws StateMachineException; - - /** - * 构建状态机 - * - * @param beanFactory \ - */ - StateMachine build(BeanFactory beanFactory) throws StateMachineException; - - /** - * 持久化配置 - * - * @author CMM - * @since 2023/02/07 16:22 - */ - StateMachinePersister stateMachinePersister(); - - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/BaseStateMachineBuilder.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/BaseStateMachineBuilder.java new file mode 100644 index 0000000..d333ce2 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/BaseStateMachineBuilder.java @@ -0,0 +1,37 @@ +package com.hz.pm.api.common.statemachine.builder; + +import org.springframework.beans.factory.BeanFactory; +import org.springframework.statemachine.StateMachine; +import org.springframework.statemachine.StateMachineException; +import org.springframework.statemachine.persist.StateMachinePersister; + +/** + *

+ * 状态机构建基础类 + *

+ * + * @author WendyYang + * @since 20:52 2024/4/2 + */ +public interface BaseStateMachineBuilder { + + StateMachine build() throws StateMachineException; + + /** + * 构建状态机 + * + * @param beanFactory \ + * @author CMM + * @since 2023/02/07 16:15 + */ + StateMachine build(BeanFactory beanFactory) throws StateMachineException; + + /** + * 持久化配置 + * + * @author CMM + * @since 2023/02/07 16:22 + */ + StateMachinePersister stateMachinePersister(); + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineBuilder.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineBuilder.java deleted file mode 100644 index 174eb70..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.hz.pm.api.common.statemachine.builder; - -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; -import com.hz.pm.api.projectlib.model.entity.Project; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.statemachine.StateMachine; -import org.springframework.statemachine.persist.StateMachinePersister; - -/** - * 项目申报状态机 - * - * @author CMM - * @since 2023/02/07 15:56 - */ -public interface ProjectDeclareStateMachineBuilder { - - StateMachine build() throws Exception; - /** - * 构建状态机 - * @param beanFactory \ - * @author CMM - * @since 2023/02/07 16:15 - */ - StateMachine build(BeanFactory beanFactory) throws Exception; - - /** - * 持久化配置 - * @author CMM - * @since 2023/02/07 16:22 - */ - StateMachinePersister getProjectPersister(); - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/SelfTestStateMachineBuilder.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/SelfTestStateMachineBuilder.java deleted file mode 100644 index 061c4ab..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/SelfTestStateMachineBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hz.pm.api.common.statemachine.builder; - -import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent; -import com.hz.pm.api.projectdeclared.model.entity.Purchase; -import com.hz.pm.api.projectlib.model.enumeration.TenderSelfTestStatusEnum; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.statemachine.StateMachine; -import org.springframework.statemachine.StateMachineException; -import org.springframework.statemachine.persist.StateMachinePersister; - -/** - * 项目申报状态机 - * - * @author CMM - * @since 2023/02/07 15:56 - */ -public interface SelfTestStateMachineBuilder { - - - StateMachine build() throws StateMachineException; - - /** - * 构建状态机 - * - * @param beanFactory \ - */ - StateMachine build(BeanFactory beanFactory) throws StateMachineException; - - /** - * 持久化配置 - * - * @author CMM - * @since 2023/02/07 16:22 - */ - StateMachinePersister stateMachinePersister(); - - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/TenderStateMachineBuilder.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/TenderStateMachineBuilder.java deleted file mode 100644 index d550b87..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/TenderStateMachineBuilder.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hz.pm.api.common.statemachine.builder; - -import com.hz.pm.api.common.statemachine.event.TenderStatusChangeEvent; -import com.hz.pm.api.projectdeclared.model.entity.Purchase; -import com.hz.pm.api.projectlib.model.enumeration.TenderStatusEnum; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.statemachine.StateMachine; -import org.springframework.statemachine.StateMachineException; -import org.springframework.statemachine.persist.StateMachinePersister; - -/** - * 项目申报状态机 - * - * @author CMM - * @since 2023/02/07 15:56 - */ -public interface TenderStateMachineBuilder { - - StateMachine build() throws StateMachineException; - - /** - * 构建状态机 - * - * @param beanFactory \ - */ - StateMachine build(BeanFactory beanFactory) throws StateMachineException; - - /** - * 持久化配置 - * - * @author CMM - * @since 2023/02/07 16:22 - */ - StateMachinePersister stateMachinePersister(); - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/TestValidStateMachineBuilder.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/TestValidStateMachineBuilder.java deleted file mode 100644 index 1def11b..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/TestValidStateMachineBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hz.pm.api.common.statemachine.builder; - -import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent; -import com.hz.pm.api.projectdeclared.model.entity.Purchase; -import com.hz.pm.api.projectlib.model.enumeration.TenderTestValidStatusEnum; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.statemachine.StateMachine; -import org.springframework.statemachine.StateMachineException; -import org.springframework.statemachine.persist.StateMachinePersister; - -/** - * 项目申报状态机 - * - * @author CMM - * @since 2023/02/07 15:56 - */ -public interface TestValidStateMachineBuilder { - - - StateMachine build() throws StateMachineException; - - /** - * 构建状态机 - * - * @param beanFactory \ - */ - StateMachine build(BeanFactory beanFactory) throws StateMachineException; - - /** - * 持久化配置 - * - * @author CMM - * @since 2023/02/07 16:22 - */ - StateMachinePersister stateMachinePersister(); - - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java index 0230c07..1fbefa5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java @@ -1,6 +1,6 @@ package com.hz.pm.api.common.statemachine.builder.impl; -import com.hz.pm.api.common.statemachine.builder.AdaptStateMachineBuilder; +import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectlib.model.enumeration.TenderAdaptStatusEnum; @@ -24,7 +24,7 @@ import java.util.EnumSet; /** *

- * 标段状态机 + * 标段适配改造状态机 *

* * @author WendyYang @@ -34,7 +34,7 @@ import java.util.EnumSet; @Component @EnableStateMachine(name = AdaptStateMachineBuilderImpl.MACHINE_ID) @RequiredArgsConstructor -public class AdaptStateMachineBuilderImpl implements AdaptStateMachineBuilder { +public class AdaptStateMachineBuilderImpl implements BaseStateMachineBuilder { public static final String MACHINE_ID = "adaptStateMachine"; @@ -53,7 +53,7 @@ public class AdaptStateMachineBuilderImpl implements AdaptStateMachineBuilder { try { return buildStateMachine(beanFactory); } catch (Exception e) { - throw new StateMachineException("状态机构件失败", e); + throw new StateMachineException("状态机构建失败", e); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectDeclareStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java similarity index 74% rename from hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectDeclareStateMachineBuilderImpl.java rename to hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java index 774c428..63d316a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectDeclareStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java @@ -1,8 +1,8 @@ package com.hz.pm.api.common.statemachine.builder.impl; import com.hz.pm.api.common.statemachine.action.ProjectDeclareActionChoice; -import com.hz.pm.api.common.statemachine.builder.ProjectDeclareStateMachineBuilder; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory.PendingPreQualificationChoiceGuard; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; @@ -12,6 +12,7 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.statemachine.StateMachine; import org.springframework.statemachine.StateMachineContext; +import org.springframework.statemachine.StateMachineException; import org.springframework.statemachine.StateMachinePersist; import org.springframework.statemachine.config.EnableStateMachine; import org.springframework.statemachine.config.StateMachineBuilder; @@ -31,17 +32,17 @@ import java.util.EnumSet; */ @Slf4j @Component -@EnableStateMachine(name = ProjectDeclareStateMachineBuilderImpl.MACHINE_ID) +@EnableStateMachine(name = ProjectStateMachineBuilderImpl.MACHINE_ID) @RequiredArgsConstructor -public class ProjectDeclareStateMachineBuilderImpl implements ProjectDeclareStateMachineBuilder { +public class ProjectStateMachineBuilderImpl implements BaseStateMachineBuilder { public static final String MACHINE_ID = "projectDeclareStateMachine"; private final BeanFactory beanFactory; @Override - public StateMachine build() throws Exception { - StateMachine stateMachine = build(beanFactory); + public StateMachine build() throws StateMachineException { + StateMachine stateMachine = build(beanFactory); log.info("状态机ID:" + stateMachine.getId()); stateMachine.start(); return stateMachine; @@ -50,13 +51,19 @@ public class ProjectDeclareStateMachineBuilderImpl implements ProjectDeclareStat /** * 构建状态机 * - * @param beanFactory - * @author CMM - * @since 2023/02/07 16:15 + * @param beanFactory \ */ @Override - public StateMachine build(BeanFactory beanFactory) throws Exception { - StateMachineBuilder.Builder builder = StateMachineBuilder.builder(); + public StateMachine build(BeanFactory beanFactory) throws StateMachineException { + try { + return buildStateMachine(beanFactory); + } catch (Exception e) { + throw new StateMachineException("状态机构建失败", e); + } + } + + private StateMachine buildStateMachine(BeanFactory beanFactory) throws Exception { + StateMachineBuilder.Builder builder = StateMachineBuilder.builder(); builder.configureConfiguration() .withConfiguration() .machineId(MACHINE_ID) @@ -74,27 +81,27 @@ public class ProjectDeclareStateMachineBuilderImpl implements ProjectDeclareStat .withExternal() .source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT) .target(ProjectStatusEnum.PENDING_PREQUALIFICATION) - .event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and() + .event(ProjectStateChangeEvent.UNDER_INTERNAL_PASS).and() // 单位内部审核驳回,从单位内部审核中到单位内部审核不通过 .withExternal() .source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT) .target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS) - .event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and() + .event(ProjectStateChangeEvent.UNDER_INTERNAL_REJECT).and() // 单位内部审核中撤回,从单位内部审核中到待申报 .withExternal() .source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT) .target(ProjectStatusEnum.TO_BE_DECLARED) - .event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and() + .event(ProjectStateChangeEvent.UNDER_INTERNAL_WITHDRAW).and() // 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中 .withExternal() .source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS) .target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT) - .event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and() + .event(ProjectStateChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and() // 待预审预审申报,从待预审到待预审选择 .withExternal() .source(ProjectStatusEnum.PENDING_PREQUALIFICATION) .target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE) - .event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and() + .event(ProjectStateChangeEvent.PRELIMINARY_REVIEW_DECLARE).and() // 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态 .withChoice() .source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE) @@ -105,38 +112,38 @@ public class ProjectDeclareStateMachineBuilderImpl implements ProjectDeclareStat .withExternal() .source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS) .target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS) - .event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and() + .event(ProjectStateChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and() // 省级部门联审通过,从省级部门联审成功到预审中 .withExternal() .source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS) .target(ProjectStatusEnum.PRE_APPLYING) - .event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and() + .event(ProjectStateChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and() // 省级部门联审不通过,从省级部门联审中到省级部门联审不通过 .withExternal() .source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS) .target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED) - .event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and() + .event(ProjectStateChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and() // 省级部门联审中撤回,从省级部门联审中到待预审 .withExternal() .source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS) .target(ProjectStatusEnum.PENDING_PREQUALIFICATION) - .event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and() + .event(ProjectStateChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and() // 预审通过,从预审中到部门联审中 .withExternal() .source(ProjectStatusEnum.PRE_APPLYING) .target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW) - .event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and() + .event(ProjectStateChangeEvent.PRELIMINARY_REVIEW_PASS).and() // 预审驳回,从预审中到预审不通过 .withExternal() .source(ProjectStatusEnum.PRE_APPLYING) .target(ProjectStatusEnum.PREQUALIFICATION_FAILED) - .event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and() + .event(ProjectStateChangeEvent.PRELIMINARY_REVIEW_REJECT).and() // 预审中撤回,从预审中到预审中撤回选择态 .withExternal() .source(ProjectStatusEnum.PRE_APPLYING) .target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE) - .event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and() + .event(ProjectStateChangeEvent.PRE_APPLYING_WITHDRAW).and() // 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态 .withChoice() .source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE) @@ -147,7 +154,7 @@ public class ProjectDeclareStateMachineBuilderImpl implements ProjectDeclareStat .withExternal() .source(ProjectStatusEnum.PREQUALIFICATION_FAILED) .target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE) - .event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and() + .event(ProjectStateChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and() // 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态 .withChoice() .source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE) @@ -157,129 +164,129 @@ public class ProjectDeclareStateMachineBuilderImpl implements ProjectDeclareStat .withExternal() .source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW) .target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN) - .event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and() + .event(ProjectStateChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and() // 部门联审驳回,从部门联审中到部门联审不通过 .withExternal() .source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW) .target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED) - .event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and() + .event(ProjectStateChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and() // 部门联审中撤回,从部门联审中到预审中 .withExternal() .source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW) .target(ProjectStatusEnum.PRE_APPLYING) - .event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and() + .event(ProjectStateChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and() // 年度计划中开启方案申报,从年度计划中到方案待申报 .withExternal() .source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN) .target(ProjectStatusEnum.PLAN_TO_BE_DECLARED) - .event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and() + .event(ProjectStateChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and() // 年度计划中暂缓,从年度计划中到被暂缓 .withExternal() .source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN) .target(ProjectStatusEnum.BE_SUSPENDED) - .event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and() + .event(ProjectStateChangeEvent.ANNUAL_PLAN_SUSPEND).and() // 方案待申报申报方案,从方案待申报到方案评审中 .withExternal() .source(ProjectStatusEnum.PLAN_TO_BE_DECLARED) .target(ProjectStatusEnum.SCHEME_UNDER_REVIEW) - .event(ProjectStatusChangeEvent.DECLARE_PLAN).and() + .event(ProjectStateChangeEvent.DECLARE_PLAN).and() // 方案评审通过,从方案评审中到待立项批复 .withExternal() .source(ProjectStatusEnum.SCHEME_UNDER_REVIEW) .target(ProjectStatusEnum.TO_BE_APPROVED) - .event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and() + .event(ProjectStateChangeEvent.PLAN_REVIEW_PASS).and() // 方案评审驳回,从方案评审中到方案评审不通过 .withExternal() .source(ProjectStatusEnum.SCHEME_UNDER_REVIEW) .target(ProjectStatusEnum.SCHEME_REVIEW_FAILED) - .event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and() + .event(ProjectStateChangeEvent.PLAN_REVIEW_REJECT).and() // 方案评审中撤回,从方案评审中到方案待申报 .withExternal() .source(ProjectStatusEnum.SCHEME_UNDER_REVIEW) .target(ProjectStatusEnum.PLAN_TO_BE_DECLARED) - .event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and() + .event(ProjectStateChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and() // 方案评审不通过重新提交,从方案评审不通过到方案评审中 .withExternal() .source(ProjectStatusEnum.SCHEME_REVIEW_FAILED) .target(ProjectStatusEnum.SCHEME_UNDER_REVIEW) - .event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and() + .event(ProjectStateChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and() // 立项备案 .withExternal() .source(ProjectStatusEnum.DECLARED_APPROVED_TO_BE_RECORD) .target(ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING) - .event(ProjectStatusChangeEvent.DECLARED_RECORD_SUBMIT).and() + .event(ProjectStateChangeEvent.DECLARED_RECORD_SUBMIT).and() .withExternal() .source(ProjectStatusEnum.DECLARED_APPROVED_RECORD_FAILED) .target(ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING) - .event(ProjectStatusChangeEvent.DECLARED_RECORD_RESUBMIT).and() + .event(ProjectStateChangeEvent.DECLARED_RECORD_RESUBMIT).and() .withExternal() .source(ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING) .target(ProjectStatusEnum.TO_BE_PURCHASED) - .event(ProjectStatusChangeEvent.DECLARED_RECORD_PASS).and() + .event(ProjectStateChangeEvent.DECLARED_RECORD_PASS).and() .withExternal() .source(ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING) .target(ProjectStatusEnum.DECLARED_APPROVED_RECORD_FAILED) - .event(ProjectStatusChangeEvent.DECLARED_RECORD_FAILED).and() + .event(ProjectStateChangeEvent.DECLARED_RECORD_FAILED).and() // 待立项批复批复,从待立项批复到待采购 .withExternal() .source(ProjectStatusEnum.TO_BE_APPROVED) .target(ProjectStatusEnum.TO_BE_PURCHASED) - .event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and() + .event(ProjectStateChangeEvent.PROJECT_APPROVAL).and() // 待采购采购备案,从待采购到实施中 .withExternal() .source(ProjectStatusEnum.TO_BE_PURCHASED) .target(ProjectStatusEnum.ON_PURCHASING) - .event(ProjectStatusChangeEvent.SUBMIT_PURCHASE_NOTICE).and() + .event(ProjectStateChangeEvent.SUBMIT_PURCHASE_NOTICE).and() // 填写试试计划 -> 待初验 .withExternal() .source(ProjectStatusEnum.ON_PURCHASING) .target(ProjectStatusEnum.TO_BE_FIRST_INSPECTED) - .event(ProjectStatusChangeEvent.SUBMIT_OPERATION_PLAN).and() + .event(ProjectStateChangeEvent.SUBMIT_OPERATION_PLAN).and() // 上传初验材料 .withExternal() .source(ProjectStatusEnum.TO_BE_FIRST_INSPECTED) .target(ProjectStatusEnum.ON_FIRST_INSPECTED) - .event(ProjectStatusChangeEvent.SUBMIT_FIRST_INSPECTED_FILES).and() + .event(ProjectStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES).and() // 初验审批通过 .withExternal() .source(ProjectStatusEnum.ON_FIRST_INSPECTED) .target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED) - .event(ProjectStatusChangeEvent.FIRST_INSPECTED_PASSED).and() + .event(ProjectStateChangeEvent.FIRST_INSPECTED_PASSED).and() // 待开工 实施,从实施到建设中 .withExternal() .source(ProjectStatusEnum.OPERATION) .target(ProjectStatusEnum.UNDER_CONSTRUCTION) - .event(ProjectStatusChangeEvent.START_TO_WORK).and() + .event(ProjectStateChangeEvent.START_TO_WORK).and() // 建设中初验备案,从建设中到待终验 .withExternal() .source(ProjectStatusEnum.UNDER_CONSTRUCTION) .target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED) - .event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and() + .event(ProjectStateChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and() // 待终验终验申请,从待终验到终验审核中 .withExternal() .source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED) .target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW) - .event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and() + .event(ProjectStateChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and() // 终审审核通过,从终审审核中到已归档 .withExternal() .source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW) .target(ProjectStatusEnum.ARCHIVED) - .event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and() + .event(ProjectStateChangeEvent.FINAL_ACCEPTANCE_PASS).and() // 终审审核不通过,从终审审核中到终审审核不通过 .withExternal() .source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW) .target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED) - .event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and() + .event(ProjectStateChangeEvent.FINAL_ACCEPTANCE_REJECT).and() // 终审审核中撤回,从终审审核中到待终验 .withExternal() .source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW) .target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED) - .event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and() + .event(ProjectStateChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and() // 终验中 重新提交 .withExternal() .source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED) .target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW) - .event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and(); + .event(ProjectStateChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and(); return builder.build(); } @@ -291,15 +298,15 @@ public class ProjectDeclareStateMachineBuilderImpl implements ProjectDeclareStat */ @Bean(name = "projectDeclareStatePersister") @Override - public StateMachinePersister getProjectPersister() { - return new DefaultStateMachinePersister<>(new StateMachinePersist() { + public StateMachinePersister stateMachinePersister() { + return new DefaultStateMachinePersister<>(new StateMachinePersist() { @Override - public void write(StateMachineContext context, Project contextObj) { + public void write(StateMachineContext context, Project contextObj) { log.info("当前项目为:{}", contextObj); } @Override - public StateMachineContext read(Project contextObj) { + public StateMachineContext read(Project contextObj) { return new DefaultStateMachineContext<>(ProjectStatusEnum.match(contextObj.getStatus()), null, null, null, null, MACHINE_ID); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java index 793af0c..a460a00 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java @@ -1,6 +1,6 @@ package com.hz.pm.api.common.statemachine.builder.impl; -import com.hz.pm.api.common.statemachine.builder.SelfTestStateMachineBuilder; +import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectlib.model.enumeration.TenderSelfTestStatusEnum; @@ -24,7 +24,7 @@ import java.util.EnumSet; /** *

- * 标段状态机 + * 标段系统自测状态机 *

* * @author WendyYang @@ -34,7 +34,7 @@ import java.util.EnumSet; @Component @EnableStateMachine(name = SelfTestStateMachineBuilderImpl.MACHINE_ID) @RequiredArgsConstructor -public class SelfTestStateMachineBuilderImpl implements SelfTestStateMachineBuilder { +public class SelfTestStateMachineBuilderImpl implements BaseStateMachineBuilder { public static final String MACHINE_ID = "selfTestStateMachine"; @@ -53,7 +53,7 @@ public class SelfTestStateMachineBuilderImpl implements SelfTestStateMachineBuil try { return buildStateMachine(beanFactory); } catch (Exception e) { - throw new StateMachineException("状态机构件失败", e); + throw new StateMachineException("状态机构建失败", e); } } 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 df8c250..ea17bc3 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,7 +1,7 @@ package com.hz.pm.api.common.statemachine.builder.impl; -import com.hz.pm.api.common.statemachine.builder.TenderStateMachineBuilder; -import com.hz.pm.api.common.statemachine.event.TenderStatusChangeEvent; +import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; +import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectlib.model.enumeration.TenderStatusEnum; import lombok.RequiredArgsConstructor; @@ -33,31 +33,31 @@ import java.util.EnumSet; @Component @EnableStateMachine(name = TenderStateMachineBuilderImpl.MACHINE_ID) @RequiredArgsConstructor -public class TenderStateMachineBuilderImpl implements TenderStateMachineBuilder { +public class TenderStateMachineBuilderImpl implements BaseStateMachineBuilder { public static final String MACHINE_ID = "tenderStateMachine"; private final BeanFactory beanFactory; @Override - public StateMachine build() throws StateMachineException { - StateMachine stateMachine = build(beanFactory); + public StateMachine build() throws StateMachineException { + StateMachine stateMachine = build(beanFactory); log.info("状态机ID:" + stateMachine.getId()); stateMachine.start(); return stateMachine; } @Override - public StateMachine build(BeanFactory beanFactory) throws StateMachineException { + public StateMachine build(BeanFactory beanFactory) throws StateMachineException { try { return buildStateMachine(beanFactory); } catch (Exception e) { - throw new StateMachineException("状态机构件失败", e); + throw new StateMachineException("状态机构建失败", e); } } - private StateMachine buildStateMachine(BeanFactory factory) throws Exception { - StateMachineBuilder.Builder builder = StateMachineBuilder.builder(); + private StateMachine buildStateMachine(BeanFactory factory) throws Exception { + StateMachineBuilder.Builder builder = StateMachineBuilder.builder(); builder.configureConfiguration() .withConfiguration() .machineId(MACHINE_ID) @@ -73,87 +73,87 @@ public class TenderStateMachineBuilderImpl implements TenderStateMachineBuilder .withExternal() .source(TenderStatusEnum.TO_BE_SUBMIT_PURCHASE_INFO) .target(TenderStatusEnum.TO_BE_SUBMIT_CONSTRUCTION_INFO) - .event(TenderStatusChangeEvent.SUBMIT_PURCHASE_INFO) + .event(TenderStateChangeEvent.SUBMIT_PURCHASE_INFO) .and() // 填写合同信息 .withExternal() .source(TenderStatusEnum.TO_BE_SUBMIT_CONSTRUCTION_INFO) .target(TenderStatusEnum.TO_BE_SUBMIT_OPERATION_PLAN) - .event(TenderStatusChangeEvent.SUBMIT_CONSTRUCTION_INFO) + .event(TenderStateChangeEvent.SUBMIT_CONSTRUCTION_INFO) .and() // 填写实施计划 .withExternal() .source(TenderStatusEnum.TO_BE_SUBMIT_OPERATION_PLAN) .target(TenderStatusEnum.TO_BE_SUBMIT_FIRST_INSPECTED_INFO) - .event(TenderStatusChangeEvent.SUBMIT_OPERATION_PLAN) + .event(TenderStateChangeEvent.SUBMIT_OPERATION_PLAN) .and() // 上传初验材料 .withExternal() .source(TenderStatusEnum.TO_BE_SUBMIT_FIRST_INSPECTED_INFO) .target(TenderStatusEnum.TO_BE_SUBMIT_XCFHX_APPLY) - .event(TenderStatusChangeEvent.SUBMIT_FIRST_INSPECTED_FILES) + .event(TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES) .and() // 信创符合性申请 .withExternal() .source(TenderStatusEnum.TO_BE_SUBMIT_XCFHX_APPLY) .target(TenderStatusEnum.ON_XCFHX_APPLY) - .event(TenderStatusChangeEvent.SUBMIT_XCFHX_APPLY) + .event(TenderStateChangeEvent.SUBMIT_XCFHX_APPLY) .and()// 信创符合性申请 .withExternal() .source(TenderStatusEnum.XCFHX_APPLY_FAILED) .target(TenderStatusEnum.ON_XCFHX_APPLY) - .event(TenderStatusChangeEvent.RESUBMIT_XCFHX_APPLY) + .event(TenderStateChangeEvent.RESUBMIT_XCFHX_APPLY) .and() // 信创符合性申请通过 .withExternal() .source(TenderStatusEnum.ON_XCFHX_APPLY) .target(TenderStatusEnum.TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY) - .event(TenderStatusChangeEvent.XCFHX_APPLY_PASSED) + .event(TenderStateChangeEvent.XCFHX_APPLY_PASSED) .and() // 信创符合性申请失败 .withExternal() .source(TenderStatusEnum.ON_XCFHX_APPLY) .target(TenderStatusEnum.XCFHX_APPLY_FAILED) - .event(TenderStatusChangeEvent.XCFHX_APPLY_FAILED) + .event(TenderStateChangeEvent.XCFHX_APPLY_FAILED) .and() // 终验申报 .withExternal() .source(TenderStatusEnum.TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY) .target(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY) - .event(TenderStatusChangeEvent.SUBMIT_FINALLY_INSPECTED) + .event(TenderStateChangeEvent.SUBMIT_FINALLY_INSPECTED) .and() // 终验申报重新提交 .withExternal() .source(TenderStatusEnum.FINALLY_INSPECTED_FAILED) .target(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY) - .event(TenderStatusChangeEvent.RESUBMIT_FINALLY_INSPECTED) + .event(TenderStateChangeEvent.RESUBMIT_FINALLY_INSPECTED) .and() // 终验申报通过 .withExternal() .source(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY) .target(TenderStatusEnum.FINALLY_INSPECTED_PASSED) - .event(TenderStatusChangeEvent.FINALLY_INSPECTED_PASSED) + .event(TenderStateChangeEvent.FINALLY_INSPECTED_PASSED) .and() // 终验申报拒绝 .withExternal() .source(TenderStatusEnum.ON_FINALLY_INSPECTED_APPLY) .target(TenderStatusEnum.FINALLY_INSPECTED_FAILED) - .event(TenderStatusChangeEvent.FINALLY_INSPECTED_FAILED) + .event(TenderStateChangeEvent.FINALLY_INSPECTED_FAILED) .and(); return builder.build(); } @Override @Bean(name = "tenderStatePersister") - public StateMachinePersister stateMachinePersister() { - return new DefaultStateMachinePersister<>(new StateMachinePersist() { + public StateMachinePersister stateMachinePersister() { + return new DefaultStateMachinePersister<>(new StateMachinePersist() { @Override - public void write(StateMachineContext context, Purchase contextObj) { + public void write(StateMachineContext context, Purchase contextObj) { log.info("当前项目为:{}", contextObj); } @Override - public StateMachineContext read(Purchase contextObj) { + public StateMachineContext read(Purchase contextObj) { return new DefaultStateMachineContext<>(TenderStatusEnum.getByStatus(contextObj.getStatus()), null, null, null, null, MACHINE_ID); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java index 0f5968c..676b6d7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java @@ -1,6 +1,6 @@ package com.hz.pm.api.common.statemachine.builder.impl; -import com.hz.pm.api.common.statemachine.builder.TestValidStateMachineBuilder; +import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectlib.model.enumeration.TenderTestValidStatusEnum; @@ -24,7 +24,7 @@ import java.util.EnumSet; /** *

- * 标段状态机 + * 标段测试验证状态机 *

* * @author WendyYang @@ -34,7 +34,7 @@ import java.util.EnumSet; @Component @EnableStateMachine(name = TestValidStateMachineBuilderImpl.MACHINE_ID) @RequiredArgsConstructor -public class TestValidStateMachineBuilderImpl implements TestValidStateMachineBuilder { +public class TestValidStateMachineBuilderImpl implements BaseStateMachineBuilder { public static final String MACHINE_ID = "testValidStateMachine"; @@ -53,7 +53,7 @@ public class TestValidStateMachineBuilderImpl implements TestValidStateMachineBu try { return buildStateMachine(beanFactory); } catch (Exception e) { - throw new StateMachineException("状态机构件失败", e); + throw new StateMachineException("状态机构建失败", e); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AbstractStateChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AbstractStateChangeEvent.java new file mode 100644 index 0000000..341b114 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AbstractStateChangeEvent.java @@ -0,0 +1,58 @@ +package com.hz.pm.api.common.statemachine.event; + +import com.ningdatech.basic.exception.BizException; +import org.apache.commons.lang3.EnumUtils; + +import java.util.Objects; + +/** + *

+ * BaseTenderAction + *

+ * + * @author WendyYang + * @since 18:58 2024/4/2 + */ +public interface AbstractStateChangeEvent { + + + Integer getPassStatusCode(); + + Integer getRejectStatusCode(); + + Integer getWithdrawStatusCode(); + + static & AbstractStateChangeEvent> E getPassEvent(Class eClass, Integer code) { + if (Objects.nonNull(code)) { + for (E t : EnumUtils.getEnumList(eClass)) { + if (code.equals(t.getPassStatusCode())) { + return t; + } + } + } + throw BizException.wrap("该状态下没有对应的通过操作!"); + } + + static & AbstractStateChangeEvent> E getRejectEvent(Class eClass, Integer code) { + if (Objects.nonNull(code)) { + for (E t : EnumUtils.getEnumList(eClass)) { + if (code.equals(t.getRejectStatusCode())) { + return t; + } + } + } + throw BizException.wrap("该状态下没有对应的驳回操作!"); + } + + static & AbstractStateChangeEvent> E getWithdrawEvent(Class eClass, Integer code) { + if (Objects.nonNull(code)) { + for (E t : EnumUtils.getEnumList(eClass)) { + if (code.equals(t.getWithdrawStatusCode())) { + return t; + } + } + } + throw BizException.wrap("该状态下没有对应的撤回操作!"); + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java index 2141057..f57a21d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java @@ -3,8 +3,6 @@ package com.hz.pm.api.common.statemachine.event; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.Objects; - /** *

* TenderStatusChangeEvent @@ -15,7 +13,7 @@ import java.util.Objects; */ @Getter @AllArgsConstructor -public enum AdaptStateChangeEvent { +public enum AdaptStateChangeEvent implements AbstractStateChangeEvent { SUBMIT_ADAPT_INFO(2100, null, null), ADAPT_INFO_PASSED(2101, null, null), @@ -27,40 +25,4 @@ public enum AdaptStateChangeEvent { private final Integer rejectStatusCode; private final Integer withdrawStatusCode; - public static AdaptStateChangeEvent getPassValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (AdaptStateChangeEvent t : AdaptStateChangeEvent.values()) { - if (code.equals(t.getPassStatusCode())) { - return t; - } - } - return null; - } - - public static AdaptStateChangeEvent getRejectValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (AdaptStateChangeEvent t : AdaptStateChangeEvent.values()) { - if (code.equals(t.getRejectStatusCode())) { - return t; - } - } - return null; - } - - public static AdaptStateChangeEvent getWithdrawValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (AdaptStateChangeEvent t : AdaptStateChangeEvent.values()) { - if (code.equals(t.getWithdrawStatusCode())) { - return t; - } - } - return null; - } - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/ProjectStatusChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/ProjectStateChangeEvent.java similarity index 84% rename from hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/ProjectStatusChangeEvent.java rename to hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/ProjectStateChangeEvent.java index 2b66b84..d59d336 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/ProjectStatusChangeEvent.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/ProjectStateChangeEvent.java @@ -3,21 +3,18 @@ package com.hz.pm.api.common.statemachine.event; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.Objects; /** - * 项目状态改变事件 + *

+ * ProjectStatusChangeEvent + *

* - * @author CMM - * @return - * @since 2023/02/07 9:22 + * @author WendyYang + * @since 20:20 2024/4/2 */ @Getter @AllArgsConstructor -@NoArgsConstructor -public enum ProjectStatusChangeEvent { +public enum ProjectStateChangeEvent implements AbstractStateChangeEvent { /** * 项目申报暂存(项目状态进入:待申报) @@ -205,43 +202,8 @@ public enum ProjectStatusChangeEvent { FINAL_RE_ACCEPTANCE_APPLICATION(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode(), null, null); - private Integer passProjectStatusCode; - private Integer rejectProjectStatusCode; - private Integer withdrawProjectStatusCode; - - public static ProjectStatusChangeEvent getPassValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (ProjectStatusChangeEvent t : ProjectStatusChangeEvent.values()) { - if (code.equals(t.getPassProjectStatusCode())) { - return t; - } - } - return null; - } - - public static ProjectStatusChangeEvent getRejectValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (ProjectStatusChangeEvent t : ProjectStatusChangeEvent.values()) { - if (code.equals(t.getRejectProjectStatusCode())) { - return t; - } - } - return null; - } - - public static ProjectStatusChangeEvent getWithdrawValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (ProjectStatusChangeEvent t : ProjectStatusChangeEvent.values()) { - if (code.equals(t.getWithdrawProjectStatusCode())) { - return t; - } - } - return null; - } + private final Integer passStatusCode; + private final Integer rejectStatusCode; + private final Integer withdrawStatusCode; + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java index 293c43c..9dd7c0e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java @@ -3,8 +3,6 @@ package com.hz.pm.api.common.statemachine.event; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.Objects; - /** *

* SelfTestStateChangeEvent @@ -15,7 +13,7 @@ import java.util.Objects; */ @Getter @AllArgsConstructor -public enum SelfTestStateChangeEvent { +public enum SelfTestStateChangeEvent implements AbstractStateChangeEvent { SUBMIT_SELF_TEST_INFO(1100, null, null), SELF_TEST_PASSED(1101, null, null), @@ -27,40 +25,4 @@ public enum SelfTestStateChangeEvent { private final Integer rejectStatusCode; private final Integer withdrawStatusCode; - public static SelfTestStateChangeEvent getPassValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (SelfTestStateChangeEvent t : SelfTestStateChangeEvent.values()) { - if (code.equals(t.getPassStatusCode())) { - return t; - } - } - return null; - } - - public static SelfTestStateChangeEvent getRejectValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (SelfTestStateChangeEvent t : SelfTestStateChangeEvent.values()) { - if (code.equals(t.getRejectStatusCode())) { - return t; - } - } - return null; - } - - public static SelfTestStateChangeEvent getWithdrawValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (SelfTestStateChangeEvent t : SelfTestStateChangeEvent.values()) { - if (code.equals(t.getWithdrawStatusCode())) { - return t; - } - } - return null; - } - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TenderStatusChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TenderStateChangeEvent.java similarity index 55% rename from hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TenderStatusChangeEvent.java rename to hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TenderStateChangeEvent.java index 3f56b34..ffb5e31 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TenderStatusChangeEvent.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TenderStateChangeEvent.java @@ -3,8 +3,6 @@ package com.hz.pm.api.common.statemachine.event; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.Objects; - /** *

* TenderStatusChangeEvent @@ -15,7 +13,7 @@ import java.util.Objects; */ @Getter @AllArgsConstructor -public enum TenderStatusChangeEvent { +public enum TenderStateChangeEvent implements AbstractStateChangeEvent { /** * 填写采购信息 @@ -71,40 +69,4 @@ public enum TenderStatusChangeEvent { private final Integer rejectStatusCode; private final Integer withdrawStatusCode; - public static TenderStatusChangeEvent getPassValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (TenderStatusChangeEvent t : TenderStatusChangeEvent.values()) { - if (code.equals(t.getPassStatusCode())) { - return t; - } - } - return null; - } - - public static TenderStatusChangeEvent getRejectValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (TenderStatusChangeEvent t : TenderStatusChangeEvent.values()) { - if (code.equals(t.getRejectStatusCode())) { - return t; - } - } - return null; - } - - public static TenderStatusChangeEvent getWithdrawValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (TenderStatusChangeEvent t : TenderStatusChangeEvent.values()) { - if (code.equals(t.getWithdrawStatusCode())) { - return t; - } - } - return null; - } - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java index 31e0b66..be7b189 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java @@ -3,8 +3,6 @@ package com.hz.pm.api.common.statemachine.event; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.Objects; - /** *

* TenderStatusChangeEvent @@ -15,7 +13,7 @@ import java.util.Objects; */ @Getter @AllArgsConstructor -public enum TestValidStateChangeEvent { +public enum TestValidStateChangeEvent implements AbstractStateChangeEvent { /** * 填写测试验证信息 @@ -39,40 +37,4 @@ public enum TestValidStateChangeEvent { private final Integer rejectStatusCode; private final Integer withdrawStatusCode; - public static TestValidStateChangeEvent getPassValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (TestValidStateChangeEvent t : TestValidStateChangeEvent.values()) { - if (code.equals(t.getPassStatusCode())) { - return t; - } - } - return null; - } - - public static TestValidStateChangeEvent getRejectValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (TestValidStateChangeEvent t : TestValidStateChangeEvent.values()) { - if (code.equals(t.getRejectStatusCode())) { - return t; - } - } - return null; - } - - public static TestValidStateChangeEvent getWithdrawValueByCode(Integer code) { - if (Objects.isNull(code)) { - return null; - } - for (TestValidStateChangeEvent t : TestValidStateChangeEvent.values()) { - if (code.equals(t.getWithdrawStatusCode())) { - return t; - } - } - return null; - } - } 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 index b6fcb2e..24bc986 100644 --- 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 @@ -1,6 +1,6 @@ package com.hz.pm.api.common.statemachine.factory; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import org.springframework.statemachine.StateContext; import org.springframework.statemachine.guard.Guard; @@ -16,9 +16,9 @@ public class ProjectDeclareGuardFactory { private ProjectDeclareGuardFactory() { } - public static class PendingPreQualificationChoiceGuard implements Guard { + public static class PendingPreQualificationChoiceGuard implements Guard { @Override - public boolean evaluate(StateContext context) { + public boolean evaluate(StateContext context) { // 判断申报项目是否是市级项目,且申报金额是否大于等于1000万元 return true; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AbstractStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AbstractStateMachineUtil.java new file mode 100644 index 0000000..c51b278 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AbstractStateMachineUtil.java @@ -0,0 +1,68 @@ +package com.hz.pm.api.common.statemachine.util; + +import com.hz.pm.api.common.statemachine.event.AbstractStateChangeEvent; +import com.ningdatech.basic.exception.BizException; +import com.wflow.exception.BusinessException; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.function.Function; + +/** + *

+ * AbstractStateMachineUtil + *

+ * + * @author WendyYang + * @since 19:39 2024/4/2 + */ +public interface AbstractStateMachineUtil & AbstractStateChangeEvent> { + + /** + * 获取状态变更事件类型 + * + * @return java.lang.Class + **/ + default Class eventClass() { + Type type = getClass().getGenericInterfaces()[0]; + return (Class) ((ParameterizedType) type).getActualTypeArguments()[1]; + } + + //通过审核 + default void pass(O obj) { + try { + execute(obj, AbstractStateChangeEvent.getPassEvent(eventClass(), statusFunction().apply(obj))); + } catch (Exception e) { + LoggerFactory.getLogger(this.getClass()).info("状态机 通过失败 :{}", e.getMessage()); + throw BizException.wrap("状态机通过失败"); + } + } + + + //拒绝 + default void reject(O obj) { + try { + execute(obj, AbstractStateChangeEvent.getRejectEvent(eventClass(), statusFunction().apply(obj))); + } catch (Exception e) { + LoggerFactory.getLogger(this.getClass()).info("状态机 拒绝失败 :{}", e.getMessage()); + throw new BusinessException("状态机拒绝失败"); + } + } + + //撤回 + default void withDraw(O obj) { + try { + execute(obj, AbstractStateChangeEvent.getWithdrawEvent(eventClass(), statusFunction().apply(obj))); + } catch (Exception e) { + LoggerFactory.getLogger(this.getClass()).info("状态机 撤回失败 :{}", e.getMessage()); + throw new BusinessException("状态机撤回失败"); + } + } + + Function statusFunction(); + + void execute(O o, E event) throws Exception; + + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java index 9e5e360..e43ded9 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java @@ -1,15 +1,12 @@ package com.hz.pm.api.common.statemachine.util; -import com.hz.pm.api.common.statemachine.builder.AdaptStateMachineBuilder; +import com.hz.pm.api.common.statemachine.builder.impl.AdaptStateMachineBuilderImpl; import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; -import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.TenderAdaptStatusEnum; import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; -import com.ningdatech.basic.exception.BizException; -import com.wflow.exception.BusinessException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; @@ -19,7 +16,7 @@ import org.springframework.statemachine.persist.StateMachinePersister; import org.springframework.stereotype.Component; import java.time.LocalDateTime; -import java.util.Objects; +import java.util.function.Function; /** *

@@ -32,46 +29,21 @@ import java.util.Objects; @Slf4j @Component @RequiredArgsConstructor -public class AdaptStateMachineUtil { +public class AdaptStateMachineUtil implements AbstractStateMachineUtil { public static final String PURCHASE = "purchaseInfo"; //================================================================================================================== - private final AdaptStateMachineBuilder adaptStateMachineBuilder; + private final AdaptStateMachineBuilderImpl adaptStateMachineBuilder; private final IPurchaseStatusChangeService purchaseStatusChangeService; - - //通过审核 - public void pass(Purchase purchase) { - try { - execute(purchase, getPassEvent(purchase.getAdaptStatus())); - } catch (Exception e) { - log.info("状态机 通过失败 :{}", e.getMessage()); - throw new BusinessException("状态机 通过失败: " + e); - } - } - - //拒绝 - public void reject(Purchase purchase) { - try { - execute(purchase, getRejectEvent(purchase.getAdaptStatus())); - } catch (Exception e) { - log.info("状态机 拒绝失败 :{}", e.getMessage()); - throw new BusinessException("状态机 拒绝失败: " + e); - } - } - - //撤回 - public void withDraw(Purchase purchase) { - try { - execute(purchase, getWithdrawEvent(purchase.getAdaptStatus())); - } catch (Exception e) { - log.info("状态机 撤回失败 :{}", e.getMessage()); - throw new BusinessException("状态机 撤回失败: " + e); - } + @Override + public Function statusFunction() { + return Purchase::getAdaptStatus; } + @Override public void execute(Purchase purchase, AdaptStateChangeEvent event) throws Exception { log.info("调用状态机前的标段状态为:{}", purchase.getStatus()); // 获取TO状态机 @@ -95,29 +67,4 @@ public class AdaptStateMachineUtil { log.info("调用状态机后的标段状态为:{}", purchase.getAdaptStatus()); } - - public AdaptStateChangeEvent getPassEvent(Integer status) { - AdaptStateChangeEvent event = AdaptStateChangeEvent.getPassValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的通过操作!"); - } - return event; - } - - public AdaptStateChangeEvent getRejectEvent(Integer status) { - AdaptStateChangeEvent event = AdaptStateChangeEvent.getRejectValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的驳回操作!"); - } - return event; - } - - public AdaptStateChangeEvent getWithdrawEvent(Integer status) { - AdaptStateChangeEvent event = AdaptStateChangeEvent.getWithdrawValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的撤回操作!"); - } - return event; - } - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/ProjectStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/ProjectStateMachineUtil.java new file mode 100644 index 0000000..0522dd5 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/ProjectStateMachineUtil.java @@ -0,0 +1,77 @@ +package com.hz.pm.api.common.statemachine.util; + +import com.hz.pm.api.common.model.constant.StateMachineConst; +import com.hz.pm.api.common.statemachine.builder.impl.ProjectStateMachineBuilderImpl; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; +import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; +import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; +import com.hz.pm.api.projectlib.service.IProjectApplicationService; +import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.messaging.Message; +import org.springframework.messaging.support.MessageBuilder; +import org.springframework.statemachine.StateMachine; +import org.springframework.statemachine.persist.StateMachinePersister; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.function.Function; + +/** + * 状态机工具类 + * + * @author CMM + * @since 2023/02/07 22:49 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class ProjectStateMachineUtil implements AbstractStateMachineUtil { + + private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE; + + private static final String APPLICATION_DECLARE = StateMachineConst.APPLICATION_DECLARE; + + //================================================================================================================== + + private final ProjectStateMachineBuilderImpl projectStateMachineBuilder; + + private final IProjectStatusChangeService projectStatusChangeService; + + private final IProjectApplicationService projectApplicationService; + + @Override + public Function statusFunction() { + return Project::getStatus; + } + + @Override + public void execute(Project project, ProjectStateChangeEvent event) throws Exception { + log.info("调用状态机前的项目状态为:{}", project.getStatus()); + // 将状态变更记录保存到项目状态变更表中 + ProjectStatusChange projectStatusChange = new ProjectStatusChange(); + projectStatusChange.setBeforeStatus(project.getStatus()); + + // 获取TO状态机 + StateMachine stateMachine = projectStateMachineBuilder.build(); + Message message = MessageBuilder.withPayload(event) + .setHeader(PROJECT_DECLARE, project) + .setHeader(APPLICATION_DECLARE, projectApplicationService.getApplicationsByProject(project)) + .build(); + //初始化状态机 + StateMachinePersister projectDeclareStateMachinePersister = projectStateMachineBuilder.stateMachinePersister(); + projectDeclareStateMachinePersister.restore(stateMachine, project); + stateMachine.sendEvent(message); + projectStatusChange.setProjectId(project.getId()); + projectStatusChange.setAfterStatus(project.getStatus()); + projectStatusChange.setEvent(event.name()); + projectStatusChange.setCreateOn(LocalDateTime.now()); + projectStatusChange.setProjectCode(project.getProjectCode()); + // 插入项目状态变更表中 + projectStatusChangeService.save(projectStatusChange); + log.info("调用状态机后的项目状态为:{}", project.getStatus()); + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java index 8c47053..89d2535 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java @@ -1,15 +1,12 @@ package com.hz.pm.api.common.statemachine.util; -import com.hz.pm.api.common.statemachine.builder.SelfTestStateMachineBuilder; +import com.hz.pm.api.common.statemachine.builder.impl.SelfTestStateMachineBuilderImpl; import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; -import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.TenderSelfTestStatusEnum; import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; -import com.ningdatech.basic.exception.BizException; -import com.wflow.exception.BusinessException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; @@ -19,7 +16,7 @@ import org.springframework.statemachine.persist.StateMachinePersister; import org.springframework.stereotype.Component; import java.time.LocalDateTime; -import java.util.Objects; +import java.util.function.Function; /** *

@@ -32,45 +29,21 @@ import java.util.Objects; @Slf4j @Component @RequiredArgsConstructor -public class SelfTestStateMachineUtil { +public class SelfTestStateMachineUtil implements AbstractStateMachineUtil { public static final String PURCHASE = "purchaseInfo"; //================================================================================================================== - private final SelfTestStateMachineBuilder selfTestStateMachineBuilder; + private final SelfTestStateMachineBuilderImpl selfTestStateMachineBuilder; private final IPurchaseStatusChangeService purchaseStatusChangeService; - //通过审核 - public void pass(Purchase purchase) { - try { - execute(purchase, getPassEvent(purchase.getSelfTestStatus())); - } catch (Exception e) { - log.info("状态机 通过失败 :{}", e.getMessage()); - throw new BusinessException("状态机 通过失败: " + e); - } - } - - //拒绝 - public void reject(Purchase purchase) { - try { - execute(purchase, getRejectEvent(purchase.getSelfTestStatus())); - } catch (Exception e) { - log.info("状态机 拒绝失败 :{}", e.getMessage()); - throw new BusinessException("状态机 拒绝失败: " + e); - } - } - - //撤回 - public void withDraw(Purchase purchase) { - try { - execute(purchase, getWithdrawEvent(purchase.getSelfTestStatus())); - } catch (Exception e) { - log.info("状态机 撤回失败 :{}", e.getMessage()); - throw new BusinessException("状态机 撤回失败: " + e); - } + @Override + public Function statusFunction() { + return Purchase::getSelfTestStatus; } + @Override public void execute(Purchase purchase, SelfTestStateChangeEvent event) throws Exception { log.info("调用状态机前的标段状态为:{}", purchase.getSelfTestStatus()); // 获取TO状态机 @@ -94,29 +67,4 @@ public class SelfTestStateMachineUtil { log.info("调用状态机后的标段状态为:{}", purchase.getSelfTestStatus()); } - - public SelfTestStateChangeEvent getPassEvent(Integer status) { - SelfTestStateChangeEvent event = SelfTestStateChangeEvent.getPassValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的通过操作!"); - } - return event; - } - - public SelfTestStateChangeEvent getRejectEvent(Integer status) { - SelfTestStateChangeEvent event = SelfTestStateChangeEvent.getRejectValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的驳回操作!"); - } - return event; - } - - public SelfTestStateChangeEvent getWithdrawEvent(Integer status) { - SelfTestStateChangeEvent event = SelfTestStateChangeEvent.getWithdrawValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的撤回操作!"); - } - return event; - } - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/StateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/StateMachineUtil.java deleted file mode 100644 index a37d7bd..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/StateMachineUtil.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.hz.pm.api.common.statemachine.util; - -import com.hz.pm.api.common.model.constant.StateMachineConst; -import com.hz.pm.api.common.statemachine.builder.ProjectDeclareStateMachineBuilder; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; -import com.hz.pm.api.projectlib.model.entity.Project; -import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; -import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; -import com.hz.pm.api.projectlib.service.IProjectApplicationService; -import com.ningdatech.basic.exception.BizException; -import com.wflow.exception.BusinessException; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.statemachine.StateMachine; -import org.springframework.statemachine.persist.StateMachinePersister; -import org.springframework.stereotype.Component; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Objects; - -/** - * 状态机工具类 - * - * @author CMM - * @since 2023/02/07 22:49 - */ -@Slf4j -@Component -@RequiredArgsConstructor -public class StateMachineUtil { - - private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE; - - private static final String APPLICATION_DECLARE = StateMachineConst.APPLICATION_DECLARE; - - //================================================================================================================== - - private final ProjectDeclareStateMachineBuilder projectDeclareStateMachineBuilder; - - private final IProjectStatusChangeService projectStatusChangeService; - - private final IProjectApplicationService projectApplicationService; - - //通过审核 - public void pass(Project project) { - try { - execute(project, getProjectStatusPassEvent(project.getStatus())); - } catch (Exception e) { - log.info("状态机 通过失败 :{}", e.getMessage()); - throw new BusinessException("状态机 通过失败: " + e); - } - } - - //拒绝 - public void reject(Project project) { - try { - execute(project, getProjectStatusRejectEvent(project.getStatus())); - } catch (Exception e) { - log.info("状态机 拒绝失败 :{}", e.getMessage()); - throw new BusinessException("状态机 拒绝失败: " + e); - } - } - - //撤回 - public void withDraw(Project project) { - try { - execute(project, getProjectStatusWithdrawEvent(project.getStatus())); - } catch (Exception e) { - log.info("状态机 撤回失败 :{}", e.getMessage()); - throw new BusinessException("状态机 撤回失败: " + e); - } - } - - public void execute(Project project, ProjectStatusChangeEvent event) throws Exception { - log.info("调用状态机前的项目状态为:{}", project.getStatus()); - // 将状态变更记录保存到项目状态变更表中 - ProjectStatusChange projectStatusChange = new ProjectStatusChange(); - projectStatusChange.setBeforeStatus(project.getStatus()); - - // 获取TO状态机 - StateMachine stateMachine = projectDeclareStateMachineBuilder.build(); - Message message = MessageBuilder.withPayload(event) - .setHeader(PROJECT_DECLARE, project) - .setHeader(APPLICATION_DECLARE, projectApplicationService.getApplicationsByProject(project)) - .build(); - //初始化状态机 - StateMachinePersister projectDeclareStateMachinePersister = projectDeclareStateMachineBuilder.getProjectPersister(); - projectDeclareStateMachinePersister.restore(stateMachine, project); - stateMachine.sendEvent(message); - projectStatusChange.setProjectId(project.getId()); - projectStatusChange.setAfterStatus(project.getStatus()); - projectStatusChange.setEvent(event.name()); - projectStatusChange.setCreateOn(LocalDateTime.now()); - projectStatusChange.setProjectCode(project.getProjectCode()); - // 插入项目状态变更表中 - projectStatusChangeService.save(projectStatusChange); - log.info("调用状态机后的项目状态为:{}", project.getStatus()); - } - - /** - * 判断项目申报金额是否大于1000万元 - * - * @param project \ - * @return boolean - * @since 2023/02/07 17:13 - */ - public static boolean judgeDeclareAmount(Project project, BigDecimal targetAmount) { - int flag = project.getDeclareAmount().compareTo(targetAmount); - return flag > 0 || flag == 0; - } - - public ProjectStatusChangeEvent getProjectStatusPassEvent(Integer status) { - ProjectStatusChangeEvent event = ProjectStatusChangeEvent.getPassValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的通过操作!"); - } - return event; - } - - public ProjectStatusChangeEvent getProjectStatusRejectEvent(Integer status) { - ProjectStatusChangeEvent event = ProjectStatusChangeEvent.getRejectValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的驳回操作!"); - } - return event; - } - - public ProjectStatusChangeEvent getProjectStatusWithdrawEvent(Integer status) { - ProjectStatusChangeEvent event = ProjectStatusChangeEvent.getWithdrawValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的撤回操作!"); - } - return event; - } - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java index 9ba84bc..94f9da0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java @@ -1,14 +1,12 @@ package com.hz.pm.api.common.statemachine.util; -import com.hz.pm.api.common.statemachine.builder.TenderStateMachineBuilder; -import com.hz.pm.api.common.statemachine.event.TenderStatusChangeEvent; +import com.hz.pm.api.common.statemachine.builder.impl.TenderStateMachineBuilderImpl; +import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; import com.hz.pm.api.projectlib.model.enumeration.TenderStatusEnum; import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; -import com.ningdatech.basic.exception.BizException; -import com.wflow.exception.BusinessException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; @@ -18,7 +16,7 @@ import org.springframework.statemachine.persist.StateMachinePersister; import org.springframework.stereotype.Component; import java.time.LocalDateTime; -import java.util.Objects; +import java.util.function.Function; /** *

@@ -31,91 +29,42 @@ import java.util.Objects; @Slf4j @Component @RequiredArgsConstructor -public class TenderStateMachineUtil { +public class TenderStateMachineUtil implements AbstractStateMachineUtil { public static final String PURCHASE = "purchaseInfo"; //================================================================================================================== - private final TenderStateMachineBuilder tenderStateMachineBuilder; + private final TenderStateMachineBuilderImpl tenderStateMachineBuilder; private final IPurchaseStatusChangeService purchaseStatusChangeService; - //通过审核 - public void pass(Purchase purchase) { - try { - execute(purchase, getPassEvent(purchase.getStatus())); - } catch (Exception e) { - log.info("状态机 通过失败 :{}", e.getMessage()); - throw new BusinessException("状态机 通过失败: " + e); - } + @Override + public Function statusFunction() { + return Purchase::getStatus; } - //拒绝 - public void reject(Purchase purchase) { - try { - execute(purchase, getRejectEvent(purchase.getStatus())); - } catch (Exception e) { - log.info("状态机 拒绝失败 :{}", e.getMessage()); - throw new BusinessException("状态机 拒绝失败: " + e); - } - } - - //撤回 - public void withDraw(Purchase purchase) { - try { - execute(purchase, getWithdrawEvent(purchase.getStatus())); - } catch (Exception e) { - log.info("状态机 撤回失败 :{}", e.getMessage()); - throw new BusinessException("状态机 撤回失败: " + e); - } - } - - public void execute(Purchase purchase, TenderStatusChangeEvent event) throws Exception { + @Override + public void execute(Purchase purchase, TenderStateChangeEvent event) throws Exception { log.info("调用状态机前的标段状态为:{}", purchase.getStatus()); // 获取TO状态机 PurchaseStatusChange change = new PurchaseStatusChange(); - change.setBeforeStatus(purchase.getAdaptStatus()); + change.setBeforeStatus(purchase.getStatus()); change.setEvent(event.name()); change.setBidId(purchase.getId()); change.setProjectId(purchase.getProjectId()); change.setProjectCode(ProjectIdCodeCacheUtil.get(purchase.getProjectId())); change.setCreateOn(LocalDateTime.now()); - StateMachine stateMachine = tenderStateMachineBuilder.build(); - Message message = MessageBuilder.withPayload(event) + StateMachine stateMachine = tenderStateMachineBuilder.build(); + Message message = MessageBuilder.withPayload(event) .setHeader(PURCHASE, purchase) .build(); //初始化状态机 - StateMachinePersister stateMachinePersister = tenderStateMachineBuilder.stateMachinePersister(); + StateMachinePersister stateMachinePersister = tenderStateMachineBuilder.stateMachinePersister(); stateMachinePersister.restore(stateMachine, purchase); stateMachine.sendEvent(message); - change.setAfterStatus(purchase.getAdaptStatus()); + change.setAfterStatus(purchase.getStatus()); purchaseStatusChangeService.save(change); log.info("调用状态机后的标段状态为:{}", purchase.getStatus()); } - - public TenderStatusChangeEvent getPassEvent(Integer status) { - TenderStatusChangeEvent event = TenderStatusChangeEvent.getPassValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的通过操作!"); - } - return event; - } - - public TenderStatusChangeEvent getRejectEvent(Integer status) { - TenderStatusChangeEvent event = TenderStatusChangeEvent.getRejectValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的驳回操作!"); - } - return event; - } - - public TenderStatusChangeEvent getWithdrawEvent(Integer status) { - TenderStatusChangeEvent event = TenderStatusChangeEvent.getWithdrawValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的撤回操作!"); - } - return event; - } - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java index 243f62f..89e58a4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java @@ -1,15 +1,12 @@ package com.hz.pm.api.common.statemachine.util; -import com.hz.pm.api.common.statemachine.builder.TestValidStateMachineBuilder; +import com.hz.pm.api.common.statemachine.builder.impl.TestValidStateMachineBuilderImpl; import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; -import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.TenderTestValidStatusEnum; import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; -import com.ningdatech.basic.exception.BizException; -import com.wflow.exception.BusinessException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; @@ -19,7 +16,7 @@ import org.springframework.statemachine.persist.StateMachinePersister; import org.springframework.stereotype.Component; import java.time.LocalDateTime; -import java.util.Objects; +import java.util.function.Function; /** *

@@ -32,45 +29,21 @@ import java.util.Objects; @Slf4j @Component @RequiredArgsConstructor -public class TestValidStateMachineUtil { +public class TestValidStateMachineUtil implements AbstractStateMachineUtil { public static final String PURCHASE = "purchaseInfo"; //================================================================================================================== - private final TestValidStateMachineBuilder testValidStateMachineBuilder; + private final TestValidStateMachineBuilderImpl testValidStateMachineBuilder; private final IPurchaseStatusChangeService purchaseStatusChangeService; - //通过审核 - public void pass(Purchase purchase) { - try { - execute(purchase, getPassEvent(purchase.getTestValidStatus())); - } catch (Exception e) { - log.info("状态机 通过失败 :{}", e.getMessage()); - throw new BusinessException("状态机 通过失败: " + e); - } - } - - //拒绝 - public void reject(Purchase purchase) { - try { - execute(purchase, getRejectEvent(purchase.getTestValidStatus())); - } catch (Exception e) { - log.info("状态机 拒绝失败 :{}", e.getMessage()); - throw new BusinessException("状态机 拒绝失败: " + e); - } - } - - //撤回 - public void withDraw(Purchase purchase) { - try { - execute(purchase, getWithdrawEvent(purchase.getTestValidStatus())); - } catch (Exception e) { - log.info("状态机 撤回失败 :{}", e.getMessage()); - throw new BusinessException("状态机 撤回失败: " + e); - } + @Override + public Function statusFunction() { + return Purchase::getTestValidStatus; } + @Override public void execute(Purchase purchase, TestValidStateChangeEvent event) throws Exception { log.info("调用状态机前的标段状态为:{}", purchase.getStatus()); // 获取TO状态机 @@ -94,29 +67,4 @@ public class TestValidStateMachineUtil { log.info("调用状态机后的标段状态为:{}", purchase.getStatus()); } - - public TestValidStateChangeEvent getPassEvent(Integer status) { - TestValidStateChangeEvent event = TestValidStateChangeEvent.getPassValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的通过操作!"); - } - return event; - } - - public TestValidStateChangeEvent getRejectEvent(Integer status) { - TestValidStateChangeEvent event = TestValidStateChangeEvent.getRejectValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的驳回操作!"); - } - return event; - } - - public TestValidStateChangeEvent getWithdrawEvent(Integer status) { - TestValidStateChangeEvent event = TestValidStateChangeEvent.getWithdrawValueByCode(status); - if (Objects.isNull(event)) { - throw new BizException("该状态下没有对应的撤回操作!"); - } - return event; - } - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java index 70948a1..15037d4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java @@ -10,7 +10,7 @@ import com.google.common.collect.Lists; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; import com.hz.pm.api.common.util.DecimalUtil; import com.hz.pm.api.common.util.ExcelDownUtil; @@ -89,7 +89,7 @@ public class ConstructionManage { private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; private final IPreInsAcceptancePersonService acceptancePersonService; private final ProcessInstanceService processInstanceService; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; private final IProjectAnnualPaymentPlanService projectPaymentPlanService; private final TenderStateMachineUtil tenderStateMachineUtil; @@ -560,7 +560,7 @@ public class ConstructionManage { .last(BizConst.LIMIT_1); if (purchaseService.count(purchaseQuery) == 0) { Project project = projectService.getById(req.getProjectId()); - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); projectService.updateById(project); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionPlanManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionPlanManage.java index 1fc533e..d7e04d9 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionPlanManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionPlanManage.java @@ -7,10 +7,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; -import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.model.constant.CommonConst; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; import com.hz.pm.api.projectdeclared.model.dto.ConstructionPlanExportDTO; @@ -46,7 +45,6 @@ import com.wflow.exception.BusinessException; import com.wflow.workflow.bean.dto.OrgInfoDTO; import com.wflow.workflow.bean.vo.ProcessStartParamsVo; import com.wflow.workflow.service.ProcessInstanceService; -import com.wflow.workflow.service.ProcessModelService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -77,7 +75,7 @@ public class ConstructionPlanManage { private final ProcessModelManage processModelManage; private final IProjectService projectService; private final ProcessInstanceService processService; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; private final IProjectInstService projectInstService; private final ProjectLibManage projectLibManage; private final DefaultDeclaredProjectManage declaredProjectManage; @@ -136,8 +134,8 @@ public class ConstructionPlanManage { //如果被禁用了的话 直接跳过 进入到下一个状态 if (Boolean.TRUE.equals(wflowModels.getIsStop())) { //被禁用了 调2次状态机 - stateMachineUtil.pass(constructProject); - stateMachineUtil.pass(constructProject); + projectStateMachineUtil.pass(constructProject); + projectStateMachineUtil.pass(constructProject); constructProject.setUpdateOn(LocalDateTime.now()); projectService.updateById(constructProject); return "因为建设方案流程被禁用了 直接跳过!"; @@ -171,7 +169,7 @@ public class ConstructionPlanManage { } private Project contructionPlanModifyProject(Project project, String instanceId) { - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); project.setUpdateOn(LocalDateTime.now()); project.setInstCode(instanceId); projectService.updateById(project); @@ -222,7 +220,7 @@ public class ConstructionPlanManage { project.setInstCode(instanceId); project.setConstructionPlanFile(constructionPlanFile); //调用状态机 进入下一个通过状态 - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); projectService.updateById(project); //保存项目和实例的关系 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java index f8be9cf..0e7903b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java @@ -1,7 +1,6 @@ package com.hz.pm.api.projectdeclared.manage; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ArrayUtil; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Assert; @@ -10,12 +9,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.UserInfoHelper; -import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; -import com.hz.pm.api.common.util.StrUtils; import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO; import com.hz.pm.api.projectdeclared.model.entity.Contract; import com.hz.pm.api.projectdeclared.model.entity.Purchase; @@ -52,7 +49,6 @@ import com.wflow.exception.BusinessException; import com.wflow.workflow.bean.dto.OrgInfoDTO; import com.wflow.workflow.bean.vo.ProcessStartParamsVo; import com.wflow.workflow.service.ProcessInstanceService; -import com.wflow.workflow.service.ProcessModelService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -86,7 +82,7 @@ public class FinalAcceptanceManage { private final DefaultDeclaredProjectManage declaredProjectManage; private final IContractService contractService; private final IProjectAnnualPaymentPlanService projectAnnualPaymentPlanService; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; private final TenderStateMachineUtil tenderStateMachineUtil; private final IProjectInstService projectInstService; private final HandlerManage handlerManage; @@ -296,7 +292,7 @@ public class FinalAcceptanceManage { List currPurchaseInstList = purchaseInstService.list(purchaseInstQuery); Set finalInspectedBidIds = CollUtils.fieldSet(currPurchaseInstList, PurchaseInst::getBidId); if (finalInspectedBidIds.size() == purchases.size()) { - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); projectService.updateById(project); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java index 8d22afb..6026f66 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java @@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; import com.hz.pm.api.projectdeclared.model.dto.OperationReq; import com.hz.pm.api.projectdeclared.model.entity.Operation; @@ -47,7 +47,7 @@ public class OperationManage { private final IPurchaseService purchaseService; private final IProjectService projectService; private final TenderStateMachineUtil tenderStateMachineUtil; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; /** * 获取实施详情 @@ -102,7 +102,7 @@ public class OperationManage { long operationCount = operationService.countByBidIds(purchaseMap.keySet()); if (operationCount == purchaseMap.size()) { // 修改项目状态 - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); projectService.updateById(project); } // 修改标段状态 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PrequalificationDeclaredProjectManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PrequalificationDeclaredProjectManage.java index b3785c9..9a7c160 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PrequalificationDeclaredProjectManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PrequalificationDeclaredProjectManage.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.UserInfoHelper; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; import com.hz.pm.api.projectdeclared.model.dto.DefaultDeclaredDTO; @@ -73,7 +73,7 @@ public class PrequalificationDeclaredProjectManage { private final ProjectLibManage projectLibManage; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; private final IProjectStagingService projectStagingService; @@ -119,7 +119,7 @@ public class PrequalificationDeclaredProjectManage { if (StringUtils.isNotBlank(projectDto.getHigherLineSuperOrgReviewComments())) { projectInfo.setHigherLineSuperOrgReviewComments(projectDto.getHigherLineSuperOrgReviewComments()); } - stateMachineUtil.pass(projectInfo); + projectStateMachineUtil.pass(projectInfo); String instanceId; //如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目) if (ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 3321690..a582dae 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -106,7 +106,7 @@ public class PurchaseManage { private final IContractService contractService; private final IPurchaseService purchaseService; private final TenderStateMachineUtil tenderStateMachineUtil; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; private final MhApiClient mhApiClient; private final MhFileClient mhFileClient; private final FileService fileService; @@ -307,7 +307,7 @@ public class PurchaseManage { }); if (purchaseService.saveOrUpdateBatch(purchaseEntities)) { - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); project.setUpdateOn(LocalDateTime.now()); // 获取总的成交时间及金额 @@ -369,7 +369,7 @@ public class PurchaseManage { return purchase; }).collect(Collectors.toList()); purchaseService.saveOrUpdateBatch(purchases); - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); projectService.updateById(project); // 发布采购公告 mhApiClient.publishPurchaseNotice(notices); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidListReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidListReq.java index ba7bd77..dee20d3 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidListReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidListReq.java @@ -23,10 +23,10 @@ public class TestValidListReq extends PagePo { private Integer status; - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createOnMin; - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createOnMax; private Boolean display; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/PurchaseStatusChange.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/PurchaseStatusChange.java new file mode 100644 index 0000000..458cbe6 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/PurchaseStatusChange.java @@ -0,0 +1,42 @@ +package com.hz.pm.api.projectlib.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * 标段状态变更记录 + *

+ * + * @author WendyYang + * @since 2024-04-01 + */ +@Data +@TableName("ND_PURCHASE_STATUS_CHANGE") +public class PurchaseStatusChange implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "ID", type = IdType.AUTO) + private Long id; + + private Long projectId; + + private Integer beforeStatus; + + private Integer afterStatus; + + private String event; + + private LocalDateTime createOn; + + private String projectCode; + + private Long bidId; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AnnualPlanHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AnnualPlanHandle.java index e586624..23b3327 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AnnualPlanHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AnnualPlanHandle.java @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.model.constant.CommonConst; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; @@ -82,7 +82,7 @@ public class AnnualPlanHandle extends AbstractProcessBusinessHandle { .last(BizConst.LIMIT_1); if (ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode().equals(status)) { // 根据部门联审通过的时间获取 - pscQuery.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS); + pscQuery.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS); ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(pscQuery); if (Objects.nonNull(projectStatusChange)) { processDetailVO.setFinishTime(projectStatusChange.getCreateOn()); @@ -90,7 +90,7 @@ public class AnnualPlanHandle extends AbstractProcessBusinessHandle { } } else if (ProjectStatusEnum.BE_SUSPENDED.getCode().equals(status)) { // 根据年度计划暂缓的时间获取 - pscQuery.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND); + pscQuery.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.ANNUAL_PLAN_SUSPEND); ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(pscQuery); if (Objects.nonNull(projectStatusChange)) { processDetailVO.setFinishTime(projectStatusChange.getCreateOn()); @@ -98,7 +98,7 @@ public class AnnualPlanHandle extends AbstractProcessBusinessHandle { } } else { // 根据开启方案申报的时间获取 - pscQuery.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE); + pscQuery.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE); ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(pscQuery); if (Objects.nonNull(projectStatusChange)) { processDetailVO.setFinishTime(projectStatusChange.getCreateOn()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ArchivedHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ArchivedHandle.java index 392de0d..acf3c66 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ArchivedHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ArchivedHandle.java @@ -13,7 +13,7 @@ import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.model.constant.CommonConst; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; @@ -56,7 +56,7 @@ public class ArchivedHandle extends AbstractProcessBusinessHandle { // 根据项目终验获取归档时间 ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class) .in(ProjectStatusChange::getProjectId, allVersionProjectIds) - .eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS.name()) + .eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.FINAL_ACCEPTANCE_PASS.name()) .orderByDesc(ProjectStatusChange::getCreateOn) .last(BizConst.LIMIT_1)); if(Objects.nonNull(projectStatusChange)){ diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProcessExecuteChainHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProcessExecuteChainHandle.java index 10ff057..6eab33a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProcessExecuteChainHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProcessExecuteChainHandle.java @@ -1,18 +1,12 @@ package com.hz.pm.api.projectlib.handle; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; -import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.model.constant.ProjectDeclareConst; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; import com.hz.pm.api.projectlib.model.entity.Project; -import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.sys.manage.ProcessModelManage; import com.wflow.bean.entity.WflowModels; import com.wflow.workflow.bean.vo.ProcessDetailVO; import com.wflow.workflow.enums.StepStatusEnum; -import com.wflow.workflow.service.ProcessModelService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectApprovalHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectApprovalHandle.java index c432167..4ec90e2 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectApprovalHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectApprovalHandle.java @@ -1,7 +1,7 @@ package com.hz.pm.api.projectlib.handle; import com.hz.pm.api.common.model.constant.CommonConst; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; @@ -58,9 +58,9 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle { || ProjectStatusEnum.DECLARED_APPROVED_TO_BE_RECORD.eq(status) || ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING.eq(status)) { // 根据建设方案评审通过的时间获取 - final List events = Arrays.asList(ProjectStatusChangeEvent.PLAN_REVIEW_PASS, - ProjectStatusChangeEvent.DECLARED_RECORD_SUBMIT, - ProjectStatusChangeEvent.DECLARED_RECORD_RESUBMIT); + final List events = Arrays.asList(ProjectStateChangeEvent.PLAN_REVIEW_PASS, + ProjectStateChangeEvent.DECLARED_RECORD_SUBMIT, + ProjectStateChangeEvent.DECLARED_RECORD_RESUBMIT); ProjectStatusChange projectStatusChange = projectStatusChangeService.getLastOne(allProjectIds, events); if (projectStatusChange != null) { processDetail.setFinishTime(projectStatusChange.getCreateOn()); @@ -68,9 +68,9 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle { processDetail.setStepStatus(StepStatusEnum.ON_GOING); } else { // 取 状态机 改变状态时间 - final List events = Arrays.asList(ProjectStatusChangeEvent.PLAN_REVIEW_PASS, - ProjectStatusChangeEvent.DECLARED_RECORD_FAILED, - ProjectStatusChangeEvent.DECLARED_RECORD_PASS); + final List events = Arrays.asList(ProjectStateChangeEvent.PLAN_REVIEW_PASS, + ProjectStateChangeEvent.DECLARED_RECORD_FAILED, + ProjectStateChangeEvent.DECLARED_RECORD_PASS); ProjectStatusChange projectStatusChange = projectStatusChangeService.getLastOne(allProjectIds, events); if (Objects.nonNull(projectStatusChange)) { processDetail.setFinishTime(projectStatusChange.getCreateOn()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectPreliminaryInspectionHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectPreliminaryInspectionHandle.java index af94e6c..3db4c41 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectPreliminaryInspectionHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectPreliminaryInspectionHandle.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.util.CollUtils; import com.hz.pm.api.common.model.constant.CommonConst; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; import com.hz.pm.api.projectlib.model.entity.Project; @@ -76,7 +76,7 @@ public class ProjectPreliminaryInspectionHandle extends AbstractProcessBusinessH // 根据初验备案的时间获取 ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class) .in(ProjectStatusChange::getProjectId, allVersionProjectIds) - .eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD.name()) + .eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD.name()) .orderByDesc(ProjectStatusChange::getCreateOn) .last(BizConst.LIMIT_1)); if(Objects.nonNull(projectStatusChange)){ diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/TenderPurchaseHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/TenderPurchaseHandle.java index dad551f..2443e71 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/TenderPurchaseHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/TenderPurchaseHandle.java @@ -3,7 +3,7 @@ package com.hz.pm.api.projectlib.handle; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.model.constant.CommonConst; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; @@ -74,7 +74,7 @@ public class TenderPurchaseHandle extends AbstractProcessBusinessHandle { // 根据采购备案的时间获取 ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class) .in(ProjectStatusChange::getProjectId, allVersionProjectIds) - .eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.SUBMIT_PURCHASE_NOTICE.name()) + .eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.SUBMIT_PURCHASE_NOTICE.name()) .orderByDesc(ProjectStatusChange::getCreateOn) .last(BizConst.LIMIT_1)); if (projectStatusChange != null) { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java index 5d19b60..73f3fa5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java @@ -17,7 +17,7 @@ import com.hz.pm.api.common.model.constant.CommonConst; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.model.entity.ExcelExportWriter; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.datascope.model.DataScopeDTO; @@ -82,7 +82,7 @@ public class AnnualPlanLibManage { private final IProjectService projectService; private final MhUnitCache mhUnitCache; private final IProjectApplicationService applicationService; - private final StateMachineUtil stateMachine; + private final ProjectStateMachineUtil stateMachine; private final UserInfoHelper userInfoHelper; private final IProjectRenewalFundDeclarationService projectRenewalFundDeclarationService; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java index c218485..e77ee5e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java @@ -15,7 +15,7 @@ import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.model.constant.TypeReferenceConst; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.utils.DataScopeUtil; @@ -334,7 +334,7 @@ public class DeclaredRecordManage { ProjectProcessStageEnum.PROJECT_RECORD_APPROVAL_PROCESS); // 保存状态变更 saveProjectStatusChangeLog(ProjectStatusEnum.DECLARED_APPROVED_TO_BE_RECORD, - newProj, ProjectStatusChangeEvent.DECLARED_RECORD_SUBMIT); + newProj, ProjectStateChangeEvent.DECLARED_RECORD_SUBMIT); if (Objects.nonNull(projectInfo.getDraftId())) { //如果是草稿箱提交 删除对应的草稿箱 projectDraftService.removeById(projectInfo.getDraftId()); @@ -417,7 +417,7 @@ public class DeclaredRecordManage { instType); // 保存状态变更 saveProjectStatusChangeLog(ProjectStatusEnum.DECLARED_APPROVED_RECORD_FAILED, - newProj, ProjectStatusChangeEvent.DECLARED_RECORD_RESUBMIT); + newProj, ProjectStateChangeEvent.DECLARED_RECORD_RESUBMIT); //发送给第一个审批人消息 noticeManage.sendFirstUser(newProj, model.getFormName(), instId, WorkNoticeConst.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); @@ -425,7 +425,7 @@ public class DeclaredRecordManage { return instId; } - private void saveProjectStatusChangeLog(ProjectStatusEnum beforeStatus, Project project, ProjectStatusChangeEvent event) { + private void saveProjectStatusChangeLog(ProjectStatusEnum beforeStatus, Project project, ProjectStateChangeEvent event) { ProjectStatusChange change = new ProjectStatusChange(); change.setAfterStatus(project.getStatus()); change.setProjectId(project.getId()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java index 75f98d6..7a87869 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java @@ -20,7 +20,7 @@ import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.model.constant.CommonConst; import com.hz.pm.api.common.model.entity.ExcelExportWriter; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.StrUtils; @@ -127,7 +127,7 @@ public class ProjectLibManage { private final IProjectApplicationService projectApplicationService; private final ProjectCodeGenUtil projectCodeGenUtil; private final IProjectInstService projectInstService; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; private final INdProjectDelayApplyService projectDelayApplyService; private final INdProjectApplyBorrowService projectApplyBorrowService; private final IPurchaseService purchaseService; @@ -1040,7 +1040,7 @@ public class ProjectLibManage { project.setCreateOn(LocalDateTime.now()); project.setUpdateOn(LocalDateTime.now()); project.setIsBackReject(Boolean.FALSE); - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); projectService.save(project); oldProject.setIsBackReject(Boolean.TRUE); @@ -1180,7 +1180,7 @@ public class ProjectLibManage { project.setIsBackReject(isBackReject); //终验材料 project.setFinalAcceptanceMaterials(dto.getFinalAcceptanceMaterials()); - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); oldProject.setIsBackReject(isBackReject); projectService.updateById(oldProject); @@ -1215,7 +1215,7 @@ public class ProjectLibManage { project.setUpdateOn(LocalDateTime.now()); // 标识保存的项目信息是否为建设方案申报项目 project.setIsConstruct(Boolean.FALSE); - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); oldProject.setIsBackReject(Boolean.TRUE); projectService.updateById(oldProject); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/PurchaseStatusChangeMapper.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/PurchaseStatusChangeMapper.java new file mode 100644 index 0000000..4b5afc4 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/PurchaseStatusChangeMapper.java @@ -0,0 +1,16 @@ +package com.hz.pm.api.projectlib.mapper; + +import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author WendyYang + * @since 2024-04-01 + */ +public interface PurchaseStatusChangeMapper extends BaseMapper { + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/PurchaseStatusChangeMapper.xml b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/PurchaseStatusChangeMapper.xml new file mode 100644 index 0000000..c422fd3 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/PurchaseStatusChangeMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java index 54f4ccc..c602c87 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectStatusChangeService.java @@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.IService; import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; import java.util.Collection; @@ -20,7 +20,7 @@ import java.util.Collection; */ public interface IProjectStatusChangeService extends IService { - default ProjectStatusChange getLastOne(ProjectStatusChangeEvent event, Long projectId) { + default ProjectStatusChange getLastOne(ProjectStateChangeEvent event, Long projectId) { Wrapper query = Wrappers.lambdaQuery(ProjectStatusChange.class) .eq(ProjectStatusChange::getEvent, event) .eq(ProjectStatusChange::getProjectId, projectId) @@ -29,7 +29,7 @@ public interface IProjectStatusChangeService extends IService projectIds) { + default ProjectStatusChange getLastOne(ProjectStateChangeEvent event, Collection projectIds) { Wrapper query = Wrappers.lambdaQuery(ProjectStatusChange.class) .in(ProjectStatusChange::getProjectId, projectIds) .eq(ProjectStatusChange::getEvent, event) @@ -38,7 +38,7 @@ public interface IProjectStatusChangeService extends IService projectIds, Collection events) { + default ProjectStatusChange getLastOne(Collection projectIds, Collection events) { LambdaQueryWrapper pscQuery = Wrappers.lambdaQuery(ProjectStatusChange.class) .in(ProjectStatusChange::getProjectId, projectIds) .in(ProjectStatusChange::getEvent, events) @@ -47,7 +47,7 @@ public interface IProjectStatusChangeService extends IService events) { + default ProjectStatusChange getLastOne(String projectCode, Collection events) { LambdaQueryWrapper pscQuery = Wrappers.lambdaQuery(ProjectStatusChange.class) .eq(ProjectStatusChange::getProjectCode, projectCode) .in(ProjectStatusChange::getEvent, events) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IPurchaseStatusChangeService.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IPurchaseStatusChangeService.java new file mode 100644 index 0000000..1754c81 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IPurchaseStatusChangeService.java @@ -0,0 +1,16 @@ +package com.hz.pm.api.projectlib.service; + +import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author WendyYang + * @since 2024-04-01 + */ +public interface IPurchaseStatusChangeService extends IService { + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/impl/PurchaseStatusChangeServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/impl/PurchaseStatusChangeServiceImpl.java new file mode 100644 index 0000000..0c16b88 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/impl/PurchaseStatusChangeServiceImpl.java @@ -0,0 +1,20 @@ +package com.hz.pm.api.projectlib.service.impl; + +import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; +import com.hz.pm.api.projectlib.mapper.PurchaseStatusChangeMapper; +import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author WendyYang + * @since 2024-04-01 + */ +@Service +public class PurchaseStatusChangeServiceImpl extends ServiceImpl implements IPurchaseStatusChangeService { + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/ProcessStartListener.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/ProcessStartListener.java index 09db53e..9fd7fd5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/ProcessStartListener.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/ProcessStartListener.java @@ -3,7 +3,7 @@ package com.hz.pm.api.scheduler.listener; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectInst; import com.hz.pm.api.projectlib.service.IProjectInstService; @@ -38,7 +38,7 @@ public class ProcessStartListener { private final HistoryService historyService; private final IProjectInstService projectInstService; private final IProjectService projectService; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; @Async @EventListener @@ -80,7 +80,7 @@ public class ProcessStartListener { //如果真的没有实时任务和历史任务 那么说明 该项目没有人审批 需要去调用状态机 Long projectId = projectInst.getProjectId(); Project project = projectService.getNewProject(projectId); - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); project.setUpdateOn(LocalDateTime.now()); projectService.updateById(project); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CheckProvincialReviewResultTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CheckProvincialReviewResultTask.java index 1267a79..eb35319 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CheckProvincialReviewResultTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CheckProvincialReviewResultTask.java @@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.model.constant.ProjectDeclareConst; import com.hz.pm.api.common.model.constant.RegionConst; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.service.IProjectService; @@ -42,7 +42,7 @@ public class CheckProvincialReviewResultTask { private final IJoinReviewProvincialBureauService reviewProvincialBureauService; private final IProjectService projectService; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; @Value("${hostname:}") private String HOST_NAME; @@ -96,7 +96,7 @@ public class CheckProvincialReviewResultTask { //在省级联审 才调状态机 否则 只改变 联审结果 if(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode().equals( project.getStatus())){ - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); } log.info("已经审批完成 进入下一状态"); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/HandlerManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/HandlerManage.java index 1cd33cc..718a1f7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/HandlerManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/HandlerManage.java @@ -87,7 +87,7 @@ public class HandlerManage { private final TaskService taskService; private final HistoryService historyService; private final IProjectService projectService; - private final StateMachineUtil stateMachineUtil; + private final ProjectStateMachineUtil projectStateMachineUtil; private final ProcessInstanceService processInstanceService; private final IProjectApplicationService projectApplicationService; private final IProjectStagingService projectStagingService; @@ -303,7 +303,7 @@ public class HandlerManage { return; } if (wflowHelper.allInstancesFinished(instCodes)) { - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); projectService.updateById(project); } } @@ -521,7 +521,7 @@ public class HandlerManage { */ public void updatePassProjectStatus(Long userId, Project project) { try { - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); project.setUpdateOn(LocalDateTime.now()); project.setUpdateBy(userId); projectService.updateById(project); @@ -541,7 +541,7 @@ public class HandlerManage { * @since 2023/02/08 */ private void updateRejectProjectStatus(Long userId, Project project, Integer instType) { - stateMachineUtil.reject(project); + projectStateMachineUtil.reject(project); project.setUpdateOn(LocalDateTime.now()); project.setUpdateBy(userId); projectService.updateById(project); @@ -579,7 +579,7 @@ public class HandlerManage { //删除项目的实例信息 historyService.deleteHistoricProcessInstance(project.getInstCode()); - stateMachineUtil.withDraw(project); + projectStateMachineUtil.withDraw(project); project.setUpdateOn(LocalDateTime.now()); project.setUpdateBy(userId); project.setInstCode(TodoCenterConst.Declared.NULL_INST_CODE); diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/sys/project/ProjectStateTest.java b/hz-pm-api/src/test/java/com/hz/pm/api/sys/project/ProjectStateTest.java index f3605fc..652c05d 100644 --- a/hz-pm-api/src/test/java/com/hz/pm/api/sys/project/ProjectStateTest.java +++ b/hz-pm-api/src/test/java/com/hz/pm/api/sys/project/ProjectStateTest.java @@ -3,7 +3,7 @@ package com.hz.pm.api.sys.project; import cn.hutool.core.date.StopWatch; import com.alibaba.fastjson.JSON; import com.hz.pm.api.AppTests; -import com.hz.pm.api.common.statemachine.util.StateMachineUtil; +import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.service.IProjectService; @@ -20,7 +20,7 @@ import javax.annotation.Resource; public class ProjectStateTest extends AppTests { @Resource - private StateMachineUtil stateMachineUtil; + private ProjectStateMachineUtil projectStateMachineUtil; @Resource private IProjectService projectService; @@ -37,7 +37,7 @@ public class ProjectStateTest extends AppTests { project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()); //调用状态机 进入下一个通过状态 - stateMachineUtil.pass(project); + projectStateMachineUtil.pass(project); stopWatch.stop(); System.out.println("调用状态机结束 :" + stopWatch.getTotalTimeSeconds());