【JBPM4】判断节点decision 方法3 handler


JPDL


<?xml version="1.0" encoding="UTF-8"?>

<process key="decision" name="decision" xmlns="http://jbpm.org/4.4/jpdl">
<start name="start1" g="22,200,48,48">
<transition name="提交" to="exclusive1" g="-15,-20"/>
</start>
<decision name="exclusive1" g="185,201,48,48">
<handler class="com.tgb.node.decision.MyDecision"/>
<transition name="到组长" to="组长" g="-49,-32">
</transition>
<transition name="到科长" to="科长" g="-56,-28">
</transition>
<transition name="到主任" to="主任" g="-47,-22">
</transition>
</decision>
<task assignee="zuzhang" name="组长" g="338,69,92,52">
<transition name="组长批准" to="归档" g="-51,-26"/>
</task>
<task assignee="kezhang" name="科长" g="342,199,92,52">
<transition name="科长批准" to="归档" g="-49,-25"/>
</task>
<task assignee="zhuren" name="主任" g="349,325,92,52">
<transition name="主任批准" to="归档" g="-41,-25"/>
</task>
<task assignee="caiwu" name="归档" g="531,201,92,52">
<transition name="通过" to="end1" g="-35,-22"/>
</task>
<end name="end1" g="689,208,48,48"/>
</process>


handler类

public class MyDecision implements DecisionHandler {

private static final long serialVersionUID = 1L;

@Override
public String decide(OpenExecution execution) {
String to = execution.getVariable("to").toString();

if(to.equals("组长")){
return "到组长";
}else if (to.endsWith("科长")){
return "到科长";
}else{
return "到主任";
}
}

}


创建流程实例
Map<String,Object> map = new HashMap<String,Object>();
map.put("to", "主任");
ProcessInstance processInstance = executionService.startProcessInstanceByKey("decision", map);
print("流程实例ID",processInstance.getId());

你可能感兴趣的:(handler)