|
@@ -50,11 +50,6 @@ func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeR
|
|
|
return "", err
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
jsonBytes, err := json.Marshal(reqParams.Data)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
@@ -78,6 +73,64 @@ func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeR
|
|
|
|
|
|
}
|
|
|
|
|
|
+func StartWorkflowTemplate(reqParams *request.StartWorkflowTemplateRequest) (string, error) {
|
|
|
+ if utils.IsStringEmpty(cwsUrl) {
|
|
|
+ return "", errors.New("未配置CWS地址")
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ customStructureInfo, err := LaunchWorkflowTemplatePrepare(&request.LaunchWorkflowTemplatePrepareParams{
|
|
|
+ StructureRootID: reqParams.StructureRootID,
|
|
|
+ CreateUserID: reqParams.CreateUserID,
|
|
|
+ TenantID: reqParams.TenantID,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+
|
|
|
+ jsonBytes, err := json.Marshal(reqParams.Data)
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+ businessObjectStr := string(jsonBytes)
|
|
|
+
|
|
|
+ reqJsonParams := &request.StartWorkflowTemplateRequest{
|
|
|
+ StructureRootID: reqParams.StructureRootID,
|
|
|
+ WorkflowTemplateName: reqParams.WorkflowTemplateName,
|
|
|
+ Process: reqParams.Process,
|
|
|
+ LaunchUserName: reqParams.LaunchUserName,
|
|
|
+ Matter: reqParams.Matter,
|
|
|
+ BusinessObject: businessObjectStr,
|
|
|
+ UserStructureID: customStructureInfo.ID,
|
|
|
+ CreateUserID: reqParams.CreateUserID,
|
|
|
+ TenantID: reqParams.TenantID,
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+
|
|
|
+ requestJson, err := json.Marshal(reqJsonParams)
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+ postResponse, err := NGCwsClient.NewRequest(http_client.WithNewRequestTimeout(cwsTimeOut)).
|
|
|
+ Post(cwsUrl+service.StartWorkFlowTemplateMethodName, requestJson)
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(response.InfoResponse[string])
|
|
|
+ err = postResponse.Json(resp)
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+ if !resp.Success {
|
|
|
+ return "", errors.New(resp.Msg)
|
|
|
+ }
|
|
|
+
|
|
|
+ return resp.Info, nil
|
|
|
+}
|
|
|
+
|
|
|
func StartWorkflow(reqParams *request.StartWorkflowRequest) (string, error) {
|
|
|
if utils.IsStringEmpty(cwsUrl) {
|
|
|
return "", errors.New("未配置CWS地址")
|
|
@@ -128,8 +181,37 @@ func getWorkTemplateInfoByBusinessType(businessType string, tenantId string) (st
|
|
|
return respInfo.Info.WorkTemplateId, nil
|
|
|
}
|
|
|
|
|
|
-func LaunchWorkflowPrepare(reqParams *request.LaunchWorkflowPrepareParams) (*response.CustomStructureInfo, error) {
|
|
|
+func LaunchWorkflowTemplatePrepare(reqParams *request.LaunchWorkflowTemplatePrepareParams) (*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.StartWorkFlowTemplatePrepareMethodName, requestJson)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
|
|
|
+ resp := new(response.InfosResponse[response.PrepareInfo])
|
|
|
+ err = postResponse.Json(resp)
|
|
|
+ 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" {
|
|
|
+ customStructureInfo.ID = info.Options[0].Value
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return customStructureInfo, nil
|
|
|
+}
|
|
|
+
|
|
|
+func LaunchWorkflowPrepare(reqParams *request.LaunchWorkflowPrepareParams) (*response.CustomStructureInfo, error) {
|
|
|
requestJson, err := json.Marshal(reqParams)
|
|
|
if err != nil {
|
|
|
return nil, err
|