张亚军 пре 1 месец
родитељ
комит
c71c49945a
11 измењених фајлова са 253 додато и 0 уклоњено
  1. 8 0
      .idea/.gitignore
  2. 9 0
      .idea/cws-sdk.iml
  3. 8 0
      .idea/modules.xml
  4. 6 0
      .idea/vcs.xml
  5. 17 0
      go.mod
  6. 61 0
      go.sum
  7. 27 0
      ng_cw_client/ng_cw_client.go
  8. 6 0
      service/method_names.go
  9. 1 0
      service/reponse/workflow.go
  10. 24 0
      service/request/workflow.go
  11. 86 0
      service/workflow.go

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 9 - 0
.idea/cws-sdk.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="Go" enabled="true" />
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/cws-sdk.iml" filepath="$PROJECT_DIR$/.idea/cws-sdk.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 17 - 0
go.mod

@@ -0,0 +1,17 @@
+module cws-sdk
+
+go 1.21.3
+
+toolchain go1.22.7
+
+require (
+	git.sxidc.com/go-tools/utils v1.5.29
+	git.sxidc.com/service-supports/dapr_api v0.2.0
+)
+
+require (
+	github.com/go-resty/resty/v2 v2.11.0 // indirect
+	github.com/kr/pretty v0.3.1 // indirect
+	github.com/satori/go.uuid v1.2.0 // indirect
+	golang.org/x/net v0.21.0 // indirect
+)

+ 61 - 0
go.sum

@@ -0,0 +1,61 @@
+git.sxidc.com/go-tools/utils v1.5.29 h1:OUrjzmnjxn+Anmz6FK2X5Pr4ljyrq5qNBaDs1dJLM6g=
+git.sxidc.com/go-tools/utils v1.5.29/go.mod h1:uTDb6QK5JZzK5+Fzsfeng7TwmnRDZiTY6JLYxIX94Qw=
+git.sxidc.com/service-supports/dapr_api v0.2.0 h1:OFTvpvWeIIHASnwPm+7khb6A5kOmy8dtH5C3CO2J2Kk=
+git.sxidc.com/service-supports/dapr_api v0.2.0/go.mod h1:lvu4Pba0W9ne4vZFs/H5cxhjedD80MxAeLtCw9B8jJs=
+github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8=
+github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A=
+github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
+github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
+github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
+github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
+github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
+github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
+golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
+golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
+golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
+golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
+golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
+golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
+golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
+golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
+golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
+golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

+ 27 - 0
ng_cw_client/ng_cw_client.go

@@ -0,0 +1,27 @@
+package ng_cw_client
+
+import (
+	"git.sxidc.com/service-supports/dapr_api/invoke"
+	"time"
+)
+
+var invokeAPI *invoke.API
+
+func Init(baseUrl string, timeoutSec time.Duration) {
+	if invokeAPI == nil {
+		invokeAPI = invoke.NewAPI(baseUrl, timeoutSec)
+	}
+}
+
+func Destroy() {
+	if invokeAPI == nil {
+		return
+	}
+
+	invoke.DestroyAPI(invokeAPI)
+	invokeAPI = nil
+}
+
+func GetInvokeAPI() *invoke.API {
+	return invokeAPI
+}

+ 6 - 0
service/method_names.go

@@ -0,0 +1,6 @@
+package service
+
+const (
+	methodNamePrefix        = "cws/api/v1"
+	startWorkFlowMethodName = methodNamePrefix + "/workflow/launch"
+)

+ 1 - 0
service/reponse/workflow.go

@@ -0,0 +1 @@
+package reponse

+ 24 - 0
service/request/workflow.go

@@ -0,0 +1,24 @@
+package request
+
+type WorkflowBusinessObject struct {
+	BusinessType   string      `json:"businessType"`
+	BusinessObject interface{} `json:"businessObject"`
+}
+
+type StartWorkflowRequest struct {
+	WorkflowTemplateID string `json:"workflowTemplateId"`
+	LaunchUserName     string `json:"launchUserName"`
+	Matter             string `json:"matter"`
+	BusinessObject     string `json:"businessObject"`
+	CreateUserID       string `json:"createUserId"`
+	TenantID           string `json:"tenantId"`
+}
+
+type StartWorkFlowByBusinessTypeRequest struct {
+	BusinessType   string      `json:"businessType"`
+	LaunchUserName string      `json:"launchUserName"`
+	Matter         string      `json:"matter"`
+	Data           interface{} `json:"data"`
+	CreateUserID   string      `json:"createUserId"`
+	TenantID       string      `json:"tenantId"`
+}

+ 86 - 0
service/workflow.go

@@ -0,0 +1,86 @@
+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
+}