package service import ( "cws-sdk/ng_cw_client" "cws-sdk/service/request" "encoding/json" "errors" "git.sxidc.com/go-tools/utils/strutils" "yunji/Gateway/websocket/api/response" ) var workflowTemplateMap = map[string]string{ "CGJH": "4e0f65ab8547436ba9f744c4dcaef14e", "CGDD": "5e9bb84779b34d31947107f2c4ead93d", "CGHT": "d0c7ac374d2a4ed58cd2ee5f1c065110", "RKZJ": "ffc0b6044e154707ad80d174c08236be", "RKYS": "bdf8eeaf78c146cd914aef8067dea8b2", "RK": "2b6338dcdddb4e51b992347e87a1044a", "XSHT": "2f1997724b4b49c99379a18bf7067cee", "XSDD": "e73bd99b5761464ea74a612d3eaf3ea7", "CK": "f82e46c9c4c04862a9babbf3734432e8", "SCJH": "762685ccfdc3499590d99d3a8d55b78f", "SCGD": "0d43eaff78bb4abf9d6c5634b74e212e", "SCZJ": "f5c091e62e6a4cef9a68fda99736fd2e", "BSD": "0973c19af66546899638d816cf5ee5c6", "BYD": "9d9762864db14271ad9ada7acc73bacd", "DBD": "c8aff838c20741758de134903d24934a", "KHTH": "1e12eb97c9db4e53bb0704bb1c3d93f7", "GYSTH": "459542e8b07a4cda93d98ba0234c079f", } func StartWorkFlowByBusinessType(reqParams *request.StartWorkFlowByBusinessTypeRequest) error { //根据业务类型获取流程模型ID workflowTempalteId := workflowTemplateMap[reqParams.BusinessType] if strutils.IsStringEmpty(workflowTempalteId) { return errors.New("未配置流程") } businessObject := &request.WorkflowBusinessObject{ BusinessType: reqParams.BusinessType, BusinessObject: reqParams.Data, } jsonBytes, err := json.Marshal(businessObject) if err != nil { return err } businessObjectStr := string(jsonBytes) err = StartWorkflow(&request.StartWorkflowRequest{ WorkflowTemplateID: workflowTempalteId, Matter: reqParams.Matter, BusinessObject: businessObjectStr, CreateUserID: reqParams.CreateUserID, TenantID: reqParams.TenantID, }) if err != nil { return err } return nil } func StartWorkflow(reqParams *request.StartWorkflowRequest) error { requestJson, err := json.Marshal(reqParams) if err != nil { return err } responseBytes, err := ng_cw_client.GetInvokeAPI().PostJSON(startWorkFlowMethodName, requestJson, nil) if err != nil { return err } resp := new(response.MsgResponse) err = json.Unmarshal(responseBytes, resp) if err != nil { return err } if !resp.Success { return errors.New(resp.Msg) } return nil }