刘光辉
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
package jnpf.flowable.service;
 
import jnpf.exception.DataException;
import jnpf.flowable.model.filepermission.WorkflowFileCheckpoint;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.function.Consumer;
 
@Service
@RequiredArgsConstructor
public class WorkflowFileCheckpointSupport {
    private final FilePermissionSnapshotService snapshots;
    private final ObjectProvider<WorkflowFileCheckpoint> checkpoint;
 
    public boolean enabled(String taskId) { return snapshots.find(taskId) != null; }
 
    public void save(String taskId, String formId, Map<String, Object> data, Consumer<Map<String, Object>> continuation) {
        save(taskId, formId, null, data, continuation);
    }
 
    public void save(String taskId, String formId, String operatorId, Map<String, Object> data,
                     Consumer<Map<String, Object>> continuation) {
        if (snapshots.find(taskId) == null) { continuation.accept(data); return; }
        WorkflowFileCheckpoint service = checkpoint.getIfAvailable();
        if (service == null) throw new DataException("当前部署尚未接入流程共享附件保存,不能继续节点操作");
        service.save(taskId, formId, operatorId, data, continuation);
    }
}