提交 | 用户 | 时间
|
722af2
|
1 |
package com.dl.web.controller.workflow; |
X |
2 |
|
|
3 |
import cn.dev33.satoken.annotation.SaCheckPermission; |
|
4 |
import cn.hutool.core.util.ObjectUtil; |
|
5 |
import com.dl.common.core.domain.R; |
|
6 |
import com.dl.workflow.domain.bo.WfTaskBo; |
|
7 |
import com.dl.workflow.service.IWfTaskService; |
|
8 |
import lombok.RequiredArgsConstructor; |
|
9 |
import lombok.extern.slf4j.Slf4j; |
|
10 |
import org.springframework.web.bind.annotation.*; |
|
11 |
|
|
12 |
import javax.imageio.ImageIO; |
|
13 |
import javax.servlet.http.HttpServletResponse; |
|
14 |
import java.awt.image.BufferedImage; |
|
15 |
import java.io.IOException; |
|
16 |
import java.io.InputStream; |
|
17 |
import java.io.OutputStream; |
|
18 |
|
|
19 |
/** |
|
20 |
* 工作流任务管理 |
|
21 |
* |
|
22 |
* @author KonBAI |
|
23 |
* @createTime 2022/3/10 00:12 |
|
24 |
*/ |
|
25 |
@Slf4j |
|
26 |
@RequiredArgsConstructor |
|
27 |
@RestController |
|
28 |
@RequestMapping("/workflow/task") |
|
29 |
public class WfTaskController { |
|
30 |
|
|
31 |
private final IWfTaskService flowTaskService; |
|
32 |
|
|
33 |
/** |
|
34 |
* 取消流程 |
|
35 |
*/ |
|
36 |
@PostMapping(value = "/stopProcess") |
|
37 |
@SaCheckPermission("workflow:process:cancel") |
|
38 |
public R stopProcess(@RequestBody WfTaskBo bo) { |
|
39 |
flowTaskService.stopProcess(bo); |
|
40 |
return R.ok(); |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* 撤回流程 |
|
45 |
*/ |
|
46 |
@PostMapping(value = "/revokeProcess") |
|
47 |
@SaCheckPermission("workflow:process:revoke") |
|
48 |
public R revokeProcess(@RequestBody WfTaskBo bo) { |
|
49 |
flowTaskService.revokeProcess(bo); |
|
50 |
return R.ok(); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* 获取流程变量 |
|
55 |
* @param taskId 流程任务Id |
|
56 |
*/ |
|
57 |
@GetMapping(value = "/processVariables/{taskId}") |
|
58 |
@SaCheckPermission("workflow:process:query") |
|
59 |
public R processVariables(@PathVariable(value = "taskId") String taskId) { |
|
60 |
return R.ok(flowTaskService.getProcessVariables(taskId)); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* 审批任务 |
|
65 |
*/ |
|
66 |
@PostMapping(value = "/complete") |
|
67 |
@SaCheckPermission("workflow:process:approval") |
|
68 |
public R complete(@RequestBody WfTaskBo bo) { |
|
69 |
flowTaskService.complete(bo); |
|
70 |
return R.ok(); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* 拒绝任务 |
|
75 |
*/ |
|
76 |
@PostMapping(value = "/reject") |
|
77 |
@SaCheckPermission("workflow:process:approval") |
|
78 |
public R taskReject(@RequestBody WfTaskBo taskBo) { |
|
79 |
flowTaskService.taskReject(taskBo); |
|
80 |
return R.ok(); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* 退回任务 |
|
85 |
*/ |
|
86 |
@PostMapping(value = "/return") |
|
87 |
@SaCheckPermission("workflow:process:approval") |
|
88 |
public R taskReturn(@RequestBody WfTaskBo bo) { |
|
89 |
flowTaskService.taskReturn(bo); |
|
90 |
return R.ok(); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* 获取所有可回退的节点 |
|
95 |
*/ |
|
96 |
@PostMapping(value = "/returnList") |
|
97 |
@SaCheckPermission("workflow:process:query") |
|
98 |
public R findReturnTaskList(@RequestBody WfTaskBo bo) { |
|
99 |
return R.ok(flowTaskService.findReturnTaskList(bo)); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* 删除任务 |
|
104 |
*/ |
|
105 |
@DeleteMapping(value = "/delete") |
|
106 |
@SaCheckPermission("workflow:process:approval") |
|
107 |
public R delete(@RequestBody WfTaskBo bo) { |
|
108 |
flowTaskService.deleteTask(bo); |
|
109 |
return R.ok(); |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* 认领/签收任务 |
|
114 |
*/ |
|
115 |
@PostMapping(value = "/claim") |
|
116 |
@SaCheckPermission("workflow:process:claim") |
|
117 |
public R claim(@RequestBody WfTaskBo bo) { |
|
118 |
flowTaskService.claim(bo); |
|
119 |
return R.ok(); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* 取消认领/签收任务 |
|
124 |
*/ |
|
125 |
@PostMapping(value = "/unClaim") |
|
126 |
@SaCheckPermission("workflow:process:claim") |
|
127 |
public R unClaim(@RequestBody WfTaskBo bo) { |
|
128 |
flowTaskService.unClaim(bo); |
|
129 |
return R.ok(); |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* 委派任务 |
|
134 |
*/ |
|
135 |
@PostMapping(value = "/delegate") |
|
136 |
@SaCheckPermission("workflow:process:approval") |
|
137 |
public R delegate(@RequestBody WfTaskBo bo) { |
|
138 |
if (ObjectUtil.hasNull(bo.getTaskId(), bo.getUserId())) { |
|
139 |
return R.fail("参数错误!"); |
|
140 |
} |
|
141 |
flowTaskService.delegateTask(bo); |
|
142 |
return R.ok(); |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* 转办任务 |
|
147 |
*/ |
|
148 |
@PostMapping(value = "/transfer") |
|
149 |
@SaCheckPermission("workflow:process:approval") |
|
150 |
public R transfer(@RequestBody WfTaskBo bo) { |
|
151 |
if (ObjectUtil.hasNull(bo.getTaskId(), bo.getUserId())) { |
|
152 |
return R.fail("参数错误!"); |
|
153 |
} |
|
154 |
flowTaskService.transferTask(bo); |
|
155 |
return R.ok(); |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* 生成流程图 |
|
160 |
* |
|
161 |
* @param processId 任务ID |
|
162 |
*/ |
|
163 |
@RequestMapping("/diagram/{processId}") |
|
164 |
public void genProcessDiagram(HttpServletResponse response, |
|
165 |
@PathVariable("processId") String processId) { |
|
166 |
InputStream inputStream = flowTaskService.diagram(processId); |
|
167 |
OutputStream os = null; |
|
168 |
BufferedImage image = null; |
|
169 |
try { |
|
170 |
image = ImageIO.read(inputStream); |
|
171 |
response.setContentType("image/png"); |
|
172 |
os = response.getOutputStream(); |
|
173 |
if (image != null) { |
|
174 |
ImageIO.write(image, "png", os); |
|
175 |
} |
|
176 |
} catch (Exception e) { |
|
177 |
e.printStackTrace(); |
|
178 |
} finally { |
|
179 |
try { |
|
180 |
if (os != null) { |
|
181 |
os.flush(); |
|
182 |
os.close(); |
|
183 |
} |
|
184 |
} catch (IOException e) { |
|
185 |
e.printStackTrace(); |
|
186 |
} |
|
187 |
} |
|
188 |
} |
|
189 |
} |