Repository navigation
Expand file tree
/
Copy pathWorkflowUtils.java
More file actions
72 lines (67 loc) · 2.43 KB
/
Copy pathWorkflowUtils.java
File metadata and controls
72 lines (67 loc) · 2.43 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
package com.wcode.util;
import com.wcode.workflow.WorkflowEntity;
import org.slf4j.Logger;
import weaver.hrm.User;
import weaver.soa.workflow.request.DetailTableInfo;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.RequestInfo;
import weaver.soa.workflow.request.RequestService;
/**
* @author Y-Aron
* @version 1.0.0
* @create 2019/10/24 12:11
*/
public class WorkflowUtils {
private static final Logger logger = LoggerUtils.getLogger();
public static String createWorkflow(WorkflowEntity wf) {
logger.debug("---------->> 开始创建流程 <<----------");
if (!checkWorkflowInfo(wf)) return null;
RequestInfo req = new RequestInfo();
// 设置创建人ID
req.setCreatorid(wf.getUid() + "");
// 设置流程ID
req.setWorkflowid(wf.getWorkflowId());
// 设置流程标题
req.setDescription(wf.getTitle());
// 设置紧急程度
req.setRequestlevel(wf.getLevel().getValue());
// 设置提醒类型
req.setRemindtype(wf.getRemindType().getCode());
// 设置主表信息
MainTableInfo mt = wf.getMainTable();
if (mt != null) {
req.setMainTableInfo(mt);
}
// 设置明细表数据
DetailTableInfo dti = wf.getDetailTableInfo();
if (dti != null) {
req.setDetailTableInfo(dti);
}
try {
RequestService service = new RequestService();
// 创建流程
String requestId = service.createRequest(req);
if (!"".equals(requestId) && Integer.parseInt(requestId) > 0) {
logger.debug("----------> 流程创建成功:requestId: {}", requestId);
} else {
logger.error("----------> 流程创建失败!msg: {}", requestId);
}
return requestId;
} catch (Exception e) {
logger.error("----------> 流程创建失败!msg: {}", e.getMessage());
return null;
}
}
private static boolean checkWorkflowInfo(WorkflowEntity wf) {
logger.debug("-----> workflow info: {}", wf);
if (wf.getWorkflowId() == null || wf.getUid() == null) {
return false;
}
User user = User.getUser(wf.getUid(), 0);
if (user == null) {
logger.debug("创建人ID={}不存在!", wf.getUid());
return false;
}
return true;
}
}