|
@@ -17,7 +17,9 @@ import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.assertj.core.util.Lists; |
|
|
import org.assertj.core.util.Lists; |
|
|
|
|
|
import org.flowable.bpmn.model.*; |
|
|
import org.flowable.engine.HistoryService; |
|
|
import org.flowable.engine.HistoryService; |
|
|
|
|
|
import org.flowable.engine.RepositoryService; |
|
|
import org.flowable.engine.history.HistoricActivityInstance; |
|
|
import org.flowable.engine.history.HistoricActivityInstance; |
|
|
import org.flowable.engine.history.HistoricProcessInstance; |
|
|
import org.flowable.engine.history.HistoricProcessInstance; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
@@ -41,6 +43,7 @@ public class WithDrawHandle { |
|
|
private final UserInfoHelper userInfoHelper; |
|
|
private final UserInfoHelper userInfoHelper; |
|
|
|
|
|
|
|
|
private final HistoryService historyService; |
|
|
private final HistoryService historyService; |
|
|
|
|
|
private final RepositoryService repositoryService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 判断 当前流程 可否被当前登录人 所撤回 |
|
|
* 判断 当前流程 可否被当前登录人 所撤回 |
|
@@ -66,7 +69,7 @@ public class WithDrawHandle { |
|
|
return checkUserIsBefore(progressInstanceDetail.getProgressInfo(),null); |
|
|
return checkUserIsBefore(progressInstanceDetail.getProgressInfo(),null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//判断当前操作人 是上一个节点的审批人 |
|
|
|
|
|
|
|
|
// 判断当前操作人 是上一个节点的审批人 |
|
|
public Boolean checkUserIsBefore(List<ProgressNode> currentProgressInfo, ReqProcessHandlerDTO param) { |
|
|
public Boolean checkUserIsBefore(List<ProgressNode> currentProgressInfo, ReqProcessHandlerDTO param) { |
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
//1.判断出 当前审批人和上一个审批人 |
|
|
//1.判断出 当前审批人和上一个审批人 |
|
@@ -74,18 +77,32 @@ public class WithDrawHandle { |
|
|
ProgressNode beforeProgressNode = null; |
|
|
ProgressNode beforeProgressNode = null; |
|
|
ProgressNode currentProgressNode = null; |
|
|
ProgressNode currentProgressNode = null; |
|
|
|
|
|
|
|
|
|
|
|
// 先排除掉抄送任务节点 |
|
|
|
|
|
currentProgressInfo = currentProgressInfo.stream() |
|
|
|
|
|
.filter(c -> !NodeTypeEnum.CC.name().equals(c.getNodeType().name())) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
if (CollUtil.isEmpty(currentProgressInfo)){ |
|
|
|
|
|
return Boolean.FALSE; |
|
|
|
|
|
} |
|
|
// 说明当前节点是子流程节点 |
|
|
// 说明当前节点是子流程节点 |
|
|
// 如果是会签 或签 当前和上个 |
|
|
// 如果是会签 或签 当前和上个 |
|
|
List<ProgressNode> thisAndOr = Lists.newArrayList(); |
|
|
List<ProgressNode> thisAndOr = Lists.newArrayList(); |
|
|
List<ProgressNode> beforeAndOr = Lists.newArrayList(); |
|
|
List<ProgressNode> beforeAndOr = Lists.newArrayList(); |
|
|
if (progressNode.getNodeType().name().equals(NodeTypeEnum.SUB.name())) { |
|
|
if (progressNode.getNodeType().name().equals(NodeTypeEnum.SUB.name())) { |
|
|
List<ProgressNode> children = progressNode.getChildren(); |
|
|
List<ProgressNode> children = progressNode.getChildren(); |
|
|
|
|
|
// 先排除掉子流程中抄送的节点,避免塞入错误的taskId |
|
|
|
|
|
children = children.stream() |
|
|
|
|
|
.filter(c -> !NodeTypeEnum.CC.name().equals(c.getNodeType().name())) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
if (CollUtil.isEmpty(currentProgressInfo)){ |
|
|
|
|
|
return Boolean.FALSE; |
|
|
|
|
|
} |
|
|
currentProgressNode = children.get(children.size() - 1); |
|
|
currentProgressNode = children.get(children.size() - 1); |
|
|
//把当前和上一个节点和 会签或签的情况 都check出来 |
|
|
//把当前和上一个节点和 会签或签的情况 都check出来 |
|
|
beforeProgressNode = checkBeforeNodeAndOr(children,currentProgressNode,thisAndOr,beforeAndOr); |
|
|
beforeProgressNode = checkBeforeNodeAndOr(children,currentProgressNode,thisAndOr,beforeAndOr); |
|
|
} else { |
|
|
} else { |
|
|
currentProgressNode = currentProgressInfo.get(currentProgressInfo.size() - 1); |
|
|
currentProgressNode = currentProgressInfo.get(currentProgressInfo.size() - 1); |
|
|
//把把当前和上一个节点和 会签或签的情况 都check出来 |
|
|
|
|
|
|
|
|
// 把当前和上一个节点和 会签或签的情况 都check出来 |
|
|
beforeProgressNode = checkBeforeNodeAndOr(currentProgressInfo,currentProgressNode,thisAndOr,beforeAndOr); |
|
|
beforeProgressNode = checkBeforeNodeAndOr(currentProgressInfo,currentProgressNode,thisAndOr,beforeAndOr); |
|
|
} |
|
|
} |
|
|
// 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 |
|
|
// 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 |
|
@@ -131,8 +148,27 @@ public class WithDrawHandle { |
|
|
|| !user.getEmployeeCode().equals(beforeProgressNode.getUserId()))){ |
|
|
|| !user.getEmployeeCode().equals(beforeProgressNode.getUserId()))){ |
|
|
return Boolean.FALSE; |
|
|
return Boolean.FALSE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//如果是true 把对应操作人 在上个审批节点的task 也传入 |
|
|
//如果是true 把对应操作人 在上个审批节点的task 也传入 |
|
|
if(Objects.nonNull(param)){ |
|
|
if(Objects.nonNull(param)){ |
|
|
|
|
|
// 获取bpmn文件中节点的连线关系,如果前一个节点的下一个节点是抄送节点, |
|
|
|
|
|
// 获取抄送节点传入param中,在执行撤回操作时,将抄送信息从抄送表中删除 |
|
|
|
|
|
HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery() |
|
|
|
|
|
.processInstanceId(param.getInstanceId()) |
|
|
|
|
|
.singleResult(); |
|
|
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()); |
|
|
|
|
|
// 传节点定义key 获取撤回操作人在流程配置中所在的节点 |
|
|
|
|
|
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(beforeProgressNode.getNodeId()); |
|
|
|
|
|
List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows(); |
|
|
|
|
|
for (SequenceFlow outgoingFlow : outgoingFlows) { |
|
|
|
|
|
//获取输出节点元素 |
|
|
|
|
|
FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement(); |
|
|
|
|
|
// 获取下一个抄送任务的节点 |
|
|
|
|
|
if(targetFlowElement instanceof ServiceTask){ |
|
|
|
|
|
param.setCcNodeId(targetFlowElement.getId()); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
param.setTaskId(beforeProgressNode.getTaskId()); |
|
|
param.setTaskId(beforeProgressNode.getTaskId()); |
|
|
} |
|
|
} |
|
|
return Boolean.TRUE; |
|
|
return Boolean.TRUE; |
|
|