From d5704b7e3cf5ba3ae44bf4798212e3e71d8a9816 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 18 Jan 2024 20:02:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BA=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pm/api/todocenter/handle/WithDrawHandle.java | 37 ++++++++++------------ .../pm/api/todocenter/manage/TodoCenterManage.java | 4 +-- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java index e652664..fab24ff 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java @@ -1,11 +1,12 @@ package com.hz.pm.api.todocenter.handle; import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.util.StrUtils; -import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.model.entity.ProjectInst; +import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.user.security.model.UserFullInfoDTO; @@ -19,7 +20,6 @@ import com.wflow.workflow.bean.vo.ProcessProgressVo; import com.wflow.workflow.enums.ProcessStatusEnum; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.assertj.core.util.Lists; import org.flowable.bpmn.model.*; import org.flowable.engine.HistoryService; @@ -61,7 +61,7 @@ public class WithDrawHandle { HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(instanceId).singleResult(); UserInfoDetails userInfoDetails = LoginUserUtil.loginUserDetail(); - String employeeCode = userInfoDetails.getEmployeeCode(); + String userId = userInfoDetails.getEmployeeCode(); //如果不是审核中 if (!ProcessStatusEnum.UNDER_REVIEW.getDesc() .equals(progressInstanceDetail.getStatus())) { @@ -69,7 +69,7 @@ public class WithDrawHandle { } // 如果当前登录用户是流程发起人,判断流程是否已经开始审批,如果开始审批,不能撤回 Boolean userIsRoot = checkUserIsRoot(instanceId, null); - if (Boolean.TRUE.equals(userIsRoot) && canRootWithDraw(historicProcessInstance, employeeCode)) { + if (Boolean.TRUE.equals(userIsRoot) && canRootWithDraw(historicProcessInstance, userId)) { return Boolean.TRUE; } ReqProcessHandlerDTO dto = new ReqProcessHandlerDTO(); @@ -264,7 +264,7 @@ public class WithDrawHandle { return null; } //进入上一个节点的标识 - Boolean enterBefore = Boolean.FALSE; + boolean enterBefore = Boolean.FALSE; //假设 作为当前会签的第一个点 String thisAndOrNodeId = curr.getNodeId(); //假设 作为上一个会签/或签的第一个点 @@ -309,23 +309,22 @@ public class WithDrawHandle { * 1.判断 当前 撤回人 是否是 发起人 * 2.并且流程 尚未开始审批 * - * @return + * @return 、 */ - public boolean canRootWithDraw(HistoricProcessInstance instance, String employeeCode) { + public boolean canRootWithDraw(HistoricProcessInstance instance, String userId) { String startUserId = instance.getStartUserId(); // 如果是申请延期或者申请借阅审批流程,流程发起人不能撤回,直接返回false - String instanceId = instance.getId(); - ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) - .eq(ProjectInst::getInstCode, instanceId)); + LambdaQueryWrapper piQuery = Wrappers.lambdaQuery(ProjectInst.class) + .select(ProjectInst::getInstType) + .eq(ProjectInst::getInstCode, instance.getId()); + ProjectInst projectInst = projectInstService.getOne(piQuery); Integer instType = projectInst.getInstType(); - if (InstTypeEnum.APPLY_DELAY.getCode().equals(instType) || - InstTypeEnum.APPLY_BORROW.getCode().equals(instType)) { + if (InstTypeEnum.APPLY_DELAY.eq(instType) || InstTypeEnum.APPLY_BORROW.eq(instType)) { return Boolean.FALSE; } //如果流程发起人 不是 当前登录人 直接返回false - if (StringUtils.isBlank(employeeCode) || StringUtils.isBlank(startUserId) - || !employeeCode.equals(startUserId)) { + if (StrUtils.hasBlank(userId, startUserId) || !userId.equals(startUserId)) { return Boolean.FALSE; } @@ -333,14 +332,10 @@ public class WithDrawHandle { .processInstanceId(instance.getId()).finished() .activityType(TodoCenterConst.Handler.ACTIVITY_APPROVAL) .orderByHistoricActivityInstanceEndTime().asc().list(); - List instances = finished.stream() + long count = finished.stream() .filter(a -> !HisProInsEndActId.WITHDRAW.equals(a.getDeleteReason())) - .collect(Collectors.toList()); + .count(); //如果有已经被审核过的 节点 返回false - if (CollUtil.isNotEmpty(instances)) { - return Boolean.FALSE; - } - - return Boolean.TRUE; + return count == 0; } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java index 354fb2b..3d9f787 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java @@ -322,7 +322,7 @@ public class TodoCenterManage { /** * 流程处理相关操作 * - * @param param + * @param param \ * @return void * @author CMM * @since 2023/02/01 @@ -403,7 +403,7 @@ public class TodoCenterManage { break; // 撤回(流程发起人和当前流程审核人的前一个审核人操作) case WITHDRAW: { - /** + /* * 新逻辑 * 不判断前端传的taskId * 1.先判断 用户是否是ROOT 发起人 并且流程没有开始审批