camunda 流程篇

1、流程实例迁移(可以迁移启动的流程)

		MigrationPlanBuilder migrationPlan = runtimeService.createMigrationPlan("fromDefinitionId", "toDefinitionId");
//                .mapActivities(); 特殊节点迁移(用于节点改变或删除(前提条件,节点类型必须相同))
        runtimeService.newMigration(migrationPlan.build()).processInstanceIds("instanceId").execute();

2、任意节点启动流程

		ProcessInstantiationBuilder processInstantiationBuilder = runtimeService.createProcessInstanceByKey(key);
        ProcessInstance execute = processInstantiationBuilder.startAfterActivity(activityId).execute();

3、添加审批意见

     	Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
   		taskService.createComment(taskId, task.getProcessInstanceId(), comment);

4、撤回(驳回)

	try {
            TaskEntity taskEntity = (TaskEntity) taskService.createTaskQuery().taskId(taskId).singleResult();
            ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(taskEntity.getProcessInstanceId()).singleResult();
            String processInstanceId = processInstance.getId();
            String taskDefinitionKey = taskEntity.getTaskDefinitionKey();
            AtomicReference<String> backTask = new AtomicReference<>("");
            List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list();
            for (HistoricTaskInstance historicTaskInstance : taskInstances) {
                String nowTask = historicTaskInstance.getTaskDefinitionKey();
                if (taskDefinitionKey.equals(nowTask)) {
                    break;
                }
                backTask.set(nowTask);
            }

            if (StringUtils.isEmpty(backTask.get())) {
                R.errorDefinition("错误");
            }

            runtimeService.createProcessInstanceModification(processInstanceId)
                    //关闭相关任务
                    .cancelAllForActivity(taskDefinitionKey)
                    .setAnnotation("comment")
                    //启动目标活动节点
                    .startBeforeActivity(backTask.get())
                    .execute();
        } catch (Exception e) {
            e.printStackTrace();
        }

5、流程撤销

runtimeService.deleteProcessInstance(processId, "流程撤销");
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值