GeneralProcessController.java
19.7 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
package com.skua.modules.system.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.skua.common.system.listener.ProcessHandleService;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.SpringContextUtils;
import com.skua.modules.audit.entity.FAuditDoing;
import com.skua.modules.audit.entity.FAuditHistory;
import com.skua.modules.audit.service.IFAuditDoingService;
import com.skua.modules.audit.service.IFAuditHistoryService;
import com.skua.modules.process.entity.FProcessCfg;
import com.skua.modules.process.entity.FProcessNode;
import com.skua.modules.process.entity.FProcessNodeApprover;
import com.skua.modules.process.service.IFProcessCfgService;
import com.skua.modules.process.service.IFProcessNodeApproverService;
import com.skua.modules.process.service.IFProcessNodePercfgService;
import com.skua.modules.process.service.IFProcessNodeService;
import com.skua.modules.system.entity.SysCustomTable;
import com.skua.modules.system.service.IGeneralProcessService;
import com.skua.modules.system.service.ISysCustomTableService;
import com.skua.modules.system.vo.ProcessAuditHistoryVO;
import com.skua.modules.system.vo.ProcessCustomAuditUserVO;
import com.skua.modules.system.vo.ProcessVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Api(tags="通用流程")
//@ApiIgnore
@RestController
@RequestMapping("/sys/sysGeneralProcess")
public class GeneralProcessController {
@Autowired
private ISysCustomTableService sysCustomTableService;
@Autowired
private IFProcessCfgService fProcessCfgService;
@Autowired
private IFProcessNodeService fProcessNodeService;
@Autowired
private IFProcessNodeApproverService fProcessNodeApproverService;
@Autowired
private IFProcessNodePercfgService fProcessNodePercfgService;
@Autowired
private IFAuditDoingService fAuditDoingService;
@Autowired
private IFAuditHistoryService fAuditHistoryService;
@Autowired
private IGeneralProcessService generalProcessService;
/**
* 添加
* @param processTable 表名
* @return
*/
@AutoLog(value = "通用流程-添加")
@ApiOperation(value="通用流程-添加", notes="通用流程-添加")
@PostMapping(value = "/add")
public Result<Map<String,Object>> add(@RequestParam(name="processTable",required=true) String processTable) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
try {
String reportId = getCustomTableIdByTableName(processTable);
if(reportId!=null){
FProcessCfg cfgBean = fProcessCfgService.getByReportId(reportId);
if(cfgBean==null){
//添加流程
FProcessCfg fProcessCfg = new FProcessCfg();
fProcessCfg.setReportId(reportId);
fProcessCfg.setVersion("1");
fProcessCfg.setProName("通用流程-"+reportId.substring(0,6));
fProcessCfg.setSortNum(1);
boolean ok = fProcessCfgService.save(fProcessCfg);
if(ok){
String processId = fProcessCfg.getId();
FProcessNode FQNode = new FProcessNode();
FProcessNode BJNode = new FProcessNode();
FQNode.setNodeName("通用流程-发起");
FQNode.setNodeValue(0);
FQNode.setProId(processId);
FQNode.setProVer("1");
BJNode.setNodeName("通用流程-办结");
BJNode.setNodeValue(-1);
BJNode.setProId(processId);
BJNode.setProVer("1");
fProcessNodeService.save(FQNode);
fProcessNodeService.save(BJNode);
}
result.success("添加成功!");
}else{
result.success("该功能已存在流程!");
}
map.put("reportId",reportId);
}else{
result.error500("库表管理中无关联!");
}
} catch (Exception e) {
result.error500("操作失败");
}
result.setResult(map);
return result;
}
@AutoLog(value = "通用流程-通过tableName获取全部信息")
@ApiOperation(value="通用流程-通过tableName获取全部信息", notes="通用流程-通过tableName获取全部信息")
@GetMapping(value = "/getAllByTableName")
public Result<Map<String,Object>> getAllByReportId(@RequestParam(name="tableName",required=true) String tableName) {
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> lcMap = new HashMap<>();
List<Map<String,Object>> allList = new ArrayList<>();
try {
String reportId = getCustomTableIdByTableName(tableName);
if(reportId!=null){
List<Map<String,Object>> reportlist = fProcessNodePercfgService.getByReportId(reportId);
FProcessCfg fProcessCfg = fProcessCfgService.getByReportId(reportId);
String processCfgId = fProcessCfg.getId();
List<FProcessNode> nodeList = fProcessNodeService.getListByProcessId(processCfgId);
if(nodeList.size() > 0){
for (int i = 1; i < nodeList.size(); i++) {
Map<String,Object> map = new HashMap();
String nodeId = nodeList.get(i).getId();
map.put("id",nodeId);
map.put("nodeName",nodeList.get(i).getNodeName());
map.put("nodeValue",nodeList.get(i).getNodeValue());
map.put("monitorClass",nodeList.get(i).getMonitorClass());
map.put("nodeButtonName",nodeList.get(i).getNodeButtonName());
map.put("proId",nodeList.get(i).getProId());
map.put("proVer",nodeList.get(i).getProVer());
List<FProcessNodeApprover> approverList = fProcessNodeApproverService.getByNodeId(nodeId);
if(approverList.size() > 0){
map.put("approver",approverList.get(0));
}else{
FProcessNodeApprover approver = new FProcessNodeApprover();
approver.setNodeId(nodeId);
map.put("approver",approver);
}
List<Map<String,Object>> percfgList = fProcessNodePercfgService.getByNodeIdAndCustomTableId(nodeId,reportId);
if(percfgList.size() > 0){
map.put("percfg",percfgList);
}else{
map.put("percfg",reportlist);
}
allList.add(map);
}
Map<String,Object> bjMap = new HashMap();
String nodeId_bj = nodeList.get(0).getId();
bjMap.put("id",nodeId_bj);
//bjMap.put("nodeName",nodeList.get(0).getNodeName());
bjMap.put("nodeName","流程结束");//办结节点作为状态节点,将人员置空改为流程结束
bjMap.put("nodeValue",nodeList.get(0).getNodeValue());
bjMap.put("monitorClass",nodeList.get(0).getMonitorClass());
bjMap.put("nodeButtonName",nodeList.get(0).getNodeButtonName());
bjMap.put("proId",nodeList.get(0).getProId());
bjMap.put("proVer",nodeList.get(0).getProVer());
List<FProcessNodeApprover> lastApproverList = fProcessNodeApproverService.getByNodeId(nodeId_bj);
if(lastApproverList.size() > 0){
bjMap.put("approver",lastApproverList.get(0));
}else{
FProcessNodeApprover approver = new FProcessNodeApprover();
approver.setNodeId(nodeId_bj);
bjMap.put("approver",approver);
}
List<Map<String,Object>> lastPercfgList = fProcessNodePercfgService.getByNodeIdAndCustomTableId(nodeId_bj,reportId);
if(lastPercfgList.size() > 0){
bjMap.put("percfg",lastPercfgList);
}else{
bjMap.put("percfg",reportlist);
}
allList.add(bjMap);
}else{
//发起-节点
FProcessNode nodeStart = new FProcessNode();
nodeStart.setNodeName("发起");
nodeStart.setNodeValue(0);
nodeStart.setProId(processCfgId);
fProcessNodeService.save(nodeStart);
//办结-节点
FProcessNode nodeEnd = new FProcessNode();
nodeEnd.setNodeName("办结");
nodeEnd.setNodeValue(-1);
nodeEnd.setProId(processCfgId);
fProcessNodeService.save(nodeEnd);
List<FProcessNode> list = fProcessNodeService.getListByProcessId(processCfgId);
for (int i = 0; i < list.size(); i++) {
Map<String,Object> map = new HashMap();
FProcessNodeApprover approver = new FProcessNodeApprover();
map.put("id",list.get(i).getId());
map.put("nodeName",list.get(i).getNodeName());
map.put("nodeValue",list.get(i).getNodeValue());
map.put("monitorClass",list.get(i).getMonitorClass());
map.put("nodeButtonName",list.get(i).getNodeButtonName());
map.put("proId",list.get(i).getProId());
map.put("proVer",list.get(i).getProVer());
approver.setNodeId(list.get(i).getId());
map.put("approver",approver);
map.put("percfg",reportlist);
allList.add(map);
}
}
lcMap.put("id",processCfgId);
lcMap.put("data",allList);
result.isSuccess();
}else{
result.error500("库表维护中无关联");
}
result.setResult(lcMap);
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
}
return result;
}
private String getCustomTableIdByTableName(String tableName) {
SysCustomTable sysCustomTable = sysCustomTableService.getOneByTable(tableName);
if(sysCustomTable==null){
return null;
}else{
return sysCustomTable.getId();
}
}
/**
* 接口
* @param tableName
* @return
*/
@GetMapping(value = "/getInfoByTableName")
public Result<Map<String,Object>> getInfoByReportId(@RequestParam(name="tableName",required=true) String tableName) {
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> lcMap = new HashMap<>();
lcMap = fProcessCfgService.getInfoByTable(tableName);
if(lcMap == null){
result.error500("操作失败");
}else{
result.success("操作成功");
}
result.setResult(lcMap);
return result;
}
@AutoLog(value = "审批流程doing-审批流程")
@ApiOperation(value="审批流程doing-审批流程", notes="审批流程doing-审批流程")
@PutMapping(value = "/spAudit")
public Result<FAuditDoing> saveAudit(@RequestBody ProcessVO processVO) {
String reportId = processVO.getReportId();//库表管理中的ID
String processId = processVO.getProcessId();//流程ID
String dataId = processVO.getDataId();//数据ID
String userId = processVO.getUserId();
String nodeValue = processVO.getNodeValue();//节点值
String approveRecord = processVO.getApproveRecord();
String approver = processVO.getApprover();
String nowNodeValue = processVO.getNowNodeValue();
String auditState = processVO.getAuditState();//审批状态
String handleUserCode = processVO.getCreateBy();//操作人登录名
if(nowNodeValue == null){
nowNodeValue = "0";
}
Result<FAuditDoing> result = new Result<FAuditDoing>();
FAuditDoing fAuditDoing = fAuditDoingService.getBeanByAllId(reportId,processId,dataId);
if(fAuditDoing!=null){//修改节点值
fAuditDoing.setNodeValue(nodeValue);
fAuditDoing.setOpeId(userId);
fAuditDoing.setReprotAttr(approveRecord);
boolean ok = fAuditDoingService.updateById(fAuditDoing);
if(ok){
FAuditHistory fAuditHistory = new FAuditHistory();
fAuditHistory.setReportId(reportId);
fAuditHistory.setProcessId(processId);
fAuditHistory.setReportContentId(dataId);
fAuditHistory.setOpeId(approver);
fAuditHistory.setNodeValue(nowNodeValue);
fAuditHistory.setReprotAttr(approveRecord);
fAuditHistory.setAuditState(auditState);
fAuditHistory.setCreateBy(handleUserCode);
fAuditHistoryService.save(fAuditHistory);
}
}else{
FAuditDoing audit = new FAuditDoing();
audit.setReportId(reportId);
audit.setProcessId(processId);
audit.setReportContentId(dataId);
audit.setOpeId(userId);
audit.setNodeValue(nodeValue);
audit.setReprotAttr(approveRecord);
boolean ok = fAuditDoingService.save(audit);
if(ok){
FAuditHistory fAuditHistory = new FAuditHistory();
fAuditHistory.setReportId(reportId);
fAuditHistory.setProcessId(processId);
fAuditHistory.setReportContentId(dataId);
fAuditHistory.setOpeId(approver);
fAuditHistory.setNodeValue(nowNodeValue);
fAuditHistory.setReprotAttr(approveRecord);
fAuditHistory.setAuditState(auditState);
fAuditHistory.setCreateBy(handleUserCode);
fAuditHistoryService.save(fAuditHistory);
}
}
FProcessNode fProcessNode = fProcessNodeService.getByProIdAndNodeValue(processId,nodeValue);
if(fProcessNode!=null&&fProcessNode.getMonitorClass()!=null&&!fProcessNode.getMonitorClass().equals("")){
boolean flag = doService(dataId,fProcessNode.getMonitorClass());
if(flag){
result.success("成功");
}else{
result.error500("失败");
}
}
return result;
}
/**
* 办结后处理其他业务
* @param dataId
* @return
*/
public boolean doService(String dataId, String monitorClass) {
try{
ProcessHandleService rocessHandleService = (ProcessHandleService)SpringContextUtils.getBean(monitorClass);
return rocessHandleService.doService(dataId);
}catch(Exception e){
return false;
}
}
@AutoLog(value = "审批流程历史-流程历史详细")
@ApiOperation(value="审批流程历史-流程历史详细", notes="审批流程历史-流程历史详细")
@GetMapping(value = "/auditHistory")
public Result<List<ProcessAuditHistoryVO>> getAuditHistory(@ApiParam(name="processId",value="流程ID",required = true) @RequestParam(name="processId",required=true) String processId,@ApiParam(name="businessId",value="业务ID",required = true) @RequestParam(name="businessId",required=true) String businessId) {
Result<List<ProcessAuditHistoryVO>> result = new Result<List<ProcessAuditHistoryVO>>();
List<ProcessAuditHistoryVO> resultList = generalProcessService.queryAuditHistory(processId, businessId);
result.success("成功");
result.setResult(resultList);
return result;
}
@AutoLog(value = "流程自定义用户获取-流程自定义用户获取")
@ApiOperation(value="流程自定义用户获取-流程自定义用户获取", notes="通过业务id获取与之关联的流程派发自定义用户")
@GetMapping(value = "/getCustomAuditUser")
public Result<List<ProcessCustomAuditUserVO>> getCustomAuditUser(@ApiParam(name="businessId",value="业务ID",required = true) @RequestParam(name="businessId",required=true) String businessId) {
Result<List<ProcessCustomAuditUserVO>> result = new Result<List<ProcessCustomAuditUserVO>>();
List<ProcessCustomAuditUserVO> resultList = generalProcessService.queryCustomAuditUser(businessId);
result.success("成功");
result.setResult(resultList);
return result;
}
@ApiOperation(value="更改业务表办结状态【办结/不予受理】", notes="当流程审批为办结或不予受理时,更新业务表办结状态")
@GetMapping(value = "/updateBusinessTableCompleteTag")
public Result<String> updateBusinessTableCompleteTag(@ApiParam(name="tableName",value="业务表名",required = true) @RequestParam(name="tableName",required=true) String tableName,
@ApiParam(name="completeTag",value="办结状态【已办结yes/未办结no/不予受理bysl】",required = true) @RequestParam(name="completeTag",required=true) String completeTag,
@ApiParam(name="businessId",value="业务id",required = true) @RequestParam(name="businessId",required=true) String businessId) {
Result<String> result = new Result<String>();
boolean updateResult = generalProcessService.updateBusinessTableCompleteTag(tableName,completeTag,businessId);
if(updateResult) {
result.success("成功");
result.setResult("更新成功");
}else {
result.error500("办结状态更新失败");
}
return result;
}
@ApiOperation(value="流程自定义审批用户配置", notes="工作流审批节点自定义用户配置")
@GetMapping(value = "/configureCustomUser")
public Result<String> configureCustomUser(@ApiParam(name="businessId",value="业务id",required = true) @RequestParam(name="businessId",required=true) String businessId,
@ApiParam(name="processId",value="流程id",required = true) @RequestParam(name="processId",required=true) String processId,
@ApiParam(name="nodeValue",value="节点值",required = true) @RequestParam(name="nodeValue",required=true) String nodeValue,
@ApiParam(name="opeId",value="操作人id",required = true) @RequestParam(name="opeId",required=true) String opeId
) {
Result<String> result = new Result<String>();
generalProcessService.configureCustomUser(businessId,processId,nodeValue,opeId);
if(true) {
result.success("成功");
result.setResult("更新成功");
}else {
result.error500("办结状态更新失败");
}
return result;
}
}