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,6 +38,12 @@ public class BpmModelPageItemRespVO extends BpmModelBaseVO { | ||
| 38 | @ApiModelProperty(value = "版本", required = true, example = "1") | 38 | @ApiModelProperty(value = "版本", required = true, example = "1") |
| 39 | private Integer version; | 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,6 +9,8 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefini | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; | 9 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; |
| 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 11 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 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 | import org.activiti.engine.repository.Model; | 14 | import org.activiti.engine.repository.Model; |
| 13 | import org.activiti.engine.repository.ProcessDefinition; | 15 | import org.activiti.engine.repository.ProcessDefinition; |
| 14 | import org.mapstruct.Mapper; | 16 | import org.mapstruct.Mapper; |
| @@ -29,16 +31,18 @@ public interface ModelConvert { | @@ -29,16 +31,18 @@ public interface ModelConvert { | ||
| 29 | ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class); | 31 | ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class); |
| 30 | 32 | ||
| 31 | default List<BpmModelPageItemRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap, | 33 | default List<BpmModelPageItemRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap, |
| 34 | + Map<String, Deployment> deploymentMap, | ||
| 32 | Map<String, ProcessDefinition> processDefinitionMap) { | 35 | Map<String, ProcessDefinition> processDefinitionMap) { |
| 33 | return CollectionUtils.convertList(list, model -> { | 36 | return CollectionUtils.convertList(list, model -> { |
| 34 | BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); | 37 | BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); |
| 35 | BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; | 38 | BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; |
| 39 | + Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null; | ||
| 36 | ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null; | 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 | BpmModelPageItemRespVO modelRespVO = new BpmModelPageItemRespVO(); | 46 | BpmModelPageItemRespVO modelRespVO = new BpmModelPageItemRespVO(); |
| 43 | modelRespVO.setId(model.getId()); | 47 | modelRespVO.setId(model.getId()); |
| 44 | modelRespVO.setName(model.getName()); | 48 | modelRespVO.setName(model.getName()); |
| @@ -54,6 +58,11 @@ public interface ModelConvert { | @@ -54,6 +58,11 @@ public interface ModelConvert { | ||
| 54 | modelRespVO.setFormName(form.getName()); | 58 | modelRespVO.setFormName(form.getName()); |
| 55 | } | 59 | } |
| 56 | modelRespVO.setProcessDefinition(this.convert(processDefinition)); | 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 | return modelRespVO; | 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,10 +5,13 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processde | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; |
| 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 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 | import org.activiti.engine.repository.ProcessDefinition; | 10 | import org.activiti.engine.repository.ProcessDefinition; |
| 9 | 11 | ||
| 10 | import javax.validation.Valid; | 12 | import javax.validation.Valid; |
| 11 | import java.util.List; | 13 | import java.util.List; |
| 14 | +import java.util.Map; | ||
| 12 | import java.util.Set; | 15 | import java.util.Set; |
| 13 | 16 | ||
| 14 | /** | 17 | /** |
| @@ -41,12 +44,38 @@ public interface BpmDefinitionService { | @@ -41,12 +44,38 @@ public interface BpmDefinitionService { | ||
| 41 | ProcessDefinition getDefinition(String id); | 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 | * @return 流程定义的数组 | 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,6 +11,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessD | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; | 11 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; |
| 12 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | 12 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; |
| 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 14 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 14 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.activiti.bpmn.converter.BpmnXMLConverter; | 16 | import org.activiti.bpmn.converter.BpmnXMLConverter; |
| 16 | import org.activiti.bpmn.model.BpmnModel; | 17 | import org.activiti.bpmn.model.BpmnModel; |
| @@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 23 | import org.springframework.validation.annotation.Validated; | 24 | import org.springframework.validation.annotation.Validated; |
| 24 | 25 | ||
| 25 | import javax.annotation.Resource; | 26 | import javax.annotation.Resource; |
| 27 | +import java.util.ArrayList; | ||
| 26 | import java.util.Collections; | 28 | import java.util.Collections; |
| 27 | import java.util.List; | 29 | import java.util.List; |
| 28 | import java.util.Set; | 30 | import java.util.Set; |
| @@ -78,6 +80,26 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService { | @@ -78,6 +80,26 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService { | ||
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | @Override | 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 | public List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentIds) { | 103 | public List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentIds) { |
| 82 | if (CollUtil.isEmpty(deploymentIds)) { | 104 | if (CollUtil.isEmpty(deploymentIds)) { |
| 83 | return Collections.emptyList(); | 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,6 +16,7 @@ import cn.iocoder.yudao.framework.common.util.object.PageUtils; | ||
| 16 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; | 16 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| 17 | import lombok.extern.slf4j.Slf4j; | 17 | import lombok.extern.slf4j.Slf4j; |
| 18 | import org.activiti.engine.RepositoryService; | 18 | import org.activiti.engine.RepositoryService; |
| 19 | +import org.activiti.engine.repository.Deployment; | ||
| 19 | import org.activiti.engine.repository.Model; | 20 | import org.activiti.engine.repository.Model; |
| 20 | import org.activiti.engine.repository.ModelQuery; | 21 | import org.activiti.engine.repository.ModelQuery; |
| 21 | import org.activiti.engine.repository.ProcessDefinition; | 22 | import org.activiti.engine.repository.ProcessDefinition; |
| @@ -75,15 +76,17 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -75,15 +76,17 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 75 | }); | 76 | }); |
| 76 | Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds); | 77 | Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds); |
| 77 | 78 | ||
| 78 | - // 获得 ProcessDefinition Map | 79 | + // 获得 Deployment Map |
| 79 | Set<String> deploymentIds = new HashSet<>(); | 80 | Set<String> deploymentIds = new HashSet<>(); |
| 80 | models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId())); | 81 | models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId())); |
| 82 | + Map<String, Deployment> deploymentMap = bpmDefinitionService.getDeploymentMap(deploymentIds); | ||
| 83 | + // 获得 ProcessDefinition Map | ||
| 81 | List<ProcessDefinition> processDefinitions = bpmDefinitionService.getDefinitionListByDeploymentIds(deploymentIds); | 84 | List<ProcessDefinition> processDefinitions = bpmDefinitionService.getDefinitionListByDeploymentIds(deploymentIds); |
| 82 | Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); | 85 | Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); |
| 83 | 86 | ||
| 84 | // 拼接结果 | 87 | // 拼接结果 |
| 85 | long modelCount = modelQuery.count(); | 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 | @Override | 92 | @Override |
yudao-admin-ui/src/views/bpm/model/index.vue
| @@ -34,14 +34,14 @@ | @@ -34,14 +34,14 @@ | ||
| 34 | <!-- 列表 --> | 34 | <!-- 列表 --> |
| 35 | <el-table v-loading="loading" :data="list"> | 35 | <el-table v-loading="loading" :data="list"> |
| 36 | <el-table-column label="流程标识" align="center" prop="key" /> | 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 | <template slot-scope="scope"> | 38 | <template slot-scope="scope"> |
| 39 | <el-button type="text" @click="handleBpmnDetail(scope.row)"> | 39 | <el-button type="text" @click="handleBpmnDetail(scope.row)"> |
| 40 | <span>{{ scope.row.name }}</span> | 40 | <span>{{ scope.row.name }}</span> |
| 41 | </el-button> | 41 | </el-button> |
| 42 | </template> | 42 | </template> |
| 43 | </el-table-column> | 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 | <template slot-scope="scope"> | 45 | <template slot-scope="scope"> |
| 46 | <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span> | 46 | <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span> |
| 47 | </template> | 47 | </template> |
| @@ -54,18 +54,38 @@ | @@ -54,18 +54,38 @@ | ||
| 54 | <label v-else>暂无表单</label> | 54 | <label v-else>暂无表单</label> |
| 55 | </template> | 55 | </template> |
| 56 | </el-table-column> | 56 | </el-table-column> |
| 57 | - <el-table-column label="流程版本" align="center" prop="processDefinition.version" /> | ||
| 58 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 57 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 59 | <template slot-scope="scope"> | 58 | <template slot-scope="scope"> |
| 60 | <span>{{ parseTime(scope.row.createTime) }}</span> | 59 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| 61 | </template> | 60 | </template> |
| 62 | </el-table-column> | 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 | <template slot-scope="scope"> | 84 | <template slot-scope="scope"> |
| 65 | <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button> | 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 | <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button> | 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 | </template> | 89 | </template> |
| 70 | </el-table-column> | 90 | </el-table-column> |
| 71 | </el-table> | 91 | </el-table> |