【功能修复】工作流:延迟器 trigger 时,租户 id 丢失的问题
This commit is contained in:
parent
b48052a5f5
commit
e380bc34f3
|
@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskApproveTypeEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskAssignStartUserHandlerTypeEnum;
|
import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskAssignStartUserHandlerTypeEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
|
@ -91,6 +92,9 @@ public class BpmTaskCandidateInvoker {
|
||||||
*/
|
*/
|
||||||
@DataPermission(enable = false) // 忽略数据权限,避免因为过滤,导致找不到候选人
|
@DataPermission(enable = false) // 忽略数据权限,避免因为过滤,导致找不到候选人
|
||||||
public Set<Long> calculateUsersByTask(DelegateExecution execution) {
|
public Set<Long> calculateUsersByTask(DelegateExecution execution) {
|
||||||
|
// 注意:解决极端情况下,Flowable 异步调用,导致租户 id 丢失的情况
|
||||||
|
// 例如说,SIMPLE 延迟器在 trigger 的时候!!!
|
||||||
|
return FlowableUtils.execute(execution.getTenantId(), () -> {
|
||||||
// 审批类型非人工审核时,不进行计算候选人。原因是:后续会自动通过、不通过
|
// 审批类型非人工审核时,不进行计算候选人。原因是:后续会自动通过、不通过
|
||||||
FlowElement flowElement = execution.getCurrentFlowElement();
|
FlowElement flowElement = execution.getCurrentFlowElement();
|
||||||
Integer approveType = BpmnModelUtils.parseApproveType(flowElement);
|
Integer approveType = BpmnModelUtils.parseApproveType(flowElement);
|
||||||
|
@ -120,6 +124,7 @@ public class BpmTaskCandidateInvoker {
|
||||||
Assert.notNull(processInstance, "流程实例({}) 不存在", execution.getProcessInstanceId());
|
Assert.notNull(processInstance, "流程实例({}) 不存在", execution.getProcessInstanceId());
|
||||||
removeStartUserIfSkip(userIds, flowElement, Long.valueOf(processInstance.getStartUserId()));
|
removeStartUserIfSkip(userIds, flowElement, Long.valueOf(processInstance.getStartUserId()));
|
||||||
return userIds;
|
return userIds;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId,
|
public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId,
|
||||||
|
|
|
@ -628,8 +628,7 @@ public class SimpleModelUtils {
|
||||||
TimerEventDefinition eventDefinition = new TimerEventDefinition();
|
TimerEventDefinition eventDefinition = new TimerEventDefinition();
|
||||||
if (node.getDelaySetting().getDelayType().equals(BpmDelayTimerType.FIXED_DATE_TIME.getType())){
|
if (node.getDelaySetting().getDelayType().equals(BpmDelayTimerType.FIXED_DATE_TIME.getType())){
|
||||||
eventDefinition.setTimeDuration(node.getDelaySetting().getDelayTime());
|
eventDefinition.setTimeDuration(node.getDelaySetting().getDelayTime());
|
||||||
}
|
} else if (node.getDelaySetting().getDelayType().equals(BpmDelayTimerType.FIXED_TIME_DURATION.getType())){
|
||||||
if (node.getDelaySetting().getDelayType().equals(BpmDelayTimerType.FIXED_TIME_DURATION.getType())){
|
|
||||||
eventDefinition.setTimeDate(node.getDelaySetting().getDelayTime());
|
eventDefinition.setTimeDate(node.getDelaySetting().getDelayTime());
|
||||||
}
|
}
|
||||||
boundaryEvent.addEventDefinition(eventDefinition);
|
boundaryEvent.addEventDefinition(eventDefinition);
|
||||||
|
|
|
@ -1250,11 +1250,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||||
processInstanceId, taskDefineKey);
|
processInstanceId, taskDefineKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 若存在直接触发接收任务,执行后续节点
|
// 若存在直接触发接收任务,执行后续节点
|
||||||
// TODO @芋艿 这里需要帮助看一下,我不懂为啥开启了租户后就一直报错:不存在租户编号
|
FlowableUtils.execute(execution.getTenantId(),
|
||||||
FlowableUtils.execute(execution.getTenantId(), () -> {
|
() -> runtimeService.trigger(execution.getId()));
|
||||||
runtimeService.trigger(execution.getId());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue