1、public interface TaskService :
/**
* A shortcut to {@link #claim} with null user in order to unclaim the task
* @param taskId task to unclaim, cannot be null.
* @throws ActivitiObjectNotFoundException when the task doesn't exist.
*/
void unclaim(String taskId);
void claim(String taskId, String userId) 都很熟悉,就是声明某个任务。使这个任务只能有
userId能完成这个任务。
怎么取消这个声明呢?activiti增加新的特性方法unclaim();
2、自己写sql来查询自己的任务和待办的任务
// 已经签收的或者直接分配到当前人的任务
StringBuffer asigneeSql = new StringBuffer(" select distinct RES.* from ACT_RU_TASK RES ");
asigneeSql.append(" inner join ACT_RE_PROCDEF D on RES.PROC_DEF_ID_ = D.ID_ ");
asigneeSql.append(" WHERE RES.ASSIGNEE_ = #{userId}");
asigneeSql.append(" and D.KEY_ = #{processDefinitionKey} ");
asigneeSql.append(" and RES.SUSPENSION_STATE_ = #{suspensionState}");
// 当前人在候选人或者候选组范围之内
StringBuffer needClaimSql = new StringBuffer("select distinct RES1.* from ACT_RU_TASK RES1 ");
needClaimSql.append(" inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES1.ID_ ");
needClaimSql.append(" inner join ACT_RE_PROCDEF D1 on RES1.PROC_DEF_ID_ = D1.ID_ ");
needClaimSql.append(" WHERE D1.KEY_ = #{processDefinitionKey} ");
needClaimSql.append(" and RES1.ASSIGNEE_ is null ");
needClaimSql.append(" and I.TYPE_ = 'candidate' ");
needClaimSql.append(" and ( I.USER_ID_ = #{userId} or ");
needClaimSql.append(" I.GROUP_ID_ IN (select g.GROUP_ID_ from ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{userId} ) ) ");
needClaimSql.append(" and RES1.SUSPENSION_STATE_ = #{suspensionState} ");