# Conflicts: # pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/util/StateMachineUtils.javatags/24080901
@@ -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.ProjectStatusChange; | ||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | import com.ningdatech.pmapi.projectlib.model.entity.Project; | ||||
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService; | import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService; | ||||
import com.wflow.exception.BusinessException; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.messaging.Message; | import org.springframework.messaging.Message; | ||||
@@ -41,37 +42,34 @@ public class StateMachineUtils { | |||||
@Resource(name = "projectDeclareStateMachinePersister") | @Resource(name = "projectDeclareStateMachinePersister") | ||||
private StateMachinePersister 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 { | public void execute(Project project, ProjectStatusChangeEvent event) throws Exception { | ||||
@@ -121,13 +121,7 @@ public class PrequalificationDeclaredProjectManage { | |||||
//TODO 再判断 该项目是否 真实走完 单位内部审批 | //TODO 再判断 该项目是否 真实走完 单位内部审批 | ||||
//使用状态机 进入下一步 看看需不需要走省级审批 | //使用状态机 进入下一步 看看需不需要走省级审批 | ||||
try { | |||||
stateMachineUtils.pass(projectInfo); | |||||
} catch (Exception e) { | |||||
log.error("项目 调用状态机出错:",e); | |||||
throw new BusinessException(projectInfo.getId() + "项目 调用状态机出错 :" + e.getMessage()); | |||||
} | |||||
stateMachineUtils.pass(projectInfo); | |||||
String instanceId = null; | String instanceId = null; | ||||
//如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目) | //如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目) | ||||
if(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS | if(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS | ||||
@@ -131,7 +131,7 @@ public class AnnualPlanLibManage { | |||||
} | } | ||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public void projectApproved(ProjectApprovedReq req) throws Exception { | |||||
public void projectApproved(ProjectApprovedReq req) { | |||||
Project project = projectService.getById(req.getProjectId()); | Project project = projectService.getById(req.getProjectId()); | ||||
stateMachine.pass(project); | stateMachine.pass(project); | ||||
LambdaUpdateWrapper<Project> update = Wrappers.lambdaUpdate(Project.class) | LambdaUpdateWrapper<Project> update = Wrappers.lambdaUpdate(Project.class) | ||||
@@ -145,7 +145,7 @@ public class AnnualPlanLibManage { | |||||
} | } | ||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public void suspendAnnualPlan(ProjectIdReq req) throws Exception { | |||||
public void suspendAnnualPlan(ProjectIdReq req) { | |||||
Project project = projectService.getById(req.getProjectId()); | Project project = projectService.getById(req.getProjectId()); | ||||
stateMachine.reject(project); | stateMachine.reject(project); | ||||
projectService.updateById(project); | projectService.updateById(project); | ||||
@@ -422,13 +422,9 @@ public class TodoCenterManage { | |||||
* @since 2023/02/08 | * @since 2023/02/08 | ||||
*/ | */ | ||||
private void updateRejectProjectStatus(Long userId, Project declaredProject) { | 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); | projectService.updateById(declaredProject); | ||||
} | } | ||||
@@ -479,13 +475,9 @@ public class TodoCenterManage { | |||||
* @since 2023/02/08 | * @since 2023/02/08 | ||||
*/ | */ | ||||
private void updatePassProjectStatus(Long userId, Project declaredProject) { | 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); | projectService.updateById(declaredProject); | ||||
} | } | ||||
@@ -22,7 +22,7 @@ public class StateMachineTest extends AppTests { | |||||
private StateMachineUtils stateMachineUtils; | private StateMachineUtils stateMachineUtils; | ||||
@Test | @Test | ||||
public void stateMachineTest() throws Exception { | |||||
public void stateMachineTest() { | |||||
Project project = new Project(); | Project project = new Project(); | ||||
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode()); | project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode()); | ||||
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode()); | project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode()); | ||||