文章目录
- 介绍
- 一、RepositoryService
- 1、Model(act_re_model)
- 2、Deployment(act_re_deployment)
- 3、ProcessDefinition(act_re_procdef)
- 4、资源相关(act_ge_bytearray)
- 5、其它
- 二、RuntimeService
- 1、ProcessInstance(act_ru_execution)
- 2、其它
- 三、TaskService
- 1、Task(act_ru_task)
- 2、完成任务
- 3、批注(act_hi_comment)
- 4、其它
- 四、HistoryService
- 1、HistoricActivityInstance(act_hi_actinst)
- 2、HistoricTaskInstance(act_hi_taskinst)
- 3、HistoricProcessInstance(act_hi_procinst)
- 五、IdentityService
介绍
- Flowable提供了很多API,注入这些Service即可直接使用
一、RepositoryService
1、Model(act_re_model)
ModelQuery repositoryService.createModelQuery();repositoryService.saveModel(ModelEntityImpl model);
2、Deployment(act_re_deployment)
repositoryService.createDeploymentQuery();Deployment deployment=repositoryService.createDeployment().key("leave").name("leave").category("0").addClasspathResource(String resource).addInputStream(String resourceName, InputStream inputStream).deploy();voidrepositoryService.deleteDeployment(deploymentId, true);
3、ProcessDefinition(act_re_procdef)
ProcessDefinition repositoryService.createProcessDefinitionQuery().deploymentId(String deploymentId).processDefinitionKey(String key).orderByProcessDefinitionKey().asc()、.desc().listPage(int firstResult, int maxResults).singleResult()list()count()
4、资源相关(act_ge_bytearray)
addModelEditorSource(String modelId, byte[] bytes);addModelEditorSourceExtra(String modelId, byte[] bytes);
5、其它
InputStream repositoryService.getResourceAsStream(String deploymentId, String resourceName);
二、RuntimeService
1、ProcessInstance(act_ru_execution)
1、ProcessInstance runtimeService.createProcessInstanceQuery().processInstanceId(String processInstanceId).processInstanceBusinessKey(String businessKey)void runtimeService.deleteProcessInstance(String processInstanceId, String deleteReason);ProcessInstance runtimeService.startProcessInstanceByKey(String processDefinitionKey);ProcessInstanceruntimeService.startProcessInstanceByKey(String processDefinitionKey,Map<String, Object> variables);ProcessInstanceruntimeService.startProcessInstanceByKey(String processDefinitionKey,String businessKey,Map<String, Object> variables);runtimeService.createProcessInstanceBuilder().name("name").businessKey("kk").variables(variables).processDefinitionKey("leave").start();
2、其它
runtimeService.setVariable(String processInstanceId, String variableName, Object value);runtimeService.setVariables(String processInstanceId, Map<String, ?> variables);runtimeService.createChangeActivityStateBuilder().processInstanceId(String processInstanceId).moveActivityIdTo(String currentActivityId,String newActivityId).changeState();
三、TaskService
1、Task(act_ru_task)
Task taskService.createTaskQuery();.taskId(String taskId).processInstanceId(String procInstdId).taskAssignee(String assignee).taskDefinitionKey(String key) .singleResult().list().count().includeTaskLocalVariables().includeIdentityLinks().includeProcessVariables();
2、完成任务
claim(String taskId, String userId);taskService.complete(String taskId);taskService.complete(String taskId, Map<String, Object> variables);
3、批注(act_hi_comment)
- 有时完成一个任务需要设置审批信息如:审批结果、审批意见、审批时间
Comment taskService.addComment(String taskId,String processInstance,String type,String message);List<Comment> getTaskComments(String taskId);List<Comment> getTaskComments(String taskId, String type);List<Comment> getCommentsByType(String type);
4、其它
taskService.setVariable(String taskId,String variableName,Object value);taskService.setVariables(String taskId, Map<String,Object> variables);Object getVariable(String taskId, String variableName);T getVariable(String taskId, String variableName, Class<T> variableClass)Map<String, Object> getVariables(String taskId, Collection<String> variableNames)taskService.setVariableLocal(String taskId, String variableName, Object value);taskService.setVariables(String taskId, Map<String,Object> variables);Map<String, Object> getVariablesLocal(String taskId);Map<String, Object> getVariablesLocal(String taskId, Collection<String> variableNames);void taskService.claim(String taskId, String userId);taskService.setAssignee(String assignee);taskService.addCandidateGroup(String taskId, String groupId);taskService.deleteCandidateGroup(String taskId, String groupId);taskService.addCandidateUser(String taskId, String userId);taskService.deleteCandidateUser(String taskId, String userId);
四、HistoryService
1、HistoricActivityInstance(act_hi_actinst)
historyService.createHistoricActivityInstanceQuery().orderByHistoricActivityInstanceEndTime().orderByHistoricActivityInstanceStartTime().asc()、desc()
2、HistoricTaskInstance(act_hi_taskinst)
historyService.createHistoricTaskInstanceQuery()includeTaskLocalVariables()includeProcessVariables()includeIdentityLinks()processInstanceId()processInstanceBusinessKey(String businessKey)processInstanceBusinessKeyLike()processInstanceBusinessKeyLikeIgnoreCase()processFinished()processUnfinished()finished()unfinished()orderByHistoricTaskInstanceStartTime()orderByHistoricTaskInstanceEndTime()asc()、desc()
3、HistoricProcessInstance(act_hi_procinst)
historyService.createHistoricProcessInstanceQuery()finished()unfinished()processInstanceId(String processInstanceId)processInstanceIds(Set<String> processInstanceIds)processInstanceBusinessKey(String businessKey)startedBy(String startedBy)involvedUser(String userId)startedBefore(Date date)、startedAfter(Date date)finishedBefore(Date date)、finishedAfter(Date date)orderByProcessInstanceEndTime()orderByProcessInstanceStartTime()orderByProcessInstanceDuration()asc()、desc()longcount()List<HistoricProcessInstance>list()includeProcessVariables()void deleteHistoricProcessInstance(String processInstanceId);
五、IdentityService
1、其它
IdentityLinkType常量类