Commit 730b9829 authored by 雍欢's avatar 雍欢

如果流程实例存在回退/打回的情况的话会存在多个申请节点,这时我们按照申请任务创建时间排序并取第一申请任务作为申请节点

parent 6f25be13
......@@ -38,6 +38,7 @@ import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.activiti.engine.repository.ProcessDefinition;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
......@@ -760,17 +761,20 @@ public class FlowBroker extends BaseApplication implements TaskListener, Executi
ThreadLocalUtil.putVariable(Constants.MAKEACOPYFORPREFIX, "办结提醒:");
List<String> executorIds = new ArrayList<>(1);
executorIds.add(applicantFullId);
// 查找流程申请节点,如果流程实例存在回退/打回的情况的话会存在多个申请节点,
// 这时我们按照申请任务创建时间排序并取第一申请任务作为申请节点
String taskId = delegateExecution.getEngineServices().getHistoryService().createHistoricTaskInstanceQuery()
.processInstanceId(delegateExecution.getProcessInstanceId())
.taskDefinitionKey("Apply")
.orderByTaskCreateTime().asc()
.listPage(0, 1)
.stream()
.map(HistoricTaskInstance::getId)
.findAny()
.orElseGet(() -> getApprovalParameter().getTaskId());
String taskId = getApprovalParameter().getTaskId();
if (StringUtils.isBlank(taskId)) {
// 查找流程申请节点,如果流程实例存在回退/打回的情况的话会存在多个申请节点,
// 这时我们按照申请任务创建时间排序并取第一申请任务作为申请节点
taskId = delegateExecution.getEngineServices().getHistoryService().createHistoricTaskInstanceQuery()
.processInstanceId(delegateExecution.getProcessInstanceId())
.taskDefinitionKey("Apply")
.orderByTaskCreateTime().asc()
.listPage(0, 1)
.stream()
.map(HistoricTaskInstance::getId)
.findAny()
.orElse(null);
}
this.workflowService.makeACopyFor(taskId, executorIds);
delegateExecution.setVariable(IS_MAKE_A_COPY_FOR, true);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment