-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessinstance.go
101 lines (89 loc) · 3.49 KB
/
processinstance.go
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
package dingtalk
import (
"fmt"
)
//https://ding-doc.dingtalk.com/document#/org-dev-guide/obtains-details-about-a-specified-approval-instance
type ProInstance struct {
Msg
RequestId string `json:"request_id"`
ProcessInstance struct {
Title string `json:"title"`
CreateTime int64 `json:"create_time"`
FinishTime int64 `json:"finish_time"`
OriginatorUserId string `json:"originator_userid"` //发起人ID
OriginatorDeptId string `json:"originator_dept_id"` //发起人部门 -1跟部门
Status string `json:"status"` //状态码 NEW:新创建 RUNNING:审批中 TERMINATED:被终止 COMPLETED:完成 CANCELED:取消
ApproverUserids []string `json:"approver_userids"` //审批人ID素组
CcUserids []string `json:"cc_userids"` //抄送人ID数组
Result string `json:"result"` //结果
BusinessId string `json:"business_id"` //审批实例业务编号。
AttachedProcessInstanceIds []string `json:"attached_process_instance_ids"` //附属实例
BizAction string `json:"biz_action"` //MODIFY:表示该审批实例是基于原来的实例修改而来 REVOKE:表示该审批实例是由原来的实例撤销后重新发起的 NONE表示正常发起
OriginatorDeptName string `json:"originator_dept_name"` //发起部门
FormComponentValues []struct {
Name string `json:"name"`
Value string `json:"value"`
Id string `json:"id"`
ComponentType string `json:"component_type"`
} `json:"form_component_values"`
} `json:"process_instance"`
}
type ProcessCodeMsg struct {
Msg
ProcessCode string `json:"process_code"`
}
func (this *DingTalk) GetProInstance(pid string) ProInstance {
token := this.GetToken()
apiUrl := fmt.Sprintf(processinstanceUrl, token)
PostData := map[string]string{"process_instance_id": pid}
var msg ProInstance
err := PostJsonPtr(apiUrl, PostData, &msg)
if err == nil {
return msg
} else {
return msg
}
}
func (this *DingTalk) GetProInstance1(pid string) string {
token := this.GetToken()
apiUrl := fmt.Sprintf(processinstanceUrl, token)
PostData := map[string]string{"process_instance_id": pid}
rs, err := PostJson(apiUrl, PostData)
if err == nil {
return string(rs)
} else {
return string(rs)
}
}
func (this *DingTalk) GetBpmProcessCodeByName(name string) string {
token := this.GetToken()
apiUrl := fmt.Sprintf(ProcessinstanceTerminateUrl, token)
PostData := map[string]string{"name": name}
var msg ProcessCodeMsg
err := PostJsonPtr(apiUrl, PostData, &msg)
if err == nil {
return msg.ProcessCode
} else {
return ""
}
}
func (this *DingTalk) StopProInstance(pid string, remark string) StopProInstanceMsg {
token := this.GetToken()
apiUrl := fmt.Sprintf(ProcessinstanceTerminateUrl, token)
PostData := map[string]interface{}{
"request": map[string]interface{}{
"is_system": true,
"process_instance_id": pid,
"remark": remark,
},
}
var msg StopProInstanceMsg
err := PostJsonPtr(apiUrl, PostData, &msg)
// fmt.Printf("%-v", PostData)
if err == nil {
return msg
} else {
fmt.Println(4, err.Error())
return msg
}
}