From faf0beacf67d0c0210e8a5aed1df3981c2c1c3c6 Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 18 Dec 2025 10:34:29 +0800 Subject: [PATCH] update: cus-eng-con-sys --- cmd/cus_eng_con_sys.go | 7 +- cus-eng-con-sys/config/config.go | 2 + cus-eng-con-sys/config/config_constant.go | 2 + cus-eng-con-sys/model/go_pdm_entrust_edit.go | 55 +++++++++++ cus-eng-con-sys/model/pdm_push_process.go | 85 +++++++++++++++++ .../model/update_pdm_production.go | 87 +++++++++++++++++ cus-eng-con-sys/service/acceptance_confirm.go | 2 +- cus-eng-con-sys/service/pdm_entrust.go | 94 +++++++++++++++++++ 8 files changed, 330 insertions(+), 4 deletions(-) create mode 100644 cus-eng-con-sys/model/go_pdm_entrust_edit.go create mode 100644 cus-eng-con-sys/model/pdm_push_process.go create mode 100644 cus-eng-con-sys/model/update_pdm_production.go create mode 100644 cus-eng-con-sys/service/pdm_entrust.go diff --git a/cmd/cus_eng_con_sys.go b/cmd/cus_eng_con_sys.go index c8261d1..f57efcf 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("25723-jf-wym.json") + j, _ := filekit.ReadString("kr.json") data := gjson.Get(j, "data").Array() for _, v := range data { name := v.Get("name").String() @@ -38,7 +38,8 @@ func run(c *config.Config) { _ = commonkit.RecoverFuncWrapper(func() { //service.ReqAccConfirm(v.Get("processInstanceId").String(), v.Get("id").String()) //service.ReqWithdrawAssign(v.Get("processInstanceId").String()) - service.ReqAccDelivery(v.Get("processInstanceId").String(), v.Get("id").String()) + //service.ReqAccDelivery(v.Get("processInstanceId").String(), v.Get("id").String()) + service.ReqPdmEntrust(v.Get("processInstanceId").String(), v.Get("id").String(), gjson.Get(v.String(), "tasktitle").String()) }) time.Sleep(1 * time.Second) } @@ -47,7 +48,7 @@ func run(c *config.Config) { func defFlagsEng(cmd *cobra.Command) { cmd.Flags().String(config.EngSysProcess, "", "Specify the process to be processed, supporting: XQXJ,ZQLX,LYXJ,YSJF") - cmd.Flags().String(config.EngSysStep, "", "Specify the steps to be processed, supporting: YSQR,JFSQ") + cmd.Flags().String(config.EngSysStep, "", "Specify the steps to be processed, supporting: SJWT,YSQR,JFSQ") cmd.Flags().String(config.EngSysSid, "", "Specify the sid") //TODO 验收确认阶段,还需要指定交付的人,暂时写死在代码里,目前只适用于周一彬,如果需要调整,则暂时先在代码里调整 } diff --git a/cus-eng-con-sys/config/config.go b/cus-eng-con-sys/config/config.go index 67b0e68..ce44b16 100644 --- a/cus-eng-con-sys/config/config.go +++ b/cus-eng-con-sys/config/config.go @@ -24,6 +24,8 @@ func Init() { configkit.Set(EngSysStep, StepYSQR) case EngSysStepJFSQ: configkit.Set(EngSysStep, StepJFSQ) + case EngSysStepSJWT: + configkit.Set(EngSysStep, StepSJWT) default: logkit.Fatal("EngSysStep Not Support!") } diff --git a/cus-eng-con-sys/config/config_constant.go b/cus-eng-con-sys/config/config_constant.go index 287a975..f35c74a 100644 --- a/cus-eng-con-sys/config/config_constant.go +++ b/cus-eng-con-sys/config/config_constant.go @@ -9,11 +9,13 @@ const ( const ( EngSysStepYSQR = "YSQR" EngSysStepJFSQ = "JFSQ" + EngSysStepSJWT = "SJWT" ) const ( StepYSQR = "验收确认" StepJFSQ = "验收交付申请" + StepSJWT = "设计委托" ) // config里入参 diff --git a/cus-eng-con-sys/model/go_pdm_entrust_edit.go b/cus-eng-con-sys/model/go_pdm_entrust_edit.go new file mode 100644 index 0000000..7828a91 --- /dev/null +++ b/cus-eng-con-sys/model/go_pdm_entrust_edit.go @@ -0,0 +1,55 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "reflect" +) + +/* +http://10.202.2.108:8086/zjgd/frm/acceptanceComfirmController/toAcceptanceComfirm?businessKey=ig0+wuJz1ydtzu4VbmlXigelzjrHpK2M95FWj1QqFZhIXAPC/wQsSLtbQzJMombk&processInstanceId=hOVgJWbcGMSpwlAyOahXOQ==&taskDefinitionKey=TbtfJ6chgqzgSldk3ONCqQ==&taskId=RjahQdQO070+0msrB5z0rQ==&startLink=Jy0nsEWMSdJA3lqME93vgA==&endLink=Jy0nsEWMSdJA3lqME93vgA==&taskflag=facpUhYPtTztlU3uwUpNpA==&ranstr=4rUNDFPWHZwTW36OfKVg1jT7bnoF1dg4/dR2wgtzWnQ=×tamp=1RhySb/bDJGzULZTDF2g4Q==&_=1720262226902 +*/ + +/* +用途 +1、/zjgd/frm/pdmProductionController/updatePdmProduction.action时入参使用 +*/ + +type GoPdmEntrustEdit struct { + BusinessKey string `map:"businessKey"` + ProcessInstanceId string `map:"processInstanceId"` + TaskDefinitionKey string `map:"taskDefinitionKey"` + TaskId string `map:"taskId"` + StartLink string `map:"startLink"` + EndLink string `map:"endLink"` + TaskFlag string `map:"taskflag"` + Ranstr string `map:"ranstr"` + Timestamp string `map:"timestamp"` + TimestampPro string `map:"_"` //工建原始请求key就这样 +} + +func NewGoPdmEntrustEdit(businessKey, processInstId, taskId string) *GoPdmEntrustEdit { + goPdmEntrustEdit := new(GoPdmEntrustEdit) + goPdmEntrustEdit.BusinessKey = businessKey + goPdmEntrustEdit.ProcessInstanceId = processInstId + goPdmEntrustEdit.TaskDefinitionKey = "JSFAWT" + goPdmEntrustEdit.TaskId = taskId //等于id + goPdmEntrustEdit.StartLink = "false" + goPdmEntrustEdit.EndLink = "false" + goPdmEntrustEdit.TaskFlag = "db" + goPdmEntrustEdit.Ranstr = cryptokit.RandomStr(true, 10, 32) + goPdmEntrustEdit.Timestamp = cryptokit.GetTimeStamp() + goPdmEntrustEdit.encrypt() + //这个最终不加密 + goPdmEntrustEdit.TimestampPro = cryptokit.GetTimeStamp() + return goPdmEntrustEdit +} + +func (th *GoPdmEntrustEdit) 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/pdm_push_process.go b/cus-eng-con-sys/model/pdm_push_process.go new file mode 100644 index 0000000..80031be --- /dev/null +++ b/cus-eng-con-sys/model/pdm_push_process.go @@ -0,0 +1,85 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "reflect" +) + +/* +/zjgd/frm/pdmEntrustController/pushProcess.action +*/ + +/* +用途:设计委托 +*/ + +type PDMPushProcess struct { + ProcessInstanceId string `map:"processInstanceId"` + TaskId string `map:"taskId"` + TaskDefinitionKey string `map:"taskDefinitionKey"` + Assignee string `map:"assignee"` + Comment string `map:"comment"` + Title string `map:"title"` + HandleType string `map:"handleType"` + Withdraw string `map:"withdraw"` + PdmServiceProviderId string `map:"pdmServiceProviderId"` + PdmProjReceiverId string `map:"pdmProjReceiverId"` + BuildModel string `map:"buildModel"` + SupervisorProviderId string `map:"supervisorProviderId"` + SupervisorReceiverId string `map:"supervisorReceiverId"` + Ranstr string `map:"ranstr"` + Timestamp string `map:"timestamp"` +} + +func NewPDMPushProcess(processInsId, taskId, taskTitle string) *PDMPushProcess { + pdmPushProcess := new(PDMPushProcess) + pdmPushProcess.ProcessInstanceId = processInsId + pdmPushProcess.TaskId = taskId + pdmPushProcess.TaskDefinitionKey = "FABZ" + pdmPushProcess.Assignee = "3083564" //todo 每个人都是这个吗 + pdmPushProcess.Comment = "请协助编制建设方案" + pdmPushProcess.Title = taskTitle + pdmPushProcess.HandleType = "1" + pdmPushProcess.Withdraw = "0" + pdmPushProcess.PdmServiceProviderId = "1538321" + pdmPushProcess.PdmProjReceiverId = "3083564" + pdmPushProcess.BuildModel = "ZJ" + pdmPushProcess.SupervisorProviderId = "309320681" + pdmPushProcess.SupervisorReceiverId = "3098707" + pdmPushProcess.Ranstr = cryptokit.RandomStr(true, 10, 32) + pdmPushProcess.Timestamp = cryptokit.GetTimeStamp() + return pdmPushProcess +} + +// GenReqParam 返回加密后的请求参数 +func (th *PDMPushProcess) GenReqParam() map[string]string { + th.encrypt() + return th.structToMap() +} + +func (th *PDMPushProcess) 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 *PDMPushProcess) 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/update_pdm_production.go b/cus-eng-con-sys/model/update_pdm_production.go new file mode 100644 index 0000000..0cc10f1 --- /dev/null +++ b/cus-eng-con-sys/model/update_pdm_production.go @@ -0,0 +1,87 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "cu-helper/cus-eng-con-sys/util" + "github.com/mizuki1412/go-core-kit/service/logkit" + "reflect" +) + +/* +http://10.202.2.108:8086/zjgd/frm/pdmProductionController/updatePdmProduction.action +*/ + +/* +用途 +1、updatePdmProduction入参 +*/ + +type UpdatePdmProduction struct { + RemandTouzi string `map:"remandTouzi"` + RemandId string `map:"remandId"` + BuildAttr string `map:"buildAttr"` + PdmServiceProviderId string `map:"pdmServiceProviderId"` + PdmProjReceiverId string `map:"pdmProjReceiverId"` + BuildModel string `map:"buildModel"` + GovEnterpId string `map:"govEnterpId"` + ResourceType string `map:"resourceType"` + IsNewNational string `map:"isNewNational"` + SupervisorProviderId string `map:"supervisorProviderId"` + SupervisorReceiverId string `map:"supervisorReceiverId"` + Ranstr string `map:"ranstr"` + Timestamp string `map:"timestamp"` +} + +func NewUpdatePdmProduction(remandId, html, taskTitle string) *UpdatePdmProduction { + updatePdmProduction := new(UpdatePdmProduction) + remandTouzi := util.RegexpFindFirst(html, `投资\s*(\d+(?:\.\d+)?)\s*元`) + updatePdmProduction.RemandTouzi = remandTouzi + updatePdmProduction.RemandId = remandId + updatePdmProduction.BuildAttr = "PT" + updatePdmProduction.PdmServiceProviderId = "1538321" + updatePdmProduction.PdmProjReceiverId = "3083564" + updatePdmProduction.BuildModel = "ZJ" + updatePdmProduction.GovEnterpId = "" + updatePdmProduction.ResourceType = "undefined" + updatePdmProduction.IsNewNational = "0" + updatePdmProduction.SupervisorProviderId = "309320681" + updatePdmProduction.SupervisorReceiverId = "3098707" + updatePdmProduction.Ranstr = cryptokit.RandomStr(true, 10, 32) + updatePdmProduction.Timestamp = cryptokit.GetTimeStamp() + logkit.Info(taskTitle + " 投资:" + remandTouzi + "元") + return updatePdmProduction +} + +// GenReqParam 返回加密后的请求参数 +func (th *UpdatePdmProduction) GenReqParam() map[string]string { + th.encrypt() + return th.structToMap() +} + +func (th *UpdatePdmProduction) 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 *UpdatePdmProduction) 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 63b2cff..80d268c 100644 --- a/cus-eng-con-sys/service/acceptance_confirm.go +++ b/cus-eng-con-sys/service/acceptance_confirm.go @@ -87,7 +87,7 @@ func getRemandId(processInstanceId, id string) string { f := model.NewGetBusinessKey() form := f.GenReqParam() resp, err := client.R(). - SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/workflowrest/tasktodopath/GkXjGzKrProcess/" + processInstanceId + "/YSQR/" + id + "/ZH_XZ") //ZH_XZ在杭州应该不变化 + SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/workflowrest/tasktodopath/GkXjGzKrProcess/" + processInstanceId + "/YSQR/" + id + "/ZH_XZ") //ZH_XZ在杭州应该不变化 扩容不一样 if err != nil { panic(exception.New(err.Error())) } diff --git a/cus-eng-con-sys/service/pdm_entrust.go b/cus-eng-con-sys/service/pdm_entrust.go new file mode 100644 index 0000000..dc5595f --- /dev/null +++ b/cus-eng-con-sys/service/pdm_entrust.go @@ -0,0 +1,94 @@ +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" +) + +// PdmEntrust 设计委托 +/* +设计委托分三个步骤进行 +1、判断是否change监理(先省略,看看有没有问题) +2、(先获取信息)再更新表单信息 +3、提交设计委托 +*/ + +func ReqPdmEntrust(processInsId, taskId, taskTitle string) { + updatePdmProduction(processInsId, taskId, taskTitle) + pdmPushProcess(processInsId, taskId, taskTitle) +} + +func updatePdmProduction(processInsId, taskId, taskTitle string) { + remandId := getRemandIdSJKR(processInsId, taskId) + html := goPdmEntrustEdit(remandId, processInsId, taskId) + h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") + header := h.GenReqParam() + f := model.NewUpdatePdmProduction(remandId, html, taskTitle) + form := f.GenReqParam() + client := resty.New().SetRetryCount(5).SetRetryWaitTime(20 * time.Second) + resp, err := client.R(). + SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/pdmProductionController/updatePdmProduction.action") + if err != nil { + panic(exception.New(err.Error())) + } + data := strings.Trim(resp.String(), `"`) + logkit.Info("updatePdmProduction:" + cryptokit.Decrypt(data)) +} + +func pdmPushProcess(processInsId, taskId, taskTitle string) { + h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") + header := h.GenReqParam() + f := model.NewPDMPushProcess(processInsId, taskId, taskTitle) + form := f.GenReqParam() + client := resty.New().SetRetryCount(5).SetRetryWaitTime(18 * time.Second) + resp, err := client.R(). + SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/pdmEntrustController/pushProcess.action") + if err != nil { + panic(exception.New(err.Error())) + } + data := strings.Trim(resp.String(), `"`) + logkit.Info("pdmPushProcess:" + cryptokit.Decrypt(data)) +} + +// businessKey=remandId,taskId=id +func goPdmEntrustEdit(businessKey, processInstId, taskId string) string { + client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second) + h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") + header := h.GenReqParam() + query := model.NewGoPdmEntrustEdit(businessKey, processInstId, taskId) + resp, err := client.R(). + SetHeaders(header).Get(config.UrlPrefix + "/zjgd/frm/pdmEntrustController/goPdmEntrustEdit?businessKey=" + query.BusinessKey + "&processInstanceId=" + query.ProcessInstanceId + "&taskDefinitionKey=" + query.TaskDefinitionKey + "&taskId=" + query.TaskId + "&startLink=" + query.StartLink + "&endLink=" + query.EndLink + "&taskflag=" + query.TaskFlag + "&ranstr=" + query.Ranstr + "×tamp=" + query.Timestamp + "&_=" + query.TimestampPro) + if err != nil { + panic(exception.New(err.Error())) + } + return resp.String() +} + +// businessKey=remandId +func getRemandIdSJKR(processInstanceId, id string) string { + client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second) + h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") + header := h.GenReqParam() + f := model.NewGetBusinessKey() + form := f.GenReqParam() + resp, err := client.R(). + SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/workflowrest/tasktodopath/GkXjGzKrProcess/" + processInstanceId + "/JSFAWT/" + id + "/ZH_KR") //ZH_XZ在杭州应该不变化 扩容不一样 + if err != nil { + panic(exception.New(err.Error())) + } + data := strings.Trim(resp.String(), `"`) + decrypt := cryptokit.Decrypt(data) + dataRow := gjson.Get(decrypt, "dataRows").Array() + if len(dataRow) == 0 { + panic(exception.New("dataRow array len = 0")) + } + logkit.Debug("拿到了businessKey/remandId:" + dataRow[0].Get("businessKey").String()) + return dataRow[0].Get("businessKey").String() +}