...
|
...
|
@@ -14,9 +14,6 @@ import ( |
|
|
"encoding/json"
|
|
|
)
|
|
|
|
|
|
type SuplusApprove struct {
|
|
|
}
|
|
|
|
|
|
var (
|
|
|
ErrorRequestSuplus = fmt.Errorf("请求素加后台失败")
|
|
|
)
|
...
|
...
|
@@ -29,12 +26,15 @@ const ( |
|
|
ApproveIntegrate = "/approve-processes/integrate"
|
|
|
)
|
|
|
|
|
|
type SuplusApprove struct {
|
|
|
}
|
|
|
|
|
|
//新增审批实例
|
|
|
func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, process []*models.AuditFlowProcess) (err error) {
|
|
|
var (
|
|
|
request NewApproveInstanceRequest
|
|
|
response NewApproveInstanceResponse
|
|
|
mapApproves map[int]Approve = make(map[int]Approve)
|
|
|
mapApproves map[int]*Approve = make(map[int]*Approve)
|
|
|
relativeId int64
|
|
|
userCompany *models.UserCompany
|
|
|
)
|
...
|
...
|
@@ -51,7 +51,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
}
|
|
|
for i := range process {
|
|
|
var (
|
|
|
approve Approve
|
|
|
approve *Approve
|
|
|
approveType int //审批类型
|
|
|
approveWay int //审批方式
|
|
|
approver *models.User
|
...
|
...
|
@@ -72,10 +72,11 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
} else {
|
|
|
approveWay = 2 //或签
|
|
|
}
|
|
|
mapApproves[i] = Approve{
|
|
|
approve = &Approve{
|
|
|
ApproveType: item.AuditFlowType,
|
|
|
ApproveWay: approveWay,
|
|
|
}
|
|
|
mapApproves[i] = approve
|
|
|
}
|
|
|
if approver, err = models.GetUserByUcid(item.Uid); err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
@@ -84,6 +85,8 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
approve.ApproveUsers = append(approve.ApproveUsers, ApproveUsers{
|
|
|
Uid: item.Uid,
|
|
|
Name: approver.NickName,
|
|
|
//RoleId:5,
|
|
|
RoleId: 0,
|
|
|
})
|
|
|
}
|
|
|
request.RelativeId = relativeId
|
...
|
...
|
@@ -92,10 +95,9 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
request.Approves = append(request.Approves, v)
|
|
|
}
|
|
|
}
|
|
|
if s.DoRequest(NewApproveInstance, http.MethodPost, request, &response); err != nil {
|
|
|
if err = s.DoRequest(NewApproveInstance, http.MethodPost, request, &response); err != nil {
|
|
|
log.Error(err)
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("success request suplus-approve:%v request:%v response:%v", NewApproveInstance, common.AssertJson(request), common.AssertJson(response)))
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -162,7 +164,8 @@ func (s SuplusApprove) DoRequest(method string, methodType string, request inter |
|
|
return
|
|
|
}
|
|
|
if message.Errno != 0 {
|
|
|
err = fmt.Errorf("request-%v response-code:%v msg:%v", url, message.Errno, message.Errmsg)
|
|
|
err = fmt.Errorf("request-%v request-%v response-code:%v msg:%v", url, common.AssertJson(request), message.Errno, message.Errmsg)
|
|
|
return
|
|
|
}
|
|
|
var responseData string
|
|
|
if len(data) > 500 {
|
...
|
...
|
@@ -170,29 +173,27 @@ func (s SuplusApprove) DoRequest(method string, methodType string, request inter |
|
|
} else {
|
|
|
responseData = string(data)
|
|
|
}
|
|
|
if err = json.Unmarshal(message.Data, &response); err != nil {
|
|
|
log.Error(err)
|
|
|
if e := json.Unmarshal(message.Data, &response); e != nil {
|
|
|
log.Debug(fmt.Sprintf("request-%v request:%v rsp:%v", url, common.AssertJson(request), string(responseData)))
|
|
|
log.Error(e)
|
|
|
return
|
|
|
}
|
|
|
log.Debug(fmt.Sprintf("request-%v request:%v rsp:%v", url, request, responseData))
|
|
|
log.Debug(fmt.Sprintf("request-%v request:%v rsp:%v", url, common.AssertJson(request), common.AssertJson(response)))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
/*NewApproveInstance 新增审批实例*/
|
|
|
type NewApproveInstanceRequest struct {
|
|
|
Approves []Approve `json:"approves"` //审批节点列表
|
|
|
CompanyId int64 `json:"companyId"` //公司id
|
|
|
Approver string `json:"approver"` //提交人
|
|
|
Uid int64 `json:"uid"` //提交人id
|
|
|
Sign string `json:"sign"` //标识 ORDER-订单 ELSERK-其他入库 CHANCE-机会
|
|
|
Type int `json:"type"` //1-新增 2-编辑
|
|
|
RelativeId int64 `json:"relativeId"` //关联id
|
|
|
Approves []*Approve `json:"approves"` //审批节点列表
|
|
|
CompanyId int64 `json:"companyId"` //公司id
|
|
|
Approver string `json:"approver"` //提交人
|
|
|
Uid int64 `json:"uid"` //提交人id
|
|
|
Sign string `json:"sign"` //标识 ORDER-订单 ELSERK-其他入库 CHANCE-机会
|
|
|
Type int `json:"type"` //1-新增 2-编辑
|
|
|
RelativeId int64 `json:"relativeId"` //关联id
|
|
|
|
|
|
}
|
|
|
type NewApproveInstanceResponse struct {
|
|
|
protocol.ErrorCode
|
|
|
Data []string `json:"data"`
|
|
|
}
|
|
|
type NewApproveInstanceResponse interface{}
|
|
|
|
|
|
//审批节点
|
|
|
type Approve struct {
|
...
|
...
|
@@ -207,7 +208,7 @@ type ApproveUsers struct { |
|
|
Name string `json:"name"` //用户名
|
|
|
IsDefault int `json:"isDefault"` //1 是默认 0 不是
|
|
|
RoleName string `json:"roleName"` //角色名/负责人
|
|
|
RoleId string `json:"roleId"` //角色id
|
|
|
RoleId int `json:"roleId"` //角色id
|
|
|
ParentIds []int `json:"parentIds"`
|
|
|
}
|
|
|
|
...
|
...
|
@@ -231,3 +232,8 @@ type ApproveIntegrateRequest struct { |
|
|
}
|
|
|
type ApproveIntegrateResponse struct {
|
|
|
}
|
|
|
|
|
|
type AppproveProcess struct {
|
|
|
ExtendRelativeId int64 `json:"extendRelativeId"`
|
|
|
Status int `json:"status"`
|
|
|
} |
...
|
...
|
|