Activiti 通過任務id獲取當前流程節點的資訊
阿新 • • 發佈:2018-12-17
/** * 查詢當前流程圖 www.fhadmin.org * @param taskId * @param response * @return * @throws Exception */ @RequestMapping("/showCurrentView") public ModelAndView showCurrentView(String taskId,HttpServletResponse response)throws Exception{ ModelAndView mav=new ModelAndView(); Task task=taskService.createTaskQuery() // 建立任務查詢 .taskId(taskId) // 根據任務id查詢 .singleResult(); String processDefinitionId=task.getProcessDefinitionId(); // 獲取流程定義id ProcessDefinition processDefinition=repositoryService.createProcessDefinitionQuery() // 建立流程定義查詢 .processDefinitionId(processDefinitionId) // 根據流程定義id查詢 .singleResult(); mav.addObject("deploymentId",processDefinition.getDeploymentId()); // 部署id mav.addObject("diagramResourceName", processDefinition.getDiagramResourceName()); // 圖片資原始檔名稱 ProcessDefinitionEntity processDefinitionEntity=(ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId); String processInstanceId=task.getProcessInstanceId(); // 獲取流程例項id ProcessInstance pi=runtimeService.createProcessInstanceQuery() // 根據流程例項id獲取流程例項 .processInstanceId(processInstanceId) .singleResult(); ActivityImpl activityImpl=processDefinitionEntity.findActivity(pi.getActivityId()); // 根據活動id獲取活動例項 mav.addObject("x", activityImpl.getX()); // x座標 mav.addObject("y", activityImpl.getY()); // y座標 mav.addObject("width", activityImpl.getWidth()); // 寬度 mav.addObject("height", activityImpl.getHeight()); // 高度 mav.setViewName("page/currentView"); return mav; }