activiti工作流已办和待办查询sql

  最近项目中遇到一个问题,需要activiti的工作流表和业务表关联分页查询,然而我对于工作流的查询并不太熟悉,所以学习并总结如下。

  想看看activiti到底怎么查询的待认领和待办、已办的查询sql,最简单的方法时,看下工作流框架后台打印的sql,默认是不打印的,需要改下日志框架的配置,logback添加如下配置就可以了:

    <!-- 工作流 sql日志打印 -->
    <logger name="org.activiti.engine.impl.persistence.entity" level="DEBUG" />

添加后,观察后台打印的日志就可以发现

查询待认领和待办的sql(其中gly为当前登录用户):

SELECT *
  FROM (SELECT A.*, ROWNUM RNUM
          FROM (SELECT DISTINCT RES.*
                  FROM ACT_RU_TASK RES
                  LEFT JOIN ACT_RU_IDENTITYLINK I ON I.TASK_ID_ = RES.ID_
                 WHERE RES.SUSPENSION_STATE_ = 1
                   AND (RES.ASSIGNEE_ = 'gly' OR
                       (RES.ASSIGNEE_ IS NULL AND
                       (I.USER_ID_ = 'gly' OR
                       I.GROUP_ID_ IN
                       (SELECT G.GROUP_ID_
                             FROM ACT_ID_MEMBERSHIP G
                            WHERE G.USER_ID_ = 'gly'))))
                 ORDER BY RES.CREATE_TIME_ DESC) A
         WHERE ROWNUM < 16)
 WHERE RNUM >= 1

已办的sql如下:

SELECT *
  FROM (SELECT A.*, ROWNUM RNUM
          FROM (SELECT DISTINCT RES.*
                  FROM ACT_HI_TASKINST RES
                 WHERE RES.ASSIGNEE_ = ?
                   AND RES.END_TIME_ IS NOT NULL
                 ORDER BY RES.END_TIME_ DESC) A
         WHERE ROWNUM < ?)
 WHERE RNUM >= ?

 

posted on 2017-09-20 15:28  锟斤拷锟斤拷  阅读(3980)  评论(0编辑  收藏  举报

导航