流程引擎flowable

  1. 引入flowable-spring-boot-stater-basic启动

    org/flowable/common/db/create/flowable.mysql.create.common.sql
     - ACT_GE_PROPERTY 流程引擎信息表
     - ACT_GE_BYTEARRAY 流程资源表
    org/flowable/idm/db/create/flowable.mysql.create.identity.sql
     - ACT_ID_PROPERTY
     - ACT_ID_BYTEARRAY
     - ACT_ID_GROUP
     - ACT_ID_MEMBERSHIP
     - ACT_ID_USER
     - ACT_ID_INFO
     - ACT_ID_TOKEN
     - ACT_ID_PRIV
     - ACT_ID_PRIV_MAPPING
    org/flowable/identitylink/service/db/create/flowable.mysql.create.identitylink.sql
     - ACT_RU_IDENTITYLINK
    org/flowable/identitylink/service/db/create/flowable.mysql.create.identitylink.history.sql
     - ACT_HI_IDENTITYLINK
    org/flowable/entitylink/service/db/create/flowable.mysql.create.entitylink.sql
     - ACT_RU_ENTITYLINK
    org/flowable/entitylink/service/db/create/flowable.mysql.create.entitylink.history.sql
     - ACT_HI_ENTITYLINK
    org/flowable/eventsubscription/service/db/create/flowable.mysql.create.eventsubscription.sql
     - ACT_RU_EVENT_SUBSCR
    org/flowable/task/service/db/create/flowable.mysql.create.task.sql
     - ACT_RU_TASK
    org/flowable/task/service/db/create/flowable.mysql.create.task.history.sql
     - ACT_HI_TASKINST
     - ACT_HI_TSK_LOG
    org/flowable/variable/service/db/create/flowable.mysql.create.variable.sql
     - ACT_RU_VARIABLE
    org/flowable/variable/service/db/create/flowable.mysql.create.variable.history.sql
     - ACT_HI_VARINST
    org/flowable/job/service/db/create/flowable.mysql.create.job.sql
     - ACT_RU_JOB
     - ACT_RU_TIMER_JOB
     - ACT_RU_SUSPENDED_JOB
     - ACT_RU_DEADLETTER_JOB
     - ACT_RU_HISTORY_JOB
    org/flowable/batch/service/db/create/flowable.mysql.create.batch.sql
     - FLW_RU_BATCH
     - FLW_RU_BATCH_PART
    org/flowable/db/create/flowable.mysql.create.engine.sql
     - ACT_RE_DEPLOYMENT
     - ACT_RE_MODEL
     - ACT_RU_EXECUTION
     - ACT_RE_PROCDEF
     - ACT_EVT_LOG
     - ACT_PROCDEF_INFO
     - ACT_RU_ACTINST
    org/flowable/db/create/flowable.mysql.create.history.sql
     - ACT_HI_PROCINST
     - ACT_HI_ACTINST
     - ACT_HI_DETAIL
     - ACT_HI_COMMENT
     - ACT_HI_ATTACHMENT
    
    

RepositoryService

createProcessDefinitionQuery():查询表act_re_procdef

List list = repositoryService.createProcessDefinitionQuery()
        .orderByDeploymentId()
        .list();

createNativeProcessDefinitionQuery():自定义sql查询,可连表查询,主表为act_re_procdef

List list = repositoryService.createNativeProcessDefinitionQuery()
        .sql("select *from act_re_procdef order by deployment_id_")
        .list();

createDeploymentQuery():查询表act_re_deployment

List list = repositoryService.createDeploymentQuery()
        .orderByDeploymenTime()
        .list();

createNativeDeploymentQuery:自定义sql查询,可连表查询,主表为act_re_deployment

List list = repositoryService.createNativeDeploymentQuery()
        .sql("select *from act_re_deployment order by deploy_time_")
        .list();

createModelQuery:流程设计器的模型查询,查询表为act_re_model

List list = repositoryService.createModelQuery()
        .orderByCreateTime()
        .list();

createNativeModelQuery:自定义sql查询

List list1 = repositoryService.createNativeModelQuery()
        .sql("select *from act_re_model order by create_time_")
        .list();        

deleteDeployment:删除流程部署

// 删除指定流程部署,如果存在该流程部署的实例job或者历史任务,都会抛出异常
repositoryService.deleteDeployment(deploymentId);
// 级联删除,删除该流程部署所创建的所有任务信息和历史数据
repositoryService.deleteDeployment(deploymentId,true);

getResourceAsStream:查询表act_ge_bytearray,通过查询该流程部署的的指定名称的资源数据

InputStream resourceAsStream = repositoryService.getResourceAsStream(deploymentId, "请假流程.bpmn20.xml");

getBpmnModel:入参流程定义的id,返回将流程定义xml解析后的java实体,可通过该实体获取流程中的所有信息

BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);

addCandidateStarterUser:给指定的流程定义设置谁可以启动该流程,但是flowable不会进行校验,只有自己获取出来进行校验

repositoryService.addCandidateStarterUser(processDefinitionId,"zhangsan");
// 从指定的设置中删除该用户
repositoryService.deleteCandidateStarterUser(processDefinitionId,"zhangsan");

addCandidateStarterGroup:给指定的流程定义设置哪个用户组可以启动该流程,但是flowable不会进行校验,只有自己获取出来进行校验

repositoryService.addCandidateStarterGroup(processDefinitionId,"java开发组");
// 从指定的设置中删除该用户组
repositoryService.deleteCandidateStarterGroup(processDefinitionId,"java开发组");

getIdentityLinksForProcessDefinition:获取指定流程定义的可操作性用户和组,查询表为:act_ru_identitylink;可根据该结果判断某个用户是否可以通过该定义开启流程实例

List identityLinksForProcessDefinition = repositoryService.getIdentityLinksForProcessDefinition(processDefinitionId);

createDeployment:部署流程,将前端传递的xml和流程xml,一级流程的设计信息,传递进行部署,返回Deployment

Deployment deployment = repositoryService.createDeployment()
        .addInputStream("请假流程1.bpmn20.xml", xmlInputStream)
        .addInputStream("请假流程1.png", pngInputStream)
        .name("请假流程1")
        .key(modelKey)
        .tenantId(tenantId)
        .category(category)
        .deploy();
// 无论资源是否一致都会将流程进行部署,如果调用builder的enableDuplicateFiltering可以当流程信息一致时,不进行部署
Deployment deployment = repositoryService.createDeployment()
        .addInputStream("请假流程1.bpmn20.xml", xmlInputStream)
        .addInputStream("请假流程1.png", pngInputStream)
        .name("请假流程1")
        .key(modelKey)
        .tenantId(tenantId)
        .category(category)
        // 开启一致检测
        .enableDuplicateFiltering()
        .deploy();

部署时,如果后缀为bpmn结尾的文件会被自动作为流程的信息文件,png后缀作为流程图的图片,如果没有上传图片。会自动生成流程图,如果不希望自动生成流程图,设置 流程引擎的配置 属性createDiagramOnDeployfalse

newModel,saveModel:前端流程设计好后,传递xml->根据xml进行部署,部署后根据deploymentId保存模型信息,以后修改模型,version依次+1

Model model = repositoryService.newModel();
model.setName("请假模型");
model.setCategory("OA表单");
model.setDeploymentId(deploymentId);
// 设置模型定义的数据
model.setMetaInfo(metaInfo);
model.setTenantId("system");
model.setKey("processkey_123");
repositoryService.saveModel(model);

HistoryService

createProcessInstanceHistoryLogQuery:查询流程的实例信息和评论信息

ProcessInstanceHistoryLog processInstanceHistoryLog = historyService.createProcessInstanceHistoryLogQuery(processInstanceId)
                // 查询评论信息
                .includeComments()
                // 查询历史节点信息
                .includeActivities()
                // 查询历史用户任务信息
                .includeTasks()
                .singleResult();

你可能感兴趣的:(流程引擎flowable)