Commit 513c23efbb1de9569206b9cda3f704e312034563

Authored by YunaiV
1 parent 7833aa5d

优化流程定义的分页接口

Showing 17 changed files with 280 additions and 342 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/ProcessDefinitionController.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/ProcessDefinitionController.java
1   -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow;
  1 +package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition;
2 2  
  3 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
  4 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
3 5 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
4   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo;
5   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO;
6 6 import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService;
7 7 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
8 8 import cn.iocoder.yudao.framework.common.pojo.PageResult;
9 9 import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
  10 +import io.swagger.annotations.Api;
10 11 import io.swagger.annotations.ApiOperation;
11   -import org.activiti.api.process.runtime.ProcessRuntime;
12   -import org.activiti.engine.RepositoryService;
  12 +import org.springframework.validation.annotation.Validated;
13 13 import org.springframework.web.bind.annotation.GetMapping;
14 14 import org.springframework.web.bind.annotation.RequestMapping;
15 15 import org.springframework.web.bind.annotation.RequestParam;
... ... @@ -19,39 +19,38 @@ import javax.annotation.Resource;
19 19 import javax.servlet.http.HttpServletResponse;
20 20 import java.io.IOException;
21 21  
22   -// TODO @json:swagger 和 validation 的注解,后续要补全下哈。可以等 workflow 基本写的差不多之后
  22 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  23 +
  24 +@Api(tags = "流程定义")
23 25 @RestController
24   -@RequestMapping("/workflow/process/definition")
  26 +@RequestMapping("/bpm/definition")
  27 +@Validated
25 28 public class ProcessDefinitionController {
26 29  
27 30 @Resource
28   - private RepositoryService repositoryService;
  31 + private BpmDefinitionService bpmDefinitionService;
29 32  
30   - @Resource
31   - private ProcessRuntime processRuntime;
32   - @Resource
33   - private BpmDefinitionService bpmProcessDefinitionService;
  33 + // TODO 芋艿:权限
34 34  
  35 + @GetMapping ("/page")
  36 + @ApiOperation(value = "获得流程定义分页")
  37 + public CommonResult<PageResult<BpmProcessDefinitionPageItemRespVO>> getDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO) {
  38 + return success(bpmDefinitionService.getDefinitionPage(pageReqVO));
  39 + }
35 40  
36 41 @GetMapping(value = "/getStartForm")
37 42 public CommonResult<String> getStartForm(@RequestParam("processKey") String processKey){
38 43 // final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().
39 44 // processDefinitionKey(processKey).latestVersion().singleResult();
40 45 // processRuntime.processDefinition(processDefinition.getId()).getFormKey();
41   - //这样查似乎有问题??, 暂时写死
42   - return CommonResult.success("/flow/leave/apply");
43   - }
44   -
45   - @GetMapping ("/page")
46   - @ApiOperation(value = "流程定义分页数据")
47   - public CommonResult<PageResult<ProcessDefinitionRespVO>> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo) {
48   - return CommonResult.success(bpmProcessDefinitionService.pageList(processDefinitionPageReqVo));
  46 + // TODO 这样查似乎有问题??, 暂时写死
  47 + return success("/flow/leave/apply");
49 48 }
50 49  
51 50 @GetMapping ("/export")
52 51 @ApiOperation(value = "流程定义的bpmnXml导出")
53   - public void pageList(@RequestParam String processDefinitionId, HttpServletResponse response) throws IOException {
54   - FileResp fileResp = bpmProcessDefinitionService.export(processDefinitionId);
  52 + public void getDefinitionPage(@RequestParam String processDefinitionId, HttpServletResponse response) throws IOException {
  53 + FileResp fileResp = bpmDefinitionService.export(processDefinitionId);
55 54 ServletUtils.writeAttachment(response, fileResp.getFileName(), fileResp.getFileByte());
56 55 }
57 56  
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionPageItemRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
  8 +
  9 +import java.util.Date;
  10 +
  11 +@ApiModel("流程定义的分页的每一项 Response VO")
  12 +@Data
  13 +@EqualsAndHashCode(callSuper = true)
  14 +@ToString(callSuper = true)
  15 +public class BpmProcessDefinitionPageItemRespVO extends ProcessDefinitionRespVO {
  16 +
  17 + @ApiModelProperty(value = "表单名字", example = "请假表单")
  18 + private String formName;
  19 +
  20 + @ApiModelProperty(value = "部署时间", required = true)
  21 + private Date deploymentTime;
  22 +
  23 +
  24 +}
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/processdefinition/ProcessDefinitionPageReqVo.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/BpmProcessDefinitionPageReqVO.java
1   -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition;
  1 +package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 4 import io.swagger.annotations.ApiModel;
... ... @@ -7,14 +7,13 @@ import lombok.Data;
7 7 import lombok.EqualsAndHashCode;
8 8 import lombok.ToString;
9 9  
10   -/**
11   - * @author yunlong.li
12   - */
13 10 @Data
14 11 @ToString(callSuper = true)
15 12 @EqualsAndHashCode(callSuper = true)
16 13 @ApiModel("流程定义分页 Request VO")
17   -public class ProcessDefinitionPageReqVo extends PageParam {
18   - @ApiModelProperty("流程名字")
19   - private String name;
  14 +public class BpmProcessDefinitionPageReqVO extends PageParam {
  15 +
  16 + @ApiModelProperty(value = "标识", example = "process1641042089407", notes = "精准匹配")
  17 + private String key;
  18 +
20 19 }
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/ProcessDefinitionRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +
  7 +import javax.validation.constraints.NotEmpty;
  8 +
  9 +@ApiModel("流程定义 Response VO")
  10 +@Data
  11 +public class ProcessDefinitionRespVO {
  12 +
  13 + @ApiModelProperty(value = "编号", required = true, example = "1024")
  14 + private String id;
  15 +
  16 + @ApiModelProperty(value = "版本", required = true, example = "1")
  17 + private Integer version;
  18 +
  19 + @ApiModelProperty(value = "流程名称", required = true, example = "芋道")
  20 + @NotEmpty(message = "流程名称不能为空")
  21 + private String name;
  22 +
  23 + @ApiModelProperty(value = "流程描述", example = "我是描述")
  24 + private String description;
  25 +
  26 + @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
  27 + @NotEmpty(message = "流程分类不能为空")
  28 + private String category;
  29 +
  30 + @ApiModelProperty(value = "表单编号", example = "1024")
  31 + private Long formId;
  32 +
  33 + @ApiModelProperty(value = "中断状态", required = true, example = "1", notes = "参见 SuspensionState 枚举")
  34 + private Integer suspensionState;
  35 +
  36 +}
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/processdefinition/ProcessDefinitionRespVO.java deleted
1   -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition;
2   -
3   -import io.swagger.annotations.ApiModel;
4   -import lombok.Data;
5   -
6   -/**
7   - * @author yunlong.li
8   - */
9   -@Data
10   -@ApiModel("流程定义数据返回 Request VO")
11   -public class ProcessDefinitionRespVO {
12   -
13   - private String formKey;
14   - private String id;
15   - private String key;
16   - private String name;
17   - private Integer version;
18   -}
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmDefinitionConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition;
  2 +
  3 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
  4 +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
  5 +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
  6 +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
  7 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
  8 +import org.activiti.engine.repository.Deployment;
  9 +import org.activiti.engine.repository.ProcessDefinition;
  10 +import org.mapstruct.Mapper;
  11 +import org.mapstruct.factory.Mappers;
  12 +
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + * Bpm 流程定义的 Convert
  18 + *
  19 + * @author yunlong.li
  20 + */
  21 +@Mapper
  22 +public interface BpmDefinitionConvert {
  23 +
  24 + BpmDefinitionConvert INSTANCE = Mappers.getMapper(BpmDefinitionConvert.class);
  25 +
  26 + default List<BpmProcessDefinitionPageItemRespVO> convertList(List<ProcessDefinition> list, Map<String, Deployment> deploymentMap,
  27 + Map<String, BpmProcessDefinitionDO> processDefinitionDOMap, Map<Long, BpmFormDO> formMap) {
  28 + return CollectionUtils.convertList(list, definition -> {
  29 + Deployment deployment = definition.getDeploymentId() != null ? deploymentMap.get(definition.getDeploymentId()) : null;
  30 + BpmProcessDefinitionDO definitionDO = processDefinitionDOMap.get(definition.getId());
  31 + BpmFormDO form = definitionDO != null ? formMap.get(definitionDO.getFormId()) : null;
  32 + return convert(definition, deployment, definitionDO, form);
  33 + });
  34 + }
  35 +
  36 + default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment,
  37 + BpmProcessDefinitionDO processDefinitionDO, BpmFormDO form) {
  38 + BpmProcessDefinitionPageItemRespVO respVO = convert(bean);
  39 + if (deployment != null) {
  40 + respVO.setDeploymentTime(deployment.getDeploymentTime());
  41 + }
  42 + if (form != null) {
  43 + respVO.setFormId(form.getId());
  44 + respVO.setFormName(form.getName());
  45 + }
  46 + if (processDefinitionDO != null) {
  47 + respVO.setDescription(processDefinitionDO.getDescription());
  48 + }
  49 + return respVO;
  50 + }
  51 +
  52 + BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean);
  53 +
  54 + BpmProcessDefinitionDO convert2(BpmDefinitionCreateReqDTO bean);
  55 +
  56 +}
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/workflow/BpmDefinitionConvert.java deleted
1   -package cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow;
2   -
3   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO;
4   -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
5   -import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
6   -import org.activiti.engine.repository.ProcessDefinition;
7   -import org.mapstruct.Mapper;
8   -import org.mapstruct.factory.Mappers;
9   -
10   -/**
11   - * Bpm 流程定义的 Convert
12   - *
13   - * @author yunlong.li
14   - */
15   -@Mapper
16   -public interface BpmDefinitionConvert {
17   -
18   - BpmDefinitionConvert INSTANCE = Mappers.getMapper(BpmDefinitionConvert.class);
19   -
20   - ProcessDefinitionRespVO convert(ProcessDefinition processDefinition);
21   -
22   - BpmProcessDefinitionDO convert(BpmDefinitionCreateReqDTO bean);
23   -
24   -}
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmProcessDefinitionMapper.java
1 1 package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition;
2 2  
3 3 import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
  4 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 6 import org.apache.ibatis.annotations.Mapper;
6 7  
  8 +import java.util.Collection;
  9 +import java.util.List;
  10 +
7 11 @Mapper
8 12 public interface BpmProcessDefinitionMapper extends BaseMapper<BpmProcessDefinitionDO> {
  13 +
  14 + default List<BpmProcessDefinitionDO> selectListByProcessDefinitionIds(Collection<String> processDefinitionIds) {
  15 + return selectList(new QueryWrapper<BpmProcessDefinitionDO>().in("process_definition_id", processDefinitionIds));
  16 + }
  17 +
9 18 }
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmDefinitionService.java
1 1 package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
2 2  
  3 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
3 4 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
4   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo;
5   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO;
  5 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
6 6 import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
7 7 import cn.iocoder.yudao.framework.common.pojo.PageResult;
8 8 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
... ... @@ -18,21 +18,24 @@ import java.util.Set;
18 18 * 流程定义接口
19 19 *
20 20 * @author yunlong.li
  21 + * @author ZJQ
21 22 */
22 23 public interface BpmDefinitionService {
23 24  
24 25 /**
25   - * 流程定义分页
26   - * @param processDefinitionPageReqVo 分页入参
27   - * @return 分页model
  26 + * 获得流程定义分页
  27 + *
  28 + * @param pageReqVO 分页入参
  29 + * @return 流程定义 Page
28 30 */
29   - PageResult<ProcessDefinitionRespVO> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo);
  31 + PageResult<BpmProcessDefinitionPageItemRespVO> getDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO);
30 32  
31 33 /**
32 34 * 导出流程 bpmn 模型
33 35 * @param processDefinitionId 分页入参
34 36 * @return 分页model
35 37 */
  38 + // TODO 芋艿:考虑下重写
36 39 FileResp export(String processDefinitionId);
37 40  
38 41 /**
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/ProcessServiceImpl.java
1 1 package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
2 2  
3   -import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.ProcessService;
4 3 import lombok.extern.slf4j.Slf4j;
5 4 import org.activiti.engine.RepositoryService;
6 5 import org.activiti.engine.repository.Deployment;
... ... @@ -14,6 +13,7 @@ import java.io.IOException;
14 13 import java.io.InputStream;
15 14 import java.util.List;
16 15 import java.util.zip.ZipInputStream;
  16 +
17 17 import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.FILE_UPLOAD_FAILED;
18 18 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
19 19  
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmDefinitionServiceImpl.java
... ... @@ -2,16 +2,19 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
4 4 import cn.hutool.core.util.StrUtil;
  5 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
  6 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
5 7 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
6   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo;
7   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO;
8   -import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.BpmDefinitionConvert;
  8 +import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmDefinitionConvert;
9 9 import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
  10 +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
10 11 import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessDefinitionMapper;
11 12 import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService;
12 13 import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
  14 +import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService;
13 15 import cn.iocoder.yudao.framework.common.pojo.PageResult;
14 16 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
  17 +import cn.iocoder.yudao.framework.common.util.object.PageUtils;
15 18 import lombok.extern.slf4j.Slf4j;
16 19 import org.activiti.bpmn.converter.BpmnXMLConverter;
17 20 import org.activiti.bpmn.model.BpmnModel;
... ... @@ -24,17 +27,16 @@ import org.springframework.transaction.annotation.Transactional;
24 27 import org.springframework.validation.annotation.Validated;
25 28  
26 29 import javax.annotation.Resource;
27   -import java.util.ArrayList;
28   -import java.util.Collections;
29   -import java.util.List;
30   -import java.util.Set;
31   -import java.util.stream.Collectors;
  30 +import java.util.*;
  31 +
  32 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
32 33  
33 34 /**
34 35 * 流程定义实现
35 36 * 主要进行 Activiti {@link ProcessDefinition} 和 {@link Deployment} 的维护
36 37 *
37 38 * @author yunlongn
  39 + * @author ZJQ
38 40 */
39 41 @Service
40 42 @Validated
... ... @@ -45,28 +47,51 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
45 47  
46 48 @Resource
47 49 private RepositoryService repositoryService;
  50 + @Resource
  51 + private BpmFormService bpmFormService;
48 52  
49 53 @Resource
50 54 private BpmProcessDefinitionMapper processDefinitionMapper;
51 55  
52 56 @Override
53   - public PageResult<ProcessDefinitionRespVO> pageList(ProcessDefinitionPageReqVo processDefinitionPageReqVo) {
54   - ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
55   - String likeName = processDefinitionPageReqVo.getName();
56   - if (StrUtil.isNotBlank(likeName)){
57   - processDefinitionQuery.processDefinitionNameLike("%"+likeName+"%");
  57 + public PageResult<BpmProcessDefinitionPageItemRespVO> getDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) {
  58 + ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();
  59 + if (StrUtil.isNotBlank(pageVO.getKey())) {
  60 + definitionQuery.processDefinitionKey(pageVO.getKey());
  61 + }
  62 + // 执行查询
  63 + List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionId().desc()
  64 + .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
  65 + if (CollUtil.isEmpty(processDefinitions)) {
  66 + return new PageResult<>(Collections.emptyList(), definitionQuery.count());
58 67 }
59   - List<ProcessDefinition> processDefinitions = processDefinitionQuery.orderByProcessDefinitionId().desc()
60   - .listPage((processDefinitionPageReqVo.getPageNo() - 1) * processDefinitionPageReqVo.getPageSize(),
61   - processDefinitionPageReqVo.getPageSize());
62   - final List<ProcessDefinitionRespVO> respVOList = processDefinitions.stream()
63   - .map(BpmDefinitionConvert.INSTANCE::convert).collect(Collectors.toList());
64   - return new PageResult<>(respVOList, processDefinitionQuery.count());
  68 +
  69 + // 获得 Deployment Map
  70 + Set<String> deploymentIds = new HashSet<>();
  71 + processDefinitions.forEach(definition -> CollectionUtils.addIfNotNull(deploymentIds, definition.getDeploymentId()));
  72 + Map<String, Deployment> deploymentMap = getDeploymentMap(deploymentIds);
  73 +
  74 + // 获得 BpmProcessDefinitionDO Map
  75 + List<BpmProcessDefinitionDO> processDefinitionDOs = Collections.emptyList();
  76 + processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds(
  77 + convertList(processDefinitions, ProcessDefinition::getId));
  78 + Map<String, BpmProcessDefinitionDO> processDefinitionDOMap = CollectionUtils.convertMap(processDefinitionDOs,
  79 + BpmProcessDefinitionDO::getProcessDefinitionId);
  80 +
  81 + // 获得 Form Map
  82 + Set<Long> formIds = CollectionUtils.convertSet(processDefinitionDOs, BpmProcessDefinitionDO::getFormId);
  83 + Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds);
  84 +
  85 + // 拼接结果
  86 + long definitionCount = definitionQuery.count();
  87 + return new PageResult<>(BpmDefinitionConvert.INSTANCE.convertList(processDefinitions, deploymentMap,
  88 + processDefinitionDOMap, formMap), definitionCount);
65 89 }
66 90  
67 91 @Override
68 92 public FileResp export(String processDefinitionId) {
69 93 BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
  94 +
70 95 byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(bpmnModel);
71 96 FileResp fileResp = new FileResp();
72 97 fileResp.setFileName( "export");
... ... @@ -121,7 +146,7 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
121 146 repositoryService.setProcessDefinitionCategory(definition.getId(), createReqDTO.getCategory());
122 147  
123 148 // 插入拓展表
124   - BpmProcessDefinitionDO definitionDO = BpmDefinitionConvert.INSTANCE.convert(createReqDTO)
  149 + BpmProcessDefinitionDO definitionDO = BpmDefinitionConvert.INSTANCE.convert2(createReqDTO)
125 150 .setProcessDefinitionId(definition.getId());
126 151 processDefinitionMapper.insert(definitionDO);
127 152 return definition.getId();
... ...
yudao-admin-ui/src/api/bpm/processDefinition.js renamed to yudao-admin-ui/src/api/bpm/definition.js
1 1 import request from '@/utils/request'
2 2  
3   -
4   -export function page(query) {
  3 +export function getDefinitionPage(query) {
5 4 return request({
6   - url: '/workflow/process/definition/page',
  5 + url: '/bpm/definition/page',
7 6 method: 'get',
8 7 params: query
9 8 })
... ...
yudao-admin-ui/src/router/index.js
... ... @@ -179,13 +179,13 @@ export const constantRoutes = [
179 179 {
180 180 path: '/bpm',
181 181 component: Layout,
182   - hidden: true, // TODO 芋艿:未来可删除,暂时作为一个测试页
  182 + hidden: true,
183 183 children: [
184 184 {
185   - path: 'manager/model/view',
186   - component: (resolve) => require(['@/views/bpm/model/modelViewer'], resolve),
187   - name: '流程模型-浏览',
188   - meta: { title: '流程模型-浏览' }
  185 + path: 'manager/definition',
  186 + component: (resolve) => require(['@/views/bpm/definition/index'], resolve),
  187 + name: '流程定义',
  188 + meta: { title: '流程定义' }
189 189 }
190 190 ]
191 191 },
... ...
yudao-admin-ui/src/views/bpm/definition/index.vue 0 → 100644
  1 +<template>
  2 + <div class="app-container">
  3 + <!-- 列表 -->
  4 + <el-table v-loading="loading" :data="list">
  5 + <el-table-column label="ID" align="center" prop="id" />
  6 + <el-table-column label="流程名字" align="center" prop="name" />
  7 + </el-table>
  8 +
  9 + <!-- 分页组件 -->
  10 + <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  11 + @pagination="getList"/>
  12 + </div>
  13 +</template>
  14 +
  15 +<script>
  16 +import {getDefinitionPage} from "@/api/bpm/definition";
  17 +
  18 +export default {
  19 + name: "processDefinition",
  20 + data() {
  21 + return {
  22 + // 遮罩层
  23 + loading: true,
  24 + // 总条数
  25 + total: 0,
  26 + // 表格数据
  27 + list: [],
  28 + // 查询参数
  29 + queryParams: {
  30 + pageNo: 1,
  31 + pageSize: 10
  32 + }
  33 + };
  34 + },
  35 + created() {
  36 + const key = this.$route.query && this.$route.query.key
  37 + if (key) {
  38 + this.queryParams['key'] = key
  39 + }
  40 + this.getList();
  41 + },
  42 + methods: {
  43 + /** 查询流程定义列表 */
  44 + getList() {
  45 + this.loading = true;
  46 + getDefinitionPage(this.queryParams).then(response => {
  47 + this.list = response.data.list;
  48 + this.total = response.data.total;
  49 + this.loading = false;
  50 + }
  51 + );
  52 + },
  53 + }
  54 +};
  55 +</script>
  56 +
... ...
yudao-admin-ui/src/views/bpm/model/index.vue
... ... @@ -68,8 +68,6 @@
68 68 </el-table-column>
69 69 <el-table-column label="激活状态" align="center" prop="processDefinition.version" width="80">
70 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 71 <el-switch v-if="scope.row.processDefinition" v-model="scope.row.processDefinition.suspensionState"
74 72 :active-value="1" :inactive-value="2" @change="handleStatusChange(scope.row)" />
75 73 </template>
... ... @@ -84,7 +82,7 @@
84 82 <template slot-scope="scope">
85 83 <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button>
86 84 <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>
  85 + <el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(scope.row)">流程定义</el-button>
88 86 <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
89 87 </template>
90 88 </el-table-column>
... ... @@ -244,6 +242,15 @@ export default {
244 242 this.showBpmnOpen = true
245 243 })
246 244 },
  245 + /** 跳转流程定义的列表 */
  246 + handleDefinitionList(row) {
  247 + this.$router.push({
  248 + path:"/bpm/manager/definition",
  249 + query:{
  250 + key: row.key
  251 + }
  252 + });
  253 + }
247 254 }
248 255 };
249 256 </script>
... ...
yudao-admin-ui/src/views/bpm/model/modelViewer.vue deleted
1   -<template>
2   - <div class="app-container">
3   -
4   - <!-- 流程设计器,负责绘制流程等 -->
5   - <my-process-viewer key="designer" v-model="xmlString" v-bind="controlForm" keyboard ref="processDesigner" />
6   -
7   - </div>
8   -</template>
9   -
10   -<script>
11   -import {getModel} from "@/api/bpm/model";
12   -export default {
13   - name: "App",
14   - components: { },
15   - data() {
16   - return {
17   - xmlString: "", // BPMN XML
18   - controlForm: {
19   - prefix: "activiti"
20   - },
21   - };
22   - },
23   - created() {
24   - // 如果 modelId 非空,说明是修改流程模型
25   - const modelId = this.$route.query && this.$route.query.modelId
26   - if (modelId) {
27   - getModel(modelId).then(response => {
28   - this.xmlString = response.data.bpmnXml
29   - })
30   - }
31   - }
32   -};
33   -</script>
34   -
35   -<style lang="scss">
36   -
37   -.my-process-designer {
38   - height: calc(100vh - 84px);
39   -}
40   -
41   -</style>
yudao-admin-ui/src/views/bpm/processDefinition/index.vue deleted
1   -<template>
2   - <div class="app-container">
3   - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
4   - <el-form-item label="模型名字" prop="name">
5   - <el-input v-model="queryParams.name" placeholder="请输入模型名字" clearable style="width: 240px;" size="small"
6   - @keyup.enter.native="handleQuery"/>
7   - </el-form-item>
8   - <el-form-item>
9   - <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
10   - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
11   - </el-form-item>
12   - </el-form>
13   - <el-row :gutter="10" class="mb8">
14   - <el-col :span="1.5">
15   - <el-button
16   - type="primary"
17   - icon="el-icon-plus"
18   - size="mini"
19   - @click="openBpmn"
20   - v-hasPermi="['infra:config:create']"
21   - >新建流程</el-button>
22   - </el-col>
23   - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
24   - </el-row>
25   - <el-table v-loading="loading" :data="list">
26   - <el-table-column label="ID" align="center" prop="id" />
27   - <el-table-column label="流程名字" align="center" prop="name" />
28   -<!-- <el-table-column label="创建时间" align="center" prop="createTime" >-->
29   -<!-- <template slot-scope="scope">-->
30   -<!-- <span>{{ parseTime(scope.row.createTime) }}</span>-->
31   -<!-- </template>-->
32   -<!-- </el-table-column>-->
33   - <el-table-column label="操作" align="center" >
34   - <template slot-scope="scope">
35   -<!-- <el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button>-->
36   -<!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="deleteModel(scope.row)">删除</el-button>-->
37   -<!-- <el-button size="mini" type="text" icon="el-icon-thumb" @click="deployModel(scope.row)">发布</el-button>-->
38   - </template>
39   - </el-table-column>
40   - </el-table>
41   -
42   - <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
43   - @pagination="getList"/>
44   - <el-dialog :visible.sync="showBpmnBool" :before-close="close" :fullscreen="true">
45   -<!-- <vue-bpmn v-if="showBpmnBool" product="activiti" @processSave="processSave" :bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="close"></vue-bpmn>-->
46   - </el-dialog>
47   - </div>
48   -</template>
49   -
50   -<script>
51   -import {page} from "@/api/bpm/processDefinition";
52   -// import VueBpmn from "@/components/bpmn/VueBpmn";
53   -
54   -export default {
55   - name: "processDefinition",
56   - data() {
57   - return {
58   - // 遮罩层
59   - loading: true,
60   - // 显示搜索条件
61   - showSearch: true,
62   - showBpmnBool: false,
63   - // 总条数
64   - total: 0,
65   - // 表格数据
66   - list: [],
67   - bpmnXML: null,
68   - bpmnData: {},
69   - // 查询参数
70   - queryParams: {
71   - pageNo: 1,
72   - pageSize: 10
73   - }
74   - };
75   - },
76   - // components: {VueBpmn},
77   - created() {
78   - this.getList();
79   - },
80   - methods: {
81   - /** 查询登录日志列表 */
82   - getList() {
83   - this.loading = true;
84   - page(this.queryParams).then(response => {
85   - this.list = response.data.list;
86   - this.total = response.data.total;
87   - this.loading = false;
88   - }
89   - );
90   -
91   - },
92   - // 登录状态字典翻译
93   - statusFormat(row, column) {
94   - return this.selectDictLabel(this.statusOptions, row.status);
95   - },
96   - /** 搜索按钮操作 */
97   - handleQuery() {
98   - this.queryParams.pageNo = 1;
99   - this.getList();
100   - },
101   - /** 重置按钮操作 */
102   - resetQuery() {
103   - this.dateRange = [];
104   - this.resetForm("queryForm");
105   - this.handleQuery();
106   - },
107   - processSave(data) {
108   - const that = this;
109   - // 如果存在id 说明是修改
110   - if (data.id) {
111   - let postData = JSON.parse(data.metaInfo)
112   - postData.bpmnXml = data.bpmnXml
113   - postData.id = data.id
114   - postData.name = data.name
115   - postData.key = data.key
116   - postData.description = data.description
117   - updateModel(postData).then(response => {
118   - this.msgSuccess("保存成功");
119   - })
120   - this.showBpmnBool = false
121   - this.getList();
122   - return
123   - }
124   - createModel(data).then(response => {
125   - that.bpmnData.id = response.data
126   - this.msgSuccess("保存成功");
127   - })
128   -
129   - this.showBpmnBool = false
130   - this.getList();
131   - },
132   - openBpmn() {
133   - this.bpmnData = {}
134   - this.bpmnXML = ""
135   - this.showBpmnBool = true
136   - },
137   - close() {
138   - this.showBpmnBool = false
139   - this.getList();
140   - },
141   - change(row) {
142   - const that = this;
143   - this.bpmnXML = ""
144   - this.bpmnData = {}
145   - // TODO @芋艿:修改成 getModel
146   - },
147   - modelDelete(row) {
148   - const that = this;
149   - this.$confirm('是否删除该流程!!', "警告", {
150   - confirmButtonText: "确定",
151   - cancelButtonText: "取消",
152   - type: "warning"
153   - }).then(function() {
154   - deleteModel({
155   - modelId: row.id
156   - }).then(response => {
157   - that.getList();
158   - that.msgSuccess("删除成功");
159   - })
160   - })
161   - },
162   - modelDeploy(row) {
163   - const that = this;
164   - this.$confirm('是否部署该流程!!', "提示", {
165   - confirmButtonText: "确定",
166   - cancelButtonText: "取消",
167   - type: "success"
168   - }).then(function() {
169   - deployModel({
170   - modelId: row.id
171   - }).then(response => {
172   - that.getList();
173   - that.msgSuccess("部署成功");
174   - })
175   - })
176   - }
177   - }
178   -};
179   -</script>
180   -<style>
181   -.el-dialog > .el-dialog__body{
182   - margin: 0;
183   - border: 0;
184   -}
185   -.bpmn-viewer-header{
186   - background: white;
187   -}
188   -.v-modal{
189   - z-index: 2000!important;
190   -}
191   -</style>
192   -