flowable-engine
flowable-engine copied to clipboard
How to sort tasks(ACT_RU_TASK) according to the form fields(ACT_RU_VARIABLE) in the task ?
Describe the bug A clear and concise description of what the bug is.
Expected behavior A clear and concise description of what you expected to happen.
Code If applicable, add the code that you are using when having the issue.
Additional context Add the version of Flowable that you are using, the database vendor and if you are using Flowable within Spring Boot, the Flowable Task application etc.
Before 6.7.2,I used 6.6.0.When I implement the query task in the following way, I sort the query task by a field in the form.The sql statement generated by the TaskQuery.listPage()method is:
select distinct RES.* from ACT_RU_TASK RES left outer join ACT_RU_VARIABLE A_OR1 on RES.PROC_INST_ID_ = A_OR1.PROC_INST_ID_ WHERE RES.PROC_INST_ID_ IN (?) and ((RES.ASSIGNEE_ = ? or (RES.ASSIGNEE_ is null and exists(select LINK.ID_ from ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_ and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = ? or LINK.GROUP_ID_ IN (?)))))) and ((A_OR1.TASK_ID_ is null and A_OR1.NAME_ = ? and A_OR1.TYPE_ = ? and (A_OR1.TEXT_ = ?))) order by field(A_OR1, ?) desc, A0.TEXT_ desc LIMIT ? OFFSET ?
This function is realized by associating tables with order by field. Although the alias of the table will be different due to different query parameters in this process, we solved this problem by debugging the adaptation.
But now that we have upgraded the version, this method cannot be used,The SQL statements generated after the upgrade become :
SELECT RES.* from ACT_RU_TASK RES WHERE RES.PROC_INST_ID_ IN (?) and exists(select 1 from ACT_RU_VARIABLE V WHERE RES.PROC_INST_ID_ = V.PROC_INST_ID_ and V.TASK_ID_ is null and V.NAME_ = ? and V.TYPE_ = ? and (V.TEXT_ LIKE ?)) and ((RES.ASSIGNEE_ = ? or (RES.ASSIGNEE_ is null and exists( select LINK.ID_ from ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_ and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = ? or (LINK.GROUP_ID_ IN (?))))))) order by field(V.NAME_, 'reportTime') desc, V.TEXT_ desc LIMIT ? OFFSET ?
This statement(order by field(V.NAME_, 'reportTime') desc, V.TEXT_ desc
) obviously cannot be executed successfully,
So I want to ask you how to implement the requirement of sorting by the fields of the form under the task when querying the task. Is there an API? Or how to customize SQL? Look forward to your answer!