public void startWorkFlow(List<TaskVo> taskVos) { if (null != taskVos && !taskVos.isEmpty()) { for (TaskVo vo : taskVos) { String businessKey = vo.getBusinessKey(); String businessName = vo.getBusinessName(); updateApproveStatus(businessKey, WebConstants.APPROVE_STATUS_NEW); startProcessInstanceByBussKey(vo); } } }
/** * @param tasks * @return */ public List<TaskVo> buildTaskVos(List<Task> tasks) { List<TaskVo> taskRtn = new ArrayList<>(); if (null != tasks && !tasks.isEmpty()) { // 根据流程的业务ID查询实体并关联 for (Task task : tasks) { String processInstanceId = task.getProcessInstanceId(); ProcessInstance processInstance = runtimeService .createProcessInstanceQuery() .processInstanceId(processInstanceId) .active() .singleResult(); String businessName = (String) task.getTaskLocalVariables().get(WebConstants.BUSINESS_NAME); String taskId = task.getId(); String businessKey = processInstance.getBusinessKey(); if (StringUtils.isBlank(businessKey)) { continue; } if (StringUtils.isBlank(businessName)) { businessName = getBusinessName(taskId, businessKey); } ProcessDefinition processDefinition = getProcessDefinition(processInstance.getProcessDefinitionId()); int version = processDefinition.getVersion(); String taskName = task.getName(); String createTime = DateUtils.SINGLETONE.format(task.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS); String assignee = task.getAssignee(); boolean suspended = task.isSuspended(); String processDefinitionId = processInstance.getProcessDefinitionId(); TaskVo taskInfo = new TaskVo(); taskInfo.setProcessInstanceId(processInstanceId); taskInfo.setBusinessKey(businessKey); taskInfo.setProcessDefinitionId(processDefinitionId); taskInfo.setId(taskId); taskInfo.setName(taskName); taskInfo.setCreateTime(createTime); taskInfo.setAssignee(assignee); taskInfo.setSuspended(suspended); taskInfo.setVersion(version); taskInfo.setBusinessName(businessName); taskRtn.add(taskInfo); } } return taskRtn; }
@Override public void startProcessInstanceByBussKey(TaskVo vo) { String businessKey = vo.getBusinessKey(); String businessName = vo.getBusinessName(); startProcessInstanceByBussKey(businessKey, businessName); }