由于公司系统使用的是mybatis-plus操作数据库,研究flowable提供API封装不太好用,故分析最终执行的SQL,进行mybatis.xml改写;此处实现了查询流程定义,我的流程,我的待办,我的已办,流程日志等连表sql;
说明:系统中没有用 flowable用户表 act_id_user,用了自定义用户表 p_project_user。
1. 查询流程定义列表
Page<WfDefinitionVO> selectDefinitionList(Page page, String tenantId);
<select id="selectDefinitionList" resultType="com.geline.cloud.workflow.pojo.WfDefinitionVO"> SELECT RES.ID_ as DEFINITION_ID_, RES.KEY_ as process_key, RES.NAME_ as process_name, RES.CATEGORY_, f.form_id, f.form_name, RES.SUSPENSION_STATE_, RES.DEPLOYMENT_ID_, d.DEPLOY_TIME_ as deployment_time, RES.VERSION_ from ACT_RE_PROCDEF RES left join ACT_RE_DEPLOYMENT d on d.ID_=RES.DEPLOYMENT_ID_ left join p_wf_deploy_form f on f.deploy_id=RES.DEPLOYMENT_ID_ WHERE 1=1 and RES.TENANT_ID_ = #{tenantId} and RES.VERSION_ = (select max(VERSION_) from ACT_RE_PROCDEF where KEY_ = RES.KEY_ and TENANT_ID_ = #{tenantId}) order by RES.KEY_ asc </select>
2.查询已发布的流程版本列表
Page<WfDefinitionVO> selectPublishList(Page page, String processKey);
<select id="selectPublishList" resultType="com.geline.cloud.workflow.pojo.WfDefinitionVO">
SELECT ID_ as definition_id, KEY_ as process_key, NAME_ as process_name, CATEGORY_, VERSION_, DEPLOYMENT_ID_, SUSPENSION_STATE_
from ACT_RE_PROCDEF
WHERE KEY_ = #{processKey}
order by VERSION_ asc
</select>
3. 查询用户发起流程列表
Page<TaskOwnVO> selectOwnList(Page page, String userId);
<select id="selectOwnList" resultType="com.geline.cloud.workflow.pojo.TaskOwnVO">
SELECT p.NAME_ as PROC_DEF_NAME_, t.ACT_NAME_, p.PROC_INST_ID_, p.PROC_DEF_ID_, d.KEY_ as PROC_DEF_KEY_, d.DEPLOYMENT_ID_,
u.user_name as start_user_name, p.BUSINESS_KEY_, p.BUSINESS_STATUS_, p.START_TIME_, p.END_TIME_, p.DURATION_
from (
SELECT PROC_INST_ID_, ACT_NAME_, END_TIME_ FROM ACT_HI_ACTINST
WHERE START_TIME_ IN(SELECT MAX(START_TIME_) FROM ACT_HI_ACTINST GROUP BY PROC_INST_ID_)
) as t
left join ACT_HI_PROCINST p on t.PROC_INST_ID_=p.PROC_INST_ID_
left join ACT_RE_PROCDEF d on p.PROC_DEF_ID_ = d.ID_
left join p_project_user u on u.id=p.START_USER_ID_
WHERE p.DELETE_REASON_ IS NULL and p.START_USER_ID_=#{userId}
order by p.START_TIME_ desc
</select>
4.查询用户待办任务列表
Page<TaskTodoVO> selectTodoList(Page page, String userId);
<select id="selectTodoList" resultType="com.geline.cloud.workflow.pojo.TaskTodoVO">
SELECT RES.ID_, p.NAME_ as proc_def_name, RES.PROC_INST_ID_, RES.PROC_DEF_ID_, pd.KEY_ as PROC_DEF_KEY_,
RES.NAME_ as task_name, p.START_USER_ID_, u.user_name as start_user_name, RES.CREATE_TIME_, p.BUSINESS_KEY_, p.BUSINESS_STATUS_
from ACT_RU_TASK RES
left join ACT_RE_PROCDEF as pd on pd.ID_=RES.PROC_DEF_ID_
left join ACT_HI_PROCINST p on p.PROC_INST_ID_=RES.PROC_INST_ID_
left join act_ru_identitylink lk on lk.TASK_ID_ = RES.ID_
left join p_project_user u on u.id=p.START_USER_ID_
WHERE RES.SUSPENSION_STATE_ = 1
AND RES.ASSIGNEE_=#{userId}
OR lk.USER_ID_ = #{userId}
OR lk.GROUP_ID_ in (select concat('ROLE', id_group_id) from p_wf_id_group2user where user_id=#{userId})
order by RES.CREATE_TIME_ desc
</select>
5.查询用户已办任务列表
Page<TaskFinishedVO> selectFinishedList(Page page, String userId);
<select id="selectFinishedList" resultType="com.geline.cloud.workflow.pojo.TaskFinishedVO">
SELECT t.PROC_INST_ID_, t.PROC_DEF_ID_, p.NAME_ as PROC_DEF_NAME_, t.ASSIGNEE_, t.NAME_ as task_name,
u.user_name as start_user_name, p.BUSINESS_STATUS_, c.TYPE_, t.START_TIME_, t.END_TIME_, t.DURATION_
from ACT_HI_TASKINST t
left join ACT_HI_COMMENT c on c.TASK_ID_=t.id_
left join ACT_HI_PROCINST p on p.PROC_INST_ID_=t.PROC_INST_ID_
left join p_project_user u on u.id=p.START_USER_ID_
WHERE c.ACTION_='AddComment' and t.ASSIGNEE_ is not null
and c.USER_ID_=#{userId}
order by t.END_TIME_ desc
</select>
6.查询流程日志列表
List<WfTaskLogVO> selectWfTaskLogVOList(String procInstId);
<select id="selectWfTaskLogVOList" resultType="com.geline.cloud.workflow.pojo.TaskLogVO">
SELECT RES.ID_ as task_id, RES.TASK_DEF_KEY_, RES.NAME_ as task_name, RES.START_TIME_, RES.END_TIME_,
RES.DURATION_ as duration_time, RES.ASSIGNEE_ as assignee_id, u.user_name as assignee_name, c.TYPE_, c.MESSAGE_
from ACT_HI_TASKINST RES
left join act_hi_comment c on c.TASK_ID_=RES.id_
left join p_project_user u on u.id=RES.ASSIGNEE_
WHERE c.ACTION_='AddComment' and RES.PROC_INST_ID_ = #{procInstId}
order by RES.START_TIME_ desc
</select>
版权声明:程序员胖胖胖虎阿 发表于 2022年10月28日 下午8:48。
转载请注明:flowable 6.7.2 工作流自定义mybatis sql查询我的待办,我的已办,流程列表,流程日志等;集成了自定义用户表 | 胖虎的工具箱-编程导航
转载请注明:flowable 6.7.2 工作流自定义mybatis sql查询我的待办,我的已办,流程列表,流程日志等;集成了自定义用户表 | 胖虎的工具箱-编程导航
相关文章
暂无评论...