标签:boolean data start you task str OLE string for
/***
* 根据bpmnmodel获取流程节点的顺序信息
* @param processInstanceId
* @param taskList
* @param flowElements
* @param workflowRequestFormData
* @param curFlowElement
*/
private void getTaskList(String processInstanceId, List<Object> taskList, Collection<FlowElement> flowElements, Map<String, Object> workflowRequestFormData, FlowElement curFlowElement) {
if (curFlowElement == null && taskList.size() == 0) {
// 获取第一个UserTask
FlowElement startElement = flowElements.stream().filter(flowElement -> flowElement instanceof StartEvent).collect(Collectors.toList()).get(0);
List<SequenceFlow> outgoingFlows = ((StartEvent) startElement).getOutgoingFlows();
String targetRef = outgoingFlows.get(0).getTargetRef();
// 根据ID找到FlowElement
FlowElement targetElementOfStartElement = getFlowElement(flowElements, targetRef);
if (targetElementOfStartElement instanceof UserTask) {
this.getTaskList(processInstanceId, taskList, flowElements, workflowRequestFormData, targetElementOfStartElement);
}
} else if (curFlowElement instanceof UserTask) {
// 只有Usertask才添加到列表中
taskList.add(curFlowElement);
String targetRef = "";
List<SequenceFlow> outgoingFlows = ((UserTask) curFlowElement).getOutgoingFlows();
if (outgoingFlows.size() == 1) {
targetRef = outgoingFlows.get(0).getTargetRef();
} else {
// 找到表达式成立的sequenceFlow的
SequenceFlow sequenceFlow = getSequenceFlow(workflowRequestFormData, outgoingFlows);
if (sequenceFlow != null) {
targetRef = sequenceFlow.getTargetRef();
}
}
// 根据ID找到FlowElement
FlowElement targetElement = getFlowElement(flowElements, targetRef);
this.getTaskList(processInstanceId, taskList, flowElements, workflowRequestFormData, targetElement);
} else if (curFlowElement instanceof ExclusiveGateway) {
String targetRef = "";
// 如果为排他网关,获取符合条件的sequenceFlow的目标FlowElement
List<SequenceFlow> exclusiveGatewayOutgoingFlows = ((ExclusiveGateway) curFlowElement).getOutgoingFlows();
// 找到表达式成立的sequenceFlow的
SequenceFlow sequenceFlow = getSequenceFlow(workflowRequestFormData, exclusiveGatewayOutgoingFlows);
if (sequenceFlow != null) {
targetRef = sequenceFlow.getTargetRef();
}
// 根据ID找到FlowElement
FlowElement targetElement = getFlowElement(flowElements, targetRef);
this.getTaskList(processInstanceId, taskList, flowElements, workflowRequestFormData, targetElement);
}
}
/***
* 根据ID找到FlowElement
* @param flowElements
* @param targetRef
* @return
*/
private FlowElement getFlowElement(Collection<FlowElement> flowElements, String targetRef) {
List<FlowElement> targetFlowElements = flowElements.stream().filter(
flowElement -> !StringUtils.isEmpty(flowElement.getId()) && flowElement.getId().equals(targetRef)
).collect(Collectors.toList());
if (targetFlowElements.size() > 0) {
return targetFlowElements.get(0);
}
return null;
}
/***
* 找到表达式成立的sequenceFlow的
* @param workflowRequestFormData
* @param outgoingFlows
* @return
*/
private SequenceFlow getSequenceFlow(Map workflowRequestFormData, List<SequenceFlow> outgoingFlows) {
List<SequenceFlow> sequenceFlows = outgoingFlows.stream().filter(item -> {
Object execConditionExpressionResult = null;
boolean re = false;
try {
execConditionExpressionResult = this.getElValue(item.getConditionExpression(), workflowRequestFormData);
} catch (Exception e) {
e.printStackTrace();
}
if (execConditionExpressionResult.equals("true")) {
re = true;
}
return (Boolean) execConditionExpressionResult;
}).collect(Collectors.toList());
if (sequenceFlows.size() > 0) {
return sequenceFlows.get(0);
}
return null;
}
标签:boolean data start you task str OLE string for
原文地址:https://blog.51cto.com/10983441/2501052