From 5c032219674f3067d8c151459f30bc1da7fae52b Mon Sep 17 00:00:00 2001 From: cuicui Date: Sun, 27 Mar 2022 21:54:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E7=AD=BE-=E5=88=9D=E6=AD=A5=E6=90=9E?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../behavior/BpmUserTaskActivityBehavior.java | 22 +++++++++++++------ .../task/BpmProcessInstanceServiceImpl.java | 4 ++-- .../yudao/module/bpm/MultiInstancesTest.java | 3 +++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java index d4ab5b67a..f6b476368 100644 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java +++ b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java @@ -76,13 +76,21 @@ public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior { @Override @DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据 protected void handleAssignments(TaskService taskService, String assignee, String owner, List candidateUsers, List candidateGroups, TaskEntity task, ExpressionManager expressionManager, DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { - // 第一步,获得任务的规则 - BpmTaskAssignRuleDO rule = getTaskRule(task); - // 第二步,获得任务的候选用户们 - Set candidateUserIds = calculateTaskCandidateUsers(task, rule); - // 第三步,设置一个作为负责人 - Long assigneeUserId = chooseTaskAssignee(candidateUserIds); - TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId)); + boolean isMultiInstance = hasMultiInstanceCharacteristics(); + if(isMultiInstance){ + //多实例 会签/或签,执行多次每个人 待办人都在execution里面获取 + Integer assigneeUserId = execution.getVariableLocal("user", Integer.class); + TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId)); + }else { + // 第一步,获得任务的规则 + BpmTaskAssignRuleDO rule = getTaskRule(task); + // 第二步,获得任务的候选用户们 + Set candidateUserIds = calculateTaskCandidateUsers(task, rule); + // 第三步,设置一个作为负责人 + Long assigneeUserId = chooseTaskAssignee(candidateUserIds); + TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId)); + } + } private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) { diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java index 9c21bd8a9..dab4405cf 100644 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java @@ -292,8 +292,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService runtimeService.setProcessInstanceName(instance.getId(), definition.getName()); // 补全流程实例的拓展表 - processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId()) - .setFormVariables(variables)); + //TODO startProcessInstance流程里面修改了 BpmProcessInstanceExt,没有提交,和下面的更新 锁持有冲突了,异步更新这个表 +// processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId()).setFormVariables(variables)); return instance.getId(); } diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/MultiInstancesTest.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/MultiInstancesTest.java index 2640e7456..4244db086 100644 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/MultiInstancesTest.java +++ b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/MultiInstancesTest.java @@ -20,6 +20,9 @@ import static org.junit.Assert.assertNotNull; * @author henryyan * 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.controller.admin.task.BpmProcessInstanceController#createProcessInstance(cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCreateReqVO) * 执行了两次,任务分配到了同一个人 */ public class MultiInstancesTest extends AbstractOATest {