eclipse和maven创建简单的activiti项目(三)

在eclipse和maven创建简单的activiti项目(二):https://blog.csdn.net/weixin_41604362/article/details/81565767中,已经创建了请假的流程图

1、pom.xml配置文件:

 <properties>
        <activiti-version>5.18.0</activiti-version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-engine</artifactId>
            <version>${activiti-version}</version>
        </dependency>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-spring</artifactId>
            <version>${activiti-version}</version>
        </dependency>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-bpmn-converter</artifactId>
            <version>${activiti-version}</version>
        </dependency>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-bpmn-model</artifactId>
            <version>${activiti-version}</version>
        </dependency>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-bpmn-layout</artifactId>
            <version>${activiti-version}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.3</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.168</version>
        </dependency>
        <!-- Mysql数据库加入链接jar -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.4.RELEASE</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.4.RELEASE</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.2.4.RELEASE</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.2.4.RELEASE</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.2.4.RELEASE</version>
            <type>jar</type>
        </dependency>

        <!-- mybatis需要的jar包 -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.2.8</version>
        </dependency>
        <!-- log4j需要的jar包 -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <!-- jstl标签库需要的jar包 -->
        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl-api</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.6</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <version>1.7.6</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <inherited>true</inherited>
                <configuration>
                    <classpathContainers>
                        <classpathContainer>org.eclipse.jdt.USER_LIBRARY/Activiti Designer
                            Extensions</classpathContainer>
                    </classpathContainers>
                </configuration>
            </plugin>
        </plugins>
    </build>

2、在默认配置文件activiti.cfg.xml中,配置自动生成23张表

<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
         <property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/exercise"></property>
        <property name="jdbcUsername" value="root"></property>
        <property name="jdbcPassword" value="123456"></property>
        <property name="databaseSchemaUpdate" value="true"/>
    </bean>
     <!-- 配置一个流程引擎工厂bean,用于创建流程引擎对象 -->
    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration"></property>
    </bean>

3、单元测试:

/**
 * activiti 使用默认配置文件,自动生成23张表
 * 
 * @author Administrator
 *
 */
public class DemoTest {
    @Test
    public void test() {
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    }
}

4、数据库中表:

5、activiti提供的23张表解析:

     1)ACT_RE_*:’RE’表示repository。这个前缀的表包含了流程定义和流程静态资源 (图片,规则等等)。

     2)ACT_RU_*:’RU’表示runtime。这些是运行时的表,包含流程实例,任务,变量,异步任务等运行中的数据。Activiti只在流程实例执行过程中保存这些数据, 在流程结束时就会删除这些记录。这样运行时表可以一直很小且速度很快。

     3)ACT_ID_*:’ID’表示identity。这些表包含身份信息,比如用户,组等等。

     4)ACT_HI_*:’HI’表示history。这些表包含历史数据,比如历史流程实例,变量,任务等等。

     5)ACT_GE_*:通用数据,用于不同场景下。

资源库流程规则表

  1. act_re_deployment:部署信息表
  2. act_re_model:流程设计模型部署表
  3. act_re_procdef:流程定义数据表

运行时数据库表

  1. act_ru_execution:运行时流程执行实例表
  2. act_ru_identitylink:运行时流程人员表,主要存储任务节点与参与者的相关信息
  3. act_ru_task:运行时任务节点表
  4. act_ru_variable:运行时流程变量数据表

历史数据库表

  1. act_hi_actinst:历史节点表
  2. act_hi_attachment:历史附件表
  3. act_hi_comment:历史意见表
  4. act_hi_identitylink:历史流程人员表
  5. act_hi_detail :历史详情表,提供历史变量的查询
  6. act_hi_procinst:历史流程实例表
  7. act_hi_taskinst:历史任务实例表
  8. act_hi_varinst:历史变量表

组织机构表

  1. act_id_group :用户组信息表
  2. act_id_info:用户扩展信息表
  3. act_id_membership:用户与用户组对应信息表
  4. act_id_user:用户信息表

这四张表很常见,基本的组织机构管理,关于用户认证方面建议还是自己开发一套,组件自带的功能太简单,使用中有很多需求难以满足。

通用数据表

  1. act_ge_bytearray:二进制数据表
  2. act_ge_property:属性数据表存储整个流程引擎级别的数据,初始化表结构时会默认插入三条记录

ProcessEngine:只要是跟工作流相关的任何操作都要使用到流程引擎对象,它是框架的核心组件

6、部署流程定义:将请假流程规则应用到数据库中

      用到的数据库表:部署表(act_re_deployment)、流程定义表(act_re_procdef)和二进制表(act_ge_bytearray)

只要部署一次,部署表(act_re_deployment)中记录就会多一条记录

7、查询流程定义

8、启动流程实例:流程定义的一次具体执行过程。

   流程定义和流程实例是一对多的关系。
   启动流程实例操作的数据表有流程实例表(act_ru_execution)、任务表(act_ru_task)

流程实例表(act_ru_execution)中插入一条记录

 

ACT_ID_字段的值意味着流程向下进行到哪个节点了,上面表中ACT_ID_字段的值是usertask1,表示流程推进到【班主任】节点

任务表(act_ru_task)同时也插入一条记录

说明张三有一个任务要处理

9、查询任务:任务表(act_ru_task)

查询出有任务后,就要办理任务,让流程进行下去

10、办理任务:任务表(act_ru_task)、流程实例表(act_ru_execution)

办理完后,流程进行到usertask2,

 

usertask2再把任务执行完后,任务就算完成了。任务表(act_ru_task)、流程实例表(act_ru_execution)里面的内容将清空

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值