Skip to content

Commit

Permalink
优化细分角色认领部门认领
Browse files Browse the repository at this point in the history
  • Loading branch information
qmdx committed Aug 27, 2024
1 parent ffce590 commit 8115819
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
13 changes: 11 additions & 2 deletions flowlong-core/src/main/java/com/aizuda/bpm/engine/TaskService.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,22 @@ default boolean executeJumpTask(Long taskId, String nodeKey, FlowCreator flowCre
boolean viewTask(Long taskId, FlwTaskActor taskActor);

/**
* 根据 任务ID 认领任务,删除其它任务参与者
* 角色根据 任务ID 认领任务,删除其它任务参与者
*
* @param taskId 任务ID
* @param flowCreator 任务认领者
* @return Task 任务对象
*/
FlwTask claim(Long taskId, FlowCreator flowCreator);
FlwTask claimRole(Long taskId, FlowCreator flowCreator);

/**
* 部门根据 任务ID 认领任务,删除其它任务参与者
*
* @param taskId 任务ID
* @param flowCreator 任务认领者
* @return Task 任务对象
*/
FlwTask claimDepartment(Long taskId, FlowCreator flowCreator);

/**
* 根据 任务ID 指定代理人
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ public enum EventType {
*/
reject,
/**
* 认领
* 角色认领
*/
claim,
claimRole,
/**
* 部门认领
*/
claimDepartment,
/**
* 拿回未执行任务
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,26 @@ public boolean viewTask(Long taskId, FlwTaskActor taskActor) {
return false;
}

@Override
public FlwTask claimRole(Long taskId, FlowCreator flowCreator) {
return claim(taskId, AgentType.claimRole, EventType.claimRole, flowCreator);
}

@Override
public FlwTask claimDepartment(Long taskId, FlowCreator flowCreator) {
return claim(taskId, AgentType.claimDepartment, EventType.claimDepartment, flowCreator);
}

/**
* 根据 任务ID 认领任务,删除其它任务参与者
*
* @param taskId 任务ID
* @param agentType 代理人类型
* @param eventType 流程引擎监听类型
* @param flowCreator 任务认领者
* @return Task 任务对象
*/
@Override
public FlwTask claim(Long taskId, FlowCreator flowCreator) {
protected FlwTask claim(Long taskId, AgentType agentType, EventType eventType, FlowCreator flowCreator) {
FlwTask flwTask = taskDao.selectCheckById(taskId);
FlwTaskActor taskActor = this.isAllowed(flwTask, flowCreator.getCreateId());
if (null == taskActor) {
Expand All @@ -418,10 +433,10 @@ public FlwTask claim(Long taskId, FlowCreator flowCreator) {
taskActorDao.deleteById(taskActor.getId());

// 插入当前用户ID作为唯一参与者
taskActorDao.insert(FlwTaskActor.ofAgent(AgentType.claimRole, flowCreator, flwTask, taskActor));
taskActorDao.insert(FlwTaskActor.ofAgent(agentType, flowCreator, flwTask, taskActor));

// 任务监听器通知
this.taskNotify(EventType.claim, () -> flwTask, null, flowCreator);
this.taskNotify(eventType, () -> flwTask, null, flowCreator);
return flwTask;
}

Expand Down

0 comments on commit 8115819

Please sign in to comment.