|
|
@@ -8,6 +8,7 @@ import (
|
|
|
"git.sxidc.com/service-supports/cws-sdk/service/response"
|
|
|
"git.sxidc.com/service-supports/cws-sdk/utils"
|
|
|
"git.sxidc.com/service-supports/cws-sdk/utils/http_client"
|
|
|
+ "git.sxidc.com/service-supports/cws-sdk/utils/request_util"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
@@ -32,7 +33,7 @@ func Destroy() {
|
|
|
|
|
|
func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeRequest) (string, error) {
|
|
|
//根据业务类型获取流程模型ID
|
|
|
- workflowTemplateId, err := getWorkTemplateInfoByBusinessType(reqParams.BusinessType, reqParams.TenantID)
|
|
|
+ workflowTemplateId, err := getWorkTemplateInfoByBusinessTypeApi(reqParams.BusinessType, reqParams.TenantID)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
@@ -54,16 +55,17 @@ func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeR
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
- businessObjectStr := string(jsonBytes)
|
|
|
+ businessEntityObjectStr := string(jsonBytes)
|
|
|
|
|
|
workflowId, err := StartWorkflow(&request.StartWorkflowRequest{
|
|
|
- WorkflowTemplateID: workflowTemplateId,
|
|
|
- LaunchUserName: reqParams.LaunchUserName,
|
|
|
- Matter: reqParams.Matter,
|
|
|
- BusinessObject: businessObjectStr,
|
|
|
- UserStructureID: customStructureInfo.ID,
|
|
|
- CreateUserID: reqParams.CreateUserID,
|
|
|
- TenantID: reqParams.TenantID,
|
|
|
+ WorkflowTemplateID: workflowTemplateId,
|
|
|
+ LaunchUserName: reqParams.LaunchUserName,
|
|
|
+ Matter: reqParams.Matter,
|
|
|
+ BusinessEntityObject: businessEntityObjectStr,
|
|
|
+ BusinessObject: businessEntityObjectStr,
|
|
|
+ UserStructureID: customStructureInfo.ID,
|
|
|
+ CreateUserID: reqParams.CreateUserID,
|
|
|
+ TenantID: reqParams.TenantID,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
@@ -73,6 +75,40 @@ func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeR
|
|
|
|
|
|
}
|
|
|
|
|
|
+func StartWorkFlowWithoutPrepareByBusinessType(reqParams *request.StartWorkFlowWithoutPrepareByBusinessTypeRequest) (string, error) {
|
|
|
+ //根据业务类型获取流程模型ID
|
|
|
+ workflowTemplateId, err := getWorkTemplateInfoByBusinessTypeApi(reqParams.BusinessType, reqParams.TenantID)
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+ if utils.IsStringEmpty(workflowTemplateId) {
|
|
|
+ return "", errors.New("该业务类型未配置流程")
|
|
|
+ }
|
|
|
+
|
|
|
+ jsonBytes, err := json.Marshal(reqParams.Data)
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+ businessEntityObjectStr := string(jsonBytes)
|
|
|
+
|
|
|
+ workflowId, err := StartWorkflow(&request.StartWorkflowRequest{
|
|
|
+ WorkflowTemplateID: workflowTemplateId,
|
|
|
+ LaunchUserName: reqParams.LaunchUserName,
|
|
|
+ Matter: reqParams.Matter,
|
|
|
+ BusinessEntityObject: businessEntityObjectStr,
|
|
|
+ BusinessObject: businessEntityObjectStr,
|
|
|
+ UserStructureID: reqParams.UserStructureID,
|
|
|
+ CreateUserID: reqParams.CreateUserID,
|
|
|
+ TenantID: reqParams.TenantID,
|
|
|
+ ChoiceApproveInfos: reqParams.ChoiceApproveInfos,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+
|
|
|
+ return workflowId, nil
|
|
|
+}
|
|
|
+
|
|
|
func StartWorkflowTemplate(reqParams *request.StartWorkflowTemplateRequest) (string, error) {
|
|
|
if utils.IsStringEmpty(cwsUrl) {
|
|
|
return "", errors.New("未配置CWS地址")
|
|
|
@@ -92,7 +128,7 @@ func StartWorkflowTemplate(reqParams *request.StartWorkflowTemplateRequest) (str
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
- businessObjectStr := string(jsonBytes)
|
|
|
+ businessEntityObjectStr := string(jsonBytes)
|
|
|
|
|
|
reqJsonParams := &request.StartWorkflowTemplateRequest{
|
|
|
StructureRootID: reqParams.StructureRootID,
|
|
|
@@ -100,7 +136,8 @@ func StartWorkflowTemplate(reqParams *request.StartWorkflowTemplateRequest) (str
|
|
|
Process: reqParams.Process,
|
|
|
LaunchUserName: reqParams.LaunchUserName,
|
|
|
Matter: reqParams.Matter,
|
|
|
- BusinessObject: businessObjectStr,
|
|
|
+ BusinessEntityObject: businessEntityObjectStr,
|
|
|
+ BusinessObject: businessEntityObjectStr,
|
|
|
UserStructureID: customStructureInfo.ID,
|
|
|
CreateUserID: reqParams.CreateUserID,
|
|
|
TenantID: reqParams.TenantID,
|
|
|
@@ -135,7 +172,13 @@ func StartWorkflow(reqParams *request.StartWorkflowRequest) (string, error) {
|
|
|
if utils.IsStringEmpty(cwsUrl) {
|
|
|
return "", errors.New("未配置CWS地址")
|
|
|
}
|
|
|
- requestJson, err := json.Marshal(reqParams)
|
|
|
+
|
|
|
+ reqMap := request_util.StructToMap(reqParams)
|
|
|
+ for nodeID, userIDs := range reqParams.ChoiceApproveInfos {
|
|
|
+ reqMap[nodeID] = userIDs
|
|
|
+ }
|
|
|
+
|
|
|
+ requestJson, err := json.Marshal(reqMap)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
@@ -157,30 +200,6 @@ func StartWorkflow(reqParams *request.StartWorkflowRequest) (string, error) {
|
|
|
return resp.Info, nil
|
|
|
}
|
|
|
|
|
|
-func getWorkTemplateInfoByBusinessType(businessType string, tenantId string) (string, error) {
|
|
|
-
|
|
|
- //查询业务类型配置
|
|
|
- queryParams := map[string]string{
|
|
|
- "code": businessType,
|
|
|
- "tenantId": tenantId,
|
|
|
- }
|
|
|
- newRequest := NGCwsClient.NewRequest(http_client.WithNewRequestTimeout(cwsTimeOut))
|
|
|
- newRequest.SetQueryParams(queryParams)
|
|
|
- resp, err := newRequest.Get(cwsUrl + service.GetWorkTemplateByCodeMethodName)
|
|
|
- if err != nil {
|
|
|
- return "", err
|
|
|
- }
|
|
|
- respInfo := new(response.InfoResponse[response.BusinessCatalogsInfoWithWorkflowTemplate])
|
|
|
- err = resp.Json(respInfo)
|
|
|
- if err != nil {
|
|
|
- return "", err
|
|
|
- }
|
|
|
- if !respInfo.Success {
|
|
|
- return "", errors.New(respInfo.Msg)
|
|
|
- }
|
|
|
- return respInfo.Info.WorkTemplateId, nil
|
|
|
-}
|
|
|
-
|
|
|
func LaunchWorkflowTemplatePrepare(reqParams *request.LaunchWorkflowTemplatePrepareParams) (*response.CustomStructureInfo, error) {
|
|
|
requestJson, err := json.Marshal(reqParams)
|
|
|
if err != nil {
|
|
|
@@ -212,24 +231,10 @@ func LaunchWorkflowTemplatePrepare(reqParams *request.LaunchWorkflowTemplatePrep
|
|
|
}
|
|
|
|
|
|
func LaunchWorkflowPrepare(reqParams *request.LaunchWorkflowPrepareParams) (*response.CustomStructureInfo, error) {
|
|
|
- requestJson, err := json.Marshal(reqParams)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- postResponse, err := NGCwsClient.NewRequest(http_client.WithNewRequestTimeout(cwsTimeOut)).
|
|
|
- Post(cwsUrl+service.StartWorkFlowPrepareMethodName, requestJson)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
- resp := new(response.InfosResponse[response.PrepareInfo])
|
|
|
- err = postResponse.Json(resp)
|
|
|
+ resp, err := launchWorkflowPrepareApi(reqParams)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- if !resp.Success {
|
|
|
- return nil, errors.New(resp.Msg)
|
|
|
- }
|
|
|
customStructureInfo := &response.CustomStructureInfo{}
|
|
|
for _, info := range resp.Infos {
|
|
|
if info.ID == "userStructureId" {
|
|
|
@@ -240,3 +245,26 @@ func LaunchWorkflowPrepare(reqParams *request.LaunchWorkflowPrepareParams) (*res
|
|
|
|
|
|
return customStructureInfo, nil
|
|
|
}
|
|
|
+
|
|
|
+func LaunchWorkflowByBusinessTypePrepare(tenantID string, businessType string, createUserID string) ([]response.PrepareInfo, error) {
|
|
|
+ //根据业务类型获取流程模型ID
|
|
|
+ workflowTemplateId, err := getWorkTemplateInfoByBusinessTypeApi(businessType, tenantID)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if utils.IsStringEmpty(workflowTemplateId) {
|
|
|
+ return nil, errors.New("该业务类型未配置流程")
|
|
|
+ }
|
|
|
+
|
|
|
+ //发起流程前校验 获取人员组织信息
|
|
|
+ resp, err := launchWorkflowPrepareApi(&request.LaunchWorkflowPrepareParams{
|
|
|
+ WorkflowTemplateID: workflowTemplateId,
|
|
|
+ CreateUserID: createUserID,
|
|
|
+ TenantID: tenantID,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return resp.Infos, nil
|
|
|
+}
|