From b2f653db0a42f69734e282526b9810ae8a24f9f0 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 10 Mar 2023 11:45:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=8A=B6=E6=80=81=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kingbasesql/project.sql | 12 +++++++++++- .../common/statemachine/util/StateMachineUtils.java | 15 +++++++++++++++ .../projectdeclared/manage/ConstructionPlanManage.java | 4 ++-- .../projectdeclared/manage/DeclaredProjectManage.java | 11 ++++++++--- .../manage/DefaultDeclaredProjectManage.java | 12 +++++------- .../manage/PrequalificationDeclaredProjectManage.java | 6 +++--- .../manage/ReviewByDeptJointManage.java | 2 +- .../manage/ReviewByProvincialDeptManage.java | 1 + .../projectdeclared/model/dto/ProjectDraftSaveDTO.java | 4 ---- .../projectdeclared/model/entity/ProjectDraft.java | 6 ++++++ .../pmapi/projectdeclared/model/vo/ProjectDraftVO.java | 6 ++++++ .../pmapi/projectlib/manage/AnnualPlanLibManage.java | 6 +++--- .../pmapi/projectlib/model/dto/ProjectDTO.java | 6 ++++++ .../pmapi/projectlib/model/entity/Project.java | 8 +++++++- .../pmapi/projectlib/model/vo/ProjectDetailVO.java | 6 ++++++ .../pmapi/scheduler/task/ProjectStatusFlowTask.java | 2 +- .../pmapi/todocenter/manage/TodoCenterManage.java | 18 +++--------------- .../pmapi/statemachine/StateMachineTest.java | 2 +- .../ningdatech/pmapi/sys/project/ProjectStateTest.java | 2 +- 19 files changed, 86 insertions(+), 43 deletions(-) diff --git a/kingbasesql/project.sql b/kingbasesql/project.sql index 7bcbfbf..1a2b341 100644 --- a/kingbasesql/project.sql +++ b/kingbasesql/project.sql @@ -1,2 +1,12 @@ ALTER TABLE PUBLIC."nd_project" ADD "org_credit_code" VARCHAR(60); -comment ON COLUMN nd_project.org_credit_code IS '企业统一信息代码'; \ No newline at end of file +comment ON COLUMN nd_project.org_credit_code IS '企业统一信息代码'; + +ALTER TABLE nd_project ADD COLUMN is_super_org int2 NOT NULL DEFAULT 0; +comment ON COLUMN nd_project.is_super_org IS '是否有主管单位'; +ALTER TABLE nd_project ADD COLUMN is_higher_super_org int2 NOT NULL DEFAULT 0; +comment ON COLUMN nd_project.is_higher_super_org IS '是否有上级条线主管单位'; + +ALTER TABLE nd_project_draft ADD COLUMN is_super_org int2 NOT NULL DEFAULT 0; +comment ON COLUMN nd_project_draft.is_super_org IS '是否有主管单位'; +ALTER TABLE nd_project_draft ADD COLUMN is_higher_super_org int2 NOT NULL DEFAULT 0; +comment ON COLUMN nd_project_draft.is_higher_super_org IS '是否有上级条线主管单位'; \ No newline at end of file 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 a60301f..a6e64af 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 @@ -41,6 +41,21 @@ public class StateMachineUtils { @Resource(name = "projectDeclareStateMachinePersister") private StateMachinePersister projectDeclareStateMachinePersister; + //通过审核 + public void pass(Project project) throws Exception { + execute(project,getProjectStatusPassEvent(project.getStatus())); + } + + //拒绝 + public void reject(Project project) throws Exception { + execute(project,getProjectStatusRejectEvent(project.getStatus())); + } + + //撤回 + public void withDraw(Project project) throws Exception { + execute(project,getProjectStatusWithdrawEvent(project.getStatus())); + } + public void execute(Project project, ProjectStatusChangeEvent event) throws Exception { log.info("调用状态机前的项目状态为>>>>>>>>>>{}" + project.getStatus()); // 将状态变更记录保存到项目状态变更表中 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java index 900a988..a9febc6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java @@ -118,7 +118,7 @@ public class ConstructionPlanManage { ); params.setFormData(dto.getFormData()); // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 - Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId); + Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId,projectInfo); String instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); log.info("建设方案项目申报成功 【{}】", instanceId); @@ -141,7 +141,7 @@ public class ConstructionPlanManage { project.setInstCode(instanceId); project.setConstructionPlanFile(constructionPlanFile); //调用状态机 进入下一个通过状态 - stateMachineUtils.execute(project, stateMachineUtils.getProjectStatusPassEvent(project.getStatus())); + stateMachineUtils.pass(project); projectService.updateById(project); //保存项目和实例的关系 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java index bd5c3bc..b62bb63 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java @@ -144,7 +144,9 @@ public class DeclaredProjectManage { params.setFormData(dto.getFormData()); //开始申报 // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 - Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId); + Project project = new Project(); + BeanUtils.copyProperties(projectInfo,project); + Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId,project); String instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); log.info("申报项目成功 【{}】", instanceId); @@ -208,7 +210,9 @@ public class DeclaredProjectManage { ); params.setFormData(dto.getFormData()); // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 - Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId); + Project project = new Project(); + BeanUtils.copyProperties(projectInfo,project); + Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId,project); String instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); log.info("重新申报项目成功 【{}】", instanceId); @@ -317,8 +321,9 @@ public class DeclaredProjectManage { ProjectDTO projectInfo = dto.getProjectInfo(); ProjectDraft draft = new ProjectDraft(); BeanUtils.copyProperties(projectInfo, draft); - draft.setUserId(dto.getUser().getUserId()); + draft.setUserId(String.valueOf(userId)); draft.setBuildOrgCode(userInfoDetails.getOrganizationCode()); + draft.setBuildOrgName(userInfoDetails.getOrganizationName()); draft.setAreaCode(userInfoDetails.getRegionCode()); if(CollUtil.isNotEmpty(projectInfo.getDynamicForm())){ diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java index 0754d51..f66435a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java @@ -67,7 +67,7 @@ public class DefaultDeclaredProjectManage { .build(); } - public Map getOrgModelInfo(Long userId) { + public Map getOrgModelInfo(Long userId,Project project) { Map orgMap = new HashMap<>(); // 查出所有的单位流程配置 @@ -80,13 +80,13 @@ public class DefaultDeclaredProjectManage { String startOrgName = startOrg.getOrganizationName(); String startOrgParentCode; String startOrgParentName; - // 如果没有上级主管单位,由该单位自己审核 - if (Objects.isNull(startOrg.getParentCode())){ + // 如果申报时 上级主管单位,由该单位自己审核 + if (Objects.isNull(project.getSuperOrgCode())){ startOrgParentCode = startOrgCode; startOrgParentName = startOrgName; }else { - startOrgParentCode = startOrg.getParentCode(); - startOrgParentName = startOrg.getParentName(); + startOrgParentCode = project.getSuperOrgCode(); + startOrgParentName = project.getSuperOrg(); } //查询 当前发起人及主管单位所在区域的 单位流程配置 OrgInfoDTO startOrgInfoDto = new OrgInfoDTO(); @@ -113,8 +113,6 @@ public class DefaultDeclaredProjectManage { orgMap.put(OrgTypeEnum.TARGET_OWNER.name(),startOrgInfoDto); orgMap.put(OrgTypeEnum.TARGET_MANAGEMENT.name(),parentOrgInfoDto); - // TODO 上级条线主管单位信息(可能是多个) - // 如果是指定单位,直接根据流程定义ID放入map OrgInfoDTO orgInfoDTO = new OrgInfoDTO(); orgInfoDTO.setOrgModelMap(orgModelsList.stream() 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 85c2156..0615c75 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 @@ -107,7 +107,7 @@ public class PrequalificationDeclaredProjectManage { //使用状态机 进入下一步 看看需不需要走省级审批 try { - stateMachineUtils.execute(projectInfo,stateMachineUtils.getProjectStatusPassEvent(projectInfo.getStatus())); + stateMachineUtils.pass(projectInfo); } catch (Exception e) { log.error("项目 调用状态机出错:",e); throw new BusinessException(projectInfo.getId() + "项目 调用状态机出错 :" + e.getMessage()); @@ -140,7 +140,7 @@ public class PrequalificationDeclaredProjectManage { params.setFormData(dto.getFormData()); // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 - Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId); + Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId,projectInfo); instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); log.info("提交预审项目成功 【{}】", instanceId); @@ -166,7 +166,7 @@ public class PrequalificationDeclaredProjectManage { project.setUpdateOn(LocalDateTime.now()); project.setInstCode(instanceId); //调用状态机 进入下一个通过状态 - stateMachineUtils.execute(project, stateMachineUtils.getProjectStatusPassEvent(project.getStatus())); + stateMachineUtils.pass(project); projectService.updateById(project); //保存项目和实例的关系 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java index 5be0b00..5b91655 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java @@ -105,7 +105,7 @@ public class ReviewByDeptJointManage { params.setFormData(formData); // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 - Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId); + Map orgModelMap = defaultDeclaredProjectManage.getOrgModelInfo(userId,project); String instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); log.info("部门联审申报成功 【{}】", instanceId); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java index 108fdf8..790165a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java @@ -43,6 +43,7 @@ public class ReviewByProvincialDeptManage { Boolean sucessProvince = Boolean.FALSE; if(sucessProvince){ //成功了后 + } return Boolean.FALSE; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/ProjectDraftSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/ProjectDraftSaveDTO.java index 28eec9d..42c92c9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/ProjectDraftSaveDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/ProjectDraftSaveDTO.java @@ -30,8 +30,4 @@ public class ProjectDraftSaveDTO implements Serializable { @ApiModelProperty("项目信息") private ProjectDTO projectInfo; - @NotNull - @ApiModelProperty("用户信息") - private ProcessInstanceUserDto user; - } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/ProjectDraft.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/ProjectDraft.java index 5463c22..d4f00af 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/ProjectDraft.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/entity/ProjectDraft.java @@ -269,12 +269,18 @@ public class ProjectDraft implements Serializable { @ApiModelProperty("批复金额") private BigDecimal approvedTotalInvestmentIncrease; + @ApiModelProperty("是否有上级条线主管部门 0没有 1有") + private Integer isHigherSuperOrg; + @ApiModelProperty("上级主管部门") private String higherSuperOrg; @ApiModelProperty("上级主管部门Code") private String higherSuperOrgCode; + @ApiModelProperty("是否有主管部门 0没有 1有") + private Integer isSuperOrg; + @ApiModelProperty("主管部门名称") private String superOrg; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ProjectDraftVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ProjectDraftVO.java index 55ae7f2..6ac564d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ProjectDraftVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/vo/ProjectDraftVO.java @@ -270,12 +270,18 @@ public class ProjectDraftVO implements Serializable { @ApiModelProperty("批复金额") private BigDecimal approvedTotalInvestmentIncrease; + @ApiModelProperty("是否有上级条线主管部门 0没有 1有") + private Integer isHigherSuperOrg; + @ApiModelProperty("上级主管部门") private String higherSuperOrg; @ApiModelProperty("上级主管部门Code") private String higherSuperOrgCode; + @ApiModelProperty("是否有主管部门 0没有 1有") + private Integer isSuperOrg; + @ApiModelProperty("主管部门名称") private String superOrg; 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 868599b..7e82aa4 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 @@ -122,7 +122,7 @@ public class AnnualPlanLibManage { }); projects.forEach(project -> { try { - stateMachine.execute(project, ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE); + stateMachine.pass(project); } catch (Exception e) { throw new BizException("开启方案申报失败"); } @@ -133,7 +133,7 @@ public class AnnualPlanLibManage { @Transactional(rollbackFor = Exception.class) public void projectApproved(ProjectApprovedReq req) throws Exception { Project project = projectService.getById(req.getProjectId()); - stateMachine.execute(project, ProjectStatusChangeEvent.PROJECT_APPROVAL); + stateMachine.pass(project); LambdaUpdateWrapper update = Wrappers.lambdaUpdate(Project.class) .set(Project::getApprovalAmount, req.getApprovedAmount()) .set(Project::getApprovedFile, req.getApprovedFileId()) @@ -147,7 +147,7 @@ public class AnnualPlanLibManage { @Transactional(rollbackFor = Exception.class) public void suspendAnnualPlan(ProjectIdReq req) throws Exception { Project project = projectService.getById(req.getProjectId()); - stateMachine.execute(project, ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND); + stateMachine.reject(project); projectService.updateById(project); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectDTO.java index d8efc71..7286598 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectDTO.java @@ -252,12 +252,18 @@ public class ProjectDTO implements Serializable { @ApiModelProperty("批复金额") private BigDecimal approvedTotalInvestmentIncrease; + @ApiModelProperty("是否有上级条线主管部门 0没有 1有") + private Integer isHigherSuperOrg; + @ApiModelProperty("上级主管部门") private String higherSuperOrg; @ApiModelProperty("上级主管部门Code") private String higherSuperOrgCode; + @ApiModelProperty("是否有主管部门 0没有 1有") + private Integer isSuperOrg; + @ApiModelProperty("主管部门名称") private String superOrg; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/Project.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/Project.java index 4b466ea..404985a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/Project.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/Project.java @@ -267,12 +267,18 @@ public class Project implements Serializable { @ApiModelProperty("批复金额") private BigDecimal approvedTotalInvestmentIncrease; - @ApiModelProperty("上级主管部门") + @ApiModelProperty("是否有上级条线主管部门 0没有 1有") + private Integer isHigherSuperOrg; + + @ApiModelProperty("上级条线主管部门") private String higherSuperOrg; @ApiModelProperty("上级主管部门Code") private String higherSuperOrgCode; + @ApiModelProperty("是否有主管部门 0没有 1有") + private Integer isSuperOrg; + @ApiModelProperty("主管部门名称") private String superOrg; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java index f9fdb5e..e468cf1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java @@ -256,12 +256,18 @@ public class ProjectDetailVO { @ApiModelProperty("批复金额") private BigDecimal approvedTotalInvestmentIncrease; + @ApiModelProperty("是否有上级条线主管部门 0没有 1有") + private Integer isHigherSuperOrg; + @ApiModelProperty("上级主管部门") private String higherSuperOrg; @ApiModelProperty("上级主管部门Code") private String higherSuperOrgCode; + @ApiModelProperty("是否有主管部门 0没有 1有") + private Integer isSuperOrg; + @ApiModelProperty("主管部门名称") private String superOrg; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/ProjectStatusFlowTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/ProjectStatusFlowTask.java index 2e99d41..be813f4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/ProjectStatusFlowTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/ProjectStatusFlowTask.java @@ -47,7 +47,7 @@ public class ProjectStatusFlowTask { //1. 定时取 项目暂存表的数据 去进行状态继续流转 List stagingList = projectStagingService.list(Wrappers.lambdaQuery(ProjectStaging.class) .eq(ProjectStaging::getDead,Boolean.FALSE) - .ge(ProjectStaging::getNextTime, LocalDateTime.now()) + .le(ProjectStaging::getNextTime, LocalDateTime.now()) .le(ProjectStaging::getRetryTimes, StagingContant.Retry.MAX_RETRY_TIMES) .orderByAsc(ProjectStaging::getProjectId)); 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 173fcf7..a22d164 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,12 +422,8 @@ public class TodoCenterManage { * @since 2023/02/08 */ private void updateRejectProjectStatus(Long userId, Project declaredProject) { - // 获取当前流程项目状态 - Integer status = declaredProject.getStatus(); - // 根据当前状态获取对应的通过事件 - ProjectStatusChangeEvent event = stateMachineUtils.getProjectStatusRejectEvent(status); try { - stateMachineUtils.execute(declaredProject, event); + stateMachineUtils.reject(declaredProject); declaredProject.setUpdateOn(LocalDateTime.now()); declaredProject.setUpdateBy(userId); } catch (Exception e) { @@ -483,12 +479,8 @@ public class TodoCenterManage { * @since 2023/02/08 */ private void updatePassProjectStatus(Long userId, Project declaredProject) { - // 获取当前流程项目状态 - Integer status = declaredProject.getStatus(); - // 根据当前状态获取对应的通过事件 - ProjectStatusChangeEvent event = stateMachineUtils.getProjectStatusPassEvent(status); try { - stateMachineUtils.execute(declaredProject, event); + stateMachineUtils.pass(declaredProject); declaredProject.setUpdateOn(LocalDateTime.now()); declaredProject.setUpdateBy(userId); } catch (Exception e) { @@ -574,12 +566,8 @@ public class TodoCenterManage { * @since 2023/02/08 */ private void updateWithdrawProjectStatus(Long userId, Project declaredProject) { - // 获取当前流程项目状态 - Integer projectStatusSecond = declaredProject.getStatus(); - // 根据当前状态获取对应的撤回事件 - ProjectStatusChangeEvent event = stateMachineUtils.getProjectStatusWithdrawEvent(projectStatusSecond); try { - stateMachineUtils.execute(declaredProject, event); + stateMachineUtils.withDraw(declaredProject); declaredProject.setUpdateOn(LocalDateTime.now()); declaredProject.setUpdateBy(userId); } catch (Exception e) { 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 4e6b197..4d964d5 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/statemachine/StateMachineTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/statemachine/StateMachineTest.java @@ -27,7 +27,7 @@ public class StateMachineTest extends AppTests { project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode()); project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode()); project.setDeclareAmount(BigDecimal.valueOf(2000)); - stateMachineUtils.execute(project, stateMachineUtils.getProjectStatusPassEvent(project.getStatus())); + stateMachineUtils.pass(project); System.out.println(String.format("project:%s", JSON.toJSONString(project))); } } diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/sys/project/ProjectStateTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/sys/project/ProjectStateTest.java index 4970683..6836c45 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/sys/project/ProjectStateTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/sys/project/ProjectStateTest.java @@ -38,7 +38,7 @@ public class ProjectStateTest extends AppTests { project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()); //调用状态机 进入下一个通过状态 - stateMachineUtils.execute(project,stateMachineUtils.getProjectStatusPassEvent(project.getStatus())); + stateMachineUtils.pass(project); stopWatch.stop(); System.out.println("调用状态机结束 :" + stopWatch.getTotalTimeSeconds());