刘光辉
昨天 bb638871a7fb692d80f1b7a758f991dc0879002c
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
50
51
52
53
54
55
56
57
58
59
60
package jnpf.dmsController;
 
import cn.dev33.satoken.annotation.SaCheckLogin;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jnpf.base.ActionResult;
import jnpf.dmsEntity.wenjianbianhao.form.DmsFlowEventForm;
import jnpf.dmsService.DmsWenjianBanbenService;
import jnpf.exception.DataException;
import jnpf.flowable.WorkFlowApi;
import jnpf.flowable.entity.TaskEntity;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@Tag(name = "DMS文件版本控制接口")
@RestController
@SaCheckLogin
@RequiredArgsConstructor
@RequestMapping("/biz/wenjian/banben")
public class DmsWenjianBanbenController {
 
    private final DmsWenjianBanbenService service;
    private final WorkFlowApi workFlowApi;
 
    @Operation(summary = "同步文件新增审核流程事件")
    @PostMapping("/xinzeng-shenhe/flow-event")
    public ActionResult<String> syncNewAuditFlowEvent(
            @Valid @RequestBody DmsFlowEventForm form) throws DataException {
        service.syncNewAuditFlow(form.getFlowId(), form.getTaskId(),
                requireWorkflowState(form.getTaskId()), form.getEventType());
        return ActionResult.success("文件新增审核版本同步成功", "文件新增审核版本同步成功");
    }
 
    @Operation(summary = "同步文件修订审核流程事件")
    @PostMapping("/xiuding-shenhe/flow-event")
    public ActionResult<String> syncRevisionAuditFlowEvent(
            @Valid @RequestBody DmsFlowEventForm form) throws DataException {
        service.syncRevisionAuditFlow(form.getFlowId(), form.getTaskId(),
                requireWorkflowState(form.getTaskId()), form.getEventType());
        return ActionResult.success("文件修订审核版本同步成功", "文件修订审核版本同步成功");
    }
 
    private Integer requireWorkflowState(String taskId) throws DataException {
        TaskEntity task = workFlowApi.getInfoSubmit(taskId.trim());
        if (task == null || task.getId() == null) {
            throw new DataException("未找到流程任务:" + taskId);
        }
        if (!taskId.trim().equals(task.getId())) {
            throw new DataException("流程任务与传入任务ID不匹配");
        }
        if (task.getStatus() == null) {
            throw new DataException("流程任务状态为空:" + taskId);
        }
        return task.getStatus();
    }
}