yangys
2025-06-27 26f07223e1b33a8eb5ee184041575e9b204cfebe
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/**
 * BladeX Commercial License Agreement
 * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
 * <p>
 * Use of this software is governed by the Commercial License Agreement
 * obtained after purchasing a license from BladeX.
 * <p>
 * 1. This software is for development use only under a valid license
 * from BladeX.
 * <p>
 * 2. Redistribution of this software's source code to any third party
 * without a commercial license is strictly prohibited.
 * <p>
 * 3. Licensees may copyright their own code but cannot use segments
 * from this software for such purposes. Copyright of this software
 * remains with BladeX.
 * <p>
 * Using this software signifies agreement to this License, and the software
 * must not be used for illegal purposes.
 * <p>
 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
 * not liable for any claims arising from secondary or illegal development.
 * <p>
 * Author: Chill Zhuang (bladejava@qq.com)
 */
package org.springblade.flow.business.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.flowable.engine.TaskService;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.flow.business.service.FlowBusinessService;
import org.springblade.flow.core.pojo.entity.BladeFlow;
import org.springblade.flow.core.utils.TaskUtil;
import org.springblade.flow.engine.entity.FlowProcess;
import org.springblade.flow.engine.service.FlowEngineService;
import org.springframework.web.bind.annotation.*;
 
/**
 * 流程事务通用接口
 *
 * @author Chill
 */
@RestController
@AllArgsConstructor
@RequestMapping("/work")
@Tag(name = "流程事务通用接口", description = "流程事务通用接口")
public class WorkController {
 
    private final TaskService taskService;
    private final FlowEngineService flowEngineService;
    private final FlowBusinessService flowBusinessService;
 
    /**
     * 发起事务列表页
     */
    @GetMapping("start-list")
    @ApiOperationSupport(order = 1)
    @Operation(summary = "发起事务列表页", description = "传入流程类型")
    public R<IPage<FlowProcess>> startList(@Parameter(description = "流程类型") String category, Query query, @RequestParam(required = false, defaultValue = "1") Integer mode) {
        IPage<FlowProcess> pages = flowEngineService.selectProcessPage(Condition.getPage(query), category, mode);
        return R.data(pages);
    }
 
    /**
     * 待签事务列表页
     */
    @GetMapping("claim-list")
    @ApiOperationSupport(order = 2)
    @Operation(summary = "待签事务列表页", description = "传入流程信息")
    public R<IPage<BladeFlow>> claimList(@Parameter(description = "流程信息") BladeFlow bladeFlow, Query query) {
        IPage<BladeFlow> pages = flowBusinessService.selectClaimPage(Condition.getPage(query), bladeFlow);
        return R.data(pages);
    }
 
    /**
     * 待办事务列表页
     */
    @GetMapping("todo-list")
    @ApiOperationSupport(order = 3)
    @Operation(summary = "待办事务列表页", description = "传入流程信息")
    public R<IPage<BladeFlow>> todoList(@Parameter(description = "流程信息") BladeFlow bladeFlow, Query query) {
        IPage<BladeFlow> pages = flowBusinessService.selectTodoPage(Condition.getPage(query), bladeFlow);
        return R.data(pages);
    }
 
    /**
     * 已发事务列表页
     */
    @GetMapping("send-list")
    @ApiOperationSupport(order = 4)
    @Operation(summary = "已发事务列表页", description = "传入流程信息")
    public R<IPage<BladeFlow>> sendList(@Parameter(description = "流程信息") BladeFlow bladeFlow, Query query) {
        IPage<BladeFlow> pages = flowBusinessService.selectSendPage(Condition.getPage(query), bladeFlow);
        return R.data(pages);
    }
 
    /**
     * 办结事务列表页
     */
    @GetMapping("done-list")
    @ApiOperationSupport(order = 5)
    @Operation(summary = "办结事务列表页", description = "传入流程信息")
    public R<IPage<BladeFlow>> doneList(@Parameter(description = "流程信息") BladeFlow bladeFlow, Query query) {
        IPage<BladeFlow> pages = flowBusinessService.selectDonePage(Condition.getPage(query), bladeFlow);
        return R.data(pages);
    }
 
    /**
     * 签收事务
     *
     * @param taskId 任务id
     */
    @PostMapping("claim-task")
    @ApiOperationSupport(order = 6)
    @Operation(summary = "签收事务", description = "传入流程信息")
    public R claimTask(@Parameter(description = "任务id") String taskId) {
        taskService.claim(taskId, TaskUtil.getTaskUser());
        return R.success("签收事务成功");
    }
 
    /**
     * 完成任务
     *
     * @param flow 请假信息
     */
    @PostMapping("complete-task")
    @ApiOperationSupport(order = 7)
    @Operation(summary = "完成任务", description = "传入流程信息")
    public R completeTask(@Parameter(description = "任务信息") @RequestBody BladeFlow flow) {
        return R.status(flowBusinessService.completeTask(flow));
    }
 
    /**
     * 删除任务
     *
     * @param taskId 任务id
     * @param reason 删除原因
     */
    @PostMapping("delete-task")
    @ApiOperationSupport(order = 8)
    @Operation(summary = "删除任务", description = "传入流程信息")
    public R deleteTask(@Parameter(description = "任务id") String taskId, @Parameter(description = "删除原因") String reason) {
        taskService.deleteTask(taskId, reason);
        return R.success("删除任务成功");
    }
 
}