刘光辉
5 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package jnpf.flowable.service;
 
import jnpf.exception.WorkFlowException;
import jnpf.flowable.entity.OperatorEntity;
import jnpf.flowable.entity.TaskEntity;
import jnpf.flowable.entity.TemplateNodeEntity;
import jnpf.flowable.mapper.TaskMapper;
import jnpf.flowable.mapper.TemplateNodeMapper;
import jnpf.flowable.model.filepermission.WorkflowAuditContextResolver;
import jnpf.flowable.util.OperatorUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
 
/** 仅由 DMS 原生保存的专属分支调用;节点名不接受请求自报值。 */
@Service
@RequiredArgsConstructor
public class WorkflowAuditContextResolverImpl implements WorkflowAuditContextResolver {
    private final OperatorUtil operators;
    private final TaskMapper tasks;
    private final TemplateNodeMapper nodes;
 
    @Override
    public Map<String, String> resolve(String taskId, String formId, String operatorId) throws WorkFlowException {
        OperatorEntity operator = operators.checkOperator(operatorId);
        if (!Objects.equals(taskId, operator.getTaskId()))
            throw new WorkFlowException("文件审计的流程与办理记录不匹配");
        // An authenticated development run has already checked its switch, form allowlist and electronic signer.
        // The scope exists only during the local native save; HTTP callers cannot supply it.
        if (!jnpf.flowable.model.util.DevApprovalActor.active()
                || !jnpf.flowable.model.util.DevApprovalActor.isActing(operatorId, jnpf.util.UserProvider.getLoginUserId()))
            operators.checkOperatorPermission(operatorId);
        TaskEntity task = tasks.getInfo(taskId);
        TemplateNodeEntity node = nodes.getList(task.getFlowId()).stream()
                .filter(n -> Objects.equals(n.getNodeCode(), operator.getNodeCode()))
                .findFirst().orElse(null);
        if (node == null || !Objects.equals(formId, node.getFormId()))
            throw new WorkFlowException("文件审计的表单与办理节点不匹配");
        Map<String, String> context = new LinkedHashMap<>();
        context.put("taskId", taskId);
        context.put("operatorId", operator.getId());
        context.put("nodeId", operator.getNodeId());
        context.put("nodeCode", operator.getNodeCode());
        context.put("nodeName", operator.getNodeName());
        return context;
    }
}