Commit 7833aa5d0e4f3a2a42d11c3690979435911948ba
1 parent
7bc36a09
完善 model 列表
Showing
6 changed files
with
102 additions
and
13 deletions
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 { |
| 38 | 38 | @ApiModelProperty(value = "版本", required = true, example = "1") |
| 39 | 39 | private Integer version; |
| 40 | 40 | |
| 41 | + @ApiModelProperty(value = "部署时间", required = true) | |
| 42 | + private Date deploymentTime; | |
| 43 | + | |
| 44 | + @ApiModelProperty(value = "中断状态", required = true, example = "1", notes = "参见 SuspensionState 枚举") | |
| 45 | + private Integer suspensionState; | |
| 46 | + | |
| 41 | 47 | } |
| 42 | 48 | |
| 43 | 49 | } | ... | ... |
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 |
| 9 | 9 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; |
| 10 | 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 11 | 11 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 12 | +import org.activiti.engine.impl.persistence.entity.SuspensionState; | |
| 13 | +import org.activiti.engine.repository.Deployment; | |
| 12 | 14 | import org.activiti.engine.repository.Model; |
| 13 | 15 | import org.activiti.engine.repository.ProcessDefinition; |
| 14 | 16 | import org.mapstruct.Mapper; |
| ... | ... | @@ -29,16 +31,18 @@ public interface ModelConvert { |
| 29 | 31 | ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class); |
| 30 | 32 | |
| 31 | 33 | default List<BpmModelPageItemRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap, |
| 34 | + Map<String, Deployment> deploymentMap, | |
| 32 | 35 | Map<String, ProcessDefinition> processDefinitionMap) { |
| 33 | 36 | return CollectionUtils.convertList(list, model -> { |
| 34 | 37 | BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); |
| 35 | 38 | BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; |
| 39 | + Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null; | |
| 36 | 40 | ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null; |
| 37 | - return convert(model, form, processDefinition); | |
| 41 | + return convert(model, form, deployment, processDefinition); | |
| 38 | 42 | }); |
| 39 | 43 | } |
| 40 | 44 | |
| 41 | - default BpmModelPageItemRespVO convert(Model model, BpmFormDO form, ProcessDefinition processDefinition) { | |
| 45 | + default BpmModelPageItemRespVO convert(Model model, BpmFormDO form, Deployment deployment, ProcessDefinition processDefinition) { | |
| 42 | 46 | BpmModelPageItemRespVO modelRespVO = new BpmModelPageItemRespVO(); |
| 43 | 47 | modelRespVO.setId(model.getId()); |
| 44 | 48 | modelRespVO.setName(model.getName()); |
| ... | ... | @@ -54,6 +58,11 @@ public interface ModelConvert { |
| 54 | 58 | modelRespVO.setFormName(form.getName()); |
| 55 | 59 | } |
| 56 | 60 | modelRespVO.setProcessDefinition(this.convert(processDefinition)); |
| 61 | + if (modelRespVO.getProcessDefinition() != null) { | |
| 62 | + modelRespVO.getProcessDefinition().setSuspensionState(processDefinition.isSuspended() ? | |
| 63 | + SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); | |
| 64 | + modelRespVO.getProcessDefinition().setDeploymentTime(deployment.getDeploymentTime()); | |
| 65 | + } | |
| 57 | 66 | return modelRespVO; |
| 58 | 67 | } |
| 59 | 68 | ... | ... |
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 |
| 5 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; |
| 6 | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 9 | +import org.activiti.engine.repository.Deployment; | |
| 8 | 10 | import org.activiti.engine.repository.ProcessDefinition; |
| 9 | 11 | |
| 10 | 12 | import javax.validation.Valid; |
| 11 | 13 | import java.util.List; |
| 14 | +import java.util.Map; | |
| 12 | 15 | import java.util.Set; |
| 13 | 16 | |
| 14 | 17 | /** |
| ... | ... | @@ -41,12 +44,38 @@ public interface BpmDefinitionService { |
| 41 | 44 | ProcessDefinition getDefinition(String id); |
| 42 | 45 | |
| 43 | 46 | /** |
| 44 | - * 获得 deploymentId 对应的 ProcessDefinition 数组 | |
| 47 | + * 获得 id 对应的 Deployment | |
| 45 | 48 | * |
| 46 | - * @param deploymentId 部署编号 | |
| 49 | + * @param id 部署编号 | |
| 50 | + * @return 流程部署 | |
| 51 | + */ | |
| 52 | + Deployment getDeployment(String id); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 获得 ids 对应的 Deployment 数组 | |
| 56 | + * | |
| 57 | + * @param ids 部署编号的数组 | |
| 58 | + * @return 流程部署的数组 | |
| 59 | + */ | |
| 60 | + List<Deployment> getDeployments(Set<String> ids); | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 获得 ids 对应的 Deployment Map | |
| 64 | + * | |
| 65 | + * @param ids 部署编号的数组 | |
| 66 | + * @return 流程部署 Map | |
| 67 | + */ | |
| 68 | + default Map<String, Deployment> getDeploymentMap(Set<String> ids) { | |
| 69 | + return CollectionUtils.convertMap(getDeployments(ids), Deployment::getId); | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 获得 deploymentIds 对应的 ProcessDefinition 数组 | |
| 74 | + * | |
| 75 | + * @param deploymentIds 部署编号的数组 | |
| 47 | 76 | * @return 流程定义的数组 |
| 48 | 77 | */ |
| 49 | - List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentId); | |
| 78 | + List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentIds); | |
| 50 | 79 | |
| 51 | 80 | /** |
| 52 | 81 | * 创建流程定义 | ... | ... |
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 |
| 11 | 11 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; |
| 12 | 12 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; |
| 13 | 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 14 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 14 | 15 | import lombok.extern.slf4j.Slf4j; |
| 15 | 16 | import org.activiti.bpmn.converter.BpmnXMLConverter; |
| 16 | 17 | import org.activiti.bpmn.model.BpmnModel; |
| ... | ... | @@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 23 | 24 | import org.springframework.validation.annotation.Validated; |
| 24 | 25 | |
| 25 | 26 | import javax.annotation.Resource; |
| 27 | +import java.util.ArrayList; | |
| 26 | 28 | import java.util.Collections; |
| 27 | 29 | import java.util.List; |
| 28 | 30 | import java.util.Set; |
| ... | ... | @@ -78,6 +80,26 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService { |
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | @Override |
| 83 | + public Deployment getDeployment(String id) { | |
| 84 | + if (StrUtil.isEmpty(id)) { | |
| 85 | + return null; | |
| 86 | + } | |
| 87 | + return repositoryService.createDeploymentQuery().deploymentId(id).singleResult(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @Override | |
| 91 | + public List<Deployment> getDeployments(Set<String> ids) { | |
| 92 | + if (CollUtil.isEmpty(ids)) { | |
| 93 | + return Collections.emptyList(); | |
| 94 | + } | |
| 95 | + List<Deployment> list = new ArrayList<>(ids.size()); | |
| 96 | + for (String id : ids) { | |
| 97 | + CollectionUtils.addIfNotNull(list, getDeployment(id)); | |
| 98 | + } | |
| 99 | + return list; | |
| 100 | + } | |
| 101 | + | |
| 102 | + @Override | |
| 81 | 103 | public List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentIds) { |
| 82 | 104 | if (CollUtil.isEmpty(deploymentIds)) { |
| 83 | 105 | return Collections.emptyList(); | ... | ... |
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; |
| 16 | 16 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| 17 | 17 | import lombok.extern.slf4j.Slf4j; |
| 18 | 18 | import org.activiti.engine.RepositoryService; |
| 19 | +import org.activiti.engine.repository.Deployment; | |
| 19 | 20 | import org.activiti.engine.repository.Model; |
| 20 | 21 | import org.activiti.engine.repository.ModelQuery; |
| 21 | 22 | import org.activiti.engine.repository.ProcessDefinition; |
| ... | ... | @@ -75,15 +76,17 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 75 | 76 | }); |
| 76 | 77 | Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds); |
| 77 | 78 | |
| 78 | - // 获得 ProcessDefinition Map | |
| 79 | + // 获得 Deployment Map | |
| 79 | 80 | Set<String> deploymentIds = new HashSet<>(); |
| 80 | 81 | models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId())); |
| 82 | + Map<String, Deployment> deploymentMap = bpmDefinitionService.getDeploymentMap(deploymentIds); | |
| 83 | + // 获得 ProcessDefinition Map | |
| 81 | 84 | List<ProcessDefinition> processDefinitions = bpmDefinitionService.getDefinitionListByDeploymentIds(deploymentIds); |
| 82 | 85 | Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); |
| 83 | 86 | |
| 84 | 87 | // 拼接结果 |
| 85 | 88 | long modelCount = modelQuery.count(); |
| 86 | - return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap, processDefinitionMap), modelCount); | |
| 89 | + return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap, deploymentMap, processDefinitionMap), modelCount); | |
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | @Override | ... | ... |
yudao-admin-ui/src/views/bpm/model/index.vue
| ... | ... | @@ -34,14 +34,14 @@ |
| 34 | 34 | <!-- 列表 --> |
| 35 | 35 | <el-table v-loading="loading" :data="list"> |
| 36 | 36 | <el-table-column label="流程标识" align="center" prop="key" /> |
| 37 | - <el-table-column label="流程名称" align="center" prop="name"> | |
| 37 | + <el-table-column label="流程名称" align="center" prop="name" width="200"> | |
| 38 | 38 | <template slot-scope="scope"> |
| 39 | 39 | <el-button type="text" @click="handleBpmnDetail(scope.row)"> |
| 40 | 40 | <span>{{ scope.row.name }}</span> |
| 41 | 41 | </el-button> |
| 42 | 42 | </template> |
| 43 | 43 | </el-table-column> |
| 44 | - <el-table-column label="流程分类" align="center" prop="category"> | |
| 44 | + <el-table-column label="流程分类" align="center" prop="category" width="100"> | |
| 45 | 45 | <template slot-scope="scope"> |
| 46 | 46 | <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span> |
| 47 | 47 | </template> |
| ... | ... | @@ -54,18 +54,38 @@ |
| 54 | 54 | <label v-else>暂无表单</label> |
| 55 | 55 | </template> |
| 56 | 56 | </el-table-column> |
| 57 | - <el-table-column label="流程版本" align="center" prop="processDefinition.version" /> | |
| 58 | 57 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 59 | 58 | <template slot-scope="scope"> |
| 60 | 59 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| 61 | 60 | </template> |
| 62 | 61 | </el-table-column> |
| 63 | - <el-table-column label="操作" align="center" width="240"> | |
| 62 | + <el-table-column label="最新部署的流程定义" align="center"> | |
| 63 | + <el-table-column label="流程版本" align="center" prop="processDefinition.version" width="80"> | |
| 64 | + <template slot-scope="scope"> | |
| 65 | + <el-tag size="medium" v-if="scope.row.processDefinition">v{{ scope.row.processDefinition.version }}</el-tag> | |
| 66 | + <el-tag size="medium" type="warning" v-else>未部署</el-tag> | |
| 67 | + </template> | |
| 68 | + </el-table-column> | |
| 69 | + <el-table-column label="激活状态" align="center" prop="processDefinition.version" width="80"> | |
| 70 | + <template slot-scope="scope"> | |
| 71 | +<!-- <el-tag type="success" v-if="scope.row.processDefinition && scope.row.processDefinition.suspensionState === 1">激活</el-tag>--> | |
| 72 | +<!-- <el-tag type="warning" v-if="scope.row.processDefinition && scope.row.processDefinition.suspensionState === 2">挂起</el-tag>--> | |
| 73 | + <el-switch v-if="scope.row.processDefinition" v-model="scope.row.processDefinition.suspensionState" | |
| 74 | + :active-value="1" :inactive-value="2" @change="handleStatusChange(scope.row)" /> | |
| 75 | + </template> | |
| 76 | + </el-table-column> | |
| 77 | + <el-table-column label="部署时间" align="center" prop="createTime" width="180"> | |
| 78 | + <template slot-scope="scope"> | |
| 79 | + <span v-if="scope.row.processDefinition">{{ parseTime(scope.row.processDefinition.deploymentTime) }}</span> | |
| 80 | + </template> | |
| 81 | + </el-table-column> | |
| 82 | + </el-table-column> | |
| 83 | + <el-table-column label="操作" align="center" width="300"> | |
| 64 | 84 | <template slot-scope="scope"> |
| 65 | 85 | <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button> |
| 86 | + <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)">发布流程</el-button> | |
| 87 | + <el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDeploy(scope.row)">流程定义</el-button> | |
| 66 | 88 | <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button> |
| 67 | - <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)">发布</el-button> | |
| 68 | - <!-- TODO 芋艿:流程定义 --> | |
| 69 | 89 | </template> |
| 70 | 90 | </el-table-column> |
| 71 | 91 | </el-table> | ... | ... |