【功能优化】 流程发起人,展示抄送节点,用于选择抄送人

This commit is contained in:
jason 2024-11-10 09:05:14 +08:00
parent 31f5aab0cf
commit 396433386c
8 changed files with 25 additions and 23 deletions

View File

@ -35,8 +35,8 @@ public interface ErrorCodeConstants {
ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1_009_004_000, "流程实例不存在");
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1_009_004_001, "流程取消失败,流程不处于运行中");
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1_009_004_002, "流程取消失败,该流程不是你发起的");
ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG = new ErrorCode(1_009_004_003, "审批任务({})的审批人未配置");
ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_EXISTS = new ErrorCode(1_009_004_004, "审批任务({})的审批人({})不存在");
ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG = new ErrorCode(1_009_004_003, "任务({})的候选人未配置");
ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_EXISTS = new ErrorCode(1_009_004_004, "任务({})的候选人({})不存在");
ErrorCode PROCESS_INSTANCE_START_USER_CAN_START = new ErrorCode(1_009_004_005, "发起流程失败,你没有权限发起该流程");
// ========== 流程任务 1-009-005-000 ==========

View File

@ -18,6 +18,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.bpmn.model.Task;
import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
@ -115,9 +116,8 @@ public class BpmProcessDefinitionController {
}
BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService.getProcessDefinitionInfo(processDefinition.getId());
BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(processDefinition.getId());
List<UserTask> userTaskList = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectUserTaskList(bpmnModel);
return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinition(
processDefinition, null, processDefinitionInfo, null, null, bpmnModel, userTaskList));
processDefinition, null, processDefinitionInfo, null, null, bpmnModel));
}
}

View File

@ -54,6 +54,9 @@ public class BpmApprovalDetailRespVO {
@Schema(description = "节点状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
private Integer status; // 参见 BpmTaskStatusEnum 枚举
@Schema(description = "候选人策略", example = "35")
private Integer candidateStrategy; // 用于审批抄送节点
@Schema(description = "节点的开始时间")
private LocalDateTime startTime;
@Schema(description = "节点的结束时间")

View File

@ -11,7 +11,6 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.UserTask;
import org.flowable.common.engine.impl.db.SuspensionState;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
@ -56,7 +55,7 @@ public interface BpmProcessDefinitionConvert {
form = MapUtil.get(formMap, processDefinitionInfo.getFormId(), BpmFormDO.class);
}
BpmCategoryDO category = MapUtil.get(categoryMap, definition.getCategory(), BpmCategoryDO.class);
return buildProcessDefinition(definition, deployment, processDefinitionInfo, form, category, null, null);
return buildProcessDefinition(definition, deployment, processDefinitionInfo, form, category, null);
});
// 排序
result.sort(Comparator.comparing(BpmProcessDefinitionRespVO::getSort));
@ -68,8 +67,7 @@ public interface BpmProcessDefinitionConvert {
BpmProcessDefinitionInfoDO processDefinitionInfo,
BpmFormDO form,
BpmCategoryDO category,
BpmnModel bpmnModel,
List<UserTask> startUserSelectUserTaskList) {
BpmnModel bpmnModel) {
BpmProcessDefinitionRespVO respVO = BeanUtils.toBean(definition, BpmProcessDefinitionRespVO.class);
respVO.setSuspensionState(definition.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode());
// Deployment
@ -91,7 +89,6 @@ public interface BpmProcessDefinitionConvert {
// BpmnModel
if (bpmnModel != null) {
respVO.setBpmnXml(BpmnModelUtils.getBpmnXml(bpmnModel));
respVO.setStartUserSelectTasks(BeanUtils.toBean(startUserSelectUserTaskList, BpmProcessDefinitionRespVO.UserTask.class));
}
return respVO;
}

View File

@ -26,7 +26,6 @@ import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcess
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
@ -243,9 +242,8 @@ public interface BpmProcessInstanceConvert {
}
// 1.2 流程定义
List<UserTask> userTaskList = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectUserTaskList(bpmnModel);
BpmProcessDefinitionRespVO definitionResp = BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinition(
processDefinition, null, processDefinitionInfo, null, null, bpmnModel, userTaskList);
processDefinition, null, processDefinitionInfo, null, null, bpmnModel);
// 1.3 流程节点
activityNodes.forEach(approveNode -> {

View File

@ -10,13 +10,16 @@ import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
import com.google.common.collect.Sets;
import jakarta.annotation.Resource;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.UserTask;
import org.flowable.bpmn.model.Task;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* 发起人自选 {@link BpmTaskCandidateUserStrategy} 实现类
@ -71,22 +74,22 @@ public class BpmTaskCandidateStartUserSelectStrategy extends AbstractBpmTaskCand
}
/**
* 获得发起人自选审批人 UserTask 列表
* 获得发起人自选审批人或抄送人 Task 列表
*
* @param bpmnModel BPMN 模型
* @return UserTask 列表
* @return Task 列表
*/
public static List<UserTask> getStartUserSelectUserTaskList(BpmnModel bpmnModel) {
public static <T extends Task> List<T> getStartUserSelectUserTaskList(BpmnModel bpmnModel, Class<T> TaskClass ) {
if (bpmnModel == null) {
return null;
}
List<UserTask> userTaskList = BpmnModelUtils.getBpmnModelElements(bpmnModel, UserTask.class);
if (CollUtil.isEmpty(userTaskList)) {
List<T> tasks = BpmnModelUtils.getBpmnModelElements(bpmnModel, TaskClass);
if (CollUtil.isEmpty(tasks)) {
return null;
}
userTaskList.removeIf(userTask -> !Objects.equals(BpmnModelUtils.parseCandidateStrategy(userTask),
tasks.removeIf(serviceTask -> !Objects.equals(BpmnModelUtils.parseCandidateStrategy(serviceTask),
BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy()));
return userTaskList;
return tasks;
}
}

View File

@ -628,10 +628,11 @@ public class SimpleModelUtils {
BpmSimpleModelNodeType nodeType = BpmSimpleModelNodeType.valueOf(currentNode.getType());
Assert.notNull(nodeType, "模型节点类型不支持");
// 情况START_NODE/START_USER_NODE/APPROVE_NODE/END_NODE
// 情况START_NODE/START_USER_NODE/APPROVE_NODE/COPY_NODE/END_NODE
if (nodeType == BpmSimpleModelNodeType.START_NODE
|| nodeType == BpmSimpleModelNodeType.START_USER_NODE
|| nodeType == BpmSimpleModelNodeType.APPROVE_NODE
|| nodeType == BpmSimpleModelNodeType.COPY_NODE
|| nodeType == BpmSimpleModelNodeType.END_NODE) {
// 添加元素
resultNodes.add(currentNode);