刘光辉
118 分钟以前 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package jnpf.dmsController;
 
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.dmsEntity.form.DmsWenjianBianhaoGuizeShengbanCheckForm;
import jnpf.dmsService.DmsWenjianBianhaoGuizeFeiqiService;
import jnpf.dmsService.DmsWenjianBianhaoGuizeShengbanCheckService;
import jnpf.dmsService.DmsWenjianBianhaoGuizeTongguoService;
import jnpf.exception.DataException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;
 
import java.util.Map;
 
@Slf4j
@Tag(name = "DMS文件编号规则接口", description = "文件编号规则业务操作")
@RestController
@RequestMapping("/biz/wenjian/bianhao/guize")
public class DmsWenjianBianhaoGuizeController {
 
    @Autowired
    private DmsWenjianBianhaoGuizeFeiqiService feiqiService;
 
    @Autowired
    private DmsWenjianBianhaoGuizeTongguoService tongguoService;
 
    @Autowired
    private DmsWenjianBianhaoGuizeShengbanCheckService shengbanCheckService;
 
    @Operation(summary = "校验文件编号规则升版")
    @PostMapping("/shengban/check")
    public ActionResult<String> checkShengban(@RequestBody(required = false) DmsWenjianBianhaoGuizeShengbanCheckForm form) {
        try {
            shengbanCheckService.check(
                    form == null ? null : form.getFId(),
                    form == null ? null : form.getGuizeLiushuihao(),
                    form == null ? null : form.getBanbenhao());
            return ActionResult.success("文件编号规则升版校验通过", "文件编号规则升版校验通过");
        } catch (DataException e) {
            log.warn("文件编号规则升版校验失败:{}", e.getMessage());
            return ActionResult.fail(e.getMessage());
        }
    }
 
    @Operation(summary = "文件编号规则审核通过")
    @PostMapping("/tongguo")
    public ActionResult<String> tongguo(@RequestBody(required = false) Map<String, Object> formData) {
        String resolvedFlowId = resolveParam(formData, "flow_id", "flowId");
        String resolvedTaskId = resolveParam(formData, "task_id", "taskId");
        try {
            tongguoService.tongguo(resolvedFlowId, resolvedTaskId);
            return ActionResult.success("文件编号规则审核通过处理成功", "文件编号规则审核通过处理成功");
        } catch (DataException e) {
            log.warn("文件编号规则审核通过处理失败:flowId={}, taskId={}, msg={}",
                    resolvedFlowId, resolvedTaskId, e.getMessage());
            return ActionResult.fail(e.getMessage());
        }
    }
 
    @Operation(summary = "废弃文件编号规则")
    @PostMapping("/feiqi")
    public ActionResult<String> feiqi(@RequestBody(required = false) Map<String, Object> formData) {
        String resolvedFlowId = resolveParam(formData, "flow_id", "flowId");
        String resolvedTaskId = resolveParam(formData, "task_id", "taskId");
        try {
            feiqiService.feiqiGuize(resolvedFlowId, resolvedTaskId);
            return ActionResult.success("文件编号规则废弃成功", "文件编号规则废弃成功");
        } catch (DataException e) {
            log.warn("文件编号规则废弃失败:flowId={}, taskId={}, msg={}",
                    resolvedFlowId, resolvedTaskId, e.getMessage());
            return ActionResult.fail(e.getMessage());
        }
    }
 
    private String resolveParam(Map<String, Object> formData, String snakeCaseKey, String camelCaseKey) {
        if (formData == null) {
            return "";
        }
        Object raw = formData.get(snakeCaseKey);
        if (raw == null) {
            raw = formData.get(camelCaseKey);
        }
        return raw == null ? "" : trimToEmpty(String.valueOf(raw));
    }
 
    private String trimToEmpty(String value) {
        return value == null ? "" : value.trim();
    }
}