【功能新增】BPM:增加流程定义的 simple 接口
This commit is contained in:
parent
fedb9242b5
commit
9927dd4439
|
@ -57,7 +57,7 @@ public class BpmModelController {
|
|||
@GetMapping("/list")
|
||||
@Operation(summary = "获得模型分页")
|
||||
@Parameter(name = "name", description = "模型名称", example = "芋艿")
|
||||
public CommonResult<List<BpmModelRespVO>> getModelPage(@RequestParam(value = "name", required = false) String name) {
|
||||
public CommonResult<List<BpmModelRespVO>> getModelList(@RequestParam(value = "name", required = false) String name) {
|
||||
List<Model> list = modelService.getModelList(name);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return success(Collections.emptyList());
|
||||
|
|
|
@ -17,6 +17,7 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
@ -31,6 +32,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
|
@ -99,6 +101,17 @@ public class BpmProcessDefinitionController {
|
|||
list, null, processDefinitionMap, null, null));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得流程定义精简列表", description = "只包含未挂起的流程,主要用于前端的下拉选项")
|
||||
public CommonResult<List<BpmProcessDefinitionRespVO>> getSimpleProcessDefinitionList() {
|
||||
// 只查询未挂起的流程
|
||||
List<ProcessDefinition> list = processDefinitionService.getProcessDefinitionListBySuspensionState(
|
||||
SuspensionState.ACTIVE.getStateCode());
|
||||
// 拼接 VO 返回,只返回 id、name、key
|
||||
return success(convertList(list, definition -> new BpmProcessDefinitionRespVO()
|
||||
.setId(definition.getId()).setName(definition.getName()).setKey(definition.getKey())));
|
||||
}
|
||||
|
||||
@GetMapping ("/get")
|
||||
@Operation(summary = "获得流程定义")
|
||||
@Parameter(name = "id", description = "流程编号", required = true, example = "1024")
|
||||
|
|
|
@ -32,10 +32,10 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 流程实例") // 流程实例,通过流程定义创建的一次“申请”
|
||||
|
@ -78,8 +78,14 @@ public class BpmProcessInstanceController {
|
|||
convertSet(processDefinitionMap.values(), ProcessDefinition::getCategory));
|
||||
Map<String, BpmProcessDefinitionInfoDO> processDefinitionInfoMap = processDefinitionService.getProcessDefinitionInfoMap(
|
||||
convertSet(pageResult.getList(), HistoricProcessInstance::getProcessDefinitionId));
|
||||
Set<Long> userIds = convertSet(pageResult.getList(), processInstance -> NumberUtils.parseLong(processInstance.getStartUserId()));
|
||||
userIds.addAll(convertSetByFlatMap(taskMap.values(),
|
||||
tasks -> tasks.stream().map(Task::getAssignee).filter(StrUtil::isNotBlank).map(Long::parseLong)));
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
|
||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
|
||||
convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
||||
return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstancePage(pageResult,
|
||||
processDefinitionMap, categoryMap, taskMap, null, null, processDefinitionInfoMap));
|
||||
processDefinitionMap, categoryMap, taskMap, userMap, deptMap, processDefinitionInfoMap));
|
||||
}
|
||||
|
||||
@GetMapping("/manager-page")
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
|
|||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -73,6 +74,13 @@ public class BpmProcessInstanceRespVO {
|
|||
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "任务分配人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2048")
|
||||
@JsonIgnore // 不返回,只是方便后续读取,赋值给 assigneeUser
|
||||
private Long assignee;
|
||||
|
||||
@Schema(description = "任务分配人", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2048")
|
||||
private UserSimpleBaseVO assigneeUser;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ public class BpmTaskPageReqVO extends PageParam {
|
|||
@Schema(description = "流程分类", example = "1")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "流程定义的标识", example = "2048")
|
||||
private String processDefinitionKey; // 精准匹配
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
|
|
@ -76,6 +76,15 @@ public interface BpmProcessInstanceConvert {
|
|||
respVO.setStartUser(BeanUtils.toBean(startUser, UserSimpleBaseVO.class));
|
||||
MapUtils.findAndThen(deptMap, startUser.getDeptId(), dept -> respVO.getStartUser().setDeptName(dept.getName()));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(respVO.getTasks())) {
|
||||
respVO.getTasks().forEach(task -> {
|
||||
AdminUserRespDTO assigneeUser = userMap.get(task.getAssignee());
|
||||
if (assigneeUser!= null) {
|
||||
task.setAssigneeUser(BeanUtils.toBean(assigneeUser, UserSimpleBaseVO.class));
|
||||
MapUtils.findAndThen(deptMap, assigneeUser.getDeptId(), dept -> task.getAssigneeUser().setDeptName(dept.getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// 摘要
|
||||
respVO.setSummary(FlowableUtils.getSummary(processDefinitionInfoMap.get(respVO.getProcessDefinitionId()),
|
||||
|
|
|
@ -85,7 +85,6 @@ public interface BpmProcessInstanceService {
|
|||
PageResult<HistoricProcessInstance> getProcessInstancePage(Long userId,
|
||||
@Valid BpmProcessInstancePageReqVO pageReqVO);
|
||||
|
||||
// TODO @芋艿:重点在 review 下
|
||||
/**
|
||||
* 获取审批详情。
|
||||
* <p>
|
||||
|
|
|
@ -122,6 +122,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||
if (StrUtil.isNotEmpty(pageVO.getCategory())) {
|
||||
taskQuery.taskCategory(pageVO.getCategory());
|
||||
}
|
||||
if (StrUtil.isNotEmpty(pageVO.getProcessDefinitionKey())) {
|
||||
taskQuery.processDefinitionKey(pageVO.getProcessDefinitionKey());
|
||||
}
|
||||
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
|
||||
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
|
||||
taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
|
||||
|
|
Loading…
Reference in New Issue