Commit 9927dd443944d787423726cdfa3f4e00ca7e0bf9

Authored by YunaiV
1 parent fedb9242

【功能新增】BPM:增加流程定义的 simple 接口

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java
... ... @@ -57,7 +57,7 @@ public class BpmModelController {
57 57 @GetMapping("/list")
58 58 @Operation(summary = "获得模型分页")
59 59 @Parameter(name = "name", description = "模型名称", example = "芋艿")
60   - public CommonResult<List<BpmModelRespVO>> getModelPage(@RequestParam(value = "name", required = false) String name) {
  60 + public CommonResult<List<BpmModelRespVO>> getModelList(@RequestParam(value = "name", required = false) String name) {
61 61 List<Model> list = modelService.getModelList(name);
62 62 if (CollUtil.isEmpty(list)) {
63 63 return success(Collections.emptyList());
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java
... ... @@ -17,6 +17,7 @@ import io.swagger.v3.oas.annotations.Parameter;
17 17 import io.swagger.v3.oas.annotations.tags.Tag;
18 18 import jakarta.annotation.Resource;
19 19 import org.flowable.bpmn.model.BpmnModel;
  20 +import org.flowable.common.engine.impl.db.SuspensionState;
20 21 import org.flowable.engine.repository.Deployment;
21 22 import org.flowable.engine.repository.ProcessDefinition;
22 23 import org.springframework.security.access.prepost.PreAuthorize;
... ... @@ -31,6 +32,7 @@ import java.util.List;
31 32 import java.util.Map;
32 33  
33 34 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  35 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
34 36 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
35 37 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
36 38  
... ... @@ -99,6 +101,17 @@ public class BpmProcessDefinitionController {
99 101 list, null, processDefinitionMap, null, null));
100 102 }
101 103  
  104 + @GetMapping("/simple-list")
  105 + @Operation(summary = "获得流程定义精简列表", description = "只包含未挂起的流程,主要用于前端的下拉选项")
  106 + public CommonResult<List<BpmProcessDefinitionRespVO>> getSimpleProcessDefinitionList() {
  107 + // 只查询未挂起的流程
  108 + List<ProcessDefinition> list = processDefinitionService.getProcessDefinitionListBySuspensionState(
  109 + SuspensionState.ACTIVE.getStateCode());
  110 + // 拼接 VO 返回,只返回 id、name、key
  111 + return success(convertList(list, definition -> new BpmProcessDefinitionRespVO()
  112 + .setId(definition.getId()).setName(definition.getName()).setKey(definition.getKey())));
  113 + }
  114 +
102 115 @GetMapping ("/get")
103 116 @Operation(summary = "获得流程定义")
104 117 @Parameter(name = "id", description = "流程编号", required = true, example = "1024")
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java
... ... @@ -32,10 +32,10 @@ import org.springframework.web.bind.annotation.*;
32 32  
33 33 import java.util.List;
34 34 import java.util.Map;
  35 +import java.util.Set;
35 36  
36 37 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
37   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
38   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  38 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
39 39 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
40 40  
41 41 @Tag(name = "管理后台 - 流程实例") // 流程实例,通过流程定义创建的一次“申请”
... ... @@ -78,8 +78,14 @@ public class BpmProcessInstanceController {
78 78 convertSet(processDefinitionMap.values(), ProcessDefinition::getCategory));
79 79 Map<String, BpmProcessDefinitionInfoDO> processDefinitionInfoMap = processDefinitionService.getProcessDefinitionInfoMap(
80 80 convertSet(pageResult.getList(), HistoricProcessInstance::getProcessDefinitionId));
  81 + Set<Long> userIds = convertSet(pageResult.getList(), processInstance -> NumberUtils.parseLong(processInstance.getStartUserId()));
  82 + userIds.addAll(convertSetByFlatMap(taskMap.values(),
  83 + tasks -> tasks.stream().map(Task::getAssignee).filter(StrUtil::isNotBlank).map(Long::parseLong)));
  84 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
  85 + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
  86 + convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
81 87 return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstancePage(pageResult,
82   - processDefinitionMap, categoryMap, taskMap, null, null, processDefinitionInfoMap));
  88 + processDefinitionMap, categoryMap, taskMap, userMap, deptMap, processDefinitionInfoMap));
83 89 }
84 90  
85 91 @GetMapping("/manager-page")
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java
... ... @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
3 3 import cn.iocoder.yudao.framework.common.core.KeyValue;
4 4 import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
5 5 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
  6 +import com.fasterxml.jackson.annotation.JsonIgnore;
6 7 import io.swagger.v3.oas.annotations.media.Schema;
7 8 import lombok.Data;
8 9  
... ... @@ -73,6 +74,13 @@ public class BpmProcessInstanceRespVO {
73 74 @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
74 75 private String name;
75 76  
  77 + @Schema(description = "任务分配人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2048")
  78 + @JsonIgnore // 不返回,只是方便后续读取,赋值给 assigneeUser
  79 + private Long assignee;
  80 +
  81 + @Schema(description = "任务分配人", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2048")
  82 + private UserSimpleBaseVO assigneeUser;
  83 +
76 84 }
77 85  
78 86 }
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java
... ... @@ -18,6 +18,9 @@ public class BpmTaskPageReqVO extends PageParam {
18 18 @Schema(description = "流程分类", example = "1")
19 19 private String category;
20 20  
  21 + @Schema(description = "流程定义的标识", example = "2048")
  22 + private String processDefinitionKey; // 精准匹配
  23 +
21 24 @Schema(description = "创建时间")
22 25 @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
23 26 private LocalDateTime[] createTime;
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java
... ... @@ -76,6 +76,15 @@ public interface BpmProcessInstanceConvert {
76 76 respVO.setStartUser(BeanUtils.toBean(startUser, UserSimpleBaseVO.class));
77 77 MapUtils.findAndThen(deptMap, startUser.getDeptId(), dept -> respVO.getStartUser().setDeptName(dept.getName()));
78 78 }
  79 + if (CollUtil.isNotEmpty(respVO.getTasks())) {
  80 + respVO.getTasks().forEach(task -> {
  81 + AdminUserRespDTO assigneeUser = userMap.get(task.getAssignee());
  82 + if (assigneeUser!= null) {
  83 + task.setAssigneeUser(BeanUtils.toBean(assigneeUser, UserSimpleBaseVO.class));
  84 + MapUtils.findAndThen(deptMap, assigneeUser.getDeptId(), dept -> task.getAssigneeUser().setDeptName(dept.getName()));
  85 + }
  86 + });
  87 + }
79 88 }
80 89 // 摘要
81 90 respVO.setSummary(FlowableUtils.getSummary(processDefinitionInfoMap.get(respVO.getProcessDefinitionId()),
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java
... ... @@ -85,7 +85,6 @@ public interface BpmProcessInstanceService {
85 85 PageResult<HistoricProcessInstance> getProcessInstancePage(Long userId,
86 86 @Valid BpmProcessInstancePageReqVO pageReqVO);
87 87  
88   - // TODO @芋艿:重点在 review 下
89 88 /**
90 89 * 获取审批详情。
91 90 * <p>
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
... ... @@ -122,6 +122,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
122 122 if (StrUtil.isNotEmpty(pageVO.getCategory())) {
123 123 taskQuery.taskCategory(pageVO.getCategory());
124 124 }
  125 + if (StrUtil.isNotEmpty(pageVO.getProcessDefinitionKey())) {
  126 + taskQuery.processDefinitionKey(pageVO.getProcessDefinitionKey());
  127 + }
125 128 if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
126 129 taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
127 130 taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
... ...