mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
【代码评审】工作流:抄送的实现逻辑
This commit is contained in:
parent
040a1bcfad
commit
b98421dfc6
@ -113,6 +113,7 @@ public interface BpmTaskConvert {
|
||||
}
|
||||
if (BpmTaskStatusEnum.RUNNING.getStatus().equals(taskStatus)){
|
||||
// 设置表单权限 TODO @芋艿 是不是还要加一个全局的权限 基于 processInstance 的权限;回复:可能不需要,但是发起人,需要有个权限配置
|
||||
// TODO @jason:貌似这么返回,主要解决当前审批 task 的表单权限,但是不同抄送人的表单权限,可能不太对。例如说,对 A 抄送人是隐藏某个字段。
|
||||
taskVO.setFieldsPermission(BpmnModelUtils.parseFormFieldsPermission(bpmnModel, task.getTaskDefinitionKey()));
|
||||
// 操作按钮设置
|
||||
taskVO.setButtonsSetting(BpmnModelUtils.parseButtonsSetting(bpmnModel, task.getTaskDefinitionKey()));
|
||||
|
@ -3,11 +3,11 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
|
||||
/**
|
||||
* BPM 通用常量
|
||||
* BPM Variable 通用常量
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class BpmConstants {
|
||||
public class BpmnVariableConstants {
|
||||
|
||||
/**
|
||||
* 流程实例的变量 - 状态
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
|
||||
|
||||
// TODO @jason:要不合并到 BpmnModelConstants 那
|
||||
/**
|
||||
* 仿钉钉快搭 JSON 常量信息
|
||||
*
|
||||
@ -7,12 +8,6 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
|
||||
*/
|
||||
public interface SimpleModelConstants {
|
||||
|
||||
// TODO @芋艿:审批方式的名字,可能要看下;
|
||||
/**
|
||||
* 审批方式属性
|
||||
*/
|
||||
String APPROVE_METHOD_ATTRIBUTE = "approveMethod";
|
||||
|
||||
// TODO @芋艿:条件表达式的字段名
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.custom.delegate;
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
||||
@ -11,13 +11,19 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.BpmCopyTaskDelegate.BEAN_NAME;
|
||||
|
||||
/**
|
||||
* 处理抄送用户的 {@link JavaDelegate} 的实现类
|
||||
*
|
||||
* 目前只有快搭模式的【抄送节点】使用
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Component
|
||||
public class BpmCopyTaskDelegate implements JavaDelegate {
|
||||
@Component(BEAN_NAME)
|
||||
public class BpmCopyTaskDelegate implements JavaDelegate {
|
||||
|
||||
public static final String BEAN_NAME = "bpmCopyTaskDelegate";
|
||||
|
||||
@Resource
|
||||
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants;
|
||||
import org.flowable.common.engine.api.delegate.Expression;
|
||||
import org.flowable.common.engine.api.variable.VariableContainer;
|
||||
import org.flowable.common.engine.impl.el.ExpressionManager;
|
||||
@ -91,7 +91,7 @@ public class FlowableUtils {
|
||||
* @return 状态
|
||||
*/
|
||||
private static Integer getProcessInstanceStatus(Map<String, Object> processVariables) {
|
||||
return (Integer) processVariables.get(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS);
|
||||
return (Integer) processVariables.get(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_STATUS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +115,7 @@ public class FlowableUtils {
|
||||
* @return 过滤后的表单
|
||||
*/
|
||||
public static Map<String, Object> filterProcessInstanceFormVariable(Map<String, Object> processVariables) {
|
||||
processVariables.remove(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS);
|
||||
processVariables.remove(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_STATUS);
|
||||
return processVariables;
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ public class FlowableUtils {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, List<Long>> getStartUserSelectAssignees(ProcessInstance processInstance) {
|
||||
return (Map<String, List<Long>>) processInstance.getProcessVariables().get(
|
||||
BpmConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES);
|
||||
BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES);
|
||||
}
|
||||
|
||||
// ========== Task 相关的工具方法 ==========
|
||||
@ -140,7 +140,7 @@ public class FlowableUtils {
|
||||
* @return 状态
|
||||
*/
|
||||
public static Integer getTaskStatus(TaskInfo task) {
|
||||
return (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS);
|
||||
return (Integer) task.getTaskLocalVariables().get(BpmnVariableConstants.TASK_VARIABLE_STATUS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,7 +150,7 @@ public class FlowableUtils {
|
||||
* @return 审批原因
|
||||
*/
|
||||
public static String getTaskReason(TaskInfo task) {
|
||||
return (String) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_REASON);
|
||||
return (String) task.getTaskLocalVariables().get(BpmnVariableConstants.TASK_VARIABLE_REASON);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,8 +174,8 @@ public class FlowableUtils {
|
||||
* @return 过滤后的表单
|
||||
*/
|
||||
public static Map<String, Object> filterTaskFormVariable(Map<String, Object> taskLocalVariables) {
|
||||
taskLocalVariables.remove(BpmConstants.TASK_VARIABLE_STATUS);
|
||||
taskLocalVariables.remove(BpmConstants.TASK_VARIABLE_REASON);
|
||||
taskLocalVariables.remove(BpmnVariableConstants.TASK_VARIABLE_STATUS);
|
||||
taskLocalVariables.remove(BpmnVariableConstants.TASK_VARIABLE_REASON);
|
||||
return taskLocalVariables;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.B
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.RejectHandler;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.*;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.BpmCopyTaskDelegate;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.simplemodel.SimpleModelConditionGroups;
|
||||
import org.flowable.bpmn.BpmnAutoLayout;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
@ -277,20 +278,22 @@ public class SimpleModelUtils {
|
||||
private static List<FlowElement> buildFlowNode(BpmSimpleModelNodeVO node, BpmSimpleModelNodeType nodeType) {
|
||||
List<FlowElement> list = new ArrayList<>();
|
||||
switch (nodeType) {
|
||||
case START_NODE: {
|
||||
// @芋艿 改成 convert 是不是好理解一点
|
||||
case START_NODE: { // 开始节点
|
||||
StartEvent startEvent = convertStartNode(node);
|
||||
list.add(startEvent);
|
||||
break;
|
||||
}
|
||||
case APPROVE_NODE: {
|
||||
// TODO @芋艿 改成 convertXXXNode, , 方面里面使用 buildBpmnXXXNode. 是否更好理解
|
||||
// 转换审批节点
|
||||
case END_NODE: { // 结束节点
|
||||
EndEvent endEvent = convertEndNode(node);
|
||||
list.add(endEvent);
|
||||
break;
|
||||
}
|
||||
case APPROVE_NODE: { // 审批节点
|
||||
List<FlowElement> flowElements = convertApproveNode(node);
|
||||
list.addAll(flowElements);
|
||||
break;
|
||||
}
|
||||
case COPY_NODE: {
|
||||
case COPY_NODE: { // 抄送节点
|
||||
ServiceTask serviceTask = convertCopyNode(node);
|
||||
list.add(serviceTask);
|
||||
break;
|
||||
@ -316,11 +319,6 @@ public class SimpleModelUtils {
|
||||
list.add(inclusiveGateway);
|
||||
break;
|
||||
}
|
||||
case END_NODE: {
|
||||
EndEvent endEvent = convertEndNode(node);
|
||||
list.add(endEvent);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// TODO 其它节点类型的实现
|
||||
}
|
||||
@ -389,13 +387,11 @@ public class SimpleModelUtils {
|
||||
serviceTask.setId(node.getId());
|
||||
serviceTask.setName(node.getName());
|
||||
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
|
||||
serviceTask.setImplementation("${bpmCopyTaskDelegate}");
|
||||
serviceTask.setImplementation("${" + BpmCopyTaskDelegate.BEAN_NAME + "}");
|
||||
|
||||
// 添加抄送候选人元素
|
||||
addCandidateElements(node.getCandidateStrategy(), node.getCandidateParam(), serviceTask);
|
||||
|
||||
// 添加表单字段权限属性元素
|
||||
// TODO @芋艿:这块关注下哈;
|
||||
addFormFieldsPermission(node.getFieldsPermission(), serviceTask);
|
||||
return serviceTask;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -19,7 +19,7 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmReasonEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskSignTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
|
||||
@ -446,7 +446,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
} else if (BpmTaskSignTypeEnum.AFTER.getType().equals(scopeType)) {
|
||||
// 只有 parentTask 处于 APPROVING 的情况下,才可以继续 complete 完成
|
||||
// 否则,一个未审批的 parentTask 任务,在加签出来的任务都被减签的情况下,就直接完成审批,这样会存在问题
|
||||
Integer status = (Integer) parentTask.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS);
|
||||
Integer status = (Integer) parentTask.getTaskLocalVariables().get(BpmnVariableConstants.TASK_VARIABLE_STATUS);
|
||||
if (ObjectUtil.notEqual(status, BpmTaskStatusEnum.APPROVING.getStatus())) {
|
||||
return;
|
||||
}
|
||||
@ -531,7 +531,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
* @param status 状态
|
||||
*/
|
||||
private void updateTaskStatus(String id, Integer status) {
|
||||
taskService.setVariableLocal(id, BpmConstants.TASK_VARIABLE_STATUS, status);
|
||||
taskService.setVariableLocal(id, BpmnVariableConstants.TASK_VARIABLE_STATUS, status);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -543,7 +543,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
*/
|
||||
private void updateTaskStatusAndReason(String id, Integer status, String reason) {
|
||||
updateTaskStatus(id, status);
|
||||
taskService.setVariableLocal(id, BpmConstants.TASK_VARIABLE_REASON, reason);
|
||||
taskService.setVariableLocal(id, BpmnVariableConstants.TASK_VARIABLE_REASON, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -692,7 +692,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
// 疑问:为什么不通过 updateTaskStatusWhenCanceled 监听取消,而是直接提前调用呢?
|
||||
// 回答:详细见 updateTaskStatusWhenCanceled 的方法,加签的场景
|
||||
taskList.forEach(task -> {
|
||||
Integer otherTaskStatus = (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS);
|
||||
Integer otherTaskStatus = (Integer) task.getTaskLocalVariables().get(BpmnVariableConstants.TASK_VARIABLE_STATUS);
|
||||
if (BpmTaskStatusEnum.isEndStatus(otherTaskStatus)) {
|
||||
return;
|
||||
}
|
||||
@ -884,7 +884,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
@Override
|
||||
public void processTaskCreated(Task task) {
|
||||
Integer status = (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS);
|
||||
Integer status = (Integer) task.getTaskLocalVariables().get(BpmnVariableConstants.TASK_VARIABLE_STATUS);
|
||||
if (status != null) {
|
||||
log.error("[updateTaskStatusWhenCreated][taskId({}) 已经有状态({})]", task.getId(), status);
|
||||
return;
|
||||
@ -908,7 +908,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
}
|
||||
|
||||
// 2. 更新 task 状态 + 原因
|
||||
Integer status = (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS);
|
||||
Integer status = (Integer) task.getTaskLocalVariables().get(BpmnVariableConstants.TASK_VARIABLE_STATUS);
|
||||
if (BpmTaskStatusEnum.isEndStatus(status)) {
|
||||
log.error("[updateTaskStatusWhenCanceled][taskId({}) 处于结果({}),无需进行更新]", taskId, status);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user