[重大更改] 移除多租户相关功能

This commit is contained in:
疯狂的狮子Li
2026-03-18 22:15:08 +08:00
parent 2f22f9dedd
commit bebc9ce293
160 changed files with 183 additions and 4808 deletions

View File

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.tenant.core.TenantEntity;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.io.Serial;
import java.util.ArrayList;
@@ -21,7 +21,7 @@ import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("flow_category")
public class FlowCategory extends TenantEntity {
public class FlowCategory extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;

View File

@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.tenant.core.TenantEntity;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.io.Serial;
@@ -18,7 +18,7 @@ import java.io.Serial;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("flow_instance_biz_ext")
public class FlowInstanceBizExt extends TenantEntity {
public class FlowInstanceBizExt extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;

View File

@@ -31,11 +31,6 @@ public class FlowDefinitionVo implements Serializable {
*/
private Date updateTime;
/**
* 租户ID
*/
private String tenantId;
/**
* 删除标记
*/

View File

@@ -35,11 +35,6 @@ public class FlowHisTaskVo implements Serializable {
*/
private Date updateTime;
/**
* 租户ID
*/
private String tenantId;
/**
* 删除标记
*/

View File

@@ -27,11 +27,6 @@ public class FlowInstanceVo {
*/
private Date updateTime;
/**
* 租户ID
*/
private String tenantId;
/**
* 删除标记
*/

View File

@@ -36,11 +36,6 @@ public class FlowTaskVo implements Serializable {
*/
private Date updateTime;
/**
* 租户ID
*/
private String tenantId;
/**
* 删除标记
*/

View File

@@ -53,11 +53,6 @@ public class RemoteWorkflowServiceImpl implements RemoteWorkflowService {
return workflowService.getInstanceIdByBusinessId(businessId);
}
@Override
public void syncDef(String tenantId) {
workflowService.syncDef(tenantId);
}
@Override
public RemoteStartProcessReturn startWorkFlow(RemoteStartProcess startProcess) {
return workflowService.startWorkFlow(startProcess);

View File

@@ -2,7 +2,6 @@ package org.dromara.workflow.handler;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.warm.flow.core.entity.Instance;
import org.dromara.warm.flow.core.entity.Task;
import org.dromara.workflow.api.event.ProcessDeleteEvent;
@@ -34,11 +33,9 @@ public class FlowProcessEventHandler {
* @param submit 当为true时为申请人节点办理
*/
public void processHandler(String flowCode, Instance instance, String status, Map<String, Object> params, boolean submit) {
String tenantId = TenantHelper.getTenantId();
log.info("【流程事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 流程状态: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 是否申请人节点: {}, 参数: {}",
tenantId, flowCode, instance.getBusinessId(), status, instance.getNodeType(), instance.getNodeCode(), instance.getNodeName(), submit, params);
log.info("【流程事件发布】流程编码: {}, 业务ID: {}, 流程状态: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 是否申请人节点: {}, 参数: {}",
flowCode, instance.getBusinessId(), status, instance.getNodeType(), instance.getNodeCode(), instance.getNodeName(), submit, params);
ProcessEvent processEvent = new ProcessEvent();
processEvent.setTenantId(tenantId);
processEvent.setFlowCode(flowCode);
processEvent.setInstanceId(instance.getId());
processEvent.setBusinessId(instance.getBusinessId());
@@ -60,11 +57,9 @@ public class FlowProcessEventHandler {
* @param params 上一个任务的办理参数
*/
public void processTaskHandler(String flowCode, Instance instance, Task nextTask, Map<String, Object> params) {
String tenantId = TenantHelper.getTenantId();
log.info("【流程任务事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}",
tenantId, flowCode, instance.getBusinessId(), nextTask.getNodeType(), nextTask.getNodeCode(), nextTask.getNodeName(), nextTask.getId());
log.info("【流程任务事件发布】流程编码: {}, 业务ID: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}",
flowCode, instance.getBusinessId(), nextTask.getNodeType(), nextTask.getNodeCode(), nextTask.getNodeName(), nextTask.getId());
ProcessTaskEvent processTaskEvent = new ProcessTaskEvent();
processTaskEvent.setTenantId(tenantId);
processTaskEvent.setFlowCode(flowCode);
processTaskEvent.setInstanceId(instance.getId());
processTaskEvent.setBusinessId(instance.getBusinessId());
@@ -84,10 +79,8 @@ public class FlowProcessEventHandler {
* @param businessId 业务ID
*/
public void processDeleteHandler(String flowCode, String businessId) {
String tenantId = TenantHelper.getTenantId();
log.info("【流程删除事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}", tenantId, flowCode, businessId);
log.info("【流程删除事件发布】流程编码: {}, 业务ID: {}", flowCode, businessId);
ProcessDeleteEvent processDeleteEvent = new ProcessDeleteEvent();
processDeleteEvent.setTenantId(tenantId);
processDeleteEvent.setFlowCode(flowCode);
processDeleteEvent.setBusinessId(businessId);
SpringUtils.context().publishEvent(processDeleteEvent);

View File

@@ -70,10 +70,4 @@ public interface IFlwDefinitionService {
*/
boolean removeDef(List<Long> ids);
/**
* 新增租户流程定义
*
* @param tenantId 租户id
*/
void syncDef(String tenantId);
}

View File

@@ -61,13 +61,6 @@ public interface WorkflowService {
*/
Long getInstanceIdByBusinessId(String businessId);
/**
* 新增租户流程定义
*
* @param tenantId 租户id
*/
void syncDef(String tenantId);
/**
* 启动流程
*

View File

@@ -45,8 +45,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.dromara.common.core.constant.TenantConstants.DEFAULT_TENANT_ID;
/**
* 流程定义 服务层实现
*
@@ -202,71 +200,4 @@ public class FlwDefinitionServiceImpl implements IFlwDefinitionService {
return true;
}
/**
* 新增租户流程定义
*
* @param tenantId 租户id
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void syncDef(String tenantId) {
FlowCategory flowCategory = flwCategoryMapper.selectOne(new LambdaQueryWrapper<FlowCategory>()
.eq(FlowCategory::getTenantId, DEFAULT_TENANT_ID)
.eq(FlowCategory::getCategoryId, FlowConstant.FLOW_CATEGORY_ID));
flowCategory.setCategoryId(null);
flowCategory.setTenantId(tenantId);
flowCategory.setCreateDept(null);
flowCategory.setCreateBy(null);
flowCategory.setCreateTime(null);
flowCategory.setUpdateBy(null);
flowCategory.setUpdateTime(null);
flwCategoryMapper.insert(flowCategory);
List<FlowDefinition> flowDefinitions = flowDefinitionMapper.selectList(new LambdaQueryWrapper<FlowDefinition>().eq(FlowDefinition::getTenantId, DEFAULT_TENANT_ID));
if (CollUtil.isEmpty(flowDefinitions)) {
return;
}
List<Long> defIds = StreamUtils.toList(flowDefinitions, FlowDefinition::getId);
List<FlowNode> flowNodes = flowNodeMapper.selectList(new LambdaQueryWrapper<FlowNode>().in(FlowNode::getDefinitionId, defIds));
List<FlowSkip> flowSkips = flowSkipMapper.selectList(new LambdaQueryWrapper<FlowSkip>().in(FlowSkip::getDefinitionId, defIds));
for (FlowDefinition definition : flowDefinitions) {
FlowDefinition flowDefinition = BeanUtil.toBean(definition, FlowDefinition.class);
flowDefinition.setId(null);
flowDefinition.setTenantId(tenantId);
flowDefinition.setIsPublish(0);
flowDefinition.setCategory(Convert.toStr(flowCategory.getCategoryId()));
int insert = flowDefinitionMapper.insert(flowDefinition);
if (insert <= 0) {
log.info("同步流程定义【{}】失败!", definition.getFlowCode());
continue;
}
log.info("同步流程定义【{}】成功!", definition.getFlowCode());
Long definitionId = flowDefinition.getId();
if (CollUtil.isNotEmpty(flowNodes)) {
List<FlowNode> nodes = StreamUtils.filter(flowNodes, node -> node.getDefinitionId().equals(definition.getId()));
if (CollUtil.isNotEmpty(nodes)) {
List<FlowNode> flowNodeList = BeanUtil.copyToList(nodes, FlowNode.class);
flowNodeList.forEach(e -> {
e.setId(null);
e.setDefinitionId(definitionId);
e.setTenantId(tenantId);
e.setPermissionFlag(null);
});
flowNodeMapper.insertOrUpdate(flowNodeList);
}
}
if (CollUtil.isNotEmpty(flowSkips)) {
List<FlowSkip> skips = StreamUtils.filter(flowSkips, skip -> skip.getDefinitionId().equals(definition.getId()));
if (CollUtil.isNotEmpty(skips)) {
List<FlowSkip> flowSkipList = BeanUtil.copyToList(skips, FlowSkip.class);
flowSkipList.forEach(e -> {
e.setId(null);
e.setDefinitionId(definitionId);
e.setTenantId(tenantId);
});
flowSkipMapper.insertOrUpdate(flowSkipList);
}
}
}
}
}

View File

@@ -762,7 +762,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
}
FlowParams flowParams = FlowParams.build().message(bo.getMessage());
if (LoginHelper.isSuperAdmin() || LoginHelper.isTenantAdmin()) {
if (LoginHelper.isSuperAdmin()) {
flowParams.ignore(true);
}

View File

@@ -18,7 +18,6 @@ import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.workflow.api.domain.RemoteStartProcess;
import org.dromara.workflow.api.event.ProcessDeleteEvent;
import org.dromara.workflow.api.event.ProcessEvent;
@@ -182,32 +181,30 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
*/
@EventListener(condition = "#processEvent.flowCode.startsWith('leave')")
public void processHandler(ProcessEvent processEvent) {
TenantHelper.dynamic(processEvent.getTenantId(), () -> {
log.info("当前任务执行了{}", processEvent.toString());
TestLeave testLeave = baseMapper.selectById(Convert.toLong(processEvent.getBusinessId()));
testLeave.setStatus(processEvent.getStatus());
// 用于例如审批附件 审批意见等 存储到业务表内 自行根据业务实现存储流程
Map<String, Object> params = processEvent.getParams();
if (MapUtil.isNotEmpty(params)) {
// 历史任务扩展(通常为附件)
String hisTaskExt = Convert.toStr(params.get("hisTaskExt"));
// 办理人
String handler = Convert.toStr(params.get("handler"));
// 办理意见
String message = Convert.toStr(params.get("message"));
log.info("当前任务执行了{}", processEvent.toString());
TestLeave testLeave = baseMapper.selectById(Convert.toLong(processEvent.getBusinessId()));
testLeave.setStatus(processEvent.getStatus());
// 用于例如审批附件 审批意见等 存储到业务表内 自行根据业务实现存储流程
Map<String, Object> params = processEvent.getParams();
if (MapUtil.isNotEmpty(params)) {
// 历史任务扩展(通常为附件)
String hisTaskExt = Convert.toStr(params.get("hisTaskExt"));
// 办理人
String handler = Convert.toStr(params.get("handler"));
// 办理意见
String message = Convert.toStr(params.get("message"));
}
if (processEvent.getSubmit()) {
if (StringUtils.isBlank(testLeave.getApplyCode())) {
String businessCode = MapUtil.getStr(params, FlowConstant.BUSINESS_CODE, StrUtil.EMPTY);
testLeave.setApplyCode(businessCode);
}
if (processEvent.getSubmit()) {
if (StringUtils.isBlank(testLeave.getApplyCode())) {
String businessCode = MapUtil.getStr(params, FlowConstant.BUSINESS_CODE, StrUtil.EMPTY);
testLeave.setApplyCode(businessCode);
}
testLeave.setStatus(BusinessStatusEnum.WAITING.getStatus());
log.info("申请人提交");
}
String status = BusinessStatusEnum.findByStatus(processEvent.getStatus());
log.info("当前流程状态为{}", status);
baseMapper.updateById(testLeave);
});
testLeave.setStatus(BusinessStatusEnum.WAITING.getStatus());
log.info("申请人提交");
}
String status = BusinessStatusEnum.findByStatus(processEvent.getStatus());
log.info("当前流程状态为{}", status);
baseMapper.updateById(testLeave);
}
/**
@@ -234,14 +231,12 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
*/
@EventListener(condition = "#processDeleteEvent.flowCode.startsWith('leave')")
public void processDeleteHandler(ProcessDeleteEvent processDeleteEvent) {
TenantHelper.dynamic(processDeleteEvent.getTenantId(), () -> {
log.info("监听删除流程事件,当前任务执行了{}", processDeleteEvent.toString());
TestLeave testLeave = baseMapper.selectById(Long.valueOf(processDeleteEvent.getBusinessId()));
if (ObjectUtil.isNull(testLeave)) {
return;
}
baseMapper.deleteById(testLeave.getId());
});
log.info("监听删除流程事件,当前任务执行了{}", processDeleteEvent.toString());
TestLeave testLeave = baseMapper.selectById(Long.valueOf(processDeleteEvent.getBusinessId()));
if (ObjectUtil.isNull(testLeave)) {
return;
}
baseMapper.deleteById(testLeave.getId());
}
}

View File

@@ -103,16 +103,6 @@ public class WorkflowServiceImpl implements WorkflowService {
return ObjectUtil.isNotNull(flowInstance) ? flowInstance.getId() : null;
}
/**
* 新增租户流程定义
*
* @param tenantId 租户id
*/
@Override
public void syncDef(String tenantId) {
flwDefinitionService.syncDef(tenantId);
}
/**
* 启动流程
*

View File

@@ -10,7 +10,6 @@
select fi.id,
fi.create_time,
fi.update_time,
fi.tenant_id,
fi.del_flag,
fi.definition_id,
fi.business_id,

View File

@@ -19,7 +19,6 @@
t.instance_id,
t.create_time,
t.update_time,
t.tenant_id,
i.business_id,
i.flow_status,
i.create_by,
@@ -68,7 +67,6 @@
a.ext,
a.create_time,
a.update_time,
a.tenant_id,
a.form_custom,
a.form_path,
b.flow_status,