processEngine.getTaskService().setAssignee(String taskId, String userId)

 

Activiti 基本操作之“受理人变量”

在流程图那条线Main Config设置${drafter},在

processEngine.getTaskService()定义drafter的值,则会自动写入act_ru_task这张表,并能被获取
Map<String, Object> params=new HashMap<String, Object>();

 网关传入的参数必须是Boolean类型的数值

params.put("drafter", true);
ProcessInstance myProcess_1 = runtimeService.startProcessInstanceByKey("AC",params);

然后根据

List<Task> tasks = taskService.createTaskQuery().taskAssignee(assignee).list();//根据assignee查询

 

 

 

 

以下是通过 Flowable 的 Java API 获取流程实例详情并解析流程图中节点信息的示例代码: ```java import org.flowable.engine.HistoryService; import org.flowable.engine.ProcessEngine; import org.flowable.engine.ProcessEngines; import org.flowable.engine.history.HistoricVariableInstance; import org.flowable.engine.history.HistoricVariableInstanceQuery; import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.runtime.ProcessInstance; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import java.io.ByteArrayInputStream; import java.util.List; public class FlowableExample { public static void main(String[] args) { // 获取 ProcessEngine 实例 ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); // 获取 HistoryService 实例 HistoryService historyService = processEngine.getHistoryService(); // 流程实例的 ID String processInstanceId = "123456"; // 使用 HistoryService 获取流程实例详情 ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); ProcessDefinition processDefinition = processEngine.getRepositoryService().getProcessDefinition(processInstance.getProcessDefinitionId()); byte[] bpmnBytes = processEngine.getRepositoryService().getProcessModel(processInstance.getProcessDefinitionId()); // 使用 DocumentBuilder 解析 BPMN XML 文件 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(bpmnBytes)); Element root = doc.getDocumentElement(); NodeList nodeList = root.getElementsByTagName("*"); // 遍历 BPMN XML 文件中所有节点 for (int i = 0; i < nodeList.getLength(); i++) { Element node = (Element) nodeList.item(i); if (node.getNodeName().equals("userTask")) { // 获取用户任务节点的审批人信息 String assignee = node.getAttribute("flowable:assignee"); String candidateUsers = node.getAttribute("flowable:candidateUsers"); String candidateGroups = node.getAttribute("flowable:candidateGroups"); // ... } } } } ``` 在解析 BPMN XML 文件时,可以使用 `DocumentBuilder` 类和 `Document` 接口来解析 XML 文件,并使用 DOM API 遍历 XML 文件中的节点信息。需要注意的是,BPMN XML 文件中节点的属性名称和属性值可能会因为 Flowable 版本不同而有所差异,因此在获取节点信息时需要根据具体的版本信息进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值