| | |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.flowable.bpmn.model.BpmnModel; |
| | | import org.flowable.bpmn.model.UserTask; |
| | | import org.flowable.common.engine.impl.identity.Authentication; |
| | | import org.flowable.engine.ProcessEngineConfiguration; |
| | | import org.flowable.engine.history.HistoricActivityInstance; |
| | | import org.flowable.engine.history.HistoricProcessInstance; |
| | | import org.flowable.engine.repository.Deployment; |
| | | import org.flowable.engine.repository.ProcessDefinition; |
| | | import org.flowable.engine.repository.ProcessDefinitionQuery; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result startProcessInstanceByKey(String procDefKey, Map<String, Object> variables) { |
| | | public Result<?> startProcessInstanceByKey(String procDefKey, Map<String, Object> variables) { |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionKey(procDefKey) |
| | | .latestVersion().singleResult(); |
| | | return startProcessInstanceById(processDefinition.getId(),variables); |
| | | Result result = startProcessInstanceById(processDefinition.getId(),variables); |
| | | return result; |
| | | } |
| | | /** |
| | | * 根据流程定义ID启动流程实例 |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public Result startProcessInstanceById(String procDefId, Map<String, Object> variables) { |
| | | public Result<?> startProcessInstanceById(String procDefId, Map<String, Object> variables) { |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionId(procDefId) |
| | | .singleResult(); |
| | |
| | | ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); |
| | | // 给第一步申请人节点设置任务执行人和意见 |
| | | Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult(); |
| | | if (!sysUser.getUsername().equals(task.getAssignee())){ |
| | | return Result.error("当前用户不是流程发起人"); |
| | | } |
| | | if (Objects.nonNull(task)) { |
| | | taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getRealname() + "发起流程申请"); |
| | | taskService.setAssignee(task.getId(), sysUser.getUsername()); |
| | | task.setDescription(variables.get("organization").toString()); |
| | | // 更新任务 |
| | | taskService.saveTask(task); |
| | | //taskService.complete(task.getId(), variables); |
| | | } |
| | | //设置所有申请人 |