|
|
@@ -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<ProjectInst> 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<HistoricActivityInstance> 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; |
|
|
|
} |
|
|
|
} |