From 82e16a24d83577834049e0b01868a0396b3dc9ae Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 14 Aug 2024 18:24:27 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20assign=20scrap=20=E5=B7=A5=E5=BB=BA?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=BA=A4=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/cus_eng_con_sys.go | 5 +- config.json | 3 +- cus-eng-con-sys/model/assign_scrap.go | 64 ++++++++++++++++++ cus-eng-con-sys/model/search_acc_send_list.go | 65 +++++++++++++++++++ cus-eng-con-sys/service/acceptance_confirm.go | 2 +- cus-eng-con-sys/service/withdraw_assign.go | 64 ++++++++++++++++++ 6 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 cus-eng-con-sys/model/assign_scrap.go create mode 100644 cus-eng-con-sys/model/search_acc_send_list.go create mode 100644 cus-eng-con-sys/service/withdraw_assign.go diff --git a/cmd/cus_eng_con_sys.go b/cmd/cus_eng_con_sys.go index 380b861..53efed5 100644 --- a/cmd/cus_eng_con_sys.go +++ b/cmd/cus_eng_con_sys.go @@ -28,7 +28,7 @@ var engSysCmd = &cobra.Command{ } func run(c *config.Config) { - j, _ := filekit.ReadString("test.json") + j, _ := filekit.ReadString("test1.json") data := gjson.Get(j, "data").Array() for _, v := range data { name := v.Get("name").String() @@ -37,6 +37,7 @@ func run(c *config.Config) { logkit.Info("***现在开始处理***:" + gjson.Get(v.String(), "tasktitle").String()) _ = commonkit.RecoverFuncWrapper(func() { service.ReqAccConfirm(v.Get("processInstanceId").String(), v.Get("id").String()) + //service.ReqWithdrawAssign(v.Get("processInstanceId").String()) }) time.Sleep(5 * time.Second) } @@ -47,5 +48,5 @@ func defFlagsEng(cmd *cobra.Command) { cmd.Flags().String(config.EngSysProcess, "", "Specify the process to be processed, supporting: XQXJ,ZQLX,LYXJ") cmd.Flags().String(config.EngSysStep, "", "Specify the steps to be processed, supporting: YSQR") cmd.Flags().String(config.EngSysSid, "", "Specify the sid") - //TODO 验收确认阶段,还需要指定交付的人,暂时写死在代码里,目前只适用于周一彬,如果需要调整,则暂时现在代码里调整 + //TODO 验收确认阶段,还需要指定交付的人,暂时写死在代码里,目前只适用于周一彬,如果需要调整,则暂时先在代码里调整 } diff --git a/config.json b/config.json index 56b9d98..15ad712 100644 --- a/config.json +++ b/config.json @@ -4,7 +4,8 @@ }, "eng": { "step": "YSQR", - "sid": "935f8b6c-2687-4475-9727-4aae7fccc5a2" + "pro": "XQXJ", + "sid": "6c167917-915b-41e6-bb9f-5b943449a0b8" }, "wechat": { "api": "", diff --git a/cus-eng-con-sys/model/assign_scrap.go b/cus-eng-con-sys/model/assign_scrap.go new file mode 100644 index 0000000..660c40e --- /dev/null +++ b/cus-eng-con-sys/model/assign_scrap.go @@ -0,0 +1,64 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "reflect" +) + +/* +/zjgd/frm/acceptanceComfirmController/assignScrap +*/ + +/* +用途:取消交付 +*/ + +type AssignScrap struct { + DeliveryId string `map:"deliveryId"` + DeliveryStatus string `map:"deliveryStatus"` + ParentProcInsId string `map:"parentProcInsId"` + Ranstr string `map:"ranstr"` + Timestamp string `map:"timestamp"` +} + +func NewAssignScrap(deliveryId, parenProcInsId string) *AssignScrap { + assignScrap := new(AssignScrap) + assignScrap.DeliveryId = deliveryId + assignScrap.DeliveryStatus = "ABANDON" + assignScrap.ParentProcInsId = parenProcInsId + assignScrap.Ranstr = cryptokit.RandomStr(true, 10, 32) + assignScrap.Timestamp = cryptokit.GetTimeStamp() + return assignScrap +} + +func (th *AssignScrap) GenReqParam() map[string]string { + th.encrypt() + return th.structToMap() +} + +func (th *AssignScrap) structToMap() map[string]string { + result := make(map[string]string) + t := reflect.TypeOf(*th) + v := reflect.ValueOf(*th) + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + value := v.Field(i) + // Use the tag value as the key in the map, if it exists; otherwise, use the field name. + tag := field.Tag.Get("map") + if tag == "" { + tag = field.Name + } + result[tag] = value.String() + } + return result +} + +func (th *AssignScrap) encrypt() { + v := reflect.ValueOf(th).Elem() + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + if field.CanSet() { + field.SetString(cryptokit.Encrypt(field.String())) + } + } +} diff --git a/cus-eng-con-sys/model/search_acc_send_list.go b/cus-eng-con-sys/model/search_acc_send_list.go new file mode 100644 index 0000000..314f1d4 --- /dev/null +++ b/cus-eng-con-sys/model/search_acc_send_list.go @@ -0,0 +1,65 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "reflect" +) + +/* +/zjgd/frm/acceptanceComfirmController/searchAccSendList +*/ + +/* +用途:取消交付 +1、获取assignScrap接口入参:deliveryId +*/ + +type SearchAccSendList struct { + Start string `map:"start"` + Length string `map:"length"` + ParentProcInsId string `map:"parentProcInsId"` + Ranstr string `map:"ranstr"` + Timestamp string `map:"timestamp"` +} + +func NewSearchAccSendList(parenProcInsId string) *SearchAccSendList { + searchAccSendList := new(SearchAccSendList) + searchAccSendList.Start = "1" + searchAccSendList.Length = "10" + searchAccSendList.ParentProcInsId = parenProcInsId + searchAccSendList.Ranstr = cryptokit.RandomStr(true, 10, 32) + searchAccSendList.Timestamp = cryptokit.GetTimeStamp() + return searchAccSendList +} + +func (th *SearchAccSendList) GenReqParam() map[string]string { + th.encrypt() + return th.structToMap() +} + +func (th *SearchAccSendList) structToMap() map[string]string { + result := make(map[string]string) + t := reflect.TypeOf(*th) + v := reflect.ValueOf(*th) + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + value := v.Field(i) + // Use the tag value as the key in the map, if it exists; otherwise, use the field name. + tag := field.Tag.Get("map") + if tag == "" { + tag = field.Name + } + result[tag] = value.String() + } + return result +} + +func (th *SearchAccSendList) encrypt() { + v := reflect.ValueOf(th).Elem() + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + if field.CanSet() { + field.SetString(cryptokit.Encrypt(field.String())) + } + } +} diff --git a/cus-eng-con-sys/service/acceptance_confirm.go b/cus-eng-con-sys/service/acceptance_confirm.go index 2fcf29a..63b2cff 100644 --- a/cus-eng-con-sys/service/acceptance_confirm.go +++ b/cus-eng-con-sys/service/acceptance_confirm.go @@ -24,7 +24,7 @@ func ReqAccConfirm(parenProcInsId, id string) { //更新ACC信息 updateAccInfo(parenProcInsId, id) //提交验收确认 - //saveProAndStart(parenProcInsId) + saveProAndStart(parenProcInsId) } func updateAccInfo(processInstanceId, id string) { diff --git a/cus-eng-con-sys/service/withdraw_assign.go b/cus-eng-con-sys/service/withdraw_assign.go new file mode 100644 index 0000000..31c4864 --- /dev/null +++ b/cus-eng-con-sys/service/withdraw_assign.go @@ -0,0 +1,64 @@ +package service + +import ( + "cu-helper/cus-eng-con-sys/config" + "cu-helper/cus-eng-con-sys/cryptokit" + "cu-helper/cus-eng-con-sys/model" + "github.com/go-resty/resty/v2" + "github.com/mizuki1412/go-core-kit/class/exception" + "github.com/mizuki1412/go-core-kit/service/logkit" + "github.com/tidwall/gjson" + "strings" + "time" +) + +// AssignScrap 取消交付 +/* +取消交付分两个步骤进行 +1、searchAccSendList获取deliveryId +2、assignScrap +*/ + +func ReqWithdrawAssign(parenProcInsId string) { + list := searchAccSendList(parenProcInsId) + assignScrap(list, parenProcInsId) +} + +func searchAccSendList(parenProcInsId string) []string { + h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") + header := h.GenReqParam() + f := model.NewSearchAccSendList(parenProcInsId) + form := f.GenReqParam() + client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second) + resp, err := client.R(). + SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/searchAccSendList") + if err != nil { + panic(exception.New(err.Error())) + } + data := strings.Trim(resp.String(), `"`) + decrypt := cryptokit.Decrypt(data) + ok := gjson.Get(decrypt, "data").Array() + var deliveryIdList []string + for _, v := range ok { + deliveryId := gjson.Get(v.String(), "deliveryId").String() + deliveryIdList = append(deliveryIdList, deliveryId) + } + return deliveryIdList +} + +func assignScrap(deliveryIdList []string, parenProcInsId string) { + client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second) + h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") + header := h.GenReqParam() + for _, v := range deliveryIdList { + f := model.NewAssignScrap(v, parenProcInsId) + form := f.GenReqParam() + resp, err := client.R(). + SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/assignScrap") + if err != nil { + panic(exception.New(err.Error())) + } + data := strings.Trim(resp.String(), `"`) + logkit.Info("assignScarp:" + cryptokit.Decrypt(data)) + } +}