From 39cef0dece1455049825aa930108815f4d73e4b4 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 31 Mar 2023 09:33:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=98=AF=E4=B8=8A=E4=B8=AA?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/todocenter/manage/TodoCenterManage.java | 195 ++++++++++++--------- .../model/vo/ProcessProgressDetailVo.java | 1 + 2 files changed, 115 insertions(+), 81 deletions(-) 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 e7397a4..2d3e3de 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 @@ -427,72 +427,33 @@ public class TodoCenterManage { break; // 撤回(流程发起人和当前流程审核人的前一个审核人操作) case WITHDRAW: - // 登录用户是流程发起人,且是流程发起人撤回 - if (employeeCode.equals(instance.getStartUserId()) - && ProcessConstant.Field.ROOT.equals(param.getTaskId())) { - processTaskService.handleTask(param, employeeCode); - // 若是流程发起人点击撤回,项目回到上一个状态,需调用状态机更新项目状态,流程状态更新为审核通过 - switch (Objects.requireNonNull(ProjectStatusEnum.getValue(projectStatus))) { - // 当前项目状态是单位内部审核中 - case UNDER_INTERNAL_AUDIT: - // 当前项目状态是预审中 - case PRE_APPLYING: - // 当前项目状态是部门联审中 - case DEPARTMENT_JOINT_REVIEW: - // 当前项目状态是方案评审中 - case SCHEME_UNDER_REVIEW: - // 当前项目状态是终验审核中 - case FINAL_ACCEPTANCE_IS_UNDER_REVIEW: - updateWithdrawProjectStatus(user.getUserId(), declaredProject); - break; - default: - throw new IllegalStateException("Unexpected value: " + projectStatus); - } - } else { - //1.判断出 当前审批人和上一个审批人 - List currentProgressInfo = currentInstanceDetail.getProgressInfo(); - ProgressNode progressNode = currentProgressInfo.get(currentProgressInfo.size() - 1); - ProgressNode beforeProgressNode = null; - ProgressNode currentProgressNode = null; - - // 说明当前节点是子流程节点 - // 如果是会签 或签 - List andOr = Lists.newArrayList(); - if (progressNode.getNodeType().name().equals(NodeTypeEnum.SUB.name())) { - List children = progressNode.getChildren(); - currentProgressNode = children.get(children.size() - 1); - //把上一个节点和 会签或签的情况 都check出来 - beforeProgressNode = checkBeforeNodeAndOr(children,currentProgressNode,andOr); - } else { - currentProgressNode = currentProgressInfo.get(currentProgressInfo.size() - 1); - //把上一个节点和 会签或签的情况 都check出来 - beforeProgressNode = checkBeforeNodeAndOr(currentProgressInfo,currentProgressNode,andOr); - } - // 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 - // 获取当前当前工作流任务当前审核人信息 - UserFullInfoDTO currentUserInfo = userInfoHelper.getUserFullInfoByEmployeeCode(currentProgressNode.getUserId()); - VUtils.isTrue(!currentUserInfo.getOrganizationCode().equals(user.getOrganizationCode())) - .throwMessage("下一个审核人和您不是同一个部门,无法撤回!"); - - UserFullInfoDTO beforeUser = null; - if(Objects.nonNull(beforeProgressNode)){ - // 获取当前工作流任务前一个审核人信息 - beforeUser = userInfoHelper.getUserFullInfoByEmployeeCode(beforeProgressNode.getUserId()); - } - Boolean isAndOr = Boolean.FALSE; - //还有种情况是 会签 或签 - if(CollUtil.isNotEmpty(andOr)){ - for(ProgressNode n : andOr){ - if(n.getUserId().equals(employeeCode)){ - isAndOr = Boolean.TRUE; - break; - } - } - } + //如果发起的root 节点的 操作 + if(ProcessConstant.Field.ROOT.equals(param.getTaskId())){ + VUtils.isTrue(!employeeCode.equals(instance.getStartUserId())).throwMessage("您不是发起人 不能进行撤回"); + }else{ + //判断当前操作人 是否上一个节点的审批人 + VUtils.isTrue(!checkUserIsBefore(currentInstanceDetail.getProgressInfo())) + .throwMessage("当前登录用户不是发起人或者上一个节点审批人 无法进行撤回操作!"); - VUtils.isTrue(!beforeUser.getUserId().equals(user.getEmployeeCode()) && !isAndOr) - .throwMessage("当前登录用户无法进行撤回操作!"); - processTaskService.handleTask(param, employeeCode); + } + // 登录用户是流程发起人,且是流程发起人撤回 + processTaskService.handleTask(param, employeeCode); + // 若是流程发起人点击撤回,项目回到上一个状态,需调用状态机更新项目状态,流程状态更新为审核通过 + switch (Objects.requireNonNull(ProjectStatusEnum.getValue(projectStatus))) { + // 当前项目状态是单位内部审核中 + case UNDER_INTERNAL_AUDIT: + // 当前项目状态是预审中 + case PRE_APPLYING: + // 当前项目状态是部门联审中 + case DEPARTMENT_JOINT_REVIEW: + // 当前项目状态是方案评审中 + case SCHEME_UNDER_REVIEW: + // 当前项目状态是终验审核中 + case FINAL_ACCEPTANCE_IS_UNDER_REVIEW: + updateWithdrawProjectStatus(user.getUserId(), declaredProject); + break; + default: + throw new IllegalStateException("Unexpected value: " + projectStatus); } break; default: @@ -500,41 +461,112 @@ public class TodoCenterManage { } } - private ProgressNode checkOptionNode(List progressInfo, String taskId) { - for(ProgressNode node : progressInfo){ - if(taskId.equals(node.getTaskId())){ - return node; - } - if(CollUtil.isNotEmpty(node.getChildren())){ - return checkOptionNode(node.getChildren(),taskId); + private Boolean checkUserIsRoot(String processInstanceId,String task){ + UserInfoDetails userInfoDetail = LoginUserUtil.loginUserDetail(); + // 获取当前要处理的流程实例 + HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery() + .processInstanceId(processInstanceId) + .singleResult(); + if (userInfoDetail.getEmployeeCode().equals(instance.getStartUserId()) && + (Objects.isNull(task) || userInfoDetail.getEmployeeCode().equals(instance.getStartUserId()))) { + return Boolean.TRUE; + } + return Boolean.FALSE; + } + + //判断当前操作人 是上一个节点的审批人 + private Boolean checkUserIsBefore(List currentProgressInfo) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + //1.判断出 当前审批人和上一个审批人 + ProgressNode progressNode = currentProgressInfo.get(currentProgressInfo.size() - 1); + ProgressNode beforeProgressNode = null; + ProgressNode currentProgressNode = null; + + // 说明当前节点是子流程节点 + // 如果是会签 或签 当前和上个 + List thisAndOr = Lists.newArrayList(); + List beforeAndOr = Lists.newArrayList(); + if (progressNode.getNodeType().name().equals(NodeTypeEnum.SUB.name())) { + List children = progressNode.getChildren(); + currentProgressNode = children.get(children.size() - 1); + //把上一个节点和 会签或签的情况 都check出来 + beforeProgressNode = checkBeforeNodeAndOr(children,currentProgressNode,thisAndOr,beforeAndOr); + } else { + currentProgressNode = currentProgressInfo.get(currentProgressInfo.size() - 1); + //把上一个节点和 会签或签的情况 都check出来 + beforeProgressNode = checkBeforeNodeAndOr(currentProgressInfo,currentProgressNode,thisAndOr,beforeAndOr); + } + // 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 + // 获取当前当前工作流任务当前审核人信息 + UserFullInfoDTO currentUserInfo = userInfoHelper.getUserFullInfoByEmployeeCode(currentProgressNode.getUserId()); + VUtils.isTrue(!currentUserInfo.getOrganizationCode().equals(user.getOrganizationCode())) + .throwMessage("当前审核人和您不是同一个部门,无法撤回!"); + + UserFullInfoDTO beforeUser = null; + Boolean isAndOr = Boolean.FALSE; + //还有种情况是 会签 或签 并且在上个节点 + if(CollUtil.isNotEmpty(beforeAndOr)){ + for(ProgressNode n : beforeAndOr){ + if(n.getUserId().equals(user.getEmployeeCode())){ + //说明当前操作人 在上个会签或者或签节点 + isAndOr = Boolean.TRUE; + break; + } } } - return null; + if(Objects.nonNull(beforeProgressNode)){ + // 获取当前工作流任务前一个审核人信息 + beforeUser = userInfoHelper.getUserFullInfoByEmployeeCode(beforeProgressNode.getUserId()); + } + + if(!isAndOr && (Objects.isNull(beforeUser) || !user.getEmployeeCode().equals(beforeUser.getEmployeeCode()))){ + return Boolean.FALSE; + } + return Boolean.TRUE; } + /** * 把上一个节点 和 或签 会签情况都check出来 * @param progressNodes andOr - * @param andOr + * @param thisAndOr beforeAndOr * @return */ private ProgressNode checkBeforeNodeAndOr(List progressNodes,ProgressNode curr, - List andOr) { - if(CollUtil.isEmpty(progressNodes)){ + List thisAndOr,List beforeAndOr) { + ProgressNode beforeNode = null; + if(progressNodes.size() == 1){ return null; } + //进入上一个节点的标识 + Boolean enterBefore = Boolean.FALSE; for(int i = progressNodes.size() - 2;i >= 0;i--){ //说明有会签 或签 if(progressNodes.get(i).getNodeId().equals(curr.getNodeId())){ - if(andOr.size() == 0){ - andOr.add(curr); + //还在当前节点 + if(!enterBefore){ + if(thisAndOr.isEmpty()){ + thisAndOr.add(curr); + } + thisAndOr.add(progressNodes.get(i)); + } + //如果在上个节点了 + else{ + if(beforeAndOr.isEmpty()){ + beforeAndOr.add(curr); + } + beforeAndOr.add(progressNodes.get(i)); } - andOr.add(progressNodes.get(i)); }else{ - return progressNodes.get(i); + if(!enterBefore){ + beforeNode = progressNodes.get(i); + enterBefore = Boolean.TRUE; + continue; + } + break; } } - return null; + return beforeNode; } /** @@ -794,6 +826,7 @@ public class TodoCenterManage { res.setProcessProgressVo(progressInstanceDetail); res.setStatus(progressInstanceDetail.getStatus()); res.setProjectId(projectId); + res.setCanWithdrew(checkUserIsRoot(instanceId,null) || checkUserIsBefore(progressInfo)); return res; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/ProcessProgressDetailVo.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/ProcessProgressDetailVo.java index 55ab9f1..c693cde 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/ProcessProgressDetailVo.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/ProcessProgressDetailVo.java @@ -33,4 +33,5 @@ public class ProcessProgressDetailVo { */ private Long projectId; + private Boolean canWithdrew; }