首页 > 其他分享 >OA 系统工作流引擎 Camunda 实践(1)

OA 系统工作流引擎 Camunda 实践(1)

时间:2022-10-27 08:55:29浏览次数:169  
标签:ci SET DEFAULT utf8 OA 引擎 Camunda NULL ID

 

Camunda是Activiti最大的贡献者之一(除Alfresco以外),同时也是它一个主 要的执行咨询合作伙伴。camunda表示Activiti可能太拘束于Alfresco对以文档为中心的工作流的需求(这个也是BPMN约束使然),而忽视了Activiti起步时 的更为普遍的BPM平台。camunda宣布他们正从Activiti 分裂出一个新的开源工程,那就是camunda BPM

 

官网

https://camunda.com/

下载

https://camunda.com/download/

Camunda文档中文站

http://camunda-cn.shaochenfeng.com/

学习路线知识点

https://www.processon.com/view/link/622da3ba1e085307a23dc108#map

 

由于公司业务限制,没有用到表单引擎和BPMN.js

模型是后端调用Camunda api(BpmnModelInstance、BpmnDiagram)自动生成的(老板嫌弃BPMN.js画的BPMN图丑),表单引擎比较复杂都是单独写,没用到在线表单生成

目前已实现功能点(国内常见的操作都能实现):发起,审批通过,驳回,转交他人审批,退回历史节点,前置加签/后置加签,撤回,重新发起,作废,转阅,催办

后面有部分代码,我也业务代码删除了,童鞋们可以参考一下,有疑问可以私信我。

 

效果图:

流程定义添加

 用户发起:

 

 审批:

 

 

 后续相关代码实现

// 工作流引擎camunda-bpm依赖
implementation "org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter:7.16.0"
implementation "org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp:7.16.0"
implementation "org.camunda.bpm:camunda-engine-plugin-spin:7.16.0"
implementation "org.camunda.spin:camunda-spin-dataformat-all:1.16.0"

Camunda工具类

package com.oa.business.flow.utils.camunda;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.galileotime.oa.business.flow.utils.camunda.constant.CamundaEnum;
import com.galileotime.oa.business.flow.utils.camunda.pojo.ProcessPOJO;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.model.bpmn.Bpmn;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import org.camunda.bpm.model.bpmn.instance.Process;
import org.camunda.bpm.model.bpmn.instance.*;
import org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnDiagram;
import org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnEdge;
import org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnPlane;
import org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape;
import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener;
import org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener;
import org.camunda.bpm.model.bpmn.instance.dc.Bounds;
import org.camunda.bpm.model.bpmn.instance.di.Waypoint;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

/**
 * @author HeZeMin
 * @className CamundaUtils
 * @description Camunda工作流引擎工具类
 * @date 2022/4/8 15:50
 */
@Slf4j
@Component
public class CamundaModelUtils {
    /**
     *
     * @Description 创建流程定义
     * @Return: void
     * @Author HeZeMin
     * @Date 2022年04月08日 15:54
     */
    public String createExecutableProcess(HashMap<String, Object> param, Long userId) {
        ProcessPOJO processPOJO = new ProcessPOJO();
        BeanUtil.copyProperties(param.get("process"), processPOJO);
        log.info(JSONUtil.toJsonStr(param));

        //1、创建一个空的 BPMN 模型实例
        BpmnModelInstance modelInstance = Bpmn.createEmptyModel();

        //2、创建BPMN定义元素,设置目标名称空间,并将其添加到新创建的模型实例中
        Definitions definitions = modelInstance.newInstance(Definitions.class);
        definitions.setTargetNamespace("http://camunda.org/examples");
        modelInstance.setDefinitions(definitions);

        // di-对于图,需要创建一个图和一个平面元素。平面被设置在一个图对象中,图被添加为子元素
        BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class);
        BpmnPlane plane = modelInstance.newInstance(BpmnPlane.class);
        bpmnDiagram.setBpmnPlane(plane);
        definitions.addChildElement(bpmnDiagram);

        //3、创建流程
        String procDefKey = CamundaEnum.PROCESS.getName() + this.id();
        Process process = createElement(definitions, procDefKey, Process.class);
        process.setName(processPOJO.getProcessName());
        process.setExecutable(true);//可执行的流程

        // di-平面元素添加process
        plane.setBpmnElement(process);

        //---业务代码处理start
        //保存流程定义
        //保存流程发起人用户
        //保存流程发起人角色
        //---业务代码处理end

        //4、创建开始事件
        StartEvent startEvent = this.createElement(process, CamundaEnum.EVENT.getName() + this.id(), StartEvent.class);
        startEvent.setCamundaInitiator("initiator");//发起人
        this.drawBpmnShape(modelInstance, plane, startEvent.getId());// di-平面元素添加节点

        //5、创建申请人节点
        UserTask userTask = this.createElement(process, CamundaEnum.ACTIVITY.getName() + this.id(), UserTask.class);
        userTask.setName("发起人");
        userTask.setCamundaAssignee("${initiator}");
        // di-平面元素添加节点
        this.drawBpmnShape(modelInstance, plane, userTask.getId());
        // 开始事件连线到申请人节点
        SequenceFlow sequenceFlow = this.createSequenceFlow(process, startEvent, userTask);
        // di-平面元素添加连线
        this.drawBpmnEdge(modelInstance, plane, sequenceFlow.getId());

        //6、创建结束事件
        EndEvent endEvent = this.createElement(process, CamundaEnum.EVENT.getName() + this.id(), EndEvent.class);
        // 结束监听器
        ExtensionElements extensionElements = this.createElement(endEvent, "", ExtensionElements.class);
        CamundaExecutionListener start = this.createElement(extensionElements, "", CamundaExecutionListener.class);
        start.setCamundaDelegateExpression("#{EndEventListener}");
        start.setCamundaEvent("start");//start||end
        CamundaExecutionListener end = this.createElement(extensionElements, "", CamundaExecutionListener.class);
        end.setCamundaDelegateExpression("#{EndEventListener}");
        end.setCamundaEvent("end");//start||end
        endEvent.setExtensionElements(extensionElements);
        this.drawBpmnShape(modelInstance, plane, endEvent.getId());// di-平面元素添加节点

        //7、处理节点数据-[递归算法]
        this.iterate(modelInstance, plane, process, userTask, endEvent, null, JSONUtil.toJsonStr(param.get("processModeel")), userId);

        //8、验证模型
        Bpmn.validateModel(modelInstance);

        //9、转换为xml字符串
        String xmlString = Bpmn.convertToString(modelInstance);
        log.info(xmlString);
        return xmlString;
    }
    /**
     *
     * @Description 修改流程定义
     * @Return: void
     * @Author HeZeMin
     * @Date 2022年04月08日 15:54
     */
    public String updateExecutableProcess(HashMap<String, Object> param, Long userId) {
        ProcessPOJO processPOJO = new ProcessPOJO();
        BeanUtil.copyProperties(param.get("process"), processPOJO);
        log.info(JSONUtil.toJsonStr(param));

        //1、创建一个空的 BPMN 模型实例
        BpmnModelInstance modelInstance = Bpmn.createEmptyModel();

        //2、创建BPMN定义元素,设置目标名称空间,并将其添加到新创建的模型实例中
        Definitions definitions = modelInstance.newInstance(Definitions.class);
        definitions.setTargetNamespace("http://camunda.org/examples");
        modelInstance.setDefinitions(definitions);

        // di-对于图,需要创建一个图和一个平面元素。平面被设置在一个图对象中,图被添加为子元素
        BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class);
        BpmnPlane plane = modelInstance.newInstance(BpmnPlane.class);
        bpmnDiagram.setBpmnPlane(plane);
        definitions.addChildElement(bpmnDiagram);

        //3、创建流程
        String procDefKey = processPOJO.getProcDefKey();
        Process process = createElement(definitions, procDefKey, Process.class);
        process.setName(processPOJO.getProcessName());
        process.setExecutable(true);//可执行的流程

        // di-平面元素添加process
        plane.setBpmnElement(process);

        //---业务代码处理start
        //修改流程定义
        //流程发起人用户全部逻辑删除
        //流程发起人角色全部逻辑删除
        //保存流程发起人用户
        //保存流程发起人角色
        //流程节点定义规则全部逻辑删除
        //流程节点定义用户规则全部逻辑删除
        //流程网关定义规则全部逻辑删除
        //流程网关定义条件规则全部逻辑删除
        //---业务代码处理end

        //4、创建开始事件
        StartEvent startEvent = this.createElement(process, CamundaEnum.EVENT.getName() + this.id(), StartEvent.class);
        startEvent.setCamundaInitiator("initiator");//发起人
        this.drawBpmnShape(modelInstance, plane, startEvent.getId());// di-平面元素添加节点

        //5、创建申请人节点
        UserTask userTask = this.createElement(process, CamundaEnum.ACTIVITY.getName() + this.id(), UserTask.class);
        userTask.setName("发起人");
        userTask.setCamundaAssignee("${initiator}");
        // di-平面元素添加节点
        this.drawBpmnShape(modelInstance, plane, userTask.getId());
        // 开始事件连线到申请人节点
        SequenceFlow sequenceFlow = this.createSequenceFlow(process, startEvent, userTask);
        // di-平面元素添加连线
        this.drawBpmnEdge(modelInstance, plane, sequenceFlow.getId());

        //6、创建结束事件
        EndEvent endEvent = this.createElement(process, CamundaEnum.EVENT.getName() + this.id(), EndEvent.class);
        // 结束监听器
        ExtensionElements extensionElements = this.createElement(endEvent, "", ExtensionElements.class);
        CamundaExecutionListener start = this.createElement(extensionElements, "", CamundaExecutionListener.class);
        start.setCamundaDelegateExpression("#{EndEventListener}");
        start.setCamundaEvent("start");//start||end
        CamundaExecutionListener end = this.createElement(extensionElements, "", CamundaExecutionListener.class);
        end.setCamundaDelegateExpression("#{EndEventListener}");
        end.setCamundaEvent("end");//start||end
        endEvent.setExtensionElements(extensionElements);
        this.drawBpmnShape(modelInstance, plane, endEvent.getId());// di-平面元素添加节点

        //7、处理节点数据-递归
        this.iterate(modelInstance, plane, process, userTask, endEvent, null, JSONUtil.toJsonStr(param.get("processModeel")), userId);

        //8、验证模型
        Bpmn.validateModel(modelInstance);

        //9、转换为xml字符串
        String xmlString = Bpmn.convertToString(modelInstance);
        log.info(xmlString);
        return xmlString;
    }
    /**
     *迭代器
     * @Description 迭代器
     * @Param process: 流程DOM对象
     * @Param previouEvent: 上一节点DOM对象
     * @Param endEvent: 结束事件DOM对象
     * @Param conditionMap: 网关条件
     * @Param jsonStr: 参数json串
     * @Return: void
     * @Author HeZeMin
     * @Date 2022年04月12日 10:35
     */
    public void iterate(BpmnModelInstance modelInstance, BpmnPlane plane, Process process, FlowNode previouEvent, FlowNode endEvent, HashMap<String, String> conditionMap, String jsonStr, Long userId) {
        JSONObject jsonObject = JSONUtil.parseObj(jsonStr);
        process.getId();
        if (ObjectUtil.isNotNull(jsonObject) && jsonObject.size() > 0) {
            Integer nodeType = jsonObject.get("nodeType", Integer.class);
            if (1 == nodeType || 2  == nodeType) {// 1=审批人,2=执行人
                Integer auditType = jsonObject.get("auditType", Integer.class);
                Integer auditMethod = jsonObject.get("auditMethod", Integer.class);
                Integer isAdminAudit = jsonObject.get("isAdminAudit", Integer.class);
                String dataType = jsonObject.get("dataType", String.class);
                String nodeName = jsonObject.get("nodeName", String.class);
                String dataValue = jsonObject.get("dataValue", String.class);
                // 创建用户任务节点
                String id = CamundaEnum.ACTIVITY.getName() + this.id();
                if (2  == nodeType) {// 执行人额外增加一个属性标识,不然不知道是执行人还是审批人
                    id = CamundaEnum.ACTIVITY.getName() + "executor_" + this.id();// 执行人标识
                }
                UserTask userTask = this.createElement(process, id, UserTask.class);
                if (2  == nodeType) {
                    userTask.setName(StrUtil.isBlank(nodeName) ? "执行人" : nodeName);
                } else {
                    userTask.setName(StrUtil.isBlank(nodeName) ? "审批人" : nodeName);
                }
                userTask.setCamundaAssignee("${assignee}");
                // 创建多人签实例
                MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = this.createElement(userTask, "", MultiInstanceLoopCharacteristics.class);
                //审批人集合参数
                multiInstanceLoopCharacteristics.setCamundaCollection("assigneeList_" + id);
                //迭代集合
                multiInstanceLoopCharacteristics.setCamundaElementVariable("assignee");
                //完成条件 已完成数等于实例数
                CompletionCondition completionCondition = this.createElement(multiInstanceLoopCharacteristics, "", CompletionCondition.class);
                if (0 == auditMethod || 1 == auditMethod) {// 或签
                    completionCondition.setTextContent("${nrOfCompletedInstances == 1}");
                } else if (2 == auditMethod) {// 会签
                    completionCondition.setTextContent("${nrOfActiveInstances == nrOfInstances}");
                } else {
                    completionCondition.setTextContent("${nrOfActiveInstances == nrOfInstances}");
                }
                multiInstanceLoopCharacteristics.setCompletionCondition(completionCondition);
                // 并行,为true时就是顺序签
                if (3 == auditMethod) {
                    multiInstanceLoopCharacteristics.setSequential(true);
                } else {
                    multiInstanceLoopCharacteristics.setSequential(false);
                }
                userTask.setLoopCharacteristics(multiInstanceLoopCharacteristics);

                // 站内信和提醒 监听器
                ExtensionElements extensionElements = this.createElement(userTask, "", ExtensionElements.class);
                CamundaTaskListener create = this.createElement(extensionElements, "", CamundaTaskListener.class);
                create.setCamundaDelegateExpression("#{TaskMessageListener}");
                create.setCamundaEvent("create");
                CamundaTaskListener complete = this.createElement(extensionElements, "", CamundaTaskListener.class);
                complete.setCamundaDelegateExpression("#{TaskMessageListener}");
                complete.setCamundaEvent("complete");
                userTask.setExtensionElements(extensionElements);

                // di-平面元素添加节点
                this.drawBpmnShape(modelInstance, plane, userTask.getId());

                //--相关数据存入数据库start
                //保存节点
                //保存节点对应的数据
                //--相关数据存入数据库end
                JSONArray nextNodeDataList = (JSONArray) jsonObject.get("nextNodeData");
                if (CollUtil.isNotEmpty(nextNodeDataList)) {//有下一个节点
                    SequenceFlow sequenceFlow = this.createSequenceFlow(process, previouEvent, userTask, conditionMap);
                    // di-平面元素添加连线
                    this.drawBpmnEdge(modelInstance, plane, sequenceFlow.getId());
                    this.iterate(modelInstance, plane, process, userTask, endEvent, null, JSONUtil.toJsonStr(nextNodeDataList.get(0)), userId);
                } else {// 没有下一个节点了,连线结束事件
                    SequenceFlow sequenceFlow = this.createSequenceFlow(process, previouEvent, userTask, conditionMap);
                    SequenceFlow sequenceFlow1 = this.createSequenceFlow(process, userTask, endEvent);
                    // di-平面元素添加连线
                    this.drawBpmnEdge(modelInstance, plane, sequenceFlow.getId());
                    // di-平面元素添加连线
                    this.drawBpmnEdge(modelInstance, plane, sequenceFlow1.getId());
                }
            } else if (3 == nodeType) {// 3=抄送人
                Integer auditType = jsonObject.get("auditType", Integer.class);
                Integer auditMethod = jsonObject.get("auditMethod", Integer.class);
                Integer isAdminAudit = jsonObject.get("isAdminAudit", Integer.class);
                String dataType = jsonObject.get("dataType", String.class);
                String dataValue = jsonObject.get("dataValue", String.class);
                String nodeName = jsonObject.get("nodeName", String.class);
                // 创建用户任务节点
                String id = CamundaEnum.ACTIVITY.getName() + "copy_" + this.id();
                UserTask userTask = this.createElement(process, id, UserTask.class);
                userTask.setName(StrUtil.isBlank(nodeName) ? "抄送人" : nodeName);

                // 抄送监听器
                ExtensionElements extensionElements = this.createElement(userTask, "", ExtensionElements.class);
                CamundaTaskListener create = this.createElement(extensionElements, "", CamundaTaskListener.class);
                create.setCamundaDelegateExpression("#{CopyListener}");
                create.setCamundaEvent("create");
                CamundaTaskListener complete = this.createElement(extensionElements, "", CamundaTaskListener.class);
                complete.setCamundaDelegateExpression("#{CopyListener}");
                complete.setCamundaEvent("complete");
                userTask.setExtensionElements(extensionElements);

                // di-平面元素添加节点
                this.drawBpmnShape(modelInstance, plane, userTask.getId());

                //--相关数据存入数据库
                //保存节点
                //保存节点对应的数据
                //--相关数据存入数据库

                JSONArray nextNodeDataList = (JSONArray) jsonObject.get("nextNodeData");
                if (CollUtil.isNotEmpty(nextNodeDataList)) {//有下一个节点
                    SequenceFlow sequenceFlow = this.createSequenceFlow(process, previouEvent, userTask, conditionMap);
                    // di-平面元素添加连线
                    this.drawBpmnEdge(modelInstance, plane, sequenceFlow.getId());
                    this.iterate(modelInstance, plane, process, userTask, endEvent, null, JSONUtil.toJsonStr(nextNodeDataList.get(0)), userId);
                } else {// 没有下一个节点了,连线结束事件
                    SequenceFlow sequenceFlow = this.createSequenceFlow(process, previouEvent, userTask, conditionMap);
                    SequenceFlow sequenceFlow1 = this.createSequenceFlow(process, userTask, endEvent);
                    // di-平面元素添加连线
                    this.drawBpmnEdge(modelInstance, plane, sequenceFlow.getId());
                    // di-平面元素添加连线
                    this.drawBpmnEdge(modelInstance, plane, sequenceFlow1.getId());
                }
            } else if (4 == nodeType){// 4=条件分支,只有网关才会有下一节点数据和条件判断数据同时出现的情况
                String nodeName = jsonObject.get("nodeName", String.class);
                // 创建网关
                String id = CamundaEnum.GATEWAY.getName() + this.id();
                // 专属网关,直走一个条件
                ExclusiveGateway gateway = this.createElement(process, id, ExclusiveGateway.class);
                // 并行网关,所有条件都走
//                ParallelGateway gateway = createElement(process, id, ParallelGateway.class);
                SequenceFlow sequenceFlow = this.createSequenceFlow(process, previouEvent, gateway, conditionMap);

                // di-平面元素添加节点
                this.drawBpmnShape(modelInstance, plane, gateway.getId());
                // di-平面元素添加连线
                this.drawBpmnEdge(modelInstance, plane, sequenceFlow.getId());

                //--相关数据存入数据库start
                // 保存网关节点
                //--相关数据存入数据库end

                // 条件判断集合
                JSONArray conditionList = (JSONArray) jsonObject.get("conditionList");
                Iterator<Object> iterator = conditionList.iterator();
                while (iterator.hasNext()) {
                    JSONObject condition = (JSONObject) iterator.next();
                    
                    //--相关数据存入数据库start
                    // 保存网关节点条件判断
                    //--相关数据存入数据库end

                    // 网关表达式
                    StringBuilder textContent = new StringBuilder();
                    textContent.append("${");
                    if (StrUtil.isNotBlank(condition.get("conditionKey_", String.class))) {//两个条件
                        textContent.append("(");
                        if (StrUtil.contains("区间", condition.get("operator", String.class))) {
                            textContent.append(condition.get("targetValue1", String.class) + condition.get("targetValue1Operator", String.class) + condition.get("conditionKey", String.class))
                                    .append(" && ")
                                    .append(condition.get("conditionKey", String.class) + condition.get("targetValue2Operator", String.class) + condition.get("targetValue2", String.class));
                        } else if (StrUtil.contains("包含", condition.get("operator", String.class))) {
                            List<String> stringList = StrUtil.split(condition.get("targetValue", String.class), ",");
                            for (int i = 0; i < stringList.size(); i++) {
                                String targetValue = stringList.get(i);
                                if (i == 0) {
                                    textContent.append(condition.get("conditionKey", String.class) + " == " + targetValue);
                                } else {
                                    textContent.append(" || ");
                                    textContent.append(condition.get("conditionKey", String.class) + " == " + targetValue);
                                }
                            }
                        } else if (StrUtil.contains("不包含", condition.get("operator", String.class))) {
                            List<String> stringList = StrUtil.split(condition.get("targetValue", String.class), ",");
                            for (int i = 0; i < stringList.size(); i++) {
                                String targetValue = stringList.get(i);
                                if (i == 0) {
                                    textContent.append(condition.get("conditionKey", String.class) + " != " + targetValue);
                                } else {
                                    textContent.append(" && ");
                                    textContent.append(condition.get("conditionKey", String.class) + " != " + targetValue);
                                }
                            }
                        } else {
                            textContent.append(condition.get("conditionKey", String.class) + condition.get("operator", String.class) + condition.get("targetValue", String.class));
                        }
                        textContent.append(") && (");
                        if (StrUtil.contains("区间", condition.get("operator_", String.class))) {
                            textContent.append(condition.get("targetValue1_", String.class) + condition.get("targetValue1Operator_", String.class) + condition.get("conditionKey_", String.class))
                                    .append(" && ")
                                    .append(condition.get("conditionKey_", String.class) + condition.get("targetValue2Operator_", String.class) + condition.get("targetValue2_", String.class));
                        } else if (StrUtil.contains("包含", condition.get("operator_", String.class))) {
                            List<String> stringList = StrUtil.split(condition.get("targetValue_", String.class), ",");
                            for (int i = 0; i < stringList.size(); i++) {
                                String targetValue = stringList.get(i);
                                if (i == 0) {
                                    textContent.append(condition.get("conditionKey_", String.class) + " == " + targetValue);
                                } else {
                                    textContent.append(" || ");
                                    textContent.append(condition.get("conditionKey_", String.class) + " == " + targetValue);
                                }
                            }
                        } else if (StrUtil.contains("不包含", condition.get("operator_", String.class))) {
                            List<String> stringList = StrUtil.split(condition.get("targetValue_", String.class), ",");
                            for (int i = 0; i < stringList.size(); i++) {
                                String targetValue = stringList.get(i);
                                if (i == 0) {
                                    textContent.append(condition.get("conditionKey_", String.class) + " != " + targetValue);
                                } else {
                                    textContent.append(" && ");
                                    textContent.append(condition.get("conditionKey_", String.class) + " != " + targetValue);
                                }
                            }
                        } else {
                            textContent.append(condition.get("conditionKey_", String.class) + condition.get("operator_", String.class) + condition.get("targetValue_", String.class));
                        }
                        textContent.append(")");
                    } else {// 一个条件
                        if (StrUtil.contains("区间", condition.get("operator", String.class))) {
                            textContent.append(condition.get("targetValue1", String.class) + condition.get("targetValue1Operator", String.class) + condition.get("conditionKey", String.class))
                                    .append(" && ")
                                    .append(condition.get("conditionKey", String.class) + condition.get("targetValue2Operator", String.class) + condition.get("targetValue2", String.class));
                        } else if (StrUtil.contains("包含", condition.get("operator", String.class))) {
                            List<String> stringList = StrUtil.split(condition.get("targetValue", String.class), ",");
                            for (int i = 0; i < stringList.size(); i++) {
                                String targetValue = stringList.get(i);
                                if (i == 0) {
                                    textContent.append(condition.get("conditionKey", String.class) + " == " + targetValue);
                                } else {
                                    textContent.append(" || ");
                                    textContent.append(condition.get("conditionKey", String.class) + " == " + targetValue);
                                }
                            }
                        } else if (StrUtil.contains("不包含", condition.get("operator", String.class))) {
                            List<String> stringList = StrUtil.split(condition.get("targetValue", String.class), ",");
                            for (int i = 0; i < stringList.size(); i++) {
                                String targetValue = stringList.get(i);
                                if (i == 0) {
                                    textContent.append(condition.get("conditionKey", String.class) + " != " + targetValue);
                                } else {
                                    textContent.append(" && ");
                                    textContent.append(condition.get("conditionKey", String.class) + " != " + targetValue);
                                }
                            }
                        } else {
                            textContent.append(condition.get("conditionKey", String.class) + condition.get("operator", String.class) + condition.get("targetValue", String.class));
                        }
                    }
                    textContent.append("}");
                    JSONArray nextNodeDataList = (JSONArray) condition.get("nextNodeData");
                    if (CollUtil.isNotEmpty(nextNodeDataList)) {//有下一个节点
                        String conditionName = condition.get("conditionName", String.class);
                        HashMap<String, String> map = new HashMap<>();
                        map.put("name", StrUtil.isBlank(conditionName) ? textContent.toString() : conditionName);
                        map.put("type", "");
                        map.put("textContent", textContent.toString());
                        this.iterate(modelInstance, plane, process, gateway, endEvent, map, JSONUtil.toJsonStr(nextNodeDataList.get(0)), userId);
                    } else {
                        SequenceFlow sequenceFlow1 = this.createSequenceFlow(process, gateway, endEvent);
                        // di-平面元素添加连线
                        this.drawBpmnEdge(modelInstance, plane, sequenceFlow1.getId());
                        // 一下注释代码暂时用不到,勿删
                        // 网关的下一个节点,不是条件下的
//                        JSONArray gatewayNnextNodeDataList = (JSONArray) jsonObject.get("nextNodeData");
//                        if (CollUtil.isNotEmpty(gatewayNnextNodeDataList)) {//有下一个节点
//                            this.createSequenceFlow(process, startEvent, gateway, conditionMap);
//                            this.iterate(process, gateway, endEvent, null, JSONUtil.toJsonStr(gatewayNnextNodeDataList.get(0)));
//                        } else {// 没有下一个节点了,连线结束事件
//                            this.createSequenceFlow(process, gateway, endEvent, conditionMap);
//                        }
                    }
                }
            }
        } else {
            // 开始事件连线到结束事件
            SequenceFlow sequenceFlow = this.createSequenceFlow(process, previouEvent, endEvent);
            // di-平面元素添加连线
            this.drawBpmnEdge(modelInstance, plane, sequenceFlow.getId());
        }
    }
    /**
     * Description:id生成器
     * @Author HeZeMin
     * @Date 2022年04月21日 15:25
     */
    protected String id() {
        Snowflake snowflake = IdUtil.getSnowflake(1, 1);
        return snowflake.nextIdStr();
    }
    /**
     * Description:创建元素-在父元素下创建子元素-
     * @Author HeZeMin
     * @Date 2022年04月21日 15:24
     */
    protected <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, String id, Class<T> elementClass) {
        T element = parentElement.getModelInstance().newInstance(elementClass);
        if (StrUtil.isNotBlank(id)) {
            element.setAttributeValue("id", id, true);
        }
        parentElement.addChildElement(element);
        return element;
    }
    /**
     * Description:创建元素-在父元素下创建子元素,需要传元素属性
     * @Author HeZeMin
     * @Date 2022年04月21日 15:24
     */
    protected <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, HashMap<String, String> params, Class<T> elementClass) {
        T element = parentElement.getModelInstance().newInstance(elementClass);
        if (CollUtil.isNotEmpty(params)) {
            params.forEach((key, value) -> {
                if ("id".equals(key)) {
                    element.setAttributeValue("id", value, true);
                } else {
                    element.setAttributeValue(key, value);
                }
            });
        }
        parentElement.addChildElement(element);
        return element;
    }
    /**
     * Description:创建线条元素-元素之间的连接线
     * @Author HeZeMin
     * @Date 2022年04月21日 14:42
     */
    protected SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
        String identifier = from.getId() + "-" + to.getId();
        SequenceFlow sequenceFlow = this.createElement(process, identifier, SequenceFlow.class);
        process.addChildElement(sequenceFlow);
        sequenceFlow.setSource(from);
        from.getOutgoing().add(sequenceFlow);
        sequenceFlow.setTarget(to);
        to.getIncoming().add(sequenceFlow);
        return sequenceFlow;
    }
    /**
     * Description:创建线条元素-网关元素之间的连接线,需要传判断条件
     * @Author HeZeMin
     * @Date 2022年04月21日 14:41
     */
    protected SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to, HashMap<String, String> conditionMap) {
        String identifier = from.getId() + "-" + to.getId();
        SequenceFlow sequenceFlow = this.createElement(process, identifier, SequenceFlow.class);
        process.addChildElement(sequenceFlow);
        sequenceFlow.setSource(from);
        from.getOutgoing().add(sequenceFlow);
        sequenceFlow.setTarget(to);
        to.getIncoming().add(sequenceFlow);
        // 判断是否有连线条件
        if (CollUtil.isNotEmpty(conditionMap)) {
            //  set条件
            sequenceFlow.setName(conditionMap.get("name"));
            ConditionExpression conditionExpression = this.createElement(sequenceFlow, "", ConditionExpression.class);
//            conditionExpression.setType(conditionMap.get("type"));
            conditionExpression.setTextContent(conditionMap.get("textContent"));
            sequenceFlow.setConditionExpression(conditionExpression);
        }
        return sequenceFlow;
    }
    /**
     * Description:绘制节点
     * @Author HeZeMin
     * @Date 2022年04月21日 14:39
     */
    protected void drawBpmnShape(BpmnModelInstance modelInstance, BpmnPlane plane, String elementById) {
        BpmnShape bpmnShape = modelInstance.newInstance(BpmnShape.class);
        BaseElement element1 = modelInstance.getModelElementById(elementById);
        bpmnShape.setBpmnElement(element1);
        bpmnShape.setId(elementById + "_di");
        Bounds bounds = modelInstance.newInstance(Bounds.class);
        bounds.setX(150);
        bounds.setY(80);
        bounds.setHeight(80);
        bounds.setWidth(100);
        if (element1 instanceof ExclusiveGateway) {
            bpmnShape.setMarkerVisible(true);
        }
        bpmnShape.setBounds(bounds);
        plane.addChildElement(bpmnShape);
    }
    /**
     * Description:绘制连线
     * @Author HeZeMin
     * @Date 2022年04月21日 14:40
     */
    protected void drawBpmnEdge(BpmnModelInstance modelInstance, BpmnPlane plane, String elementById) {
        BpmnEdge bpmnEdge = modelInstance.newInstance(BpmnEdge.class);
        BaseElement element0 = modelInstance.getModelElementById(elementById);
        bpmnEdge.setId(elementById + "_di");
        bpmnEdge.setBpmnElement(element0);
        Waypoint wp1 = modelInstance.newInstance(Waypoint.class);
        wp1.setX(300);
        wp1.setY(100);
        bpmnEdge.addChildElement(wp1);
        Waypoint wp2 = modelInstance.newInstance(Waypoint.class);
        wp2.setX(300);
        wp2.setY(100);
        bpmnEdge.addChildElement(wp2);
        plane.addChildElement(bpmnEdge);
    }
}
package com.oa.business.flow.utils.camunda;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.camunda.bpm.engine.*;
import org.camunda.bpm.engine.history.HistoricVariableInstance;
import org.camunda.bpm.engine.impl.RepositoryServiceImpl;
import org.camunda.bpm.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
import org.camunda.bpm.engine.impl.el.ExpressionManager;
import org.camunda.bpm.engine.impl.javax.el.ExpressionFactory;
import org.camunda.bpm.engine.impl.javax.el.ValueExpression;
import org.camunda.bpm.engine.impl.juel.ExpressionFactoryImpl;
import org.camunda.bpm.engine.impl.juel.SimpleContext;
import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.camunda.bpm.engine.impl.pvm.PvmActivity;
import org.camunda.bpm.engine.impl.pvm.PvmTransition;
import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
import org.camunda.bpm.engine.impl.task.TaskDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;

/**
 * Camunda节点操作工具类
 * @author HeZeMin
 * @className CamundaNodeUtils
 * @date 2022/6/22 15:01
 */
@Slf4j
@Component
public class CamundaNodeUtils {

    @Autowired
    RepositoryService repositoryService;// 部署服务
    @Autowired
    RuntimeService runtimeService;// 运行服务
    @Autowired
    IdentityService identityService;// 用户服务
    @Autowired
    AuthorizationService authorizationService;// 授权服务
    @Autowired
    TaskService taskService;// 任务服务
    @Autowired
    HistoryService historyService;// 历史服务

    /**
     * Description:根据流程实例ID查询审批节点集合
     * @Author HeZeMin
     * @Date 2022年06月22日 17:05
     */
    public List<JSONObject> simulationNextPath(String processInstanceId, boolean isHistoric) {
        log.debug("-------------------------------------------------------");
        Map<String, Object> condition = new HashMap<>();
        if (isHistoric) {
            List<HistoricVariableInstance> variableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list();
            condition = new HashMap<>(variableInstanceList.size());
            for (int i = 0; i < variableInstanceList.size(); i++) {
                condition.put(variableInstanceList.get(i).getName(), variableInstanceList.get(i).getValue());
            }
        } else {
            condition = runtimeService.getVariables(processInstanceId);
        }
        log.debug("condition---->" + JSONUtil.toJsonStr(condition));
        List<TaskDefinition> tasks = null;
        try {
            tasks = this.getNextTaskInfos(processInstanceId, condition, isHistoric);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.debug("----------->" + JSONUtil.toJsonStr(tasks));
        List<JSONObject> ja = new ArrayList<>();
        if (CollUtil.isNotEmpty(tasks)) {
            for (TaskDefinition task : tasks) {
                JSONObject jo = new JSONObject();
                jo.set("key", task.getKey());
                jo.set("name", task.getNameExpression().getExpressionText());
                jo.set("assignment", task.getAssigneeExpression() == null ? "" : task.getAssigneeExpression().getExpressionText());
                ja.add(jo);
            }
        }
        log.debug("----->" + ja.toString());
        log.debug("-------------------------------------------------------");
        return ja;
    }
    /**
     * 获取下一个节点任务信息
     *
     * @param processInstanceId
     *            流程实例ID
     * @return 下一个节点信息
     * @throws Exception
     */
    public List<TaskDefinition> getNextTaskInfos(String processInstanceId, Map<String, Object> condition, boolean isHistoric) {
        ProcessDefinitionEntity processDefinitionEntity = null;
        List<TaskDefinition> tasks = new CopyOnWriteArrayList<TaskDefinition>();
        // 获取流程发布Id信息
        String definitionId = "";
        if (isHistoric) {
            definitionId = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId();
        } else {
            definitionId = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId)
                    .singleResult().getProcessDefinitionId();
        }
        processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(definitionId);
        // 获取流程所有节点信息
        List<ActivityImpl> activitiList = processDefinitionEntity.getActivities();

        activitiList = activitiList.stream().filter(activity -> activity.getProperty("type").equals("startEvent")).collect(Collectors.toList());
        this.nextTaskDefinitions(tasks, activitiList, activitiList.get(0).getId(), processInstanceId, condition);

        return tasks;
    }

    private List<TaskDefinition> nextTaskDefinitions(List<TaskDefinition> tasks, List<ActivityImpl> activityList, String activityId,
                                                     String processInstanceId, Map<String, Object> condition) {
        activityList.forEach(activity -> {
            PvmActivity ac = null;
            Object expression = null;// 表达式
            log.debug("activityImpl.getActivityId()---->"+activity.getActivityId()+"---activityId---------->"+activityId+"--->"+activity.getProperty("type"));
            // 如果遍历节点为用户任务并且节点不是当前节点信息
            if ("userTask".equals(activity.getProperty("type")) && !activityId.equals(activity.getId())) {
                // 获取该节点下一个节点信息
                TaskDefinition taskDefinition = ((UserTaskActivityBehavior) activity.getActivityBehavior()).getTaskDefinition();
                tasks.add(taskDefinition);
                List<PvmTransition> outTransitions = activity.getOutgoingTransitions();
                List<ActivityImpl> activityListTmp = new ArrayList<>();
                activityListTmp.add((ActivityImpl)(outTransitions.get(0).getDestination()));
                this.nextTaskDefinitions(tasks, activityListTmp, activityListTmp.get(0).getId(), processInstanceId, condition);
            }else if (activity.getProperty("type").toString().contains("EndEvent") && !activityId.equals(activity.getId())) {
                // 设置结束节点
                TaskDefinition taskDefinition = new TaskDefinition(null);
                ExpressionManager expressionManager = new ExpressionManager();
                taskDefinition.setKey(activity.getId() == null ? "end" : activity.getId());
                String name = activity.getProperty("name") == null ? "结束" : activity.getProperty("name").toString();
                taskDefinition.setNameExpression(expressionManager.createExpression(name));
//                    taskDefinitions.add(taskDefinition);
            } else if ("multiInstanceBody".equals(activity.getProperty("type")) && !activityId.equals(activity.getId())) {
                // 获取该节点下一个节点信息
                List<ActivityImpl> list = ((ActivityImpl) activity).getActivities();
                for(ActivityImpl act : list){
                    //log.debug("act-------------->"+act.getActivityBehavior().getClass().getTypeName());
                    TaskDefinition taskDefinition = ((UserTaskActivityBehavior) act.getActivityBehavior()).getTaskDefinition();
                    tasks.add(taskDefinition);
                }
                List<ActivityImpl> activityListTmp = new ArrayList<>();
                activityListTmp.add((ActivityImpl) activity);
                this.nextTaskDefinitions(tasks, activityListTmp, activityListTmp.get(0).getId(), processInstanceId, condition);
                // 当前节点为exclusiveGateway或inclusiveGateway
            } else if ("exclusiveGateway".equals(activity.getProperty("type")) || "inclusiveGateway".equals(activity.getProperty("type"))) {
                List<PvmTransition> outTransitions = activity.getOutgoingTransitions();
                String defaultTransition = (String) activity.getProperty("default");
                if (outTransitions.size() == 1) {
                    List<ActivityImpl> activityListTmp = new ArrayList<>();
                    activityListTmp.add((ActivityImpl) outTransitions.get(0).getDestination());
                    this.nextTaskDefinitions(tasks, activityListTmp,activityListTmp.get(0).getId(), processInstanceId, condition);
                } else if (outTransitions.size() > 1) { // 如果排他网关有多条线路信息
                    for (PvmTransition tr1 : outTransitions) {
                        ActivityImpl actImpl = (ActivityImpl) tr1.getDestination();
                        if (actImpl.getProperty("type").toString().contains("EndEvent")) {
                            TaskDefinition taskDefinition = new TaskDefinition(null);
                            ExpressionManager expressionManager = new ExpressionManager();
                            taskDefinition.setKey(actImpl.getId() == null ? "end" : actImpl.getId());
                            String name = actImpl.getProperty("name") == null ? "结束" : actImpl.getProperty("name").toString();
                            taskDefinition.setNameExpression(expressionManager.createExpression(name));
//                                taskDefinitions.add(taskDefinition);
                            break;
                        }
                        expression = tr1.getProperty("conditionText"); // 获取排他网关线路判断条件信息
                        if (null == expression) {
                            continue;
                        }
                        // 判断el表达式是否成立
                        if (isCondition(condition, StringUtils.trim(expression.toString()))) {
                            List<ActivityImpl> activityListTmp = new ArrayList<>();
                            activityListTmp.add(actImpl);
                            this.nextTaskDefinitions(tasks, activityListTmp, "", processInstanceId, condition);
                        }
                    }
                }
            } else if ("parrallelGateway".equals(activity.getProperty("type"))) {
                List<PvmTransition> outTransitions = activity.getOutgoingTransitions();
                for (PvmTransition tr1 : outTransitions) {
                    List<ActivityImpl> activityListTmp = new ArrayList<>();
                    activityListTmp.add((ActivityImpl) tr1.getDestination());
                    this.nextTaskDefinitions(tasks, activityListTmp,activityListTmp.get(0).getId(), processInstanceId, condition);
                }
            } else {//***************************************************************
                // 获取节点所有流向线路信息
                List<PvmTransition> outTransitions = activity.getOutgoingTransitions();
                List<PvmTransition> outTransitionsTemp = null;
                for (PvmTransition tr : outTransitions) {
                    ac = tr.getDestination(); // 获取线路的终点节点
                    log.debug("ac----------->" + ac.getId() + "------>" + ac.getProperty("type"));
                    // 如果流向线路为排他网关或包容网关
                    if ("exclusiveGateway".equals(ac.getProperty("type")) || "inclusiveGateway".equals(ac.getProperty("type"))) {
                        outTransitionsTemp = ac.getOutgoingTransitions();
                        String defaultTransition = (String) ac.getProperty("default");
                        // 如果排他网关只有一条线路信息
                        if (outTransitionsTemp.size() == 1) {
                            List<ActivityImpl> activityListTmp = new ArrayList<>();
                            activityListTmp.add((ActivityImpl) outTransitionsTemp.get(0).getDestination());
                            this.nextTaskDefinitions(tasks, activityListTmp,activityListTmp.get(0).getId(), processInstanceId, condition);
                        } else if (outTransitionsTemp.size() > 1) { // 如果排他网关有多条线路信息
                            for (PvmTransition tr1 : outTransitionsTemp) {
                                PvmActivity ac1 = tr1.getDestination();
                                ActivityImpl actImpl = (ActivityImpl) ac1;
                                if (actImpl.getProperty("type").toString().contains("EndEvent")) {
                                    TaskDefinition taskDefinition2 = new TaskDefinition(null);
                                    ExpressionManager expressionManager2 = new ExpressionManager();
                                    taskDefinition2.setKey(actImpl.getId() == null ? "end" : actImpl.getId());
                                    String name2 = actImpl.getProperty("name") == null ? "结束" : actImpl.getProperty("name").toString();
                                    taskDefinition2.setNameExpression(expressionManager2.createExpression(name2));
//                                        taskDefinitions.add(taskDefinition2);
                                    break;
                                }
                                expression = tr1.getProperty("conditionText"); // 获取排他网关线路判断条件信息
                                if (null == expression) {
                                    continue;
                                }
                                // 判断el表达式是否成立
                                if (this.isCondition(condition, StringUtils.trim(expression.toString()))) {
                                    List<ActivityImpl> activityListTmp = new ArrayList<>();
                                    activityListTmp.add(actImpl);
                                    this.nextTaskDefinitions(tasks, activityListTmp,"", processInstanceId, condition);
                                }
                            }
                        }
                    } else if ("userTask".equals(ac.getProperty("type"))) {
                        tasks.add(((UserTaskActivityBehavior) ((ActivityImpl) ac).getActivityBehavior()).getTaskDefinition());
                        TaskDefinition taskDefinition = ((UserTaskActivityBehavior) ((ActivityImpl) ac).getActivityBehavior()).getTaskDefinition();
                        List<ActivityImpl> activityListTmp = new ArrayList<>();
                        activityListTmp.add((ActivityImpl) ac);
                        this.nextTaskDefinitions(tasks, activityListTmp,activityListTmp.get(0).getId(), processInstanceId, condition);
                    } else if ("multiInstanceBody".equals(ac.getProperty("type"))) {
                        List<ActivityImpl> list = ((ActivityImpl) ac).getActivities();
                        for(ActivityImpl act : list){
                            //log.debug("act-------------->"+act.getActivityBehavior().getClass().getTypeName());
                            TaskDefinition taskDefinition = ((UserTaskActivityBehavior) act.getActivityBehavior()).getTaskDefinition();
                            tasks.add(taskDefinition);
                        }
                        List<ActivityImpl> activityListTmp = new ArrayList<>();
                        activityListTmp.add((ActivityImpl) ac);
                        this.nextTaskDefinitions(tasks, activityListTmp,activityListTmp.get(0).getId(), processInstanceId, condition);
                    } else if (ac.getProperty("type").toString().contains("EndEvent")) {
                        // 设置结束节点
                        TaskDefinition taskDefinition = new TaskDefinition(null);
                        ExpressionManager expressionManager = new ExpressionManager();
                        taskDefinition.setKey(ac.getId() == null ? "end" : ac.getId());
                        String name = ac.getProperty("name") == null ? "结束" : ac.getProperty("name").toString();
                        taskDefinition.setNameExpression(expressionManager.createExpression(name));
//                            taskDefinitions.add(taskDefinition);
                    } else if ("parrallelGateway".equals(ac.getProperty("type"))) {
                        List<PvmTransition> poutTransitions = ac.getOutgoingTransitions();
                        for (PvmTransition tr1 : poutTransitions) {
                            tasks.add(((UserTaskActivityBehavior) ((ActivityImpl) ac).getActivityBehavior()).getTaskDefinition());
                            List<ActivityImpl> activityListTmp = new ArrayList<>();
                            activityListTmp.add((ActivityImpl) ac);
                            this.nextTaskDefinitions(tasks, activityListTmp, "", processInstanceId, condition);
                        }
                    }
                }
            }
//                return taskDefinitions;
        });
        return null;
    }

    private boolean isCondition(Map<String, Object> condition, String expression) {
        try {
            ExpressionFactory factory = new ExpressionFactoryImpl();
            SimpleContext context = new SimpleContext();
            if (condition != null) {
                Iterator<Map.Entry<String, Object>> iterator = condition.entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry<String, Object> value = iterator.next();
                    context.setVariable(value.getKey(), factory.createValueExpression(value.getValue(), String.class));
                }
            }
            ValueExpression e = factory.createValueExpression(context, expression, boolean.class);
            return (Boolean) e.getValue(context);
        } catch (Exception e) {
            log.error("operation error");
            throw e;
        }
    }
}
package com.oa.business.flow.utils.camunda;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.*;
import org.camunda.bpm.engine.history.HistoricActivityInstance;
import org.camunda.bpm.engine.history.HistoricTaskInstance;
import org.camunda.bpm.engine.impl.RepositoryServiceImpl;
import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
import org.camunda.bpm.engine.repository.Deployment;
import org.camunda.bpm.engine.runtime.ActivityInstance;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.runtime.ProcessInstanceModificationBuilder;
import org.camunda.bpm.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author HeZeMin
 * @className CamundaServiceUtils
 * @description Camunda服务工具类
 * @date 2022/4/12 11:44
 */
@Slf4j
@Component
public class CamundaServiceUtils {
    @Autowired
    RepositoryService repositoryService;// 部署服务
    @Autowired
    RuntimeService runtimeService;// 运行服务
    @Autowired
    IdentityService identityService;// 用户服务
    @Autowired
    AuthorizationService authorizationService;// 授权服务
    @Autowired
    TaskService taskService;// 任务服务
    @Autowired
    HistoryService historyService;// 历史服务
    @Autowired
    ManagementService managementService;

    // 1、部署流程定义
    public JSONObject deployProcess(JSONObject params) {
        // 获取参数
        String name = params.get("processName", String.class);
        String bpmnXmlStr = params.get("bpmnXmlStr", String.class);
        // 部署流程定义
        Deployment deployment = repositoryService.createDeployment()
                .name(name)
                .addString(name + ".bpmn20.xml", bpmnXmlStr)
                .deploy();
//        managementService.registerProcessApplication(deployment.getId(), Context.getCurrentProcessApplication());
        // 封装返回结果集
        JSONObject res = new JSONObject();
        res.set("deploymentId", deployment.getId());
        res.set("deploymentName", deployment.getName());
        return  res;
    }

    // 2、启动流程实例
    public JSONObject startProcess(Map<String, Object> params) {
        String initiator = (String) params.get("initiator");
        String processDefinitionKey = (String) params.get("processDefinitionKey");
        String businessKey = (String) params.get("businessKey");
        Map<String, Object> variables = (Map<String, Object>) params.get("variables");
        // 设置发起人
        identityService.setAuthenticatedUserId(initiator);
        // 启动流程定义
        ProcessInstance simpleTest = runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, variables);
        if (ObjectUtil.isNull(simpleTest)) {
            return null;
        }
        // 自动跳过发起人节点
//        List<Task> list = taskService.createTaskQuery().taskAssignee(initiator).processInstanceId(simpleTest.getId()).list();
//        if (CollUtil.isNotEmpty(list)) {
//            taskService.complete(list.get(0).getId());
//        }
        // 结果集封装
        JSONObject res = new JSONObject();
        res.set("processInstanceId", simpleTest.getId());
        res.set("initiator", initiator);
        res.set("processInstanceParentId", simpleTest.getProcessInstanceId());
        res.set("processDefinitionId", simpleTest.getProcessDefinitionId());
        return  res;
    }

    // 3、审批同意
    public JSONObject pass(JSONObject params) {
        // 获取变量
        String taskId = params.get("taskId", String.class);
        String userId = params.get("userId", String.class);
        String processInstanceId = params.get("processInstanceId", String.class);
        String comment = params.get("comment", String.class);
        Map<String, Object> variables = params.get("variables", Map.class);
        // 添加审批人
        identityService.setAuthenticatedUserId(userId);
        // 判断是否有审批意见
        if (StrUtil.isNotBlank(comment)) {
            // 提交审批意见
            taskService.createComment(taskId, processInstanceId, comment);
        }
        // 完成当前任务实例
        taskService.complete(taskId, variables);
        // 结果集封装
        JSONObject res = new JSONObject();
        return res;
    }

    // 4、审批拒绝
    public JSONObject reject(JSONObject params) {
        // 获取变量
        String taskId = params.get("taskId", String.class);
        String processInstanceId = params.get("processInstanceId", String.class);
        String userId = params.get("userId", String.class);
        String comment = params.get("comment", String.class);
        // 添加审批人
        identityService.setAuthenticatedUserId(userId);
        // 获取当前任务,未办理任务id
        HistoricTaskInstance currTask = historyService.createHistoricTaskInstanceQuery()
                .taskId(taskId)
                .singleResult();
        if (ObjectUtil.isNull(currTask)) {
            log.error("没有查询到审批任务");
            JSONObject res = new JSONObject();
            res.set("msg", "没有查询到审批任务");
            return res;
        }
        // 驳回审批意见
        taskService.createComment(taskId, currTask.getProcessInstanceId(), comment);
        //获取流程实例
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                .processInstanceId(currTask.getProcessInstanceId())
                .singleResult();
        //获取流程定义
        ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(currTask.getProcessDefinitionId());

        ActivityImpl currentActivity = (processDefinitionEntity).findActivity(currTask.getTaskDefinitionKey());
        // 获取起始活动
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery()
                .activityType("userTask")
                .processInstanceId(processInstanceId)
                .finished()
                .orderByHistoricActivityInstanceEndTime()
                .asc()
                .list();
        if(historicActivityInstances.size() == 0){
            JSONObject res = new JSONObject();
            return res;
        }
        // 起始节点活动
        ActivityImpl lastActivity = processDefinitionEntity.findActivity(historicActivityInstances.get(0).getActivityId());

        // 退回至起点申请人
        runtimeService.createProcessInstanceModification(processInstanceId)
                // 关闭当前活动任务节点
                .cancelAllForActivity(currentActivity.getActivityId())
                .setAnnotation("驳回")
                // 启动申请人节点
                .startBeforeActivity(lastActivity.getActivityId())
                .execute();
        // 结果集封装
        JSONObject res = new JSONObject();
        return res;
    }

    // 5、转交
    public JSONObject transfer(JSONObject params) {
        // 获取变量
        String taskId = params.get("taskId", String.class);
        String userId = params.get("userId", String.class);
        Date transferTime = params.get("transferTime", Date.class);
        // 添加审批人
        identityService.setAuthenticatedUserId(userId);
        // 委托他人
        taskService.delegateTask(taskId, userId);
        JSONObject res = new JSONObject();
        return res;
    }

    // 6、退回
    public JSONObject returnOldTask(JSONObject params) {
        // 获取变量
        String taskId = params.get("taskId", String.class);
        String processInstanceId = params.get("processInstanceId", String.class);
        String targetActivityId = params.get("targetActivityId", String.class);
        String comment = params.get("comment", String.class);

        // 退回意见
        taskService.createComment(taskId, processInstanceId, comment);

        //获取当前环节实例
        ProcessInstanceModificationBuilder processInstanceModificationBuilder = runtimeService.createProcessInstanceModification(processInstanceId);
        Set<String> activityIdSet = new HashSet<>();
        taskService.createTaskQuery().processInstanceId(processInstanceId).active().list().forEach(taskQuery -> {
            String activityId = taskQuery.getTaskDefinitionKey();
            if(activityIdSet.add(activityId)){
                processInstanceModificationBuilder.cancelAllForActivity(activityId);
            }
        });
//        ArrayList<String> userIds = (ArrayList<String>) runtimeService.getVariable(processInstanceId, "assigneeList_" + targetActivityId);
//        log.info(JSONUtil.toJsonStr(userIds));
//        Map<String, Object> vars = new HashMap<String, Object>(1);
//        vars.put("assigneeList_" + targetActivityId, userIds);
        processInstanceModificationBuilder.startBeforeActivity(targetActivityId + "#multiInstanceBody")
//                .setVariable("assigneeList_" + targetActivityId, userIds)
//                .setVariable("assignee", "${assignee}")
//                .setVariablesLocal(map)
                .execute();

        JSONObject res = new JSONObject();
        return res;
    }

    // 7、加签(前后都能加)
    public JSONObject addSignature(JSONObject params) {
        JSONObject res = new JSONObject();
        // 获取变量
        String userId = params.get("userId", String.class);// 当前用户id
        String taskId = params.get("taskId", String.class);// 当前任务id
        String processInstanceId = params.get("processInstanceId", String.class);// 当前流程实例id
        String comment = params.get("comment", String.class);// 加签意见
        Integer type = params.get("type", Integer.class);// 加签类型(1=前置加签,2=后置加签)
        String addUserId = params.get("addUserId", String.class);// 加签用户id
        Integer auditMethod = params.get("auditMethod", Integer.class);// // 审批类型:1=或签,2=会签,3=顺序签
        // 获取当前任务,未办理任务id
        HistoricTaskInstance currTask = historyService.createHistoricTaskInstanceQuery()
                .taskId(taskId).singleResult();
        if (ObjectUtil.isNull(currTask)) {
            log.error("没有查询到审批任务,只有任务所属人才可以加签");
            return null;
        }
        // 加签意见
        taskService.createComment(taskId, currTask.getProcessInstanceId(), comment);
        // 获取当前活动实例
        ActivityInstance activity = runtimeService.getActivityInstance(processInstanceId);
        ActivityInstance[] childActivityInstances = activity.getChildActivityInstances();
        ActivityInstance childActivityInstance = childActivityInstances[0];
        String activityId = childActivityInstance.getActivityId().split("#")[0];

        // 获取到原来的人员变量,进行加签
        List<String> variableList = (List<String>) runtimeService.getVariableLocal(currTask.getProcessInstanceId(), "assigneeList_" + activityId);
//        if (variableList.size() > 1) {
//            System.out.println("该节点审批人数超过一个,无法加签");
//        }
        LinkedList<String> linkedList = variableList.stream().collect(Collectors.toCollection(LinkedList::new));
        // 当前审批人的索引
        int indexOf = linkedList.indexOf(userId);
        if (1 == type) {//前置加签
            if (indexOf == 0) {
                linkedList.addFirst(addUserId);
            } else {
                linkedList.add(indexOf, addUserId);
            }
        } else if (2 == type) {//后置加签
            if (linkedList.size() - 1 == indexOf) {
                linkedList.addLast(addUserId);
            } else {
                linkedList.add(indexOf + 1, addUserId);
            }
        } else {
            if (indexOf == 0) {
                linkedList.addFirst(addUserId);
            } else {
                linkedList.add(indexOf, addUserId);
            }
        }
        // 人员变量
        Map<String, Object> vars = new HashMap<String, Object>(1);
        if (auditMethod == 3) {// 顺序签处理
            int indexOfto = linkedList.indexOf(userId);
            List<String> userIds = new ArrayList<>();
            for (int i = 0; i < linkedList.size(); i++) {
                String id = linkedList.get(i);
                if (1 == type) {// 前置
                    if ((indexOfto - 1) <= i) {
                        userIds.add(id);
                    }
                } else if (2 == type) {// 后置
                    if (indexOfto <= i) {
                        userIds.add(id);
                    }
                } else {
                    userIds.add(id);
                }
            }
            res.set("userIds", userIds);
            vars.put("assigneeList_" + activityId, userIds);
        } else {
            res.set("userIds", linkedList);
            vars.put("assigneeList_" + activityId, linkedList.stream().collect(Collectors.toList()));
        }

        // 获取当前环节实例
        ProcessInstanceModificationBuilder processInstanceModificationBuilder = runtimeService.createProcessInstanceModification(processInstanceId);
        Set<String> activityIdSet = new HashSet<>();
        taskService.createTaskQuery().processInstanceId(processInstanceId).active().list().forEach(taskQuery -> {
            String activityId1 = taskQuery.getTaskDefinitionKey();
            if(activityIdSet.add(activityId1)){
                // 关闭当前多实例活动任务节点
                processInstanceModificationBuilder.cancelAllForActivity(activityId1);
            }
        });
        // 启动当前多实例活动任务节点
        processInstanceModificationBuilder.startBeforeActivity(childActivityInstance.getActivityId())
            // 局部变量
            .setVariablesLocal(vars)
            .execute();
        return res;
    }

    // 8、todo 我的待办-待审核
    public JSONObject pending(JSONObject params) {
        String userId = params.get("userId", String.class);
        Integer pageIndex = params.get("pageIndex", Integer.class);
        Integer pageSize = params.get("pageSize", Integer.class);
        int firstResult = (pageIndex - 1) * pageSize ;
        int maxResults = pageSize;
        //查询待办
        List<Task> list = taskService.createTaskQuery().taskAssignee(userId).listPage(firstResult, maxResults);
        long count = taskService.createTaskQuery().taskAssignee(userId).count();
        // 封装结果集
        JSONObject res = new JSONObject();
        res.set("list", list);
        res.set("pageCount", count);
        return res;
    }

    // 8、todo 我的已办
    public JSONObject done(JSONObject params) {
        String userId = params.get("userId", String.class);
        Integer pageIndex = params.get("pageIndex", Integer.class);
        Integer pageSize = params.get("pageSize", Integer.class);
        int firstResult = (pageIndex - 1) * pageSize ;
        int maxResults = pageSize;

        List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery()
                .taskAssignee(userId)
                .finished()
                .listPage(firstResult, maxResults);
        long count = historyService.createHistoricTaskInstanceQuery()
                .taskAssignee(userId)
                .finished()
                .count();

        JSONObject res = new JSONObject();
        res.set("list", historicTaskInstances);
        res.set("pageCount", count);
        return res;
    }

    // 9、todo 作废
    public JSONObject invalid(JSONObject params) {
        // 流程到了最后一个审批节点可以作废,流程实例和业务数据关系表状态变更,业务数据回滚,
        // 获取变量
        String processInstanceId = params.get("processInstanceId", String.class);
        String userId = params.get("userId", String.class);
        String comment = params.get("comment", String.class);//作废意见


        JSONObject res = new JSONObject();
        return res;
    }

    // 10、todo 转阅
    public JSONObject forward(JSONObject params) {
        JSONObject res = new JSONObject();
        return res;
    }

    // 11、撤回
    public JSONObject withdraw(JSONObject params) {
        // 获取变量
        String taskId = params.get("taskId", String.class);
        String processInstanceId = params.get("processInstanceId", String.class);
        String userId = params.get("userId", String.class);
        // 获取当前任务,未办理任务id
        HistoricTaskInstance currTask = historyService.createHistoricTaskInstanceQuery()
                .taskId(taskId).singleResult();
        if (ObjectUtil.isNull(currTask)) {
            log.error("没有查询到审批任务");
            JSONObject res = new JSONObject();
            res.set("msg", "没有查询到审批任务");
            return res;
        }
        // 撤回审批意见
        taskService.createComment(taskId, processInstanceId, "发起人撤回");

        // 退回至起点申请人
        ProcessInstanceModificationBuilder processInstanceModificationBuilder = runtimeService.createProcessInstanceModification(processInstanceId);
        Set<String> activityIdSet = new HashSet<>();
        taskService.createTaskQuery().processInstanceId(processInstanceId).active().list().forEach(taskQuery -> {
            String activityId = taskQuery.getTaskDefinitionKey();
            if(activityIdSet.add(activityId)){
                processInstanceModificationBuilder.cancelAllForActivity(activityId);
            }
        });
        processInstanceModificationBuilder.setAnnotation("撤回")
            // 启动申请人节点
            .startBeforeActivity(currTask.getTaskDefinitionKey())
            .execute();
        // 结果集封装
        JSONObject res = new JSONObject();
        return res;
    }

    // 12、todo 催办
    public JSONObject urge(JSONObject params) {
        JSONObject res = new JSONObject();
        return res;
    }
    // 13、todo 获取历史节点
    public JSONObject listHistoricalNode(JSONObject params) {
//        // 新建一个有序不重复集合
//        LinkedHashSet linkedHashSet = new LinkedHashSet();
 获取当前的任务节点
//        String activeTask = "Activity_0lj34xv";
//        String backTask = "";
//        historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).orderByHistoricTaskInstanceEndTime().asc().list().stream().forEach(historicTaskInstance -> {
//            linkedHashSet.add(historicTaskInstance.getTaskDefinitionKey());
//        });
//        if(linkedHashSet.size() == 0){
//            return ;
//        }
 遍历到当前的任务节点后,取上一次遍历的值
//        Iterator<String> iterator = linkedHashSet.iterator();
//        while(iterator.hasNext()){
//            String nowTask = iterator.next();
//            if(StrUtil.equals(nowTask,activeTask)){
//                return backTask;
//            }
//            backTask = nowTask;
//        }
//        backTask.toString();
        JSONObject res = new JSONObject();
        return res;
    }

    // 14、重新启动流程实例
    public JSONObject relaunch(Map<String, Object> params) {
        String initiator = (String) params.get("initiator");
        String processDefinitionId = (String) params.get("processDefinitionId");
        String processInstanceId = (String) params.get("processInstanceId");
        String businessKey = (String) params.get("businessKey");
        Map<String, Object> variables = (Map<String, Object>) params.get("variables");

        // 覆盖所有变量
        runtimeService.setVariables(processInstanceId, variables);

        // 跳过发起人节点,进行审批
        List<Task> list = taskService.createTaskQuery().taskAssignee(initiator).taskName("发起人").processInstanceId(processInstanceId).list();
        if (CollUtil.isNotEmpty(list)) {
            taskService.complete(list.get(0).getId());
        }
        // 结果集封装
        JSONObject res = new JSONObject();
        return  res;
    }
}
package com.oa.business.flow.utils.camunda.constant;
/**
 * @author HeZeMin
 * @className CamundaE
 * @description 流程引擎枚举类
 * @date 2022/4/8 18:02
 */
public enum CamundaEnum {
    PROCESS("Process_"),
    EVENT("Event_"),
    ACTIVITY("Activity_"),
    GATEWAY("Gateway_"),
    TASK("Task_");

    private final String name;

    private CamundaEnum(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
}

 Camunda监听器实现

package com.oa.business.flow.utils.camunda.listener;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.oa.dubbo.api.flow.service.act.ActHiProcinstService;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.TaskListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Description:抄送人服务
 * @Author HeZeMin
 * @Date 2022年04月20日 17:24
 */
@Slf4j
@Component("CopyListener")
public class CopyListener implements TaskListener {
    @Autowired
    TaskService taskService;
    @Autowired
    ActHiProcinstService actHiProcinstService;

    /**
     *基本思路 - 监听器实现
     * 可以通过给抄送节点添加监听器,进而在通过自己的业务实现数据库消息表的添加。
     * 拿到当前task的一些信息,查询要抄送的人的信息,然后通过Spring IOC中拿到的service进行相应的业务逻辑添加(消息表新增),然后对该节点进行一个通过。
     */
    @Override
    public void notify(DelegateTask delegateTask) {
        String eventName = delegateTask.getEventName();
        String taskId = delegateTask.getId();
        String processInstanceId = delegateTask.getProcessInstanceId();
        String taskDefinitionKey = delegateTask.getTaskDefinitionKey();
        List<String> userIdList = (List<String>) delegateTask.getVariable("assigneeList_" + taskDefinitionKey);
        if("create".equals(eventName)){
            // 抄送人  业务处理
            log.info("create===========抄送人逻辑开始");

            // 更新流程步骤的审批状态

            if (CollUtil.isNotEmpty(userIdList)) {
                    // 保存待阅
                    // 给抄送人发站内信和提醒
            }
            // 该抄送任务完成
            taskService.complete(delegateTask.getId());
        } else if("assigment".equals(eventName)){
            log.info("assigment===========流程部署");
        } else if("complete".equals(eventName)){
            log.info("complete===========抄送人逻辑完成");
        } else if("delete".equals(eventName)){
            log.info("delete===========流程结束");
        }
        log.info("delegateTask.getAssignee() = " + delegateTask.getAssignee());
        log.info("delegateTask.getId() = " + delegateTask.getId());
        log.info("taskDefinitionKey = " + taskDefinitionKey);
        log.info("variables = " + JSONUtil.toJsonStr(delegateTask.getVariables()));
        log.info("userIdList = " + JSONUtil.toJsonStr(userIdList));
        log.info("=--------------------------------=");
    }

}
package com.oa.business.flow.utils.camunda.listener;

import com.oa.dubbo.api.flow.service.act.ActHiProcinstService;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.ExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Description:流程结束服务
 * @Author HeZeMin
 * @Date 2022年04月20日 17:24
 */
@Slf4j
@Component("EndEventListener")
public class EndEventListener implements ExecutionListener {
    @Autowired
    TaskService taskService;
    @Autowired
    ActHiProcinstService actHiProcinstService;

    /**
     * 基本思路 - 监听器实现
     * 可以通过给结束节点添加监听器,进而在通过自己的业务实现数据库消息表的添加。
     * 拿到流程实例信息,变更业务表状态为已通过,或者同步申请数据到业务表
     */
    @Override
    public void notify(DelegateExecution execution) throws Exception {
        log.info("===========流程结束了==========");
        String eventName = execution.getEventName();
        String businessKey = execution.getProcessBusinessKey();
        String processDefinitionId = execution.getProcessDefinitionId();
        String processInstanceId = execution.getProcessInstanceId();
        String initiator = (String) execution.getVariable("initiator");
        String tableName = "";
        if("start".equals(eventName)){
            log.info("start===========流程启动");
            // 给发起人发消息
        }else if("end".equals(eventName)){
            // 修改流程实例关系状态为 已完成
            log.info("end===========流程结束");
        }
        log.info("delegateTask.getId() = " + execution.getId());
        log.info("tableName = " + tableName);
        log.info("processDefinitionId = " + processDefinitionId);
        log.info("processInstanceId = " + processInstanceId);
        log.info("businessKey = " + businessKey);
        log.info("=--------------------------------=");
    }

}
package com.oa.business.flow.utils.camunda.listener;

import com.oa.dubbo.api.flow.service.act.ActHiProcinstService;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.TaskListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Description:审批和执行人的站内信和提醒 监听器
 * @Author HeZeMin
 * @Date 2022年06月17日 9:39
 */
@Slf4j
@Component("TaskMessageListener")
public class TaskMessageListener implements TaskListener {
    @Autowired
    TaskService taskService;
    @Autowired
    ActHiProcinstService actHiProcinstService;

    /**
     *基本思路 - 监听器实现
     * 可以通过给抄送节点添加监听器,进而在通过自己的业务实现数据库消息表的添加。
     * 拿到当前task的一些信息,查询要抄送的人的信息,然后通过Spring IOC中拿到的service进行相应的业务逻辑添加(消息表新增),然后对该节点进行一个通过。
     */
    @Override
    public void notify(DelegateTask delegateTask) {
        String eventName = delegateTask.getEventName();
        String taskId = delegateTask.getId();
        String taskDefinitionKey = delegateTask.getTaskDefinitionKey();
        String processInstanceId = delegateTask.getProcessInstanceId();


        if(TaskListener.EVENTNAME_CREATE.equals(eventName)){
            log.info("create===========审批节点开始");
            // 更新流程步骤的审批状态

            // 给待审核人发提醒

        }else if("assigment".equals(eventName)){
            log.info("assigment===========流程部署");
        }else if("complete".equals(eventName)){
            log.info("complete===========流程完成");
            // 更新流程步骤的审批状态
        }else if("delete".equals(eventName)){
            log.info("delete===========流程结束");
        }
        log.info("delegateTask.getAssignee() = " + delegateTask.getAssignee());
        log.info("taskId = " + taskId);
        log.info("taskDefinitionKey = " + taskDefinitionKey);
        log.info("eventName = " + eventName);
        log.info("processInstanceId = " + processInstanceId);
        log.info("=--------------------------------=");
    }

}

Camunda框架的49张表结构

/*
 Navicat Premium Data Transfer

 Source Server         : 222.175.63.26-oa-prod
 Source Server Type    : MySQL
 Source Server Version : 80024
 Source Host           : 222.175.63.26:13307
 Source Schema         : oa_cloud_master

 Target Server Type    : MySQL
 Target Server Version : 80024
 File Encoding         : 65001

 Date: 21/10/2022 10:17:48
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for act_ge_bytearray
-- ----------------------------
DROP TABLE IF EXISTS `act_ge_bytearray`;
CREATE TABLE `act_ge_bytearray`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部署ID',
  `BYTES_` longblob NULL COMMENT '字节内容',
  `GENERATED_` tinyint NULL DEFAULT NULL COMMENT '是否系统生成(0用户创建,null系统生成)',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `TYPE_` int NULL DEFAULT NULL COMMENT '类型',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例根ID',
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `DEPLOYMENT_ID_`(`DEPLOYMENT_ID_`) USING BTREE,
  INDEX `ROOT_PROC_INST_ID_`(`ROOT_PROC_INST_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程通用数据/流程引擎二进制数据表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ge_property
-- ----------------------------
DROP TABLE IF EXISTS `act_ge_property`;
CREATE TABLE `act_ge_property`  (
  `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `VALUE_` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '值',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  PRIMARY KEY (`NAME_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程通用数据/流程引擎属性配置表【初始化】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ge_schema_log
-- ----------------------------
DROP TABLE IF EXISTS `act_ge_schema_log`;
CREATE TABLE `act_ge_schema_log`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `TIMESTAMP_` datetime(0) NULL DEFAULT NULL COMMENT '时间戳',
  `VERSION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程通用数据/数据库脚本执行日志表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_actinst
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_actinst`;
CREATE TABLE `act_hi_actinst`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `PARENT_ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父节点实例ID',
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义KEY',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '流程定义ID',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例根ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '流程实例ID',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '执行实例ID',
  `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '节点ID',
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务ID',
  `CALL_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '调用外部的流程实例ID',
  `CALL_CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '调用外部的案例实例ID',
  `ACT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点名称',
  `ACT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '节点类型',
  `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '办理人',
  `START_TIME_` datetime(0) NOT NULL COMMENT '开始时间',
  `END_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
  `DURATION_` bigint NULL DEFAULT NULL COMMENT '耗时',
  `ACT_INST_STATE_` int NULL DEFAULT NULL COMMENT '活动实例状态',
  `SEQUENCE_COUNTER_` bigint NULL DEFAULT NULL COMMENT '序列计数器',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `ACT_ID_`(`ACT_ID_`) USING BTREE,
  INDEX `TASK_ID_`(`TASK_ID_`) USING BTREE,
  INDEX `EXECUTION_ID_`(`EXECUTION_ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `ROOT_PROC_INST_ID_`(`ROOT_PROC_INST_ID_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE,
  INDEX `PROC_DEF_KEY_`(`PROC_DEF_KEY_`) USING BTREE,
  INDEX `PARENT_ACT_INST_ID_`(`PARENT_ACT_INST_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的活动实例表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_attachment
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_attachment`;
CREATE TABLE `act_hi_attachment`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `URL_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CONTENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程附件表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_batch
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_batch`;
CREATE TABLE `act_hi_batch`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TOTAL_JOBS_` int NULL DEFAULT NULL,
  `JOBS_PER_SEED_` int NULL DEFAULT NULL,
  `INVOCATIONS_PER_JOB_` int NULL DEFAULT NULL,
  `SEED_JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `MONITOR_JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `BATCH_JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CREATE_USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `START_TIME_` datetime(0) NOT NULL,
  `END_TIME_` datetime(0) NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的批处理记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_caseactinst
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_caseactinst`;
CREATE TABLE `act_hi_caseactinst`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `PARENT_ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `CASE_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CALL_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CALL_CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_ACT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_ACT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CREATE_TIME_` datetime(0) NOT NULL,
  `END_TIME_` datetime(0) NULL DEFAULT NULL,
  `DURATION_` bigint NULL DEFAULT NULL,
  `STATE_` int NULL DEFAULT NULL,
  `REQUIRED_` bit(1) NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的CMMN活动实例表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_caseinst
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_caseinst`;
CREATE TABLE `act_hi_caseinst`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `BUSINESS_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `CREATE_TIME_` datetime(0) NOT NULL,
  `CLOSE_TIME_` datetime(0) NULL DEFAULT NULL,
  `DURATION_` bigint NULL DEFAULT NULL,
  `STATE_` int NULL DEFAULT NULL,
  `CREATE_USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SUPER_CASE_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SUPER_PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的CMMN实例表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_comment
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_comment`;
CREATE TABLE `act_hi_comment`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型(event事件、comment意见)',
  `TIME_` datetime(0) NOT NULL COMMENT '时间',
  `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '处理人',
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务ID',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例跟ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `ACTION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '行为类型',
  `MESSAGE_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '基本内容',
  `FULL_MSG_` longblob NULL COMMENT '全部内容',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '移除时间',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `TASK_ID_`(`TASK_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程审批意见表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_dec_in
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_dec_in`;
CREATE TABLE `act_hi_dec_in`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `DEC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `CLAUSE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CLAUSE_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `VAR_TYPE_` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DOUBLE_` double NULL DEFAULT NULL,
  `LONG_` bigint NULL DEFAULT NULL,
  `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的DMN变量输入表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_dec_out
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_dec_out`;
CREATE TABLE `act_hi_dec_out`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `DEC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `CLAUSE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CLAUSE_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RULE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RULE_ORDER_` int NULL DEFAULT NULL,
  `VAR_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `VAR_TYPE_` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DOUBLE_` double NULL DEFAULT NULL,
  `LONG_` bigint NULL DEFAULT NULL,
  `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的DMN变量输出表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_decinst
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_decinst`;
CREATE TABLE `act_hi_decinst`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `DEC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `DEC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `DEC_DEF_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `EVAL_TIME_` datetime(0) NOT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  `COLLECT_VALUE_` double NULL DEFAULT NULL,
  `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ROOT_DEC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DEC_REQ_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DEC_REQ_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的DMN实例表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_detail
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_detail`;
CREATE TABLE `act_hi_detail`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类型',
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义KEY',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例根ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程执行ID',
  `CASE_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例定义KEY',
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例定义ID',
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例实例ID',
  `CASE_EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例执行ID',
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务ID',
  `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点实例ID',
  `VAR_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程变量记录ID',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `VAR_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '变量类型',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `TIME_` datetime(0) NOT NULL COMMENT '时间戳',
  `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '二进制数据对应ID',
  `DOUBLE_` double NULL DEFAULT NULL COMMENT 'double类型值',
  `LONG_` bigint NULL DEFAULT NULL COMMENT 'long类型值',
  `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文本类型值',
  `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文本类型值2',
  `SEQUENCE_COUNTER_` bigint NULL DEFAULT NULL COMMENT '序列计数器',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `OPERATION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '移除时间',
  `INITIAL_` bit(1) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `PROC_DEF_KEY_`(`PROC_DEF_KEY_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE,
  INDEX `ROOT_PROC_INST_ID_`(`ROOT_PROC_INST_ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `EXECUTION_ID_`(`EXECUTION_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程运行时变量详情记录表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_ext_task_log
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_ext_task_log`;
CREATE TABLE `act_hi_ext_task_log`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `TIMESTAMP_` timestamp(0) NOT NULL,
  `EXT_TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `RETRIES_` int NULL DEFAULT NULL,
  `TOPIC_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `WORKER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PRIORITY_` bigint NOT NULL DEFAULT 0,
  `ERROR_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ERROR_DETAILS_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `STATE_` int NULL DEFAULT NULL,
  `REV_` int NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程任务消息执行表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_identitylink
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_identitylink`;
CREATE TABLE `act_hi_identitylink`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `TIMESTAMP_` timestamp(0) NOT NULL COMMENT '时间戳',
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型',
  `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户ID',
  `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户组ID',
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务ID',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例根ID',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `OPERATION_TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作类型',
  `ASSIGNER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分配者ID',
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义KEY',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '移除时间',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `TASK_ID_`(`TASK_ID_`) USING BTREE,
  INDEX `ROOT_PROC_INST_ID_`(`ROOT_PROC_INST_ID_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE,
  INDEX `PROC_DEF_KEY_`(`PROC_DEF_KEY_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程运行过程中用户关系【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_incident
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_incident`;
CREATE TABLE `act_hi_incident`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CREATE_TIME_` timestamp(0) NOT NULL,
  `END_TIME_` timestamp(0) NULL DEFAULT NULL,
  `INCIDENT_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `INCIDENT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ACTIVITY_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `FAILED_ACTIVITY_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CAUSE_INCIDENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ROOT_CAUSE_INCIDENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `HISTORY_CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `INCIDENT_STATE_` int NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ANNOTATION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程异常事件记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_job_log
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_job_log`;
CREATE TABLE `act_hi_job_log`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `TIMESTAMP_` datetime(0) NOT NULL,
  `JOB_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `JOB_DUEDATE_` datetime(0) NULL DEFAULT NULL,
  `JOB_RETRIES_` int NULL DEFAULT NULL,
  `JOB_PRIORITY_` bigint NOT NULL DEFAULT 0,
  `JOB_EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `JOB_EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `JOB_STATE_` int NULL DEFAULT NULL,
  `JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `JOB_DEF_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `JOB_DEF_CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `FAILED_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROCESS_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROCESS_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SEQUENCE_COUNTER_` bigint NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `HOSTNAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程作业记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_op_log
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_op_log`;
CREATE TABLE `act_hi_op_log`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `JOB_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `BATCH_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TIMESTAMP_` timestamp(0) NOT NULL,
  `OPERATION_TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `OPERATION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ENTITY_TYPE_` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROPERTY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ORG_VALUE_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `NEW_VALUE_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  `CATEGORY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `EXTERNAL_TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ANNOTATION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `DEPLOYMENT_ID_`(`DEPLOYMENT_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/操作历史日志【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_procinst
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_procinst`;
CREATE TABLE `act_hi_procinst`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '流程实例ID',
  `BUSINESS_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务KEY',
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义KEY',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '流程定义ID',
  `START_TIME_` datetime(0) NOT NULL COMMENT '开始时间',
  `END_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '移除时间',
  `DURATION_` bigint NULL DEFAULT NULL COMMENT '耗时',
  `START_USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '启动人ID',
  `START_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '启动节点ID',
  `END_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '结束节点ID',
  `SUPER_PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父流程实例ID',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例根ID',
  `SUPER_CASE_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父案例实例ID',
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例实例ID',
  `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '删除原因',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `STATE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `BUSINESS_KEY_`(`BUSINESS_KEY_`) USING BTREE,
  INDEX `PROC_DEF_KEY_`(`PROC_DEF_KEY_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程实例【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_taskinst
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_taskinst`;
CREATE TABLE `act_hi_taskinst`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `TASK_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务定义KEY',
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义KEY',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例根ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程执行ID',
  `CASE_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例定义KEY',
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例定义ID',
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例实例ID',
  `CASE_EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例执行ID',
  `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点实例ID',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `PARENT_TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父任务ID',
  `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
  `OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '委托人ID',
  `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '办理人ID',
  `START_TIME_` datetime(0) NOT NULL COMMENT '开始时间',
  `END_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
  `DURATION_` bigint NULL DEFAULT NULL COMMENT '耗时',
  `DELETE_REASON_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '删除原因',
  `PRIORITY_` int NULL DEFAULT NULL COMMENT '优先级',
  `DUE_DATE_` datetime(0) NULL DEFAULT NULL COMMENT '超时时间',
  `FOLLOW_UP_DATE_` datetime(0) NULL DEFAULT NULL COMMENT '跟踪时间',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '移除时间',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `TASK_DEF_KEY_`(`TASK_DEF_KEY_`) USING BTREE,
  INDEX `PROC_DEF_KEY_`(`PROC_DEF_KEY_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE,
  INDEX `ROOT_PROC_INST_ID_`(`ROOT_PROC_INST_ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `EXECUTION_ID_`(`EXECUTION_ID_`) USING BTREE,
  INDEX `ACT_INST_ID_`(`ACT_INST_ID_`) USING BTREE,
  INDEX `ASSIGNEE_`(`ASSIGNEE_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的任务实例【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_hi_varinst
-- ----------------------------
DROP TABLE IF EXISTS `act_hi_varinst`;
CREATE TABLE `act_hi_varinst`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义KEY',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例根ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程执行ID',
  `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点实例ID',
  `CASE_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例定义KEY',
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例定义ID',
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例实例ID',
  `CASE_EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例执行ID',
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务ID',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `VAR_TYPE_` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '变量类型',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '二进制数据ID',
  `DOUBLE_` double NULL DEFAULT NULL COMMENT 'double类型值',
  `LONG_` bigint NULL DEFAULT NULL COMMENT 'long类型值',
  `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文本类型值',
  `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文本类型值2',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `STATE_` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态',
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '移除时间',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `PROC_DEF_KEY_`(`PROC_DEF_KEY_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE,
  INDEX `ROOT_PROC_INST_ID_`(`ROOT_PROC_INST_ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `EXECUTION_ID_`(`EXECUTION_ID_`) USING BTREE,
  INDEX `TASK_ID_`(`TASK_ID_`) USING BTREE,
  INDEX `ACT_INST_ID_`(`ACT_INST_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程历史记录/历史的流程变量记录表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_id_group
-- ----------------------------
DROP TABLE IF EXISTS `act_id_group`;
CREATE TABLE `act_id_group`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '组名称',
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '组类型(SYSTEM系统、WORKFLOW业务)',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '组织用户信息/群组信息表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_id_info
-- ----------------------------
DROP TABLE IF EXISTS `act_id_info`;
CREATE TABLE `act_id_info`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `USER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `VALUE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PASSWORD_` longblob NULL,
  `PARENT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '组织用户信息/用户扩展信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_id_membership
-- ----------------------------
DROP TABLE IF EXISTS `act_id_membership`;
CREATE TABLE `act_id_membership`  (
  `USER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户ID',
  `GROUP_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '组ID',
  PRIMARY KEY (`USER_ID_`, `GROUP_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '组织用户信息/用户群组关系表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_id_tenant
-- ----------------------------
DROP TABLE IF EXISTS `act_id_tenant`;
CREATE TABLE `act_id_tenant`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '组织用户信息/租户信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_id_tenant_member
-- ----------------------------
DROP TABLE IF EXISTS `act_id_tenant_member`;
CREATE TABLE `act_id_tenant_member`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `USER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `GROUP_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '组织用户信息/用户租户关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_id_user
-- ----------------------------
DROP TABLE IF EXISTS `act_id_user`;
CREATE TABLE `act_id_user`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `FIRST_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '姓',
  `LAST_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名',
  `EMAIL_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮件',
  `PWD_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
  `SALT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '盐值',
  `LOCK_EXP_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '锁定过期时间',
  `ATTEMPTS_` int NULL DEFAULT NULL COMMENT '尝试次数',
  `PICTURE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片ID',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '组织用户信息/用户信息表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_re_camformdef
-- ----------------------------
DROP TABLE IF EXISTS `act_re_camformdef`;
CREATE TABLE `act_re_camformdef`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `VERSION_` int NOT NULL,
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程资源存储/' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_re_case_def
-- ----------------------------
DROP TABLE IF EXISTS `act_re_case_def`;
CREATE TABLE `act_re_case_def`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `VERSION_` int NOT NULL,
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DGRM_RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `HISTORY_TTL_` int NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程资源存储/CMMN案例管理模型定义表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_re_decision_def
-- ----------------------------
DROP TABLE IF EXISTS `act_re_decision_def`;
CREATE TABLE `act_re_decision_def`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `VERSION_` int NOT NULL,
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DGRM_RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DEC_REQ_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DEC_REQ_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `HISTORY_TTL_` int NULL DEFAULT NULL,
  `VERSION_TAG_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程资源存储/DMN决策模型定义表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_re_decision_req_def
-- ----------------------------
DROP TABLE IF EXISTS `act_re_decision_req_def`;
CREATE TABLE `act_re_decision_req_def`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `VERSION_` int NOT NULL,
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DGRM_RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程资源存储/决策需求定义表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_re_deployment
-- ----------------------------
DROP TABLE IF EXISTS `act_re_deployment`;
CREATE TABLE `act_re_deployment`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程名称',
  `DEPLOY_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '部署时间',
  `SOURCE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '来源',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程资源存储/流程部署表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_re_procdef
-- ----------------------------
DROP TABLE IF EXISTS `act_re_procdef`;
CREATE TABLE `act_re_procdef`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `CATEGORY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义的Namespace分类',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义名称',
  `KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '流程定义KEY',
  `VERSION_` int NOT NULL COMMENT '流程定义版本号',
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部署ID',
  `RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源名称',
  `DGRM_RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'DGRM资源名称',
  `HAS_START_FORM_KEY_` tinyint NULL DEFAULT NULL COMMENT '是否有启动表单',
  `SUSPENSION_STATE_` int NULL DEFAULT NULL COMMENT '流程挂起',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `VERSION_TAG_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本标签',
  `HISTORY_TTL_` int NULL DEFAULT NULL,
  `STARTABLE_` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否是可启动流程',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `KEY_`(`KEY_`) USING BTREE,
  INDEX `DEPLOYMENT_ID_`(`DEPLOYMENT_ID_`) USING BTREE,
  INDEX `VERSION_`(`VERSION_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程资源存储/BPMN流程模型定义表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_authorization
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_authorization`;
CREATE TABLE `act_ru_authorization`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NOT NULL,
  `TYPE_` int NOT NULL,
  `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RESOURCE_TYPE_` int NOT NULL,
  `RESOURCE_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PERMS_` int NULL DEFAULT NULL,
  `REMOVAL_TIME_` datetime(0) NULL DEFAULT NULL,
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程运行时收取表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_batch
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_batch`;
CREATE TABLE `act_ru_batch`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NOT NULL,
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TOTAL_JOBS_` int NULL DEFAULT NULL,
  `JOBS_CREATED_` int NULL DEFAULT NULL,
  `JOBS_PER_SEED_` int NULL DEFAULT NULL,
  `INVOCATIONS_PER_JOB_` int NULL DEFAULT NULL,
  `SEED_JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `BATCH_JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `MONITOR_JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SUSPENSION_STATE_` int NULL DEFAULT NULL,
  `CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CREATE_USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程执行批处理表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_case_execution
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_case_execution`;
CREATE TABLE `act_ru_case_execution`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SUPER_CASE_EXEC_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SUPER_EXEC_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `BUSINESS_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PARENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PREV_STATE_` int NULL DEFAULT NULL,
  `CURRENT_STATE_` int NULL DEFAULT NULL,
  `REQUIRED_` bit(1) NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/CMMN案例运行执行表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_case_sentry_part
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_case_sentry_part`;
CREATE TABLE `act_ru_case_sentry_part`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NULL DEFAULT NULL,
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_EXEC_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SENTRY_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SOURCE_CASE_EXEC_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `STANDARD_EVENT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SOURCE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `VARIABLE_EVENT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `VARIABLE_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `SATISFIED_` bit(1) NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/CMMN案例运行时哨兵部分表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_event_subscr
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_event_subscr`;
CREATE TABLE `act_ru_event_subscr`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `EVENT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '事件类型',
  `EVENT_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事件名称',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '执行ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `ACTIVITY_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点ID',
  `CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '配置',
  `CREATED_` datetime(0) NOT NULL COMMENT '创建时间',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程事件订阅表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_execution
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_execution`;
CREATE TABLE `act_ru_execution`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例根ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `BUSINESS_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务KEY',
  `PARENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程父实例ID',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `SUPER_EXEC_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父流程实例对应的执行',
  `SUPER_CASE_EXEC_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父案例实例对应的执行',
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例实例ID',
  `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点ID',
  `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点实例ID',
  `IS_ACTIVE_` tinyint NULL DEFAULT NULL COMMENT '是否激活',
  `IS_CONCURRENT_` tinyint NULL DEFAULT NULL COMMENT '是否并行',
  `IS_SCOPE_` tinyint NULL DEFAULT NULL COMMENT '是否多实例范围',
  `IS_EVENT_SCOPE_` tinyint NULL DEFAULT NULL COMMENT '是否事件多实例范围',
  `SUSPENSION_STATE_` int NULL DEFAULT NULL COMMENT '挂起状态',
  `CACHED_ENT_STATE_` int NULL DEFAULT NULL COMMENT '缓存状态',
  `SEQUENCE_COUNTER_` bigint NULL DEFAULT NULL COMMENT '序列计数器',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `BUSINESS_KEY_`(`BUSINESS_KEY_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE,
  INDEX `ACT_INST_ID_`(`ACT_INST_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/BPMN流程运行时记录表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_ext_task
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_ext_task`;
CREATE TABLE `act_ru_ext_task`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NOT NULL,
  `WORKER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TOPIC_NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `RETRIES_` int NULL DEFAULT NULL,
  `ERROR_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ERROR_DETAILS_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `LOCK_EXP_TIME_` datetime(0) NULL DEFAULT NULL,
  `SUSPENSION_STATE_` int NULL DEFAULT NULL,
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `ACT_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PRIORITY_` bigint NOT NULL DEFAULT 0,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程任务消息执行表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_filter
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_filter`;
CREATE TABLE `act_ru_filter`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REV_` int NOT NULL,
  `RESOURCE_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `QUERY_` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `PROPERTIES_` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程定义查询配置表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_identitylink
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_identitylink`;
CREATE TABLE `act_ru_identitylink`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `GROUP_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户组ID',
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型',
  `USER_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户ID',
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务ID',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/运行时流程人员表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_incident
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_incident`;
CREATE TABLE `act_ru_incident`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NOT NULL COMMENT '版本',
  `INCIDENT_TIMESTAMP_` datetime(0) NOT NULL COMMENT '事件时间戳',
  `INCIDENT_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事件信息',
  `INCIDENT_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '事件类型',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程执行ID',
  `ACTIVITY_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点ID',
  `FAILED_ACTIVITY_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `CAUSE_INCIDENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事件原因ID',
  `ROOT_CAUSE_INCIDENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事件原因根ID',
  `CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事件配置',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'JOB定义ID',
  `ANNOTATION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/运行时异常事件表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_job
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_job`;
CREATE TABLE `act_ru_job`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类型',
  `LOCK_EXP_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '锁定过期时间',
  `LOCK_OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '锁定用户',
  `EXCLUSIVE_` bit(1) NULL DEFAULT NULL COMMENT '独占标识',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '执行ID',
  `PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `PROCESS_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `PROCESS_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义KEY',
  `RETRIES_` int NULL DEFAULT NULL COMMENT '重试次数',
  `EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '异常堆栈ID',
  `EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '异常信息',
  `FAILED_ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `DUEDATE_` datetime(0) NULL DEFAULT NULL COMMENT '截止时间',
  `REPEAT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '重复',
  `REPEAT_OFFSET_` bigint NULL DEFAULT 0,
  `HANDLER_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '处理类型',
  `HANDLER_CFG_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '处理配置',
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部署ID',
  `SUSPENSION_STATE_` int NOT NULL DEFAULT 1 COMMENT '挂起状态',
  `JOB_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '作业定义ID',
  `PRIORITY_` bigint NOT NULL DEFAULT 0 COMMENT '作业优先级',
  `SEQUENCE_COUNTER_` bigint NULL DEFAULT NULL COMMENT '序列计数器',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程运行时作业表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_jobdef
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_jobdef`;
CREATE TABLE `act_ru_jobdef`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `PROC_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义KEY',
  `ACT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点ID',
  `JOB_TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'JOB类型',
  `JOB_CONFIGURATION_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'JOB配置',
  `SUSPENSION_STATE_` int NULL DEFAULT NULL COMMENT '挂起状态',
  `JOB_PRIORITY_` bigint NULL DEFAULT NULL COMMENT '优先级',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程作业定义表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_meter_log
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_meter_log`;
CREATE TABLE `act_ru_meter_log`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `REPORTER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `VALUE_` bigint NULL DEFAULT NULL,
  `TIMESTAMP_` datetime(0) NULL DEFAULT NULL,
  `MILLISECONDS_` bigint NULL DEFAULT 0,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程运行时度量日志表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_task
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_task`;
CREATE TABLE `act_ru_task`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程执行ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程定义ID',
  `CASE_EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例执行ID',
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例实例ID',
  `CASE_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例定义ID',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `PARENT_TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父任务ID',
  `DESCRIPTION_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
  `TASK_DEF_KEY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务定义KEY',
  `OWNER_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '委托人',
  `ASSIGNEE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '办理人',
  `DELEGATION_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '委托状态',
  `PRIORITY_` int NULL DEFAULT NULL COMMENT '优先级',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `DUE_DATE_` datetime(0) NULL DEFAULT NULL COMMENT '截止时间',
  `FOLLOW_UP_DATE_` datetime(0) NULL DEFAULT NULL COMMENT '跟踪时间',
  `SUSPENSION_STATE_` int NULL DEFAULT NULL COMMENT '挂起状态',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `EXECUTION_ID_`(`EXECUTION_ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE,
  INDEX `PARENT_TASK_ID_`(`PARENT_TASK_ID_`) USING BTREE,
  INDEX `ASSIGNEE_`(`ASSIGNEE_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程运行时任务表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_task_meter_log
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_task_meter_log`;
CREATE TABLE `act_ru_task_meter_log`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ASSIGNEE_HASH_` bigint NULL DEFAULT NULL,
  `TIMESTAMP_` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/运行时task度量日志表【常用】' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for act_ru_variable
-- ----------------------------
DROP TABLE IF EXISTS `act_ru_variable`;
CREATE TABLE `act_ru_variable`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `REV_` int NULL DEFAULT NULL COMMENT '版本',
  `TYPE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '变量类型',
  `NAME_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '变量名称',
  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程执行ID',
  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `PROC_DEF_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CASE_EXECUTION_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例执行ID',
  `CASE_INST_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '案例实例ID',
  `TASK_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务ID',
  `BATCH_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '二进制内容ID',
  `DOUBLE_` double NULL DEFAULT NULL COMMENT 'DOUBLE类型值',
  `LONG_` bigint NULL DEFAULT NULL COMMENT 'LONG类型值',
  `TEXT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文本值',
  `TEXT2_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文本值2',
  `VAR_SCOPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '变量范围',
  `SEQUENCE_COUNTER_` bigint NULL DEFAULT NULL COMMENT '序列计数器',
  `IS_CONCURRENT_LOCAL_` tinyint NULL DEFAULT NULL COMMENT '是否并发',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `PROC_DEF_ID_`(`PROC_DEF_ID_`) USING BTREE,
  INDEX `PROC_INST_ID_`(`PROC_INST_ID_`) USING BTREE,
  INDEX `EXECUTION_ID_`(`EXECUTION_ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程运行时/流程运行时变量表【常用】' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

 

标签:ci,SET,DEFAULT,utf8,OA,引擎,Camunda,NULL,ID
From: https://www.cnblogs.com/hezemin/p/16830826.html

相关文章