From 6b13839488edcd06046e26a41fe897358176689c Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期五, 13 十二月 2024 17:56:41 +0800 Subject: [PATCH] 采集质量 --- iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java | 47 ++++++++++++++++++++++++++++++++++------------- 1 files changed, 34 insertions(+), 13 deletions(-) diff --git a/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java index a59f234..3519a91 100644 --- a/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java +++ b/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java @@ -5,6 +5,7 @@ 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; @@ -13,6 +14,7 @@ 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; @@ -36,8 +38,6 @@ * 流程定义实现 * 主要进行 Flowable {@link ProcessDefinition} 和 {@link Deployment} 的维护 * - * @author yunlongn - * @author ZJQ * @author iailab */ @Service @@ -79,7 +79,22 @@ @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 @@ -103,8 +118,8 @@ } @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()) @@ -129,7 +144,9 @@ // 插入拓展表 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()); } @@ -155,6 +172,11 @@ } @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); } @@ -172,6 +194,7 @@ @Override public PageResult<ProcessDefinition> getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) { ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); + query.processDefinitionTenantId(FlowableUtils.getTenantId()); if (StrUtil.isNotBlank(pageVO.getKey())) { query.processDefinitionKey(pageVO.getKey()); } @@ -186,7 +209,7 @@ } @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)) { @@ -194,13 +217,11 @@ } 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(); } -- Gitblit v1.9.3