activiti 挂起任务能查到吗
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了activiti 挂起任务能查到吗相关的知识,希望对你有一定的参考价值。
参考技术A 1、首先是根据流程ID获取当前任务:Listlt;Task; tasks = taskService.createTaskQuery().processInstanceId(procInstanceId).list();
2、然后根据当前任务获取当前流程的流程定义,然后根据流程定义获得所有的节点:
ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)rs).getDeployedProcessDefinition(task.getProcessDefinitionId());
Listlt;ActivityImpl; activitiList = def.getActivities(); //rs是指RepositoryService的实例
3、根据任务获取当前流程执行ID,执行实例以及当前流程节点的ID:
String excId = task.getExecutionId();
ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(excId).singleResult();
String activitiId = execution.getActivityId();
4、然后循环activitiList 并判断出当前流程所处节点,然后得到当前节点实例,根据节点实例获取所有从当前节点出发的路径,然后根据路径获得下一个节点实例:
for(ActivityImpl activityImpl:activitiList)
String id = activityImpl.getId();
if(activitiId.equals(id))
System.out.println(当前任务:+activityImpl.getProperty(name)); //输出某个节点的某种属性
Listlt;PvmTransition; outTransitions = activityImpl.getOutgoingTransitions();//获取从某个节点出来的所有线路
for(PvmTransition tr:outTransitions)
PvmActivity ac = tr.getDestination(); //获取线路的终点节点
System.out.println(下一步任务任务:+ac.getProperty(name));
break;
本回答被提问者采纳
Activiti7工作流引擎:挂起状态和任务组
挂起和激活流程实例
某些情况可能由于流程变更需要将当前运行的流程暂停而不是直接删除,流程暂停后将不会继续执行。
全部流程实例挂起
操作流程定义为挂起状态,该流程定义下边所有的流程实例全部暂停:流程定义为挂起状态该流程定义将不允许启动新的流程实例,同时该流程定义下所有的流程实例将全部挂起暂停执行。
@Test
public void testProcessSuspended()
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey("offwork")
.singleResult();
if (processDefinition.isSuspended())
repositoryService.activateProcessDefinitionById(processDefinition.getId());
else
repositoryService.suspendProcessDefinitionById(processDefinition.getId());
ACT_RE_PROCDEF.SUSPENSION_STATE_ 挂起状态 2:挂起,1:激活
update ACT_RE_PROCDEF
set
REV_ = 2,
SUSPENSION_STATE_ = 2,
CATEGORY_ = 'http://www.activiti.org/test'
WHERE ID_ = 'offwork:1:3' and REV_ = 1;
挂起单个流程实例。将ACT_RU_TASK和ACT_RU_EXECUTION的SUSPENSION_STATE_修改为2
@Test
public void testSuspendedProcessInstance()
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId("2501")
.singleResult();
boolean suspended = processInstance.isSuspended();
if (suspended)
runtimeService.activateProcessInstanceById(processInstance.getId());
else
runtimeService.suspendProcessInstanceById(processInstance.getId());
-- ACT_RU_TASK.SUSPENSION_STATE_ = 2
update ACT_RU_TASK
SET
REV_ = 2, NAME_ = '项目经理', PARENT_TASK_ID_ = null, PRIORITY_ = 50, CREATE_TIME_ = '2021-12-11 16:41:26.558', OWNER_ = null, ASSIGNEE_ = '傻经理', DELEGATION_ = null, EXECUTION_ID_ = '2505', PROC_DEF_ID_ = 'offwork:1:3', DESCRIPTION_ = null, DUE_DATE_ = null, CATEGORY_ = null,
SUSPENSION_STATE_ = 2,
FORM_KEY_ = null, CLAIM_TIME_ = null
WHERE ID_= '5002' and REV_ = 1;
-- ACT_RU_EXECUTION.SUSPENSION_STATE_ = 2
update ACT_RU_EXECUTION
set
REV_ = 2, BUSINESS_KEY_ = '1', PROC_DEF_ID_ = 'offwork:1:3', ACT_ID_ = null, IS_ACTIVE_ = true, IS_CONCURRENT_ = false, IS_SCOPE_ = true, IS_EVENT_SCOPE_ = false, IS_MI_ROOT_ = false, PARENT_ID_ = null, SUPER_EXEC_ = null, ROOT_PROC_INST_ID_ = '2501',
SUSPENSION_STATE_ = 2,
NAME_ = null, IS_COUNT_ENABLED_ = false, EVT_SUBSCR_COUNT_ = 0, TASK_COUNT_ = 0, JOB_COUNT_ = 0, TIMER_JOB_COUNT_ = 0, SUSP_JOB_COUNT_ = 0, DEADLETTER_JOB_COUNT_ = 0, VAR_COUNT_ = 0, ID_LINK_COUNT_ = 0
WHERE ID_ = '2501' and REV_ = 1;
候选人CandidateUsers
在流程定义中在任务结点的 assignee 固定设置任务负责人,在流程定义时将参与者固定设置在.bpmn 文件中,如果临时任务负责人变更则需要修改流程定义,系统可扩展性差。
针对这种情况可以给任务设置多个候选人,可以从候选人中选择参与者来完成任务。
步骤:
- 查询组任务
- 拾取任务:将任务的负责人设置为自己
- 查询个人任务
- 办理任务
@Test
public void test()
// 1. 查询组任务 TODO SQL
String currentUserId = "lisipm";
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
TaskService taskService = processEngine.getTaskService();
List<Task> taskList = taskService.createTaskQuery()
.processDefinitionKey("candidateUsers")
.taskCandidateUser(currentUserId)
.list();
for (Task task : taskList)
// 拾取任务,将自己设为任务的负责人
taskService.claim(task.getId(), currentUserId);
// 归还任务,将任务负责人设置为null
taskService.setAssignee(task.getId(), null);
// 任务交接,将自己的任务交给给候选人中的其它人
taskService.setAssignee(task.getId(), "wangwupm");
以上是关于activiti 挂起任务能查到吗的主要内容,如果未能解决你的问题,请参考以下文章