会签-初步搞定

This commit is contained in:
cuicui 2022-03-27 21:54:12 +08:00
parent 222732f7e0
commit 5c03221967
3 changed files with 20 additions and 9 deletions

View File

@ -76,6 +76,12 @@ public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior {
@Override @Override
@DataPermission(enable = false) // 不需要处理数据权限 不然会有问题查询不到数据 @DataPermission(enable = false) // 不需要处理数据权限 不然会有问题查询不到数据
protected void handleAssignments(TaskService taskService, String assignee, String owner, List<String> candidateUsers, List<String> candidateGroups, TaskEntity task, ExpressionManager expressionManager, DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { protected void handleAssignments(TaskService taskService, String assignee, String owner, List<String> candidateUsers, List<String> candidateGroups, TaskEntity task, ExpressionManager expressionManager, DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) {
boolean isMultiInstance = hasMultiInstanceCharacteristics();
if(isMultiInstance){
//多实例 会签/或签,执行多次每个人 待办人都在execution里面获取
Integer assigneeUserId = execution.getVariableLocal("user", Integer.class);
TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId));
}else {
// 第一步获得任务的规则 // 第一步获得任务的规则
BpmTaskAssignRuleDO rule = getTaskRule(task); BpmTaskAssignRuleDO rule = getTaskRule(task);
// 第二步获得任务的候选用户们 // 第二步获得任务的候选用户们
@ -85,6 +91,8 @@ public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior {
TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId)); TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId));
} }
}
private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) { private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) {
List<BpmTaskAssignRuleDO> taskRules = bpmTaskRuleService.getTaskAssignRuleListByProcessDefinitionId(task.getProcessDefinitionId(), List<BpmTaskAssignRuleDO> taskRules = bpmTaskRuleService.getTaskAssignRuleListByProcessDefinitionId(task.getProcessDefinitionId(),
task.getTaskDefinitionKey()); task.getTaskDefinitionKey());

View File

@ -292,8 +292,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
runtimeService.setProcessInstanceName(instance.getId(), definition.getName()); runtimeService.setProcessInstanceName(instance.getId(), definition.getName());
// 补全流程实例的拓展表 // 补全流程实例的拓展表
processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId()) //TODO startProcessInstance流程里面修改了 BpmProcessInstanceExt,没有提交和下面的更新 锁持有冲突了异步更新这个表
.setFormVariables(variables)); // processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId()).setFormVariables(variables));
return instance.getId(); return instance.getId();
} }

View File

@ -20,6 +20,9 @@ import static org.junit.Assert.assertNotNull;
* @author henryyan * @author henryyan
* testMultiInstanceForUserTask 会签 * testMultiInstanceForUserTask 会签
* cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.BpmUserTaskActivityBehavior#handleAssignments(org.flowable.task.service.TaskService, java.lang.String, java.lang.String, java.util.List, java.util.List, org.flowable.task.service.impl.persistence.entity.TaskEntity, org.flowable.common.engine.impl.el.ExpressionManager, org.flowable.engine.delegate.DelegateExecution, org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl) * cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.BpmUserTaskActivityBehavior#handleAssignments(org.flowable.task.service.TaskService, java.lang.String, java.lang.String, java.util.List, java.util.List, org.flowable.task.service.impl.persistence.entity.TaskEntity, org.flowable.common.engine.impl.el.ExpressionManager, org.flowable.engine.delegate.DelegateExecution, org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl)
*
* 发生了死锁
* cn.iocoder.yudao.module.bpm.controller.admin.task.BpmProcessInstanceController#createProcessInstance(cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCreateReqVO)
* 执行了两次,任务分配到了同一个人 * 执行了两次,任务分配到了同一个人
*/ */
public class MultiInstancesTest extends AbstractOATest { public class MultiInstancesTest extends AbstractOATest {