activiti 挂起任务能查到吗

activiti 挂起任务能查到吗,第1张

1、首先是根据流程ID获取当前任务

Listlt;Task; tasks = taskServicecreateTaskQuery()processInstanceId(procInstanceId)list();

2、然后根据当前任务获取当前流程的流程定义,然后根据流程定义获得所有的节点

ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)rs)getDeployedProcessDefinition(taskgetProcessDefinitionId());

Listlt;ActivityImpl; activitiList = defgetActivities(); //rs是指RepositoryService的实例

3、根据任务获取当前流程执行ID,执行实例以及当前流程节点的ID:

String excId = taskgetExecutionId();

ExecutionEntity execution = (ExecutionEntity) runtimeServicecreateExecutionQuery()executionId(excId)singleResult();

String activitiId = executiongetActivityId();

4、然后循环activitiList 并判断出当前流程所处节点,然后得到当前节点实例,根据节点实例获取所有从当前节点出发的路径,然后根据路径获得下一个节点实例:

for(ActivityImpl activityImpl:activitiList){

String id = activityImplgetId();

if(activitiIdequals(id)){

Systemoutprintln(当前任务:+activityImplgetProperty(name)); //输出某个节点的某种属性

Listlt;PvmTransition; outTransitions = activityImplgetOutgoingTransitions();//获取从某个节点出来的所有线路

for(PvmTransition tr:outTransitions){

PvmActivity ac = trgetDestination(); //获取线路的终点节点

Systemoutprintln(下一步任务任务:+acgetProperty(name));

}

break;

}

}

/

根据实例编号查找下一个任务节点

@param String procInstId :实例编号

@return

/

public TaskDefinition nextTaskDefinition(String procInstId){

//流程标示

String processDefinitionId = historyServicecreateHistoricProcessInstanceQuery()processInstanceId(procInstId)singleResult()getProcessDefinitionId();

ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)repositoryService)getDeployedProcessDefinition(processDefinitionId);

//执行实例

ExecutionEntity execution = (ExecutionEntity) runtimeServicecreateProcessInstanceQuery()processInstanceId(procInstId)singleResult();

//当前实例的执行到哪个节点

String activitiId = executiongetActivityId();

//获得当前任务的所有节点

List<ActivityImpl> activitiList = defgetActivities();

String id = null;

for(ActivityImpl activityImpl:activitiList){

id = activityImplgetId();

if(activitiIdequals(id)){

Systemoutprintln("当前任务:"+activityImplgetProperty("name"));

return nextTaskDefinition(activityImpl, activityImplgetId(),"${iscorrect==1}");

// Systemoutprintln(taskDefinitiongetCandidateGroupIdExpressions()toArray()[0]);

// return taskDefinition;

}

}

return null;

}

/

下一个任务节点

@param activityImpl

@param activityId

@param elString

@return

/

private TaskDefinition nextTaskDefinition(ActivityImpl activityImpl, String activityId, String elString){

if("userTask"equals(activityImplgetProperty("type")) && !activityIdequals(activityImplgetId())){

TaskDefinition taskDefinition = ((UserTaskActivityBehavior)activityImplgetActivityBehavior())getTaskDefinition();

// taskDefinitiongetCandidateGroupIdExpressions()toArray();

return taskDefinition;

}else{

List<PvmTransition> outTransitions = activityImplgetOutgoingTransitions();

List<PvmTransition> outTransitionsTemp = null;

for(PvmTransition tr:outTransitions){

PvmActivity ac = trgetDestination(); //获取线路的终点节点

if("exclusiveGateway"equals(acgetProperty("type"))){

outTransitionsTemp = acgetOutgoingTransitions();

if(outTransitionsTempsize() == 1){

return nextTaskDefinition((ActivityImpl)outTransitionsTempget(0)getDestination(), activityId, elString);

}else if(outTransitionsTempsize() > 1){

for(PvmTransition tr1 : outTransitionsTemp){

Object s = tr1getProperty("conditionText");

if(elStringequals(StrUtilstrim(stoString()))){

return nextTaskDefinition((ActivityImpl)tr1getDestination(), activityId, elString);

}

}

}

}else if("userTask"equals(acgetProperty("type"))){

return ((UserTaskActivityBehavior)((ActivityImpl)ac)getActivityBehavior())getTaskDefinition();

}else{

loggerdebug(acgetProperty("type"));

}

}

return null;

}

}

以上就是关于activiti 挂起任务能查到吗全部的内容,包括:activiti 挂起任务能查到吗、工作流怎么获取下一个节点task、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9477335.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存