Browse Source

撤回逻辑

master
PoffyZhang 1 year ago
parent
commit
b20d3e9d88
1 changed files with 71 additions and 19 deletions
  1. +71
    -19
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java

+ 71
- 19
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletResponse;

import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Lists;
import org.flowable.bpmn.model.*;
import org.flowable.engine.HistoryService;
@@ -448,36 +449,50 @@ public class TodoCenterManage {
throw new IllegalStateException("Unexpected value: " + projectStatus);
}
} else {
// 当前撤回节点不是流程发起人节点
//1.判断出 当前审批人和上一个审批人
List<ProgressNode> currentProgressInfo = currentInstanceDetail.getProgressInfo();
ProgressNode progressNode = currentProgressInfo.get(currentProgressInfo.size() - 1);
ProgressNode beforeProgressNode;
ProgressNode currentProgressNode;
ProgressNode beforeProgressNode = null;
ProgressNode currentProgressNode = null;

// 说明当前节点是子流程节点
// 如果是会签 或签
List<ProgressNode> andOr = Lists.newArrayList();
if (progressNode.getNodeType().name().equals(NodeTypeEnum.SUB.name())) {
List<ProgressNode> children = progressNode.getChildren();
beforeProgressNode = children.get(children.size() - 2);
currentProgressNode = children.get(children.size() - 1);
//把上一个节点和 会签或签的情况 都check出来
beforeProgressNode = checkBeforeNodeAndOr(children,currentProgressNode,andOr);
} else {
beforeProgressNode = currentProgressInfo.get(currentProgressInfo.size() - 2);
currentProgressNode = currentProgressInfo.get(currentProgressInfo.size() - 1);
//把上一个节点和 会签或签的情况 都check出来
beforeProgressNode = checkBeforeNodeAndOr(currentProgressInfo,currentProgressNode,andOr);
}
// 获取当前工作流任务前一个审核人信息
ProcessInstanceUserDto beforeUser = beforeProgressNode.getUser();
UserFullInfoDTO beforeUserInfo = userInfoHelper.getUserFullInfoByEmployeeCode(beforeUser.getUserId());
// 获取当前当前工作流任务当前审核人信息
ProcessInstanceUserDto currentUser = currentProgressNode.getUser();
UserFullInfoDTO currentUserInfo = userInfoHelper.getUserFullInfoByEmployeeCode(currentUser.getUserId());
// 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常
boolean orgFlag = currentUserInfo.getOrganizationCode().equals(beforeUserInfo.getOrganizationCode());
boolean userFlag = beforeUser.getUserId().equals(user.getEmployeeCode());
if (!orgFlag) {
throw new BizException("下一个审核人和您不是同一个部门,无法撤回!");
} else if (!userFlag) {
throw new BizException("当前登录用户无法进行撤回操作!");
} else {
processTaskService.handleTask(param, employeeCode);
// 获取当前当前工作流任务当前审核人信息
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;
}
}
}

VUtils.isTrue(!beforeUser.getUserId().equals(user.getEmployeeCode()) && !isAndOr)
.throwMessage("当前登录用户无法进行撤回操作!");
processTaskService.handleTask(param, employeeCode);
}
break;
default:
@@ -485,6 +500,43 @@ public class TodoCenterManage {
}
}

private ProgressNode checkOptionNode(List<ProgressNode> progressInfo, String taskId) {
for(ProgressNode node : progressInfo){
if(taskId.equals(node.getTaskId())){
return node;
}
if(CollUtil.isNotEmpty(node.getChildren())){
return checkOptionNode(node.getChildren(),taskId);
}
}
return null;
}

/**
* 把上一个节点 和 或签 会签情况都check出来
* @param progressNodes andOr
* @param andOr
* @return
*/
private ProgressNode checkBeforeNodeAndOr(List<ProgressNode> progressNodes,ProgressNode curr,
List<ProgressNode> andOr) {
if(CollUtil.isEmpty(progressNodes)){
return null;
}
for(int i = progressNodes.size() - 2;i >= 0;i--){
//说明有会签 或签
if(progressNodes.get(i).getNodeId().equals(curr.getNodeId())){
if(andOr.size() == 0){
andOr.add(curr);
}
andOr.add(progressNodes.get(i));
}else{
return progressNodes.get(i);
}
}
return null;
}

/**
* 装配项目审核工作通知
* @param userId


Loading…
Cancel
Save