Pre Merge pull request !1289 from KAILIN/master
This commit is contained in:
commit
e11e5d9b27
|
@ -1,6 +1,5 @@
|
||||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||||
|
@ -24,6 +23,10 @@ import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
import org.flowable.task.api.TaskInfo;
|
import org.flowable.task.api.TaskInfo;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -39,7 +42,10 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
public class FlowableUtils {
|
@Component
|
||||||
|
public class FlowableUtils implements ApplicationContextAware {
|
||||||
|
|
||||||
|
private static Boolean tenantEnabled;
|
||||||
|
|
||||||
// ========== User 相关的工具方法 ==========
|
// ========== User 相关的工具方法 ==========
|
||||||
|
|
||||||
|
@ -63,8 +69,14 @@ public class FlowableUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTenantId() {
|
public static String getTenantId() {
|
||||||
Long tenantId = TenantContextHolder.getTenantId();
|
if (tenantEnabled == null) {
|
||||||
return tenantId != null ? String.valueOf(tenantId) : ProcessEngineConfiguration.NO_TENANT_ID;
|
throw new RuntimeException("tenantEnabled 参数未加载完成");
|
||||||
|
} else if (tenantEnabled) {
|
||||||
|
Long tenantId = TenantContextHolder.getTenantId();
|
||||||
|
return tenantId != null ? String.valueOf(tenantId) : ProcessEngineConfiguration.NO_TENANT_ID;
|
||||||
|
} else {
|
||||||
|
return ProcessEngineConfiguration.NO_TENANT_ID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void execute(String tenantIdStr, Runnable runnable) {
|
public static void execute(String tenantIdStr, Runnable runnable) {
|
||||||
|
@ -359,4 +371,9 @@ public class FlowableUtils {
|
||||||
return getExpressionValue(variableContainer, expressionString);
|
return getExpressionValue(variableContainer, expressionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
// yudao.tenant.enable = false时,tenantFrameworkService Bean 不会注入
|
||||||
|
tenantEnabled = applicationContext.containsBean("tenantFrameworkService");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue