| | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.framework.common.util.object.PageUtils; |
| | | import com.iailab.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO; |
| | | import com.iailab.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; |
| | | import com.iailab.module.bpm.dal.dataobject.definition.BpmFormDO; |
| | | import com.iailab.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; |
| | |
| | | import com.iailab.module.bpm.framework.flowable.core.util.FlowableUtils; |
| | | import com.iailab.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.flowable.bpmn.model.BpmnModel; |
| | | import org.flowable.common.engine.impl.db.SuspensionState; |
| | | import org.flowable.engine.RepositoryService; |
| | |
| | | * 流程定义实现 |
| | | * 主要进行 Flowable {@link ProcessDefinition} 和 {@link Deployment} 的维护 |
| | | * |
| | | * @author yunlongn |
| | | * @author ZJQ |
| | | * @author iailab |
| | | */ |
| | | @Service |
| | |
| | | |
| | | @Override |
| | | public ProcessDefinition getActiveProcessDefinition(String key) { |
| | | return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).active().singleResult(); |
| | | return repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionTenantId(FlowableUtils.getTenantId()) |
| | | .processDefinitionKey(key).active().singleResult(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean canUserStartProcessDefinition(BpmProcessDefinitionInfoDO processDefinition, Long userId) { |
| | | if (processDefinition == null) { |
| | | return false; |
| | | } |
| | | // 为空,则所有人都可以发起 |
| | | if (CollUtil.isEmpty(processDefinition.getStartUserIds())) { |
| | | return true; |
| | | } |
| | | // 不为空,则需要存在里面 |
| | | return processDefinition.getStartUserIds().contains(userId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String createProcessDefinition(Model model, BpmModelMetaInfoRespDTO modelMetaInfo, |
| | | byte[] bpmnBytes, BpmFormDO form) { |
| | | public String createProcessDefinition(Model model, BpmModelMetaInfoVO modelMetaInfo, |
| | | byte[] bpmnBytes, String simpleJson, BpmFormDO form) { |
| | | // 创建 Deployment 部署 |
| | | Deployment deploy = repositoryService.createDeployment() |
| | | .key(model.getKey()).name(model.getName()).category(model.getCategory()) |
| | |
| | | |
| | | // 插入拓展表 |
| | | BpmProcessDefinitionInfoDO definitionDO = BeanUtils.toBean(modelMetaInfo, BpmProcessDefinitionInfoDO.class) |
| | | .setModelId(model.getId()).setProcessDefinitionId(definition.getId()); |
| | | .setModelId(model.getId()).setProcessDefinitionId(definition.getId()) |
| | | .setModelType(modelMetaInfo.getType()).setSimpleModel(simpleJson); |
| | | |
| | | if (form != null) { |
| | | definitionDO.setFormFields(form.getFields()).setFormConf(form.getConf()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateProcessDefinitionSortByModelId(String modelId, Long sort) { |
| | | processDefinitionMapper.updateByModelId(modelId, new BpmProcessDefinitionInfoDO().setSort(sort)); |
| | | } |
| | | |
| | | @Override |
| | | public BpmnModel getProcessDefinitionBpmnModel(String id) { |
| | | return repositoryService.getBpmnModel(id); |
| | | } |
| | |
| | | @Override |
| | | public PageResult<ProcessDefinition> getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) { |
| | | ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); |
| | | query.processDefinitionTenantId(FlowableUtils.getTenantId()); |
| | | if (StrUtil.isNotBlank(pageVO.getKey())) { |
| | | query.processDefinitionKey(pageVO.getKey()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ProcessDefinition> getProcessDefinitionListBySuspensionState(Integer suspensionState) { |
| | | public List<ProcessDefinition> getProcessDefinitionListBySuspensionState(Integer suspensionState, String categoryId) { |
| | | // 拼接查询条件 |
| | | ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); |
| | | if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), suspensionState)) { |
| | |
| | | } else if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), suspensionState)) { |
| | | query.active(); |
| | | } |
| | | // 执行查询 |
| | | // 关闭多租户查询,不添加tenantId条件 |
| | | if (StrUtil.isNotBlank(FlowableUtils.getTenantId())) { |
| | | query.processDefinitionTenantId(FlowableUtils.getTenantId()); |
| | | } else { |
| | | query.processDefinitionWithoutTenantId(); |
| | | if(ObjectUtils.isNotEmpty(categoryId)) { |
| | | query.processDefinitionCategory(categoryId); |
| | | } |
| | | // 执行查询 |
| | | query.processDefinitionTenantId(FlowableUtils.getTenantId()); |
| | | return query.list(); |
| | | } |
| | | |