Java Code Examples for org.activiti.engine.runtime.ProcessInstance#getActivityId()
The following examples show how to use
org.activiti.engine.runtime.ProcessInstance#getActivityId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiKit.java From my_curd with Apache License 2.0 | 5 votes |
/** * 根据 业务表单记录id 查询流程信息 * * @param businessKey 业务表主键 * @return */ public static Map<String, Object> getInstanceInfoByBusinessKey(String businessKey) { Map<String, Object> ret = new HashMap<>(); // 查询正在运行流程 ProcessInstance instance = ActivitiKit.getRuntimeService().createProcessInstanceQuery() .processInstanceBusinessKey(businessKey) .singleResult(); if (instance != null) { // 正运行流程 存在 ret.put("processInstanceId", instance.getId()); // 流程实例id String definitionId = instance.getProcessDefinitionId(); String activityId = instance.getActivityId(); ret.put("processDefinitionId", definitionId); // 流程定义id ret.put("currentActivityId", activityId); // 当前任务节点 id ActivityImpl activity = ActivitiKit.getActivity(definitionId, activityId); if (activity != null) { ret.put("currentActivityName", activity.getProperty("name")); //当前任务节点名 } } else { // 正运行流程 不存在 查询历史流程 HistoricProcessInstance historicProcessInstance = ActivitiKit.getHistoryService().createHistoricProcessInstanceQuery() .processInstanceBusinessKey(businessKey) .singleResult(); if (historicProcessInstance != null) { ret.put("hisProcessInstanceId", historicProcessInstance.getId());// 流程实例id ret.put("processDefinitionId", historicProcessInstance.getProcessDefinitionId());// 流程定义id ret.put("startTime", historicProcessInstance.getStartTime()); // 开始时间 ret.put("endTime", historicProcessInstance.getEndTime()); // 结束时间 ret.put("durationInMillis", historicProcessInstance.getDurationInMillis());// 持续时间 } } // hisProcessInstanceId 和 processInstanceId 是 一致的 return ret; }
Example 2
Source File: BpmActivityServiceImpl.java From hsweb-framework with Apache License 2.0 | 5 votes |
@Override public ActivityImpl getActivityByProcInstId(String procDefId, String procInstId) { ProcessInstance processInstance = runtimeService .createProcessInstanceQuery() .processInstanceId(procInstId) .active() .singleResult(); String activityId = processInstance.getActivityId(); return getProcessDefinition(procDefId).findActivity(activityId); }
Example 3
Source File: BpmProcessServiceImpl.java From hsweb-framework with Apache License 2.0 | 4 votes |
@Override public ProcessInstance startProcessInstance(StartProcessRequest request) { request.tryValidate(); ProcessInstance processInstance; logger.debug("start workflow :{}", request); try { identityService.setAuthenticatedUserId(request.getCreatorId()); ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(request.getProcessDefineId()) .singleResult(); if (definition == null) { throw new NotFoundException("流程[" + request.getProcessDefineId() + "]不存在"); } //创建业务ID String businessKey = IDGenerator.MD5.generate(); //启动流程 processInstance = runtimeService.startProcessInstanceById( request.getProcessDefineId() , businessKey , request.getVariables()); //候选人设置 Consumer<Task> candidateUserSetter = (task) -> { if (task == null) { return; } //指定了下一环节的办理人 if (!StringUtils.isNullOrEmpty(request.getNextClaimUserId())) { taskService.addCandidateUser(task.getId(), request.getNextClaimUserId()); } else { bpmTaskService.setCandidate(request.getCreatorId(), task); } }; List<Task> tasks = bpmTaskService.selectTaskByProcessId(processInstance.getProcessDefinitionId()); //当前节点 String activityId = processInstance.getActivityId(); if (activityId == null) { //所有task设置候选人 tasks.forEach(candidateUserSetter); } else { candidateUserSetter.accept(taskService .createTaskQuery() .processInstanceId(processInstance.getProcessInstanceId()) .taskDefinitionKey(activityId) .active() .singleResult()); } workFlowFormService.saveProcessForm(processInstance, SaveFormRequest .builder() .userId(request.getCreatorId()) .userName(request.getCreatorName()) .formData(request.getFormData()) .build()); ProcessHistoryEntity history = ProcessHistoryEntity.builder() .type("start") .typeText("启动流程") .businessKey(businessKey) .creatorId(request.getCreatorId()) .creatorName(request.getCreatorName()) .processInstanceId(processInstance.getProcessInstanceId()) .processDefineId(processInstance.getProcessDefinitionId()) .build(); processHistoryService.insert(history); } finally { identityService.setAuthenticatedUserId(null); } return processInstance; }