提交 | 用户 | 时间
|
722af2
|
1 |
package com.dl.web.controller.workflow; |
X |
2 |
|
|
3 |
import cn.dev33.satoken.annotation.SaCheckPermission; |
|
4 |
import cn.hutool.core.bean.BeanUtil; |
|
5 |
import cn.hutool.core.util.ObjectUtil; |
|
6 |
import com.dl.common.annotation.Log; |
|
7 |
import com.dl.common.core.controller.BaseController; |
|
8 |
import com.dl.common.core.domain.PageQuery; |
|
9 |
import com.dl.common.core.domain.R; |
|
10 |
import com.dl.common.core.page.TableDataInfo; |
|
11 |
import com.dl.common.enums.BusinessType; |
|
12 |
import com.dl.common.utils.poi.ExcelUtil; |
|
13 |
import com.dl.flowable.core.domain.ProcessQuery; |
|
14 |
import com.dl.workflow.domain.bo.WfCopyBo; |
|
15 |
import com.dl.workflow.domain.vo.*; |
|
16 |
import com.dl.workflow.service.IWfCopyService; |
|
17 |
import com.dl.workflow.service.IWfProcessService; |
|
18 |
import lombok.RequiredArgsConstructor; |
|
19 |
import lombok.extern.slf4j.Slf4j; |
|
20 |
import org.springframework.validation.annotation.Validated; |
|
21 |
import org.springframework.web.bind.annotation.*; |
|
22 |
|
|
23 |
import javax.servlet.http.HttpServletResponse; |
|
24 |
import java.util.List; |
|
25 |
import java.util.Map; |
|
26 |
|
|
27 |
/** |
|
28 |
* 工作流流程管理 |
|
29 |
* |
|
30 |
* @author KonBAI |
|
31 |
* @createTime 2022/3/24 18:54 |
|
32 |
*/ |
|
33 |
@Slf4j |
|
34 |
@RequiredArgsConstructor |
|
35 |
@RestController |
|
36 |
@RequestMapping("/workflow/process") |
|
37 |
public class WfProcessController extends BaseController { |
|
38 |
|
|
39 |
private final IWfProcessService processService; |
|
40 |
private final IWfCopyService copyService; |
|
41 |
|
|
42 |
/** |
|
43 |
* 查询可发起流程列表 |
|
44 |
* |
|
45 |
* @param pageQuery 分页参数 |
|
46 |
*/ |
|
47 |
@GetMapping(value = "/list") |
|
48 |
@SaCheckPermission("workflow:process:startList") |
|
49 |
public TableDataInfo<WfDefinitionVo> startProcessList(ProcessQuery processQuery, PageQuery pageQuery) { |
|
50 |
return processService.selectPageStartProcessList(processQuery, pageQuery); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* 我拥有的流程 |
|
55 |
*/ |
|
56 |
@SaCheckPermission("workflow:process:ownList") |
|
57 |
@GetMapping(value = "/ownList") |
|
58 |
public TableDataInfo<WfTaskVo> ownProcessList(ProcessQuery processQuery, PageQuery pageQuery) { |
|
59 |
return processService.selectPageOwnProcessList(processQuery, pageQuery); |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* 获取待办列表 |
|
64 |
*/ |
|
65 |
@SaCheckPermission("workflow:process:todoList") |
|
66 |
@GetMapping(value = "/todoList") |
|
67 |
public TableDataInfo<WfTaskVo> todoProcessList(ProcessQuery processQuery, PageQuery pageQuery) { |
|
68 |
return processService.selectPageTodoProcessList(processQuery, pageQuery); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* 获取待签列表 |
|
73 |
* |
|
74 |
* @param processQuery 流程业务对象 |
|
75 |
* @param pageQuery 分页参数 |
|
76 |
*/ |
|
77 |
@SaCheckPermission("workflow:process:claimList") |
|
78 |
@GetMapping(value = "/claimList") |
|
79 |
public TableDataInfo<WfTaskVo> claimProcessList(ProcessQuery processQuery, PageQuery pageQuery) { |
|
80 |
return processService.selectPageClaimProcessList(processQuery, pageQuery); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* 获取已办列表 |
|
85 |
* |
|
86 |
* @param pageQuery 分页参数 |
|
87 |
*/ |
|
88 |
@SaCheckPermission("workflow:process:finishedList") |
|
89 |
@GetMapping(value = "/finishedList") |
|
90 |
public TableDataInfo<WfTaskVo> finishedProcessList(ProcessQuery processQuery, PageQuery pageQuery) { |
|
91 |
return processService.selectPageFinishedProcessList(processQuery, pageQuery); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* 获取抄送列表 |
|
96 |
* |
|
97 |
* @param copyBo 流程抄送对象 |
|
98 |
* @param pageQuery 分页参数 |
|
99 |
*/ |
|
100 |
@SaCheckPermission("workflow:process:copyList") |
|
101 |
@GetMapping(value = "/copyList") |
|
102 |
public TableDataInfo<WfCopyVo> copyProcessList(WfCopyBo copyBo, PageQuery pageQuery) { |
|
103 |
copyBo.setUserId(getUserId()); |
|
104 |
return copyService.selectPageList(copyBo, pageQuery); |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* 导出可发起流程列表 |
|
109 |
*/ |
|
110 |
@SaCheckPermission("workflow:process:startExport") |
|
111 |
@Log(title = "可发起流程", businessType = BusinessType.EXPORT) |
|
112 |
@PostMapping("/startExport") |
|
113 |
public void startExport(@Validated ProcessQuery processQuery, HttpServletResponse response) { |
|
114 |
List<WfDefinitionVo> list = processService.selectStartProcessList(processQuery); |
|
115 |
ExcelUtil.exportExcel(list, "可发起流程", WfDefinitionVo.class, response); |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* 导出我拥有流程列表 |
|
120 |
*/ |
|
121 |
@SaCheckPermission("workflow:process:ownExport") |
|
122 |
@Log(title = "我拥有流程", businessType = BusinessType.EXPORT) |
|
123 |
@PostMapping("/ownExport") |
|
124 |
public void ownExport(@Validated ProcessQuery processQuery, HttpServletResponse response) { |
|
125 |
List<WfTaskVo> list = processService.selectOwnProcessList(processQuery); |
|
126 |
List<WfOwnTaskExportVo> listVo = BeanUtil.copyToList(list, WfOwnTaskExportVo.class); |
|
127 |
for (WfOwnTaskExportVo exportVo : listVo) { |
|
128 |
exportVo.setStatus(ObjectUtil.isNull(exportVo.getFinishTime()) ? "进行中" : "已完成"); |
|
129 |
} |
|
130 |
ExcelUtil.exportExcel(listVo, "我拥有流程", WfOwnTaskExportVo.class, response); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* 导出待办流程列表 |
|
135 |
*/ |
|
136 |
@SaCheckPermission("workflow:process:todoExport") |
|
137 |
@Log(title = "待办流程", businessType = BusinessType.EXPORT) |
|
138 |
@PostMapping("/todoExport") |
|
139 |
public void todoExport(@Validated ProcessQuery processQuery, HttpServletResponse response) { |
|
140 |
List<WfTaskVo> list = processService.selectTodoProcessList(processQuery); |
|
141 |
List<WfTodoTaskExportVo> listVo = BeanUtil.copyToList(list, WfTodoTaskExportVo.class); |
|
142 |
ExcelUtil.exportExcel(listVo, "待办流程", WfTodoTaskExportVo.class, response); |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* 导出待签流程列表 |
|
147 |
*/ |
|
148 |
@SaCheckPermission("workflow:process:claimExport") |
|
149 |
@Log(title = "待签流程", businessType = BusinessType.EXPORT) |
|
150 |
@PostMapping("/claimExport") |
|
151 |
public void claimExport(@Validated ProcessQuery processQuery, HttpServletResponse response) { |
|
152 |
List<WfTaskVo> list = processService.selectClaimProcessList(processQuery); |
|
153 |
List<WfClaimTaskExportVo> listVo = BeanUtil.copyToList(list, WfClaimTaskExportVo.class); |
|
154 |
ExcelUtil.exportExcel(listVo, "待签流程", WfClaimTaskExportVo.class, response); |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* 导出已办流程列表 |
|
159 |
*/ |
|
160 |
@SaCheckPermission("workflow:process:finishedExport") |
|
161 |
@Log(title = "已办流程", businessType = BusinessType.EXPORT) |
|
162 |
@PostMapping("/finishedExport") |
|
163 |
public void finishedExport(@Validated ProcessQuery processQuery, HttpServletResponse response) { |
|
164 |
List<WfTaskVo> list = processService.selectFinishedProcessList(processQuery); |
|
165 |
List<WfFinishedTaskExportVo> listVo = BeanUtil.copyToList(list, WfFinishedTaskExportVo.class); |
|
166 |
ExcelUtil.exportExcel(listVo, "已办流程", WfFinishedTaskExportVo.class, response); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* 导出抄送流程列表 |
|
171 |
*/ |
|
172 |
@SaCheckPermission("workflow:process:copyExport") |
|
173 |
@Log(title = "抄送流程", businessType = BusinessType.EXPORT) |
|
174 |
@PostMapping("/copyExport") |
|
175 |
public void copyExport(WfCopyBo copyBo, HttpServletResponse response) { |
|
176 |
copyBo.setUserId(getUserId()); |
|
177 |
List<WfCopyVo> list = copyService.selectList(copyBo); |
|
178 |
ExcelUtil.exportExcel(list, "抄送流程", WfCopyVo.class, response); |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* 查询流程部署关联表单信息 |
|
183 |
* |
|
184 |
* @param definitionId 流程定义id |
|
185 |
* @param deployId 流程部署id |
|
186 |
*/ |
|
187 |
@GetMapping("/getProcessForm") |
|
188 |
@SaCheckPermission("workflow:process:start") |
|
189 |
public R<?> getForm(@RequestParam(value = "definitionId") String definitionId, |
|
190 |
@RequestParam(value = "deployId") String deployId, |
|
191 |
@RequestParam(value = "procInsId", required = false) String procInsId) { |
|
192 |
return R.ok(processService.selectFormContent(definitionId, deployId, procInsId)); |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* 根据流程定义id启动流程实例 |
|
197 |
* |
|
198 |
* @param processDefId 流程定义id |
|
199 |
* @param variables 变量集合,json对象 |
|
200 |
*/ |
|
201 |
@SaCheckPermission("workflow:process:start") |
|
202 |
@PostMapping("/start/{processDefId}") |
|
203 |
public R<Void> start(@PathVariable(value = "processDefId") String processDefId, @RequestBody Map<String, Object> variables) { |
|
204 |
processService.startProcessByDefId(processDefId, variables); |
|
205 |
return R.ok("流程启动成功"); |
|
206 |
|
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* 删除流程实例 |
|
211 |
* |
|
212 |
* @param instanceIds 流程实例ID串 |
|
213 |
*/ |
|
214 |
@DeleteMapping("/instance/{instanceIds}") |
|
215 |
public R<Void> delete(@PathVariable String[] instanceIds) { |
|
216 |
processService.deleteProcessByIds(instanceIds); |
|
217 |
return R.ok(); |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* 读取xml文件 |
|
222 |
* @param processDefId 流程定义ID |
|
223 |
*/ |
|
224 |
@GetMapping("/bpmnXml/{processDefId}") |
|
225 |
public R<String> getBpmnXml(@PathVariable(value = "processDefId") String processDefId) { |
|
226 |
return R.ok(null, processService.queryBpmnXmlById(processDefId)); |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* 查询流程详情信息 |
|
231 |
* |
|
232 |
* @param procInsId 流程实例ID |
|
233 |
* @param taskId 任务ID |
|
234 |
*/ |
|
235 |
@GetMapping("/detail") |
|
236 |
public R detail(String procInsId, String taskId) { |
|
237 |
return R.ok(processService.queryProcessDetail(procInsId, taskId)); |
|
238 |
} |
|
239 |
|
|
240 |
|
|
241 |
/** |
|
242 |
* 根据业务主键id查询流程信息 |
|
243 |
* @param businessKey |
|
244 |
* @return |
|
245 |
*/ |
|
246 |
@GetMapping("/detail/{businessKey}") |
|
247 |
public R detail(@PathVariable String businessKey) { |
|
248 |
return R.ok(processService.queryProcessDetail(businessKey)); |
|
249 |
} |
|
250 |
} |