| | |
| | | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; |
| | | import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionInfoMapper; |
| | | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; |
| | | import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmProcessDefinitionIdUtils; |
| | | import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.flowable.bpmn.model.BpmnModel; |
| | | import org.flowable.common.engine.api.FlowableObjectNotFoundException; |
| | | import org.flowable.common.engine.impl.db.SuspensionState; |
| | | import org.flowable.engine.RepositoryService; |
| | | import org.flowable.engine.repository.Deployment; |
| | |
| | | * |
| | | * @author yunlongn |
| | | * @author ZJQ |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @Validated |
| | |
| | | |
| | | @Override |
| | | public ProcessDefinition getProcessDefinition(String id) { |
| | | return repositoryService.getProcessDefinition(id); |
| | | String definitionId = BpmProcessDefinitionIdUtils.normalize(id); |
| | | if (StrUtil.isBlank(definitionId)) { |
| | | return null; |
| | | } |
| | | // 编号不存在时 Flowable 会抛 FlowableObjectNotFoundException, |
| | | // 这里统一转成 null 由调用方处理,避免前端拿到 500「系统异常」 |
| | | try { |
| | | return repositoryService.getProcessDefinition(definitionId); |
| | | } catch (FlowableObjectNotFoundException ex) { |
| | | log.warn("[getProcessDefinition][流程定义({}) 不存在]", definitionId); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<ProcessDefinition> getProcessDefinitionList(Set<String> ids) { |
| | | return repositoryService.createProcessDefinitionQuery().processDefinitionIds(ids).list(); |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return emptyList(); |
| | | } |
| | | return repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionIds(ids.stream().map(BpmProcessDefinitionIdUtils::normalize) |
| | | .collect(java.util.stream.Collectors.toSet())).list(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public ProcessDefinition getActiveProcessDefinition(String key) { |
| | | return repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionTenantId(FlowableUtils.getTenantId()) |
| | | .processDefinitionKey(key).active().singleResult(); |
| | | .processDefinitionKey(BpmProcessDefinitionIdUtils.normalize(key)).active().singleResult(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public BpmnModel getProcessDefinitionBpmnModel(String id) { |
| | | return repositoryService.getBpmnModel(id); |
| | | String definitionId = BpmProcessDefinitionIdUtils.normalize(id); |
| | | if (StrUtil.isBlank(definitionId)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return repositoryService.getBpmnModel(definitionId); |
| | | } catch (FlowableObjectNotFoundException ex) { |
| | | log.warn("[getProcessDefinitionBpmnModel][流程定义({}) 不存在]", definitionId); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public BpmProcessDefinitionInfoDO getProcessDefinitionInfo(String id) { |
| | | return processDefinitionMapper.selectByProcessDefinitionId(id); |
| | | return processDefinitionMapper.selectByProcessDefinitionId(BpmProcessDefinitionIdUtils.normalize(id)); |
| | | } |
| | | |
| | | @Override |
| | | public List<BpmProcessDefinitionInfoDO> getProcessDefinitionInfoList(Collection<String> ids) { |
| | | return processDefinitionMapper.selectListByProcessDefinitionIds(ids); |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return emptyList(); |
| | | } |
| | | return processDefinitionMapper.selectListByProcessDefinitionIds(ids.stream() |
| | | .map(BpmProcessDefinitionIdUtils::normalize).collect(java.util.stream.Collectors.toSet())); |
| | | } |
| | | |
| | | @Override |