From 02c3ef21ebfb6645f30cfcfca89672fba25da75c Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 16 Aug 2024 15:54:09 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E5=AE=8C=E5=96=84=E5=B7=A5=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/cus_eng_con_sys.go | 13 +- cus-eng-con-sys/config/config.go | 4 + cus-eng-con-sys/config/config_constant.go | 4 + cus-eng-con-sys/model/back_flow.go | 62 +++++ cus-eng-con-sys/model/go_acc_delivery_edit.go | 55 +++++ cus-eng-con-sys/model/jf_push_process.go | 77 ++++++ cus-eng-con-sys/model/push_process.go | 231 ++++++++++++++++++ .../service/acceptance_delivery.go | 56 +++++ cus-eng-con-sys/service/withdraw_assign.go | 96 ++++++-- 9 files changed, 574 insertions(+), 24 deletions(-) create mode 100644 cus-eng-con-sys/model/back_flow.go create mode 100644 cus-eng-con-sys/model/go_acc_delivery_edit.go create mode 100644 cus-eng-con-sys/model/jf_push_process.go create mode 100644 cus-eng-con-sys/model/push_process.go create mode 100644 cus-eng-con-sys/service/acceptance_delivery.go diff --git a/cmd/cus_eng_con_sys.go b/cmd/cus_eng_con_sys.go index 53efed5..204eafe 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("test1.json") + j, _ := filekit.ReadString("testo.json") data := gjson.Get(j, "data").Array() for _, v := range data { name := v.Get("name").String() @@ -36,17 +36,18 @@ func run(c *config.Config) { if name == c.Step && process == c.Process { 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()) + //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()) }) - time.Sleep(5 * time.Second) + time.Sleep(1 * time.Second) } } } 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.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.EngSysSid, "", "Specify the sid") //TODO 验收确认阶段,还需要指定交付的人,暂时写死在代码里,目前只适用于周一彬,如果需要调整,则暂时先在代码里调整 } diff --git a/cus-eng-con-sys/config/config.go b/cus-eng-con-sys/config/config.go index 90a0e52..67b0e68 100644 --- a/cus-eng-con-sys/config/config.go +++ b/cus-eng-con-sys/config/config.go @@ -22,6 +22,8 @@ func Init() { switch step { case EngSysStepYSQR: configkit.Set(EngSysStep, StepYSQR) + case EngSysStepJFSQ: + configkit.Set(EngSysStep, StepJFSQ) default: logkit.Fatal("EngSysStep Not Support!") } @@ -37,6 +39,8 @@ func Init() { configkit.Set(EngSysProcess, ProcessNewBuilding) case EngSysProcessZQLX: configkit.Set(EngSysProcess, ProcessNewLX) + case EngSysProcessYSJF: + configkit.Set(EngSysProcess, ProcessYSJF) 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 ac66ff7..287a975 100644 --- a/cus-eng-con-sys/config/config_constant.go +++ b/cus-eng-con-sys/config/config_constant.go @@ -8,10 +8,12 @@ const ( const ( EngSysStepYSQR = "YSQR" + EngSysStepJFSQ = "JFSQ" ) const ( StepYSQR = "验收确认" + StepJFSQ = "验收交付申请" ) // config里入参 @@ -19,6 +21,7 @@ const ( EngSysProcessXQXJ = "XQXJ" EngSysProcessZQLX = "ZQLX" //TODO 这个还不确定是不是就是零星 EngSysProcessLYXJ = "LYXJ" + EngSysProcessYSJF = "YSJF" ) // 替换成系统能识别的参数 @@ -26,6 +29,7 @@ const ( ProcessNewBuilding = "JkDkhfgProcess" //楼宇新建 ProcessNewHouse = "GkXjGzKrProcess" //小区新建 ProcessNewLX = "ZQKHProcess" //政企零星 //TODO 这个还不确定 + ProcessYSJF = "YSJFProcess" ) const UrlPrefix = "http://10.202.2.108:8086" diff --git a/cus-eng-con-sys/model/back_flow.go b/cus-eng-con-sys/model/back_flow.go new file mode 100644 index 0000000..7fcbcd9 --- /dev/null +++ b/cus-eng-con-sys/model/back_flow.go @@ -0,0 +1,62 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "reflect" +) + +/* +/zjgd/frm/acceptanceComfirmController/backFlow +*/ + +/* +用途:撤回交付 +*/ + +type BackFlow struct { + DeliveryId string `map:"deliveryId"` + ParentProcInsId string `map:"parentProcInsId"` + Ranstr string `map:"ranstr"` + Timestamp string `map:"timestamp"` +} + +func NewBackFlow(deliveryId, parenProcInsId string) *BackFlow { + backFlow := new(BackFlow) + backFlow.DeliveryId = deliveryId + backFlow.ParentProcInsId = parenProcInsId + backFlow.Ranstr = cryptokit.RandomStr(true, 10, 32) + backFlow.Timestamp = cryptokit.GetTimeStamp() + return backFlow +} + +func (th *BackFlow) GenReqParam() map[string]string { + th.encrypt() + return th.structToMap() +} + +func (th *BackFlow) 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 *BackFlow) 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/go_acc_delivery_edit.go b/cus-eng-con-sys/model/go_acc_delivery_edit.go new file mode 100644 index 0000000..93409f7 --- /dev/null +++ b/cus-eng-con-sys/model/go_acc_delivery_edit.go @@ -0,0 +1,55 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "reflect" +) + +/* +/zjgd/frm/acceptanceComfirmController/goAccDeliveryEdit?businessKey=GRNd813lMc5xouGwqRPf7OJtFi2VoRa91V0vs2R7wHAZXvuFFHppwhcX5huFVrN3&processInstanceId=R5xOyY/6RHNkvnBAhuM2ng==&taskDefinitionKey=5LZPb0vNSm2PgEmBIHWeaQ==&taskId=gbXnKZwFUpB3HaRgHukedg==&startLink=DuAb1TXHvyGSasSql6BmZw==&endLink=DuAb1TXHvyGSasSql6BmZw==&taskflag=vROIUK5V0hGnD6kIyfnQBA==&ranstr=rWoHhc1OImhN1akYk0kyjhbJXpY6vUlP7dhw4pIMErI=×tamp=07I1MQdK8OJUh8R5uzl0RQ==&_=1723698475861 +*/ + +/* +用途 +1、jfPushProcess时入参使用,和ToAcceptanceConfirm其实就相差一个字段的值,后期看看能否合并 todo +*/ + +type GoAccDeliveryEdit 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 NewGoAccDeliveryEdit(businessKey, processInstId, taskId string) *GoAccDeliveryEdit { + goAccDeliveryEdit := new(GoAccDeliveryEdit) + goAccDeliveryEdit.BusinessKey = businessKey + goAccDeliveryEdit.ProcessInstanceId = processInstId + goAccDeliveryEdit.TaskDefinitionKey = "JFSQ" + goAccDeliveryEdit.TaskId = taskId //等于id + goAccDeliveryEdit.StartLink = "false" + goAccDeliveryEdit.EndLink = "false" + goAccDeliveryEdit.TaskFlag = "db" + goAccDeliveryEdit.Ranstr = cryptokit.RandomStr(true, 10, 32) + goAccDeliveryEdit.Timestamp = cryptokit.GetTimeStamp() + goAccDeliveryEdit.encrypt() + //这个最终不加密 + goAccDeliveryEdit.TimestampPro = cryptokit.GetTimeStamp() + return goAccDeliveryEdit +} + +func (th *GoAccDeliveryEdit) 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/jf_push_process.go b/cus-eng-con-sys/model/jf_push_process.go new file mode 100644 index 0000000..2529031 --- /dev/null +++ b/cus-eng-con-sys/model/jf_push_process.go @@ -0,0 +1,77 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "reflect" +) + +/* +/zjgd/frm/acceptanceComfirmController/jfPushProcess +*/ + +/* +用途:验收交付确认 +*/ + +type JFPushProcess struct { + ProcessInstanceId string `map:"processInstanceId"` + TaskId string `map:"taskId"` + DeliveryId string `map:"deliveryId"` + TaskDefinitionKey string `map:"taskDefinitionKey"` + Assignee string `map:"assignee"` + Comment string `map:"comment"` + HandleType string `map:"handleType"` + BusinessKey string `map:"businessKey"` + Withdraw string `map:"withdraw"` + Ranstr string `map:"ranstr"` + Timestamp string `map:"timestamp"` +} + +func NewJFPushProcess(processInsId, taskId, deliveryId, businessKey string) *JFPushProcess { + jfPushProcess := new(JFPushProcess) + jfPushProcess.ProcessInstanceId = processInsId + jfPushProcess.TaskId = taskId + jfPushProcess.DeliveryId = deliveryId + jfPushProcess.TaskDefinitionKey = "JFQR" + jfPushProcess.Assignee = "3072887" //todo 每个人都是这个吗 + jfPushProcess.Comment = "请确认" + jfPushProcess.HandleType = "1" + jfPushProcess.BusinessKey = businessKey + jfPushProcess.Withdraw = "0" + jfPushProcess.Ranstr = cryptokit.RandomStr(true, 10, 32) + jfPushProcess.Timestamp = cryptokit.GetTimeStamp() + return jfPushProcess +} + +// GenReqParam 返回加密后的请求参数 +func (th *JFPushProcess) GenReqParam() map[string]string { + th.encrypt() + return th.structToMap() +} + +func (th *JFPushProcess) 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 *JFPushProcess) 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/push_process.go b/cus-eng-con-sys/model/push_process.go new file mode 100644 index 0000000..cd4e986 --- /dev/null +++ b/cus-eng-con-sys/model/push_process.go @@ -0,0 +1,231 @@ +package model + +import ( + "cu-helper/cus-eng-con-sys/cryptokit" + "cu-helper/cus-eng-con-sys/util" + "github.com/mizuki1412/go-core-kit/library/mathkit" + "github.com/spf13/cast" + "reflect" +) + +/* +/zjgd/frm/acceptanceComfirmController/pushProcess.action +*/ + +/* +用途 +PushProcess +*/ + +//tip 工建能写出这么多form参数的的程序员,也是个人才,不能用json吗?我真服了你! + +type PushProcess struct { + AccId string `map:"accId"` + Token string `map:"token"` + RemandId string `map:"remandId"` + RemandCode string `map:"remandCode"` + IsSplitedRemand string `map:"isSplitedRemand"` + IsCross string `map:"isCross"` + InvestmentConfigId string `map:"investmentConfigId"` + IsGrid string `map:"isGrid"` + GridId string `map:"gridId"` + AttachGrid string `map:"attachGrid"` + ResourceGridOrg string `map:"resourceGridOrg"` + RemandCreateBy string `map:"remandCreateBy"` + BuildAttr string `map:"buildAttr"` + BussCode string `map:"bussCode"` + Prov string `map:"prov"` + City string `map:"city"` + County string `map:"county"` + LinkCode string `map:"linkCode"` + SpecC string `map:"specC"` + IsBd string `map:"isBd"` + ProcessInstId string `map:"processInstId"` + RemandName string `map:"remandName"` + ProjectName string `map:"projectName"` + ProjectCode string `map:"projectCode"` + RemandCreateName string `map:"remandCreateName"` + RemandTouzi string `map:"remandTouzi"` + ProjectManagerName string `map:"projectManagerName"` + RemandCreatedDate string `map:"remandCreatedDate"` + PdmCreatedName string `map:"pdmCreatedName"` + PdmCreatedDate string `map:"pdmCreatedDate"` + ReplyDate string `map:"replyDate"` + ReplyInvestment string `map:"replyInvestment"` + ActStartDate string `map:"actStartDate"` + ActOrgName string `map:"actOrgName"` + ActFinishDate string `map:"actFinishDate"` + AccApplyDesc string `map:"accApplyDesc"` + EquipCost string `map:"equipCost"` + EnginCost string `map:"enginCost"` + SafetyProdCost string `map:"safetyProdCost"` + SurveyCost string `map:"surveyCost"` + SupervisionCost string `map:"supervisionCost"` + OtherCost string `map:"otherCost"` + AccInvestment string `map:"accInvestment"` + IsInstall string `map:"isInstall"` + PasteCode string `map:"pasteCode"` + OnuLightWane string `map:"onuLightWane"` + WorkAcc string `map:"workAcc"` + MaterialAcc string `map:"materialAcc"` + IsTestSpeed string `map:"isTestSpeed"` + UserRate string `map:"userRate"` + TestSpeedAcc string `map:"testSpeedAcc"` + BuildingNum string `map:"buildingNum"` + PortNum string `map:"portNum"` + InstallNum string `map:"installNum"` + UnconditionalInstall string `map:"unconditionalInstall"` + IsRecordAll string `map:"isRecordAll"` + ResourcesAcc string `map:"resourcesAcc"` + BeamasPlitter string `map:"beamasPlitter"` + OtherNetworkResource string `map:"otherNetworkResource"` + //DoubleExcellent string `map:"doubleExcellent"` //是否双优 + IsSupClock string `map:"isSupClock"` + NotClockName string `map:"notClockName"` + NotClockDesc string `map:"notClockDesc"` + PassOrNo string `map:"passOrNo"` + RadioName0 string `map:"radioName_0"` + RecordReason string `map:"recordReason"` + RadioName1 string `map:"radioName_1"` + RadioName2 string `map:"radioName_2"` + RadioName3 string `map:"radioName_3"` + LeavRadio string `map:"leavRadio"` + AccRemainingProb string `map:"accRemainingProb"` + AccConfirmDesc string `map:"accConfirmDesc"` + //最后全部点完后,验收确认多几个参数 + TaskDefinitionKey string `map:"taskDefinitionKey"` + BusinessKey string `map:"businessKey"` + Comment string `map:"comment"` + Assignee string `map:"assignee"` + ProcessInstanceId string `map:"processInstanceId"` + TaskId string `map:"taskId"` + HandleType string `map:"handleType"` + Withdraw string `map:"withdraw"` + IndInfo string `map:"indInfo"` + //最后全部点完后,验收确认多几个参数 + Ranstr string `map:"ranstr"` + Timestamp string `map:"timestamp"` +} + +// NewPushProcess remandId=businessKey +func NewPushProcess(taskId, token, remandId, html1, html2 string) *PushProcess { + pushProcess := new(PushProcess) + pushProcess.AccId = util.RegexpFindFirst(html1, `"accId":"([^"]+)"`) + pushProcess.Token = token + pushProcess.RemandId = remandId + pushProcess.RemandCode = util.RegexpFindFirst(html1, `"remandCode":"([^"]+)"`) + pushProcess.IsSplitedRemand = util.RegexpFindFirst(html1, `"isSplitedRemand":"([^"]+)"`) + pushProcess.IsCross = util.HTMLContentFindFirst(html1, "isCross") + pushProcess.InvestmentConfigId = util.HTMLContentFindFirst(html1, "investmentConfigId") + pushProcess.IsGrid = util.HTMLContentFindFirst(html1, "isGrid") + pushProcess.GridId = util.HTMLContentFindFirst(html1, "gridId") + pushProcess.AttachGrid = util.HTMLContentFindFirst(html1, "attachGrid") + pushProcess.ResourceGridOrg = util.HTMLContentFindFirst(html1, "resourceGridOrg") + pushProcess.RemandCreateBy = util.HTMLContentFindFirst(html1, "remandCreateBy") + pushProcess.BuildAttr = util.HTMLContentFindFirst(html1, "buildAttr") + pushProcess.BussCode = util.HTMLContentFindFirst(html1, "bussCode") + pushProcess.Prov = util.HTMLContentFindFirst(html1, "prov") + pushProcess.City = util.HTMLContentFindFirst(html1, "city") + pushProcess.County = util.HTMLContentFindFirst(html1, "county") + pushProcess.LinkCode = util.HTMLContentFindFirst(html1, "linkCode") + pushProcess.SpecC = util.HTMLContentFindFirst(html1, "specC") + pushProcess.IsBd = util.HTMLContentFindFirst(html1, "isBd") + pushProcess.ProcessInstId = util.HTMLContentFindFirst(html1, "processInstId") + pushProcess.RemandName = util.RegexpFindFirst(html1, `"remandName":"([^"]+)"`) + pushProcess.ProjectName = util.HTMLContentFindFirst(html2, "projectName") + pushProcess.ProjectCode = util.HTMLContentFindFirst(html2, "projectCode") + pushProcess.RemandCreateName = util.HTMLContentFindFirst(html2, "remandCreateName") + pushProcess.RemandTouzi = util.HTMLContentFindFirst(html2, "remandTouzi") + pushProcess.ProjectManagerName = util.HTMLContentFindFirst(html2, "projectManagerName") + pushProcess.RemandCreatedDate = util.HTMLContentFindFirst(html2, "remandCreatedDate") + pushProcess.PdmCreatedName = util.HTMLContentFindFirst(html2, "pdmCreatedName") + pushProcess.PdmCreatedDate = util.HTMLContentFindFirst(html2, "pdmCreatedDate") + pushProcess.ReplyDate = util.HTMLContentFindFirst(html2, "replyDate") + pushProcess.ReplyInvestment = util.HTMLContentFindFirst(html2, "replyInvestment") + pushProcess.ActStartDate = util.HTMLContentFindFirst(html2, "actStartDate") + pushProcess.ActOrgName = util.HTMLContentFindFirst(html2, "actOrgName") + pushProcess.ActFinishDate = util.HTMLContentFindFirst(html2, "actFinishDate") + pushProcess.AccApplyDesc = util.HTMLContentFindFirst(html1, "accApplyDesc") + pushProcess.EquipCost = util.RegexpFindFirst(html1, `"equipCost":(\d+(\.\d+)?)`) + pushProcess.EnginCost = util.RegexpFindFirst(html1, `"enginCost":(\d+(\.\d+)?)`) + pushProcess.SafetyProdCost = util.RegexpFindFirst(html1, `"safetyProdCost":(\d+(\.\d+)?)`) + pushProcess.SurveyCost = util.RegexpFindFirst(html1, `"surveyCost":(\d+(\.\d+)?)`) + pushProcess.SupervisionCost = util.RegexpFindFirst(html1, `"supervisionCost":(\d+(\.\d+)?)`) + pushProcess.OtherCost = util.RegexpFindFirst(html1, `"otherCost":(\d+(\.\d+)?)`) + pushProcess.AccInvestment = cast.ToString(mathkit.FloatRound(cast.ToFloat64(pushProcess.EquipCost)+cast.ToFloat64(pushProcess.EnginCost)+cast.ToFloat64(pushProcess.SafetyProdCost)+cast.ToFloat64(pushProcess.SurveyCost)+cast.ToFloat64(pushProcess.SupervisionCost)+cast.ToFloat64(pushProcess.OtherCost), 2)) + pushProcess.IsInstall = "ALL" + pushProcess.PasteCode = "1" + pushProcess.OnuLightWane = "DOWN" + pushProcess.WorkAcc = "1" + pushProcess.MaterialAcc = "1" + pushProcess.IsTestSpeed = "1" + pushProcess.UserRate = "1000" + pushProcess.TestSpeedAcc = "1" + pushProcess.BuildingNum = util.RegexpFindFirst(html1, `"buildingNum":(\d+(\.\d+)?)`) + pushProcess.PortNum = util.RegexpFindFirst(html1, `"portNum":(\d+(\.\d+)?)`) + pushProcess.InstallNum = util.RegexpFindFirst(html1, `"installNum":(\d+(\.\d+)?)`) + pushProcess.UnconditionalInstall = "ALL" + pushProcess.IsRecordAll = "1" + pushProcess.ResourcesAcc = "1" + pushProcess.BeamasPlitter = "1" + pushProcess.OtherNetworkResource = "" + //pushProcess.DoubleExcellent = "0" //是否双优 + pushProcess.IsSupClock = "0" + pushProcess.NotClockName = "无需" + pushProcess.NotClockDesc = "无需" + pushProcess.PassOrNo = "1" + pushProcess.RadioName0 = "on" + pushProcess.RecordReason = "" + pushProcess.RadioName1 = "on" + pushProcess.RadioName2 = "on" + pushProcess.RadioName3 = "on" + pushProcess.LeavRadio = "1" + pushProcess.AccRemainingProb = "" + pushProcess.AccConfirmDesc = "" + pushProcess.TaskDefinitionKey = "endevent1" + pushProcess.BusinessKey = util.RegexpFindFirst(html1, `"accId":"([^"]+)"`) + pushProcess.Comment = "完成" + pushProcess.Assignee = "" + pushProcess.ProcessInstanceId = util.HTMLContentFindFirst(html1, "processInstId") + pushProcess.TaskId = taskId + pushProcess.HandleType = "1" + pushProcess.Withdraw = "0" + pushProcess.IndInfo = "" + pushProcess.Ranstr = cryptokit.RandomStr(true, 10, 32) + pushProcess.Timestamp = cryptokit.GetTimeStamp() + return pushProcess +} + +// GenReqParam 返回加密后的请求参数 +func (th *PushProcess) GenReqParam() map[string]string { + th.encrypt() + return th.structToMap() +} + +func (th *PushProcess) 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 *PushProcess) 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_delivery.go b/cus-eng-con-sys/service/acceptance_delivery.go new file mode 100644 index 0000000..2a4a193 --- /dev/null +++ b/cus-eng-con-sys/service/acceptance_delivery.go @@ -0,0 +1,56 @@ +package service + +import ( + "cu-helper/cus-eng-con-sys/config" + "cu-helper/cus-eng-con-sys/cryptokit" + "cu-helper/cus-eng-con-sys/model" + "cu-helper/cus-eng-con-sys/util" + "github.com/go-resty/resty/v2" + "github.com/mizuki1412/go-core-kit/class/exception" + "github.com/mizuki1412/go-core-kit/service/logkit" + "strings" + "time" +) + +// ReqAccDelivery 验收确认请求 +/* +验收确认分一个步骤进行 +1、先获取指定人的deliveryId +2、获取businessKey +3、提交验收确认 +*/ + +func ReqAccDelivery(processInsId, taskId string) { + businessKey := getRemandId(processInsId, taskId) + deliveryId := getDeliveryId(processInsId, taskId, businessKey) + jfPushProcess(processInsId, taskId, deliveryId, businessKey) +} + +func jfPushProcess(processInsId, taskId, deliveryId, businessKey string) { + h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") + header := h.GenReqParam() + f := model.NewJFPushProcess(processInsId, taskId, deliveryId, businessKey) + 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/acceptanceComfirmController/jfPushProcess") + if err != nil { + panic(exception.New(err.Error())) + } + data := strings.Trim(resp.String(), `"`) + logkit.Info("jfPushProcess:" + cryptokit.Decrypt(data)) +} + +func getDeliveryId(processInsId, taskId, businessKey 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.NewGoAccDeliveryEdit(businessKey, processInsId, taskId) + resp, err := client.R(). + SetHeaders(header).Get(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/goAccDeliveryEdit?businessKey=" + query.BusinessKey + "&processInstanceId=" + query.ProcessInstanceId + "&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())) + } + deliveryId := util.HTMLContentFindFirst(resp.String(), "deliveryId") + return deliveryId +} diff --git a/cus-eng-con-sys/service/withdraw_assign.go b/cus-eng-con-sys/service/withdraw_assign.go index 31c4864..7e970be 100644 --- a/cus-eng-con-sys/service/withdraw_assign.go +++ b/cus-eng-con-sys/service/withdraw_assign.go @@ -15,16 +15,36 @@ import ( // AssignScrap 取消交付 /* 取消交付分两个步骤进行 -1、searchAccSendList获取deliveryId -2、assignScrap +1、searchAccSendList获取RemovalInfo +2、根据RemovalInfo判断哪个需要撤回和废除 +4、 +3、assignScrap */ func ReqWithdrawAssign(parenProcInsId string) { list := searchAccSendList(parenProcInsId) - assignScrap(list, parenProcInsId) + for _, v := range list { + if v.DeliveryId == "" { + continue + } + if v.DeliveryStatus == "COMPLETE" { + //先撤回,再废除 + backFlow(v.Name, v.DeliveryId, parenProcInsId) + assignScrap(v.Name, v.DeliveryId, parenProcInsId) + } else { + //未完成的直接废除 + assignScrap(v.Name, v.DeliveryId, parenProcInsId) + } + } } -func searchAccSendList(parenProcInsId string) []string { +type RemovalInfo struct { + Name string + DeliveryId string + DeliveryStatus string +} + +func searchAccSendList(parenProcInsId string) []RemovalInfo { h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") header := h.GenReqParam() f := model.NewSearchAccSendList(parenProcInsId) @@ -38,27 +58,67 @@ func searchAccSendList(parenProcInsId string) []string { data := strings.Trim(resp.String(), `"`) decrypt := cryptokit.Decrypt(data) ok := gjson.Get(decrypt, "data").Array() - var deliveryIdList []string + var removalList []RemovalInfo + seen := make(map[string]gjson.Result) for _, v := range ok { + splitName := gjson.Get(v.String(), "splitName").String() deliveryId := gjson.Get(v.String(), "deliveryId").String() - deliveryIdList = append(deliveryIdList, deliveryId) + deliveryStatus := gjson.Get(v.String(), "deliveryStatus").String() + if deliveryStatus == "ABANDON" { + continue + } + if existing, exists := seen[splitName]; exists { + existingStatus := gjson.Get(existing.String(), "deliveryStatus").String() + + if existingStatus == "SUBMIT" && deliveryStatus == "COMPLETE" { + removalList = append(removalList, RemovalInfo{ + Name: splitName, + DeliveryId: existing.Get("deliveryId").String(), + DeliveryStatus: existingStatus, + }) + seen[splitName] = v + } else { + removalList = append(removalList, RemovalInfo{ + Name: splitName, + DeliveryId: deliveryId, + DeliveryStatus: deliveryStatus, + }) + } + } else { + seen[splitName] = v + } + } - return deliveryIdList + return removalList } -func assignScrap(deliveryIdList []string, parenProcInsId string) { +func backFlow(name, deliveryId, 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)) + f := model.NewBackFlow(deliveryId, parenProcInsId) + form := f.GenReqParam() + resp, err := client.R(). + SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/backFlow") + if err != nil { + panic(exception.New(err.Error())) } + data := strings.Trim(resp.String(), `"`) + logkit.Info("backFlow:" + name + cryptokit.Decrypt(data)) + +} + +func assignScrap(name, deliveryId, 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() + f := model.NewAssignScrap(deliveryId, 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:" + name + cryptokit.Decrypt(data)) }