mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-31 17:40:05 +08:00
仿钉钉流程设计- code review 修改
This commit is contained in:
parent
5c2fcdce15
commit
479d664a63
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType;
|
import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
@ -46,6 +47,7 @@ public class BpmSimpleModelNodeVO {
|
|||||||
* 附加节点 Id, 该节点不从前端传入。 由程序生成. 由于当个节点无法完成功能。 需要附加节点来完成。
|
* 附加节点 Id, 该节点不从前端传入。 由程序生成. 由于当个节点无法完成功能。 需要附加节点来完成。
|
||||||
* 例如: 会签时需要按拒绝人数来终止流程。 需要 userTask + ServiceTask 两个节点配合完成。 serviceTask 由后端生成。
|
* 例如: 会签时需要按拒绝人数来终止流程。 需要 userTask + ServiceTask 两个节点配合完成。 serviceTask 由后端生成。
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
private String attachNodeId;
|
private String attachNodeId;
|
||||||
// Map<String, Integer> formPermissions; 表单权限;仅发起、审批、抄送节点会使用
|
// Map<String, Integer> formPermissions; 表单权限;仅发起、审批、抄送节点会使用
|
||||||
// Integer approveMethod; 审批方式;仅审批节点会使用
|
// Integer approveMethod; 审批方式;仅审批节点会使用
|
||||||
|
@ -1,38 +1,35 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.service.task;
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.custom.delegate;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceCopyService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.flowable.bpmn.model.FlowElement;
|
import org.flowable.bpmn.model.FlowElement;
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
|
import org.flowable.engine.delegate.JavaDelegate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仿钉钉快搭各个节点 Service
|
* 处理抄送用户的代理
|
||||||
*
|
*
|
||||||
* @author jason
|
* @author jason
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class BpmSimpleNodeService {
|
public class CopyUserDelegate implements JavaDelegate {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
||||||
@Resource
|
@Resource
|
||||||
private BpmProcessInstanceCopyService processInstanceCopyService;
|
private BpmProcessInstanceCopyService processInstanceCopyService;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 仿钉钉快搭抄送
|
public void execute(DelegateExecution execution) {
|
||||||
*
|
|
||||||
* @param execution 执行的任务(ScriptTask)
|
|
||||||
*/
|
|
||||||
public Boolean copy(DelegateExecution execution) {
|
|
||||||
// TODO @芋艿:可能要考虑,系统抄送,没有 taskId 的情况。
|
// TODO @芋艿:可能要考虑,系统抄送,没有 taskId 的情况。
|
||||||
Set<Long> userIds = taskCandidateInvoker.calculateUsers(execution);
|
Set<Long> userIds = taskCandidateInvoker.calculateUsers(execution);
|
||||||
FlowElement currentFlowElement = execution.getCurrentFlowElement();
|
FlowElement currentFlowElement = execution.getCurrentFlowElement();
|
||||||
processInstanceCopyService.createProcessInstanceCopy(userIds, execution.getProcessInstanceId(),
|
processInstanceCopyService.createProcessInstanceCopy(userIds, execution.getProcessInstanceId(),
|
||||||
currentFlowElement.getId(), currentFlowElement.getName());
|
currentFlowElement.getId(), currentFlowElement.getName());
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.expression;
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.custom.delegate;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.BooleanUtil;
|
import cn.hutool.core.util.BooleanUtil;
|
||||||
@ -12,12 +12,12 @@ import org.flowable.engine.delegate.JavaDelegate;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理会签 Service Task 代理表达式
|
* 处理会签 Service Task 代理
|
||||||
*
|
*
|
||||||
* @author jason
|
* @author jason
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class MultiInstanceServiceTaskExpression implements JavaDelegate {
|
public class MultiInstanceServiceTaskDelegate implements JavaDelegate {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BpmProcessInstanceService processInstanceService;
|
private BpmProcessInstanceService processInstanceService;
|
||||||
@ -35,4 +35,5 @@ public class MultiInstanceServiceTaskExpression implements JavaDelegate {
|
|||||||
BpmCommentTypeEnum.REJECT.formatComment("会签任务拒绝人数满足条件"));
|
BpmCommentTypeEnum.REJECT.formatComment("会签任务拒绝人数满足条件"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.expression;
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.custom.expression;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
@ -44,8 +44,6 @@ public class SimpleModelUtils {
|
|||||||
*/
|
*/
|
||||||
public static final String JOIN_GATE_WAY_NODE_ID_SUFFIX = "_join";
|
public static final String JOIN_GATE_WAY_NODE_ID_SUFFIX = "_join";
|
||||||
|
|
||||||
public static final String BPMN_SIMPLE_COPY_EXECUTION_SCRIPT = "#{bpmSimpleNodeService.copy(execution)}";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有审批人同意的表达式
|
* 所有审批人同意的表达式
|
||||||
*/
|
*/
|
||||||
@ -371,7 +369,7 @@ public class SimpleModelUtils {
|
|||||||
serviceTask.setId(id);
|
serviceTask.setId(id);
|
||||||
serviceTask.setName("会签服务任务");
|
serviceTask.setName("会签服务任务");
|
||||||
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
|
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
|
||||||
serviceTask.setImplementation("${multiInstanceServiceTaskExpression}");
|
serviceTask.setImplementation("${multiInstanceServiceTaskDelegate}");
|
||||||
serviceTask.setAsynchronous(false);
|
serviceTask.setAsynchronous(false);
|
||||||
addExtensionElement(serviceTask, SERVICE_TASK_ATTACH_USER_TASK_ID, node.getId());
|
addExtensionElement(serviceTask, SERVICE_TASK_ATTACH_USER_TASK_ID, node.getId());
|
||||||
node.setAttachNodeId(id);
|
node.setAttachNodeId(id);
|
||||||
@ -417,9 +415,8 @@ public class SimpleModelUtils {
|
|||||||
ServiceTask serviceTask = new ServiceTask();
|
ServiceTask serviceTask = new ServiceTask();
|
||||||
serviceTask.setId(node.getId());
|
serviceTask.setId(node.getId());
|
||||||
serviceTask.setName(node.getName());
|
serviceTask.setName(node.getName());
|
||||||
// TODO @jason:建议用 delegateExpression;原因是,直接走 bpmSimpleNodeService.copy(execution) 的话,万一后续抄送改实现,可能比较麻烦。最好是搞个独立的 bean,然后它去调用抄 bpmSimpleNodeService;
|
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
|
||||||
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
|
serviceTask.setImplementation("${copyUserDelegate}");
|
||||||
serviceTask.setImplementation(BPMN_SIMPLE_COPY_EXECUTION_SCRIPT);
|
|
||||||
|
|
||||||
// 添加抄送候选人元素
|
// 添加抄送候选人元素
|
||||||
addCandidateElements(MapUtil.getInt(node.getAttributes(), BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY),
|
addCandidateElements(MapUtil.getInt(node.getAttributes(), BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY),
|
||||||
|
@ -47,7 +47,7 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
|||||||
// TODO @芋艿:这里多加了一个 name;
|
// TODO @芋艿:这里多加了一个 name;
|
||||||
@Override
|
@Override
|
||||||
public void createProcessInstanceCopy(Collection<Long> userIds, String processInstanceId, String taskId, String taskName) {
|
public void createProcessInstanceCopy(Collection<Long> userIds, String processInstanceId, String taskId, String taskName) {
|
||||||
// 1.1 校验任务存在 暂时去掉这个校验. 因为任务可能仿钉钉快搭的抄送节点(ScriptTask) TODO jason:抄送节点,会没有来源的 taskId 么? @芋艿 是否校验一下 传递进来的 id 不为空就行
|
// 1.1 校验任务存在 暂时去掉这个校验. 因为任务可能仿钉钉快搭的抄送节点(UserTask) TODO jason:抄送节点,会没有来源的 taskId 么? @芋艿 是否校验一下 传递进来的 id 不为空就行
|
||||||
// Task task = taskService.getTask(taskId);
|
// Task task = taskService.getTask(taskId);
|
||||||
// if (ObjectUtil.isNull(task)) {
|
// if (ObjectUtil.isNull(task)) {
|
||||||
// throw exception(ErrorCodeConstants.TASK_NOT_EXISTS);
|
// throw exception(ErrorCodeConstants.TASK_NOT_EXISTS);
|
||||||
|
Loading…
Reference in New Issue
Block a user