|
@@ -52,9 +52,12 @@ var workflowTemplateMap = map[string]string{
|
|
|
|
|
|
func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeRequest) error {
|
|
func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeRequest) error {
|
|
//根据业务类型获取流程模型ID
|
|
//根据业务类型获取流程模型ID
|
|
- workflowTempalteId := workflowTemplateMap[reqParams.BusinessType]
|
|
|
|
- if utils.IsStringEmpty(workflowTempalteId) {
|
|
|
|
- return errors.New("未配置流程")
|
|
|
|
|
|
+ workflowTemplateId, err := getWorkTemplateInfoByBusinessType(reqParams.BusinessType, reqParams.TenantID)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ if utils.IsStringEmpty(workflowTemplateId) {
|
|
|
|
+ return errors.New("该业务类型未配置流程")
|
|
}
|
|
}
|
|
|
|
|
|
businessObject := &request.WorkflowBusinessObject{
|
|
businessObject := &request.WorkflowBusinessObject{
|
|
@@ -69,7 +72,7 @@ func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeR
|
|
|
|
|
|
err = StartWorkflow(&request.StartWorkflowRequest{
|
|
err = StartWorkflow(&request.StartWorkflowRequest{
|
|
LaunchUserName: reqParams.LaunchUserName,
|
|
LaunchUserName: reqParams.LaunchUserName,
|
|
- WorkflowTemplateID: workflowTempalteId,
|
|
|
|
|
|
+ WorkflowTemplateID: workflowTemplateId,
|
|
Matter: reqParams.Matter,
|
|
Matter: reqParams.Matter,
|
|
BusinessObject: businessObjectStr,
|
|
BusinessObject: businessObjectStr,
|
|
CreateUserID: reqParams.CreateUserID,
|
|
CreateUserID: reqParams.CreateUserID,
|
|
@@ -102,10 +105,33 @@ func StartWorkflow(reqParams *request.StartWorkflowRequest) error {
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
-
|
|
|
|
if !resp.Success {
|
|
if !resp.Success {
|
|
return errors.New(resp.Msg)
|
|
return errors.New(resp.Msg)
|
|
}
|
|
}
|
|
|
|
|
|
return nil
|
|
return 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
|
|
|
|
+}
|