diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelPageItemRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelPageItemRespVO.java index 4ff9040c0..c90578ed6 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelPageItemRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelPageItemRespVO.java @@ -38,6 +38,12 @@ public class BpmModelPageItemRespVO extends BpmModelBaseVO { @ApiModelProperty(value = "版本", required = true, example = "1") private Integer version; + @ApiModelProperty(value = "部署时间", required = true) + private Date deploymentTime; + + @ApiModelProperty(value = "中断状态", required = true, example = "1", notes = "参见 SuspensionState 枚举") + private Integer suspensionState; + } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/ModelConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/ModelConvert.java index 640e13cdf..3cd30fef4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/ModelConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/ModelConvert.java @@ -9,6 +9,8 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefini import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import org.activiti.engine.impl.persistence.entity.SuspensionState; +import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.Model; import org.activiti.engine.repository.ProcessDefinition; import org.mapstruct.Mapper; @@ -29,16 +31,18 @@ public interface ModelConvert { ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class); default List convertList(List list, Map formMap, + Map deploymentMap, Map processDefinitionMap) { return CollectionUtils.convertList(list, model -> { BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; + Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null; ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null; - return convert(model, form, processDefinition); + return convert(model, form, deployment, processDefinition); }); } - default BpmModelPageItemRespVO convert(Model model, BpmFormDO form, ProcessDefinition processDefinition) { + default BpmModelPageItemRespVO convert(Model model, BpmFormDO form, Deployment deployment, ProcessDefinition processDefinition) { BpmModelPageItemRespVO modelRespVO = new BpmModelPageItemRespVO(); modelRespVO.setId(model.getId()); modelRespVO.setName(model.getName()); @@ -54,6 +58,11 @@ public interface ModelConvert { modelRespVO.setFormName(form.getName()); } modelRespVO.setProcessDefinition(this.convert(processDefinition)); + if (modelRespVO.getProcessDefinition() != null) { + modelRespVO.getProcessDefinition().setSuspensionState(processDefinition.isSuspended() ? + SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); + modelRespVO.getProcessDefinition().setDeploymentTime(deployment.getDeploymentTime()); + } return modelRespVO; } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmDefinitionService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmDefinitionService.java index 4d902a586..9b0394c41 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmDefinitionService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmDefinitionService.java @@ -5,10 +5,13 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processde import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.ProcessDefinition; import javax.validation.Valid; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -41,12 +44,38 @@ public interface BpmDefinitionService { ProcessDefinition getDefinition(String id); /** - * 获得 deploymentId 对应的 ProcessDefinition 数组 + * 获得 id 对应的 Deployment * - * @param deploymentId 部署编号 + * @param id 部署编号 + * @return 流程部署 + */ + Deployment getDeployment(String id); + + /** + * 获得 ids 对应的 Deployment 数组 + * + * @param ids 部署编号的数组 + * @return 流程部署的数组 + */ + List getDeployments(Set ids); + + /** + * 获得 ids 对应的 Deployment Map + * + * @param ids 部署编号的数组 + * @return 流程部署 Map + */ + default Map getDeploymentMap(Set ids) { + return CollectionUtils.convertMap(getDeployments(ids), Deployment::getId); + } + + /** + * 获得 deploymentIds 对应的 ProcessDefinition 数组 + * + * @param deploymentIds 部署编号的数组 * @return 流程定义的数组 */ - List getDefinitionListByDeploymentIds(Set deploymentId); + List getDefinitionListByDeploymentIds(Set deploymentIds); /** * 创建流程定义 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmDefinitionServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmDefinitionServiceImpl.java index 5d00473fc..a91fa4d9d 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmDefinitionServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmDefinitionServiceImpl.java @@ -11,6 +11,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessD import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import lombok.extern.slf4j.Slf4j; import org.activiti.bpmn.converter.BpmnXMLConverter; import org.activiti.bpmn.model.BpmnModel; @@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; @@ -77,6 +79,26 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService { return repositoryService.getProcessDefinition(id); } + @Override + public Deployment getDeployment(String id) { + if (StrUtil.isEmpty(id)) { + return null; + } + return repositoryService.createDeploymentQuery().deploymentId(id).singleResult(); + } + + @Override + public List getDeployments(Set ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } + List list = new ArrayList<>(ids.size()); + for (String id : ids) { + CollectionUtils.addIfNotNull(list, getDeployment(id)); + } + return list; + } + @Override public List getDefinitionListByDeploymentIds(Set deploymentIds) { if (CollUtil.isEmpty(deploymentIds)) { diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/impl/BpmModelServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/impl/BpmModelServiceImpl.java index 66179a6f9..13a5d4255 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/impl/BpmModelServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/impl/BpmModelServiceImpl.java @@ -16,6 +16,7 @@ import cn.iocoder.yudao.framework.common.util.object.PageUtils; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import lombok.extern.slf4j.Slf4j; import org.activiti.engine.RepositoryService; +import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.Model; import org.activiti.engine.repository.ModelQuery; import org.activiti.engine.repository.ProcessDefinition; @@ -75,15 +76,17 @@ public class BpmModelServiceImpl implements BpmModelService { }); Map formMap = bpmFormService.getFormMap(formIds); - // 获得 ProcessDefinition Map + // 获得 Deployment Map Set deploymentIds = new HashSet<>(); models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId())); + Map deploymentMap = bpmDefinitionService.getDeploymentMap(deploymentIds); + // 获得 ProcessDefinition Map List processDefinitions = bpmDefinitionService.getDefinitionListByDeploymentIds(deploymentIds); Map processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); // 拼接结果 long modelCount = modelQuery.count(); - return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap, processDefinitionMap), modelCount); + return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap, deploymentMap, processDefinitionMap), modelCount); } @Override diff --git a/yudao-admin-ui/src/views/bpm/model/index.vue b/yudao-admin-ui/src/views/bpm/model/index.vue index e71491455..78451032b 100644 --- a/yudao-admin-ui/src/views/bpm/model/index.vue +++ b/yudao-admin-ui/src/views/bpm/model/index.vue @@ -34,14 +34,14 @@ - + - + @@ -54,18 +54,38 @@ - - + + + + + + + + + + + +