diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/util/StateMachineUtils.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/util/StateMachineUtils.java index c8c4dd7..d818f2a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/util/StateMachineUtils.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/util/StateMachineUtils.java @@ -9,6 +9,7 @@ import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService; +import com.wflow.exception.BusinessException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; @@ -41,37 +42,34 @@ public class StateMachineUtils { @Resource(name = "projectDeclareStateMachinePersister") private StateMachinePersister projectDeclareStateMachinePersister; - /** - * 审核通过 - * @param project - * @return void - * @author CMM - * @since 2023/03/10 13:40 - */ - public void pass(Project project) throws Exception { - execute(project,getProjectStatusPassEvent(project.getStatus())); + //通过审核 + public void pass(Project project) { + try{ + execute(project,getProjectStatusPassEvent(project.getStatus())); + }catch (Exception e){ + log.info("状态机 通过失败 :{}",e.getMessage()); + throw new BusinessException("状态机 通过失败: " + e); + } } - /** - * 审核驳回 - * @param project - * @return void - * @author CMM - * @since 2023/03/10 13:40 - */ - public void reject(Project project) throws Exception { - execute(project,getProjectStatusRejectEvent(project.getStatus())); + //拒绝 + public void reject(Project project) { + try{ + execute(project,getProjectStatusRejectEvent(project.getStatus())); + }catch (Exception e){ + log.info("状态机 拒绝失败 :{}",e.getMessage()); + throw new BusinessException("状态机 拒绝失败: " + e); + } } - /** - * 审核撤回 - * @param project - * @return void - * @author CMM - * @since 2023/03/10 13:40 - */ - public void withDraw(Project project) throws Exception { - execute(project,getProjectStatusWithdrawEvent(project.getStatus())); + //撤回 + 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 { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java index 182f653..c59cb87 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java @@ -121,13 +121,7 @@ public class PrequalificationDeclaredProjectManage { //TODO 再判断 该项目是否 真实走完 单位内部审批 //使用状态机 进入下一步 看看需不需要走省级审批 - try { - stateMachineUtils.pass(projectInfo); - } catch (Exception e) { - log.error("项目 调用状态机出错:",e); - throw new BusinessException(projectInfo.getId() + "项目 调用状态机出错 :" + e.getMessage()); - } - + stateMachineUtils.pass(projectInfo); String instanceId = null; //如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目) if(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java index 7e82aa4..c3ebe2c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java @@ -131,7 +131,7 @@ public class AnnualPlanLibManage { } @Transactional(rollbackFor = Exception.class) - public void projectApproved(ProjectApprovedReq req) throws Exception { + public void projectApproved(ProjectApprovedReq req) { Project project = projectService.getById(req.getProjectId()); stateMachine.pass(project); LambdaUpdateWrapper update = Wrappers.lambdaUpdate(Project.class) @@ -145,7 +145,7 @@ public class AnnualPlanLibManage { } @Transactional(rollbackFor = Exception.class) - public void suspendAnnualPlan(ProjectIdReq req) throws Exception { + public void suspendAnnualPlan(ProjectIdReq req) { Project project = projectService.getById(req.getProjectId()); stateMachine.reject(project); projectService.updateById(project); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 3a93ba6..3e9dd7e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -422,13 +422,9 @@ public class TodoCenterManage { * @since 2023/02/08 */ private void updateRejectProjectStatus(Long userId, Project declaredProject) { - try { - stateMachineUtils.reject(declaredProject); - declaredProject.setUpdateOn(LocalDateTime.now()); - declaredProject.setUpdateBy(userId); - } catch (Exception e) { - throw new BizException("状态机执行失败!"); - } + stateMachineUtils.reject(declaredProject); + declaredProject.setUpdateOn(LocalDateTime.now()); + declaredProject.setUpdateBy(userId); projectService.updateById(declaredProject); } @@ -479,13 +475,9 @@ public class TodoCenterManage { * @since 2023/02/08 */ private void updatePassProjectStatus(Long userId, Project declaredProject) { - try { - stateMachineUtils.pass(declaredProject); - declaredProject.setUpdateOn(LocalDateTime.now()); - declaredProject.setUpdateBy(userId); - } catch (Exception e) { - throw new BizException("状态机执行失败!"); - } + stateMachineUtils.pass(declaredProject); + declaredProject.setUpdateOn(LocalDateTime.now()); + declaredProject.setUpdateBy(userId); projectService.updateById(declaredProject); } diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/statemachine/StateMachineTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/statemachine/StateMachineTest.java index 4d964d5..c127bc7 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/statemachine/StateMachineTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/statemachine/StateMachineTest.java @@ -22,7 +22,7 @@ public class StateMachineTest extends AppTests { private StateMachineUtils stateMachineUtils; @Test - public void stateMachineTest() throws Exception { + public void stateMachineTest() { Project project = new Project(); project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode()); project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());